xorriso  1.5.4.pl02
About: GNU xorriso creates, loads, manipulates and writes ISO 9660 filesystem images with Rock Ridge extensions. It is suitable for incremental data backup and for production of bootable ISO 9660 images. GNU xorriso is a statical compilation of the libraries libburn, libisofs, libisoburn, and libjte.
  Fossies Dox: xorriso-1.5.4.pl02.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

fsource.c File Reference
#include "fsource.h"
#include <stdlib.h>
Include dependency graph for fsource.c:

Go to the source code of this file.

Functions

void iso_file_source_ref (IsoFileSource *src)
 
void iso_file_source_unref (IsoFileSource *src)
 
void iso_filesystem_ref (IsoFilesystem *fs)
 
void iso_filesystem_unref (IsoFilesystem *fs)
 
char * iso_file_source_get_path (IsoFileSource *src)
 
char * iso_file_source_get_name (IsoFileSource *src)
 
int iso_file_source_lstat (IsoFileSource *src, struct stat *info)
 
int iso_file_source_access (IsoFileSource *src)
 
int iso_file_source_stat (IsoFileSource *src, struct stat *info)
 
int iso_file_source_open (IsoFileSource *src)
 
int iso_file_source_close (IsoFileSource *src)
 
int iso_file_source_read (IsoFileSource *src, void *buf, size_t count)
 
off_t iso_file_source_lseek (IsoFileSource *src, off_t offset, int flag)
 
int iso_file_source_readdir (IsoFileSource *src, IsoFileSource **child)
 
int iso_file_source_readlink (IsoFileSource *src, char *buf, size_t bufsiz)
 
IsoFilesystemiso_file_source_get_filesystem (IsoFileSource *src)
 
int iso_file_source_get_aa_string (IsoFileSource *src, unsigned char **aa_string, int flag)
 

Variables

unsigned int iso_fs_global_id = 1000
 

Function Documentation

◆ iso_file_source_access()

int iso_file_source_access ( IsoFileSource src)
inline

Check if the process has access to read file contents. Note that this is not necessarily related with (l)stat functions. For example, in a filesystem implementation to deal with an ISO image, if the user has read access to the image it will be able to read all files inside it, despite of the particular permission of each file in the RR tree, that are what the above functions return.

Returns
1 if process has read access, < 0 on error Error codes: ISO_FILE_ACCESS_DENIED ISO_FILE_BAD_PATH ISO_FILE_DOESNT_EXIST ISO_OUT_OF_MEM ISO_FILE_ERROR ISO_NULL_POINTER
Since
0.6.2

Definition at line 71 of file fsource.c.

References IsoFileSource_Iface::access, and iso_file_source::class.

Referenced by iso_cut_out_stream_new(), and iso_file_source_stream_new().

◆ iso_file_source_close()

int iso_file_source_close ( IsoFileSource src)
inline

Close a previously opened file

Returns
1 on success, < 0 on error Error codes: ISO_FILE_ERROR ISO_NULL_POINTER ISO_FILE_NOT_OPENED
Since
0.6.2

Definition at line 89 of file fsource.c.

References iso_file_source::class, and IsoFileSource_Iface::close.

Referenced by cut_out_close(), fsrc_close(), ifs_get_file(), and iso_add_dir_src_rec().

◆ iso_file_source_get_aa_string()

int iso_file_source_get_aa_string ( IsoFileSource src,
unsigned char **  aa_string,
int  flag 
)
inline

Get the AAIP string with encoded ACL and xattr. (Not to be confused with ECMA-119 Extended Attributes).

Parameters
srcThe file source object to be inquired.
aa_stringReturns a pointer to the AAIP string data. If no AAIP string is available, *aa_string becomes NULL. (See doc/susp_aaip_2_0.txt for the meaning of AAIP.) The caller is responsible for finally calling free() on non-NULL results.
flagBitfield for control purposes bit0= Transfer ownership of AAIP string data. src will free the eventual cached data and might not be able to produce it again. bit1= No need to get ACL (but no guarantee of exclusion) bit2= No need to get xattr (but no guarantee of exclusion) bit3= if not bit2: import all xattr namespaces from local filesystem, not only "user."
Since
1.5.0
Returns
1 means success (*aa_string == NULL is possible) <0 means failure and must b a valid libisofs error code (e.g. ISO_FILE_ERROR if no better one can be found).
Since
0.6.14

Definition at line 126 of file fsource.c.

References iso_file_source::class, IsoFileSource_Iface::get_aa_string, and IsoFileSource_Iface::version.

