libisofs
1.5.4
About: libisofs is a library to create an ISO 9660 filesystem, supports extensions like RockRidge or Joliet, makes bootable ISO 9660, and records file attributes which are of interest for data backups.
![]() ![]() |
#include "libisofs.h"
#include "stream.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
Go to the source code of this file.
Data Structures | |
struct | iso_extended_info |
struct | Iso_Node |
struct | Iso_Dir |
struct | Iso_File |
struct | Iso_Symlink |
struct | Iso_Special |
struct | iso_dir_iter_iface |
struct | Iso_Dir_Iter |
An iterator for directory children. More... | |
struct | zisofs_zf_info |
Parameter structure which is to be managed by zisofs_zf_xinfo_func. More... | |
Macros | |
#define | LIBISOFS_NODE_NAME_MAX 255 |
#define | LIBISOFS_NODE_PATH_MAX 1024 |
Typedefs | |
typedef struct iso_extended_info | IsoExtendedInfo |
The extended information is a way to attach additional information to each IsoNode. More... | |
Functions | |
int | iso_node_new_root (IsoDir **root) |
int | iso_node_new_dir (char *name, IsoDir **dir) |
Create a new IsoDir. More... | |
int | iso_node_new_file (char *name, IsoStream *stream, IsoFile **file) |
Create a new file node. More... | |
int | iso_node_new_symlink (char *name, char *dest, IsoSymlink **link) |
Creates a new IsoSymlink node. More... | |
int | iso_node_new_special (char *name, mode_t mode, dev_t dev, IsoSpecial **special) |
Create a new special file node. More... | |
int | iso_node_is_valid_name (const char *name) |
Check if a given name is valid for an iso node. More... | |
int | iso_node_is_valid_link_dest (const char *dest) |
Check if a given path is valid for the destination of a link. More... | |
void | iso_dir_find (IsoDir *dir, const char *name, IsoNode ***pos) |
Find the position where to insert a node. More... | |
int | iso_dir_exists (IsoDir *dir, const char *name, IsoNode ***pos) |
Check if a node with the given name exists in a dir. More... | |
int | iso_dir_insert (IsoDir *dir, IsoNode *node, IsoNode **pos, enum iso_replace_mode replace) |
Inserts a given node in a dir, at the specified position. More... | |
int | iso_dir_iter_register (IsoDirIter *iter) |
Add a new iterator to the registry. More... | |
void | iso_dir_iter_unregister (IsoDirIter *iter) |
Unregister a directory iterator. More... | |
void | iso_notify_dir_iters (IsoNode *node, int flag) |
int | iso_node_set_perms_internal (IsoNode *node, mode_t mode, int flag) |
See API function iso_node_set_permissions() More... | |
int | iso_aa_get_acl_text (unsigned char *aa_string, mode_t st_mode, char **access_text, char **default_text, int flag) |
Like iso_node_get_acl_text() with param node replaced by aa_string and st_mode from where to obtain the ACLs. More... | |
int | iso_aa_get_attrs (unsigned char *aa_string, size_t *num_attrs, char ***names, size_t **value_lengths, char ***values, int flag) |
Backend of iso_node_get_attrs() with parameter node replaced by the AAIP string from where to get the attribute list. More... | |
int | iso_aa_lookup_attr (unsigned char *aa_string, char *name, size_t *value_length, char **value, int flag) |
Search given name. More... | |
int | zisofs_zf_xinfo_func (void *data, int flag) |
Function to identify and manage ZF parameters which do not stem from ZF fields (those are known to the FileSource) and do not stem from filters ("ziso" knows them globally, "osiz" knows them individually) but rather from an inspection of the file content header for zisofs magic number and plausible parameters. More... | |
int | iso_file_zf_by_magic (IsoFile *file, int flag) |
Checks whether a file effectively bears a zisofs file header and eventually marks this by a struct zisofs_zf_info as xinfo of the file node. More... | |
int | iso_node_get_id (IsoNode *node, unsigned int *fs_id, dev_t *dev_id, ino_t *ino_id, int flag) |
int | iso_node_set_unique_id (IsoNode *node, IsoImage *image, int flag) |
int | iso_node_set_ino (IsoNode *node, ino_t ino, int flag) |
int | iso_node_cmp_flag (IsoNode *n1, IsoNode *n2, int flag) |
int | iso_file_set_isofscx (IsoFile *file, unsigned int checksum_index, int flag) |
Set the checksum index (typically coming from IsoFileSrc.checksum_index) of a regular file node. More... | |
int | iso_root_set_isofsca (IsoNode *node, uint32_t start_lba, uint32_t end_lba, uint32_t count, uint32_t size, char *typetext, int flag) |
Set the checksum area description. More... | |
int | iso_root_get_isofsca (IsoNode *node, uint32_t *start_lba, uint32_t *end_lba, uint32_t *count, uint32_t *size, char typetext[81], int flag) |
Get the checksum area description. More... | |
int | iso_root_set_isofsnt (IsoNode *node, uint32_t truncate_mode, uint32_t truncate_length, int flag) |
Record and get truncation parameters as of iso_image_set_truncate_mode() by "isofs.nt". More... | |
int | iso_root_get_isofsnt (IsoNode *node, uint32_t *truncate_mode, uint32_t *truncate_length, int flag) |
int | iso_node_clone_xinfo (IsoNode *from_node, IsoNode *to_node, int flag) |
Copy the xinfo list from one node to the another. More... | |
int | iso_px_ino_xinfo_func (void *data, int flag) |
The iso_node_xinfo_func instance which governs the storing of the inode number from Rock Ridge field PX. More... | |
int | iso_px_ino_xinfo_cloner (void *old_data, void **new_data, int flag) |
int | zisofs_zf_xinfo_cloner (void *old_data, void **new_data, int flag) |
int | iso_dir_get_node_trunc (IsoDir *dir, int truncate_length, const char *name, IsoNode **node) |
typedef struct iso_extended_info IsoExtendedInfo |
The extended information is a way to attach additional information to each IsoNode.
External applications may want to use this extension system to store application specific information related to each node. On the other side, libisofs may make use of this struct to attach information to nodes in some particular, uncommon, cases, without incrementing the size of the IsoNode struct.
It is implemented like a chained list.
int iso_aa_get_acl_text | ( | unsigned char * | aa_string, |
mode_t | st_mode, | ||
char ** | access_text, | ||
char ** | default_text, | ||
int | flag | ||
) |
Like iso_node_get_acl_text() with param node replaced by aa_string and st_mode from where to obtain the ACLs.
All other parameter specs apply.
Definition at line 2180 of file node.c.
References iso_aa_get_attrs(), and iso_attr_get_acl_text().
Referenced by default_create_node(), and src_aa_to_node().
int iso_aa_get_attrs | ( | unsigned char * | aa_string, |
size_t * | num_attrs, | ||
char *** | names, | ||
size_t ** | value_lengths, | ||
char *** | values, | ||
int | flag | ||
) |
Backend of iso_node_get_attrs() with parameter node replaced by the AAIP string from where to get the attribute list.
All other parameter specs apply.
Definition at line 1647 of file node.c.
References aaip_count_bytes(), aaip_decode_attrs(), aaip_get_decoded_attrs(), attrs_cleanout_name(), and ISO_AAIP_BAD_AASTRING.
Referenced by iso_aa_get_acl_text(), iso_aa_lookup_attr(), and iso_node_get_attrs().
int iso_aa_lookup_attr | ( | unsigned char * | aa_string, |
char * | name, | ||
size_t * | value_length, | ||
char ** | value, | ||
int | flag | ||
) |
Search given name.
Eventually calloc() and copy value. Add trailing 0 byte for caller convenience.
Definition at line 1724 of file node.c.
References iso_aa_get_attrs(), and ISO_OUT_OF_MEM.
Referenced by iso_image_import(), and iso_node_lookup_attr().
Check if a node with the given name exists in a dir.
dir | A valid dir. It can't be NULL |
name | The node name to search for. It can't be NULL |
pos | If not NULL, will be filled with the position where to insert. If the node exists, (**pos) will refer to the given node. |
Definition at line 1338 of file node.c.
References iso_dir_find().
Referenced by iso_add_dir_src_rec(), iso_dir_get_node(), iso_tree_add_new_cut_out_node(), iso_tree_add_new_dir(), iso_tree_add_new_file(), iso_tree_add_new_node(), iso_tree_add_new_special(), iso_tree_add_new_symlink(), iso_tree_add_node_builder(), and make_really_unique_name().
Find the position where to insert a node.
dir | A valid dir. It can't be NULL |
name | The node name to search for. It can't be NULL |
pos | Will be filled with the position where to insert. It can't be NULL |
Definition at line 1330 of file node.c.
References Iso_Dir::children.
Referenced by iso_dir_add_node(), and iso_dir_exists().
int iso_dir_get_node_trunc | ( | IsoDir * | dir, |
int | truncate_length, | ||
const char * | name, | ||
IsoNode ** | node | ||
) |
Definition at line 654 of file node.c.
References iso_dir_get_node(), ISO_OUT_OF_MEM, iso_truncate_rr_name(), and LIBISO_FREE_MEM.
Referenced by iso_image_dir_get_node(), and iso_tree_path_to_node_flag().
int iso_dir_insert | ( | IsoDir * | dir, |
IsoNode * | node, | ||
IsoNode ** | pos, | ||
enum iso_replace_mode | replace | ||
) |
Inserts a given node in a dir, at the specified position.
dir | Dir where to insert. It can't be NULL |
node | The node to insert. It can't be NULL |
pos | Position where the node will be inserted. It is a pointer previously obtained with a call to iso_dir_exists() or iso_dir_find(). It can't be NULL. |
replace | Whether to replace an old node with the same name with the new node. |
Definition at line 1349 of file node.c.
References ISO_ASSERT_FAILURE, ISO_NODE_NAME_NOT_UNIQUE, iso_node_unref(), ISO_REPLACE_ALWAYS, ISO_REPLACE_IF_NEWER, ISO_REPLACE_IF_SAME_TYPE, ISO_REPLACE_IF_SAME_TYPE_AND_NEWER, ISO_REPLACE_NEVER, Iso_Node::mode, Iso_Node::mtime, Iso_Node::name, Iso_Dir::nchildren, Iso_Node::next, and Iso_Node::parent.
Referenced by iso_add_dir_src_rec(), iso_dir_add_node(), iso_tree_add_new_cut_out_node(), iso_tree_add_new_dir(), iso_tree_add_new_file(), iso_tree_add_new_node(), iso_tree_add_new_special(), iso_tree_add_new_symlink(), and iso_tree_add_node_builder().
int iso_dir_iter_register | ( | IsoDirIter * | iter | ) |
Add a new iterator to the registry.
The iterator register keeps track of all iterators being used, and are notified when directory structure changes.
Definition at line 1418 of file node.c.
References ISO_OUT_OF_MEM, ISO_SUCCESS, iter_reg_node::iter, and iter_reg.
Referenced by iso_dir_find_children(), and iso_dir_get_children().
void iso_dir_iter_unregister | ( | IsoDirIter * | iter | ) |
Unregister a directory iterator.
Definition at line 1434 of file node.c.
References iter_reg_node::iter, iter_reg, and iter_reg_node::next.
Referenced by iso_dir_iter_free().
int iso_file_set_isofscx | ( | IsoFile * | file, |
unsigned int | checksum_index, | ||
int | flag | ||
) |
Set the checksum index (typically coming from IsoFileSrc.checksum_index) of a regular file node.
The index is encoded as xattr "isofs.cx" with four bytes of value.
Definition at line 2887 of file node.c.
References iso_node_set_attrs().
Referenced by checksum_prepare_nodes(), iso_file_src_create(), and process_preserved_cx().
int iso_file_zf_by_magic | ( | IsoFile * | file, |
int | flag | ||
) |
Checks whether a file effectively bears a zisofs file header and eventually marks this by a struct zisofs_zf_info as xinfo of the file node.
flag | bit0= inquire the most original stream of the file bit1= permission to overwrite existing zisofs_zf_info bit2= if no zisofs header is found: create xinfo with parameters which indicate no zisofs |
Definition at line 2448 of file node.c.
References zisofs_zf_info::block_size_log2, zisofs_zf_info::header_size_div4, iso_file_get_stream(), iso_node_add_xinfo(), iso_node_get_xinfo(), iso_node_remove_xinfo(), ISO_OUT_OF_MEM, iso_stream_get_input_stream(), zisofs_zf_info::uncompressed_size, ziso_is_zisofs_stream(), zisofs_zf_info::zisofs_algo, and zisofs_zf_xinfo_func().
Referenced by iso_node_zf_by_magic().
Copy the xinfo list from one node to the another.
Definition at line 286 of file node.c.
References iso_node_add_xinfo(), iso_node_get_next_xinfo(), iso_node_remove_all_xinfo(), iso_node_revert_xinfo_list(), iso_node_xinfo_get_cloner(), and ISO_XINFO_NO_CLONE.
Referenced by iso_tree_copy_node_attr().
Definition at line 2743 of file node.c.
References aaip_count_bytes(), aaip_xinfo_func(), Iso_Node::atime, Iso_Node::ctime, Iso_Symlink::dest, Iso_Special::dev, Iso_Symlink::fs_id, Iso_Special::fs_id, Iso_Node::gid, iso_node_get_id(), iso_node_get_xinfo(), iso_stream_cmp_ino(), LIBISO_FILE, LIBISO_SPECIAL, LIBISO_SYMLINK, Iso_Node::mode, Iso_Node::mtime, Iso_Symlink::st_dev, Iso_Special::st_dev, Iso_Symlink::st_ino, Iso_Special::st_ino, Iso_File::stream, Iso_Node::type, and Iso_Node::uid.
Referenced by ecma119_node_cmp_flag(), and iso_node_cmp_ino().
int iso_node_get_id | ( | IsoNode * | node, |
unsigned int * | fs_id, | ||
dev_t * | dev_id, | ||
ino_t * | ino_id, | ||
int | flag | ||
) |
Definition at line 2592 of file node.c.
References Iso_Symlink::fs_id, Iso_Special::fs_id, ISO_IMAGE_FS_ID, iso_node_get_xinfo(), iso_px_ino_xinfo_func(), iso_stream_get_id(), LIBISO_FILE, LIBISO_SPECIAL, LIBISO_SYMLINK, Iso_Symlink::st_dev, Iso_Special::st_dev, Iso_Symlink::st_ino, Iso_Special::st_ino, Iso_File::stream, and Iso_Node::type.
Referenced by img_register_ino(), img_update_ino(), iso_node_cmp_flag(), and match_hardlinks().
int iso_node_is_valid_link_dest | ( | const char * | dest | ) |
Check if a given path is valid for the destination of a link.
Definition at line 1283 of file node.c.
References iso_node_is_valid_name(), ISO_NULL_POINTER, ISO_OUT_OF_MEM, ISO_RR_NAME_RESERVED, ISO_RR_PATH_TOO_LONG, and LIBISOFS_NODE_PATH_MAX.
Referenced by iso_node_new_symlink(), and iso_symlink_set_dest().
int iso_node_is_valid_name | ( | const char * | name | ) |
Check if a given name is valid for an iso node.
Definition at line 1245 of file node.c.
References ISO_NULL_POINTER, ISO_RR_NAME_RESERVED, ISO_RR_NAME_TOO_LONG, and LIBISOFS_NODE_NAME_MAX.
Referenced by iso_node_is_valid_link_dest(), iso_node_new_dir(), iso_node_new_file(), iso_node_new_special(), iso_node_new_symlink(), iso_node_set_name_trunc(), and iso_tree_add_boot_node().
int iso_node_new_dir | ( | char * | name, |
IsoDir ** | dir | ||
) |
Create a new IsoDir.
Attributes, uid/gid, timestamps, etc are set to default (0) values. You must set them.
name | Name for the node. It is not strdup() so you shouldn't use this reference when this function returns successfully. NULL is not allowed. |
dir |
Definition at line 1481 of file node.c.
References iso_node_is_valid_name(), ISO_NULL_POINTER, ISO_OUT_OF_MEM, ISO_SUCCESS, and LIBISO_DIR.
Referenced by default_create_node(), and iso_tree_add_new_dir().
Create a new file node.
Attributes, uid/gid, timestamps, etc are set to default (0) values. You must set them.
name | Name for the node. It is not strdup() so you shouldn't use this reference when this function returns successfully. NULL is not allowed. |
stream | Source for file contents. The reference is taken by the node, you must call iso_stream_ref() if you need your own ref. |
Definition at line 1507 of file node.c.
References iso_node_is_valid_name(), ISO_NULL_POINTER, ISO_OUT_OF_MEM, ISO_SUCCESS, and LIBISO_FILE.
Referenced by default_create_file(), default_create_node(), and iso_tree_add_new_file().
int iso_node_new_root | ( | IsoDir ** | root | ) |
Definition at line 1460 of file node.c.
References Iso_Node::atime, Iso_Node::ctime, iso_nowtime(), ISO_OUT_OF_MEM, ISO_SUCCESS, LIBISO_DIR, Iso_Node::mode, Iso_Node::mtime, Iso_Dir::node, Iso_Node::parent, Iso_Node::refcount, and Iso_Node::type.
Referenced by iso_image_import(), and iso_image_new().
int iso_node_new_special | ( | char * | name, |
mode_t | mode, | ||
dev_t | dev, | ||
IsoSpecial ** | special | ||
) |
Create a new special file node.
As far as libisofs concerns, an special file is a block device, a character device, a FIFO (named pipe) or a socket. You can choose the specific kind of file you want to add by setting mode properly (see man 2 stat).
Note that special files are only written to image when Rock Ridge extensions are enabled. Moreover, a special file is just a directory entry in the image tree, no data is written beyond that.
Owner and hidden atts are taken from parent. You can modify any of them later.
name | name for the new special file. It is not strdup() so you shouldn't use this reference when this function returns successfully. NULL is not allowed. |
mode | file type and permissions for the new node. Note that you can't specify any kind of file here, only special types are allowed. i.e, S_IFSOCK, S_IFBLK, S_IFCHR and S_IFIFO are valid types; S_IFLNK, S_IFREG and S_IFDIR aren't. |
dev | device ID, equivalent to the st_rdev field in man 2 stat. |
special | place where to store a pointer to the newly created special file. |
Definition at line 1573 of file node.c.
References iso_node_is_valid_name(), ISO_NULL_POINTER, ISO_OUT_OF_MEM, ISO_SUCCESS, ISO_WRONG_ARG_VALUE, and LIBISO_SPECIAL.
Referenced by default_create_node(), and iso_tree_add_new_special().
int iso_node_new_symlink | ( | char * | name, |
char * | dest, | ||
IsoSymlink ** | link | ||
) |
Creates a new IsoSymlink node.
Attributes, uid/gid, timestamps, etc are set to default (0) values. You must set them.
name | name for the new symlink. It is not strdup() so you shouldn't use this reference when this function returns successfully. NULL is not allowed. |
dest | destination of the link. It is not strdup() so you shouldn't use this reference when this function returns successfully. NULL is not allowed. |
link | place where to store a pointer to the newly created link. |
Definition at line 1538 of file node.c.
References iso_node_is_valid_link_dest(), iso_node_is_valid_name(), ISO_NULL_POINTER, ISO_OUT_OF_MEM, ISO_SUCCESS, and LIBISO_SYMLINK.
Referenced by default_create_node(), and iso_tree_add_new_symlink().
int iso_node_set_ino | ( | IsoNode * | node, |
ino_t | ino, | ||
int | flag | ||
) |
Definition at line 2672 of file node.c.
References Iso_Symlink::fs_id, Iso_Special::fs_id, ISO_IMAGE_FS_ID, iso_node_get_xinfo(), iso_node_set_ino_xinfo(), iso_px_ino_xinfo_func(), iso_stream_set_image_ino(), LIBISO_FILE, LIBISO_SPECIAL, LIBISO_SYMLINK, Iso_Symlink::st_ino, Iso_Special::st_ino, Iso_File::stream, and Iso_Node::type.
Referenced by image_builder_create_node(), iso_image_import(), and iso_node_set_unique_id().
int iso_node_set_perms_internal | ( | IsoNode * | node, |
mode_t | mode, | ||
int | flag | ||
) |
See API function iso_node_set_permissions()
flag | bit0= do not adjust ACL |
Definition at line 430 of file node.c.
References iso_node_set_acl_text(), and Iso_Node::mode.
Referenced by default_create_node(), iso_node_set_acl_text(), and iso_node_set_permissions().
Definition at line 2718 of file node.c.
References img_give_ino_number(), and iso_node_set_ino().
Referenced by img_update_ino().
void iso_notify_dir_iters | ( | IsoNode * | node, |
int | flag | ||
) |
Definition at line 1448 of file node.c.
References Iso_Dir_Iter::class, Iso_Dir_Iter::dir, iter_reg_node::iter, iter_reg, iter_reg_node::next, iso_dir_iter_iface::notify_child_taken, and Iso_Node::parent.
Referenced by iso_node_take().
int iso_px_ino_xinfo_cloner | ( | void * | old_data, |
void ** | new_data, | ||
int | flag | ||
) |
Definition at line 2571 of file node.c.
References ISO_OUT_OF_MEM, and ISO_XINFO_NO_CLONE.
Referenced by iso_init_with_flag().
int iso_px_ino_xinfo_func | ( | void * | data, |
int | flag | ||
) |
The iso_node_xinfo_func instance which governs the storing of the inode number from Rock Ridge field PX.
Definition at line 2559 of file node.c.
Referenced by iso_init_with_flag(), iso_node_get_id(), iso_node_set_ino(), and iso_node_set_ino_xinfo().
int iso_root_get_isofsca | ( | IsoNode * | node, |
uint32_t * | start_lba, | ||
uint32_t * | end_lba, | ||
uint32_t * | count, | ||
uint32_t * | size, | ||
char | typetext[81], | ||
int | flag | ||
) |
Get the checksum area description.
node should be the root node. It is encoded as xattr "isofs.ca".
Definition at line 2941 of file node.c.
References iso_node_lookup_attr(), ISO_SUCCESS, and iso_util_decode_len_bytes().
Referenced by iso_image_import().
int iso_root_get_isofsnt | ( | IsoNode * | node, |
uint32_t * | truncate_mode, | ||
uint32_t * | truncate_length, | ||
int | flag | ||
) |
Definition at line 3001 of file node.c.
References iso_node_lookup_attr(), ISO_SUCCESS, and iso_util_decode_len_bytes().
Referenced by iso_image_import().
int iso_root_set_isofsca | ( | IsoNode * | node, |
uint32_t | start_lba, | ||
uint32_t | end_lba, | ||
uint32_t | count, | ||
uint32_t | size, | ||
char * | typetext, | ||
int | flag | ||
) |
Set the checksum area description.
node should be the root node. It is encoded as xattr "isofs.ca".
Definition at line 2910 of file node.c.
References iso_node_set_attrs(), and iso_util_encode_len_bytes().
Referenced by checksum_prepare_image(), checksum_writer_compute_data_blocks(), and ecma119_writer_write_dirs().
int iso_root_set_isofsnt | ( | IsoNode * | node, |
uint32_t | truncate_mode, | ||
uint32_t | truncate_length, | ||
int | flag | ||
) |
Record and get truncation parameters as of iso_image_set_truncate_mode() by "isofs.nt".
Definition at line 2982 of file node.c.
References iso_node_set_attrs(), and iso_util_encode_len_bytes().
Referenced by ecma119_image_new().
int zisofs_zf_xinfo_cloner | ( | void * | old_data, |
void ** | new_data, | ||
int | flag | ||
) |
Definition at line 2423 of file node.c.
References ISO_OUT_OF_MEM, and ISO_XINFO_NO_CLONE.
Referenced by iso_init_with_flag().
int zisofs_zf_xinfo_func | ( | void * | data, |
int | flag | ||
) |
Function to identify and manage ZF parameters which do not stem from ZF fields (those are known to the FileSource) and do not stem from filters ("ziso" knows them globally, "osiz" knows them individually) but rather from an inspection of the file content header for zisofs magic number and plausible parameters.
The parameters get attached in struct zisofs_zf_info as xinfo to an IsoNode.
Definition at line 2411 of file node.c.
Referenced by add_zf_field(), iso_file_zf_by_magic(), iso_init_with_flag(), and iso_node_zf_by_magic().