Referenced by default_create_node(), iso_image_import(), and src_aa_to_node().

◆ iso_file_source_get_filesystem()

IsoFilesystem* iso_file_source_get_filesystem ( IsoFileSource src)
inline

Get the filesystem for this source. No extra ref is added, so you must not unref the IsoFilesystem.

Returns
The filesystem, NULL on error
Since
0.6.2

Definition at line 119 of file fsource.c.

References iso_file_source::class, and IsoFileSource_Iface::get_filesystem.

Referenced by cut_out_get_id(), default_create_node(), fsrc_get_id(), and iso_file_source_stream_new().

◆ iso_file_source_get_name()

char* iso_file_source_get_name ( IsoFileSource src)
inline

Get the name of the file, with the dir component of the path.

Returns
the name of the file, it should be freed when no more needed.
Since
0.6.2

Definition at line 59 of file fsource.c.

References iso_file_source::class, and IsoFileSource_Iface::get_name.

Referenced by default_create_file(), default_create_node(), ifs_get_file(), image_builder_create_node(), and iso_tree_add_node_builder().

◆ iso_file_source_get_path()

char* iso_file_source_get_path ( IsoFileSource src)
inline

Get the absolute path in the filesystem this file source belongs to.

Returns
the path of the FileSource inside the filesystem, it should be freed when no more needed.
Since
0.6.2

Definition at line 53 of file fsource.c.

References iso_file_source::class, and IsoFileSource_Iface::get_path.

Referenced by iso_add_dir_src_rec(), iso_stream_get_file_name(), iso_stream_get_source_path(), and lfs_get_aa_string().

◆ iso_file_source_lseek()

off_t iso_file_source_lseek ( IsoFileSource src,
off_t  offset,
int  flag 
)
inline

Repositions the offset of the given IsoFileSource (must be opened) to the given offset according to the value of flag.

Parameters
srcThe given source
offsetin bytes
flag0 The offset is set to offset bytes (SEEK_SET) 1 The offset is set to its current location plus offset bytes (SEEK_CUR) 2 The offset is set to the size of the file plus offset bytes (SEEK_END).
Returns
Absolute offset position on the file, or < 0 on error. Cast the returning value to int to get a valid libisofs error.
Since
0.6.4

Definition at line 101 of file fsource.c.

References iso_file_source::class, and IsoFileSource_Iface::lseek.

Referenced by cut_out_open().

◆ iso_file_source_lstat()

int iso_file_source_lstat ( IsoFileSource src,
struct stat *  info 
)
inline

Get information about the file.

Returns
1 success, < 0 error Error codes: ISO_FILE_ACCESS_DENIED ISO_FILE_BAD_PATH ISO_FILE_DOESNT_EXIST ISO_OUT_OF_MEM ISO_FILE_ERROR ISO_NULL_POINTER
Since
0.6.2

Definition at line 65 of file fsource.c.

References iso_file_source::class, and IsoFileSource_Iface::lstat.

Referenced by default_create_node(), image_builder_create_node(), iso_add_dir_src_rec(), and iso_image_import().

◆ iso_file_source_open()

int iso_file_source_open ( IsoFileSource src)
inline

Opens the source.

Returns
1 on success, < 0 on error Error codes: ISO_FILE_ALREADY_OPENED ISO_FILE_ACCESS_DENIED ISO_FILE_BAD_PATH ISO_FILE_DOESNT_EXIST ISO_OUT_OF_MEM ISO_FILE_ERROR ISO_NULL_POINTER
Since
0.6.2

Definition at line 83 of file fsource.c.

References iso_file_source::class, and IsoFileSource_Iface::open.

Referenced by cut_out_open(), fsrc_open(), ifs_get_file(), and iso_add_dir_src_rec().

◆ iso_file_source_read()

int iso_file_source_read ( IsoFileSource src,
void *  buf,
size_t  count 
)
inline

Attempts to read up to count bytes from the given source into the buffer starting at buf.

The file src must be open() before calling this, and close() when no more needed. Not valid for dirs. On symlinks it reads the destination file.

Parameters
srcThe given source
bufPointer to a buffer of at least count bytes where the read data will be stored
countBytes to read
Returns
number of bytes read, 0 if EOF, < 0 on error Error codes: ISO_FILE_ERROR ISO_NULL_POINTER ISO_FILE_NOT_OPENED ISO_WRONG_ARG_VALUE -> if count == 0 ISO_FILE_IS_DIR ISO_OUT_OF_MEM ISO_INTERRUPTED
Since
0.6.2

Definition at line 95 of file fsource.c.

References iso_file_source::class, and IsoFileSource_Iface::read.

Referenced by cut_out_read(), and fsrc_read().

◆ iso_file_source_readdir()

int iso_file_source_readdir ( IsoFileSource src,
IsoFileSource **  child 
)
inline

Read a directory.

Each call to this function will return a new child, until we reach the end of file (i.e, no more children), in that case it returns 0.

The dir must be open() before calling this, and close() when no more needed. Only valid for dirs.

Note that "." and ".." children MUST NOT BE returned.

Parameters
srcThe given source
childpointer to be filled with the given child. Undefined on error or OEF
Returns
1 on success, 0 if EOF (no more children), < 0 on error Error codes: ISO_FILE_ERROR ISO_NULL_POINTER ISO_FILE_NOT_OPENED ISO_FILE_IS_NOT_DIR ISO_OUT_OF_MEM
Since
0.6.2

Definition at line 107 of file fsource.c.

References iso_file_source::class, and IsoFileSource_Iface::readdir.

Referenced by ifs_get_file(), and iso_add_dir_src_rec().

◆ iso_file_source_readlink()

int iso_file_source_readlink ( IsoFileSource src,
char *  buf,
size_t  bufsiz 
)
inline

Read the destination of a symlink. You don't need to open the file to call this.

Parameters
srcAn IsoFileSource corresponding to a symbolic link.
bufAllocated buffer of at least bufsiz bytes. The destination string will be copied there, and it will be 0-terminated if the return value indicates success or ISO_RR_PATH_TOO_LONG.
bufsizMaximum number of buf characters + 1. The string will be truncated if it is larger than bufsiz - 1 and ISO_RR_PATH_TOO_LONG. will be returned.
Returns
1 on success, < 0 on error Error codes: ISO_FILE_ERROR ISO_NULL_POINTER ISO_WRONG_ARG_VALUE -> if bufsiz <= 0 ISO_FILE_IS_NOT_SYMLINK ISO_OUT_OF_MEM ISO_FILE_BAD_PATH ISO_FILE_DOESNT_EXIST ISO_RR_PATH_TOO_LONG (
Since
1.0.6)
0.6.2

Definition at line 113 of file fsource.c.

References iso_file_source::class, and IsoFileSource_Iface::readlink.

Referenced by default_create_node(), and image_builder_create_node().

◆ iso_file_source_ref()

void iso_file_source_ref ( IsoFileSource src)

◆ iso_file_source_stat()

int iso_file_source_stat ( IsoFileSource src,
struct stat *  info 
)
inline

Get information about the file. If the file is a symlink, the info returned refers to the destination.

Returns
1 success, < 0 error Error codes: ISO_FILE_ACCESS_DENIED ISO_FILE_BAD_PATH ISO_FILE_DOESNT_EXIST ISO_OUT_OF_MEM ISO_FILE_ERROR ISO_NULL_POINTER
Since
0.6.2

Definition at line 77 of file fsource.c.

References iso_file_source::class, and IsoFileSource_Iface::stat.

Referenced by cut_out_open(), default_create_file(), default_create_node(), fsrc_is_repeatable(), fsrc_open(), fsrc_update_size(), iso_add_dir_src_rec(), iso_cut_out_stream_new(), iso_file_source_stream_new(), iso_tree_add_dir_rec(), and iso_tree_add_new_cut_out_node().

◆ iso_file_source_unref()

void iso_file_source_unref ( IsoFileSource src)

◆ iso_filesystem_ref()

void iso_filesystem_ref ( IsoFilesystem fs)

Take a ref to the given IsoFilesystem

Since
0.6.2

Definition at line 35 of file fsource.c.

References iso_filesystem::refcount.

Referenced by create_boot_img_filesrc(), ifs_clone_src(), iso_file_source_new_lfs(), iso_local_filesystem_new(), and lfs_clone_src().

◆ iso_filesystem_unref()

void iso_filesystem_unref ( IsoFilesystem fs)

Drop your ref to the given IsoFilesystem, evetually freeing associated resources.

Since
0.6.2

Definition at line 40 of file fsource.c.

References iso_filesystem::free, and iso_filesystem::refcount.

Referenced by ifs_free(), iso_image_import(), iso_image_new(), iso_image_unref(), and lfs_free().

Variable Documentation

◆ iso_fs_global_id

unsigned int iso_fs_global_id = 1000

Values belong 1000 are reserved for libisofs usage

Definition at line 20 of file fsource.c.