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)  

tree.c File Reference
#include "libisofs.h"
#include "node.h"
#include "image.h"
#include "fsource.h"
#include "builder.h"
#include "messages.h"
#include "tree.h"
#include "util.h"
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <limits.h>
#include <stdio.h>
#include <fnmatch.h>
Include dependency graph for tree.c:

Go to the source code of this file.

Functions

int iso_tree_add_new_dir (IsoDir *parent, const char *name, IsoDir **dir)
 
int iso_image_add_new_dir (IsoImage *image, IsoDir *parent, const char *name, IsoDir **dir)
 
int iso_tree_add_new_symlink (IsoDir *parent, const char *name, const char *dest, IsoSymlink **link)
 
int iso_image_add_new_symlink (IsoImage *image, IsoDir *parent, const char *name, const char *dest, IsoSymlink **link)
 
int iso_tree_add_new_special (IsoDir *parent, const char *name, mode_t mode, dev_t dev, IsoSpecial **special)
 
int iso_image_add_new_special (IsoImage *image, IsoDir *parent, const char *name, mode_t mode, dev_t dev, IsoSpecial **special)
 
int iso_tree_add_new_file (IsoDir *parent, const char *name, IsoStream *stream, IsoFile **file)
 
int iso_image_add_new_file (IsoImage *image, IsoDir *parent, const char *name, IsoStream *stream, IsoFile **file)
 
void iso_tree_set_follow_symlinks (IsoImage *image, int follow)
 
int iso_tree_get_follow_symlinks (IsoImage *image)
 
void iso_tree_set_ignore_hidden (IsoImage *image, int skip)
 
int iso_tree_get_ignore_hidden (IsoImage *image)
 
void iso_tree_set_replace_mode (IsoImage *image, enum iso_replace_mode mode)
 
enum iso_replace_mode iso_tree_get_replace_mode (IsoImage *image)
 
void iso_tree_set_ignore_special (IsoImage *image, int skip)
 
int iso_tree_get_ignore_special (IsoImage *image)
 
void iso_tree_set_report_callback (IsoImage *image, int(*report)(IsoImage *, IsoFileSource *))
 
int iso_tree_add_exclude (IsoImage *image, const char *path)
 
int iso_tree_remove_exclude (IsoImage *image, const char *path)
 
static int iso_tree_add_node_builder (IsoImage *image, IsoDir *parent, IsoFileSource *src, IsoNodeBuilder *builder, IsoNode **node)
 
int iso_tree_add_node (IsoImage *image, IsoDir *parent, const char *path, IsoNode **node)
 
int iso_tree_add_new_node (IsoImage *image, IsoDir *parent, const char *name, const char *path, IsoNode **node)
 
int iso_tree_add_new_cut_out_node (IsoImage *image, IsoDir *parent, const char *name, const char *path, off_t offset, off_t size, IsoNode **node)
 
static int check_excludes (IsoImage *image, const char *path)
 
static int check_hidden (IsoImage *image, const char *name)
 
static int check_special (IsoImage *image, mode_t mode)
 
static void ascii_increment (char *name, int len, int pos, int rollover_carry)
 
static int insert_underscores (char *name, int *len, int *at_pos, int count, char **new_name)
 
static int make_incrementable_name (char **name, char **unique_name, int *low_pos, int *rollover_carry, int *pre_check)
 
static int make_really_unique_name (IsoDir *parent, char **name, char **unique_name, IsoNode ***pos, int flag)
 
int iso_add_dir_src_rec (IsoImage *image, IsoDir *parent, IsoFileSource *dir)
 
int iso_tree_add_dir_rec (IsoImage *image, IsoDir *parent, const char *dir)
 
int iso_tree_path_to_node_flag (IsoImage *image, const char *path, IsoNode **node, int flag)
 
int iso_tree_path_to_node (IsoImage *image, const char *path, IsoNode **node)
 
int iso_image_path_to_node (IsoImage *image, const char *path, IsoNode **node)
 
char * iso_tree_get_node_path (IsoNode *node)
 
int iso_tree_get_node_of_block (IsoImage *image, IsoDir *dir, uint32_t block, IsoNode **found, uint32_t *next_above, int flag)
 
static int iso_tree_copy_node_attr (IsoNode *old_node, IsoNode *new_node, int flag)
 
static int iso_tree_clone_dir (IsoDir *old_dir, IsoDir *new_parent, char *new_name, IsoNode **new_node, int flag)
 
static int iso_tree_clone_file (IsoFile *old_file, IsoDir *new_parent, char *new_name, IsoNode **new_node, int flag)
 
static int iso_tree_clone_symlink (IsoSymlink *node, IsoDir *new_parent, char *new_name, IsoNode **new_node, int flag)
 
static int iso_tree_clone_special (IsoSpecial *node, IsoDir *new_parent, char *new_name, IsoNode **new_node, int flag)
 
int iso_tree_clone_trunc (IsoNode *node, IsoDir *new_parent, char *new_name_in, IsoNode **new_node, int truncate_length, int flag)
 
int iso_tree_clone (IsoNode *node, IsoDir *new_parent, char *new_name, IsoNode **new_node, int flag)
 
int iso_image_tree_clone (IsoImage *image, IsoNode *node, IsoDir *new_parent, char *new_name, IsoNode **new_node, int flag)
 
int iso_tree_resolve_symlink (IsoImage *img, IsoSymlink *sym, IsoNode **res, int *depth, int flag)
 

Function Documentation

◆ ascii_increment()

static void ascii_increment ( char *  name,
int  len,
int  pos,
int  rollover_carry 
)
static

Definition at line 813 of file tree.c.

Referenced by make_really_unique_name().

◆ check_excludes()

static int check_excludes ( IsoImage image,
const char *  path 
)
static

Definition at line 759 of file tree.c.

References Iso_Image::excludes, and Iso_Image::nexcludes.

Referenced by iso_add_dir_src_rec().

◆ check_hidden()

static int check_hidden ( IsoImage image,
const char *  name 
)
static

Definition at line 786 of file tree.c.

References Iso_Image::ignore_hidden.

Referenced by iso_add_dir_src_rec().

◆ check_special()

static int check_special ( IsoImage image,
mode_t  mode 
)
static

Definition at line 792 of file tree.c.

References Iso_Image::ignore_special.

Referenced by iso_add_dir_src_rec().

◆ insert_underscores()

static int insert_underscores ( char *  name,
int *  len,
int *  at_pos,
int  count,
char **  new_name 
)
static

Definition at line 850 of file tree.c.

References ISO_SUCCESS, and LIBISO_ALLOC_MEM.

Referenced by make_incrementable_name().

◆ iso_add_dir_src_rec()

◆ iso_image_add_new_dir()

int iso_image_add_new_dir ( IsoImage image,
IsoDir parent,
const char *  name,
IsoDir **  dir 
)

Add a new directory to the iso tree. Permissions, owner and hidden atts are taken from parent, you can modify them later.

Parameters
imageThe image object to which the new directory shall belong.
parentThe directory node where the new directory will be grafted in.
nameName for the new directory. If truncation mode is set to 1, an oversized name gets truncated before further processing. If a node with same name already exists on parent, this function fails with ISO_NODE_NAME_NOT_UNIQUE.
dirplace where to store a pointer to the newly created dir. No extra ref is added, so you will need to call iso_node_ref() if you really need it. You can pass NULL in this parameter if you don't need the pointer.
Returns
number of nodes in parent if success, < 0 otherwise Possible errors: ISO_NULL_POINTER, if parent or name are NULL ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists ISO_OUT_OF_MEM ISO_RR_NAME_TOO_LONG
Since
1.4.2

Definition at line 103 of file tree.c.

References iso_image_truncate_name(), and iso_tree_add_new_dir().

Referenced by Xorriso_graft_in(), and Xorriso_graft_split().

◆ iso_image_add_new_file()

int iso_image_add_new_file ( IsoImage image,
IsoDir parent,
const char *  name,
IsoStream stream,
IsoFile **  file 
)

Add a new regular file to the iso tree. Permissions are set to 0444, owner and hidden atts are taken from parent. You can modify any of them later.

Parameters
imageThe image object to which the new file shall belong.
parentThe directory node where the new directory will be grafted in.
nameName for the new file. If truncation mode is set to 1, an oversized name gets truncated before further processing. If a node with same name already exists on parent, this function fails with ISO_NODE_NAME_NOT_UNIQUE.
streamIsoStream for the contents of the file. The reference will be taken by the newly created file, you will need to take an extra ref to it if you need it.
fileplace where to store a pointer to the newly created file. No extra ref is added, so you will need to call iso_node_ref() if you really need it. You can pass NULL in this parameter if you don't need the pointer
Returns
number of nodes in parent if success, < 0 otherwise Possible errors: ISO_NULL_POINTER, if parent, name or dest are NULL ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists ISO_OUT_OF_MEM ISO_RR_NAME_TOO_LONG
Since
1.4.2

Definition at line 383 of file tree.c.

References iso_image_truncate_name(), and iso_tree_add_new_file().

◆ iso_image_add_new_special()

int iso_image_add_new_special ( IsoImage image,
IsoDir parent,
const char *  name,
mode_t  mode,
dev_t  dev,
IsoSpecial **  special 
)

Add a new special file to the directory tree. As far as libisofs concerns, a 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.

Parameters
imageThe image object to which the new special file shall belong.
parentThe directory node where the new special file will be grafted in.
nameName for the new special file. If truncation mode is set to 1, an oversized name gets truncated before further processing. If a node with same name already exists on parent, this function fails with ISO_NODE_NAME_NOT_UNIQUE.
modeFile type and permissions for the new node. Note that only the file types S_IFSOCK, S_IFBLK, S_IFCHR, and S_IFIFO are allowed. S_IFLNK, S_IFREG, or S_IFDIR are not.
devDevice ID, equivalent to the st_rdev field in man 2 stat.
specialPlace where to store a pointer to the newly created special file. No extra ref is added, so you will need to call iso_node_ref() if you really need it. You can pass NULL in this parameter if you don't need the pointer.
Returns
Number of nodes in parent if success, < 0 otherwise Possible errors: ISO_NULL_POINTER, if parent, name or dest are NULL ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists ISO_WRONG_ARG_VALUE if you select a incorrect mode ISO_OUT_OF_MEM ISO_RR_NAME_TOO_LONG
Since
1.4.2

Definition at line 294 of file tree.c.

References iso_image_truncate_name(), and iso_tree_add_new_special().

◆ iso_image_add_new_symlink()

int iso_image_add_new_symlink ( IsoImage image,
IsoDir parent,
const char *  name,
const char *  dest,
IsoSymlink **  link 
)

Add a new symbolic link to the directory tree. Permissions are set to 0777, owner and hidden atts are taken from parent. You can modify any of them later.

Parameters
imageThe image object to which the new directory shall belong.
parentThe directory node where the new symlink will be grafted in.
nameName for the new symlink. If truncation mode is set to 1, an oversized name gets truncated before further processing. If a node with same name already exists on parent, this function fails with ISO_NODE_NAME_NOT_UNIQUE.
destThe destination path of the link. The components of this path are not checked for being oversized.
linkPlace where to store a pointer to the newly created link. No extra ref is added, so you will need to call iso_node_ref() if you really need it. You can pass NULL in this parameter if you don't need the pointer
Returns
number of nodes in parent if success, < 0 otherwise Possible errors: ISO_NULL_POINTER, if parent, name or dest are NULL ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists ISO_OUT_OF_MEM ISO_RR_NAME_TOO_LONG
Since
1.4.2

Definition at line 191 of file tree.c.

References iso_image_truncate_name(), and iso_tree_add_new_symlink().

Referenced by Xorriso_add_symlink().

◆ iso_image_path_to_node()

int iso_image_path_to_node ( IsoImage image,
const char *  path,
IsoNode **  node 
)

Locate a node by its absolute path in the image. The IsoImage context defines a maximum permissible name length and a mode how to react on oversized names. See iso_image_set_truncate_mode().

Parameters
imageThe image to which the node belongs.
pathFile path beginning at the root directory of image. If truncation mode is set to 1, oversized path components will be truncated before lookup.
nodeLocation for a pointer to the node, it will be filled with NULL if the given path does not exists on image. The node will be owned by the image and shouldn't be unref(). Just call iso_node_ref() to get your own reference to the node. Note that you can pass NULL is the only thing you want to do is check if a node with such path really exists.
Returns
1 node found 0 no truncation was needed, path not found in image 2 truncation happened, truncated path component not found in parent dir < 0 error, see iso_dir_get_node().
Since
1.4.2

Definition at line 1242 of file tree.c.

References iso_tree_path_to_node_flag().

Referenced by Xorriso_node_from_path().

◆ iso_image_tree_clone()

int iso_image_tree_clone ( IsoImage image,
IsoNode node,
IsoDir new_parent,
char *  new_name,
IsoNode **  new_node,
int  flag 
)

Create a copy of the given node under a different path. If the node is actually a directory then clone its whole subtree. This call may fail because an IsoFile is encountered which gets fed by an IsoStream which cannot be cloned. See also IsoStream_Iface method clone_stream(). Surely clonable node types are: IsoDir, IsoSymlink, IsoSpecial, IsoFile from a loaded ISO image, IsoFile referring to local filesystem files, IsoFile created by iso_tree_add_new_file from a stream created by iso_memory_stream_new(), IsoFile created by iso_tree_add_new_cut_out_node() Silently ignored are nodes of type IsoBoot. An IsoFile node with IsoStream filters can be cloned if all those filters are clonable and the node would be clonable without filter. Clonable IsoStream filters are created by: iso_file_add_zisofs_filter() iso_file_add_gzip_filter() iso_file_add_external_filter() An IsoNode with extended information as of iso_node_add_xinfo() can only be cloned if each of the iso_node_xinfo_func instances is associated to a clone function. See iso_node_xinfo_make_clonable(). All internally used classes of extended information are clonable.

The IsoImage context defines a maximum permissible name length and a mode how to react on oversized names. See iso_image_set_truncate_mode().

Parameters
imageThe image object to which the node belongs.
nodeThe node to be cloned.
new_parentThe existing directory node where to insert the cloned node.
new_nameThe name for the cloned node. It must not yet exist in new_parent, unless it is a directory and node is a directory and flag bit0 is set.
new_nodeWill return a pointer (without reference) to the newly created clone.
flagBitfield for control purposes. Submit any undefined bits as 0. bit0= Merge directories rather than returning ISO_NODE_NAME_NOT_UNIQUE. This will not allow to overwrite any existing node. Attributes of existing directories will not be overwritten. bit1= issue warning in case of new_name truncation
Returns
<0 means error, 1 = new node created, 2 = if flag bit0 is set: new_node is a directory which already existed.
Since
1.4.2

Definition at line 1563 of file tree.c.

References iso_tree_clone_trunc(), Iso_Image::truncate_length, and Iso_Image::truncate_mode.

Referenced by Xorriso_clone_tree(), and Xorriso_clone_under().

◆ iso_tree_add_dir_rec()

int iso_tree_add_dir_rec ( IsoImage image,
IsoDir parent,
const char *  dir 
)

Add the contents of a dir to a given directory of the iso tree.

There are several options to control what files are added or how they are managed. Take a look at iso_tree_set_* functions to see different options for recursive directory addition.

TODO comment Builder and Filesystem related issues when exposing both

Parameters
imageThe image to which the directory belongs.
parentDirectory on the image tree where to add the contents of the dir
dirPath to a dir in the filesystem
Returns
number of nodes in parent if success, < 0 otherwise
Since
0.6.2

Definition at line 1144 of file tree.c.

References Iso_Image::fs, iso_filesystem::get_by_path, iso_add_dir_src_rec(), ISO_FILE_IS_NOT_DIR, iso_file_source_stat(), iso_file_source_unref(), and ISO_NULL_POINTER.

◆ iso_tree_add_exclude()

int iso_tree_add_exclude ( IsoImage image,
const char *  path 
)

Add a excluded path. These are paths that won't never added to image, and will be excluded even when adding recursively its parent directory.

For example, in

iso_tree_add_exclude(image, "/home/user/data/private"); iso_tree_add_dir_rec(image, root, "/home/user/data");

the directory /home/user/data/private won't be added to image.

Returns
1 on success, < 0 on error

Definition at line 504 of file tree.c.

References Iso_Image::excludes, ISO_NULL_POINTER, ISO_OUT_OF_MEM, ISO_SUCCESS, and Iso_Image::nexcludes.

◆ iso_tree_add_new_cut_out_node()

int iso_tree_add_new_cut_out_node ( IsoImage image,
IsoDir parent,
const char *  name,
const char *  path,
off_t  offset,
off_t  size,
IsoNode **  node 
)

Add a new node to the image tree with the given name that must not exist on dir. The node data content will be a byte interval out of the data content of a file in the local filesystem.

Parameters
imageThe image
parentThe directory in the image tree where the node will be added.
nameThe leaf name that the node will have on image, possibly truncated according to iso_image_set_truncate_mode(). Its directory path depends on the parent node.
pathThe absolute path of the file in the local filesystem. For now only regular files and symlinks to regular files are supported.
offsetByte number in the given file from where to start reading data.
sizeMax size of the file. This may be more than actually available from byte offset to the end of the file in the local filesystem.
nodeplace where to store a pointer to the newly added file. No extra ref is added, so you will need to call iso_node_ref() if you really need it. You can pass NULL in this parameter if you don't need the pointer.
Returns
number of nodes in parent if success, < 0 otherwise Possible errors: ISO_NULL_POINTER, if image, parent or path are NULL ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists ISO_OUT_OF_MEM ISO_RR_NAME_TOO_LONG
Since
0.6.4

Definition at line 674 of file tree.c.

References Iso_Image::builder, Iso_Node_Builder::create_file, Iso_Image::fs, iso_filesystem::get_by_path, iso_cut_out_stream_new(), iso_dir_exists(), iso_dir_insert(), iso_file_source_stat(), iso_file_source_unref(), iso_image_truncate_name(), ISO_NODE_NAME_NOT_UNIQUE, iso_node_set_name(), iso_node_unref(), ISO_NULL_POINTER, ISO_REPLACE_NEVER, iso_stream_unref(), and ISO_WRONG_ARG_VALUE.

Referenced by Xorriso_tree_graft_node().

◆ iso_tree_add_new_dir()

int iso_tree_add_new_dir ( IsoDir parent,
const char *  name,
IsoDir **  dir 
)

Add a new directory to the iso tree.

Parameters
parentthe dir where the new directory will be created
namename for the new dir. If a node with same name already exists on parent, this functions fails with ISO_NODE_NAME_NOT_UNIQUE.
dirplace where to store a pointer to the newly created dir. No extra ref is added, so you will need to call iso_node_ref() if you really need it. You can pass NULL in this parameter if you don't need the pointer.
Returns
number of nodes in dir if success, < 0 otherwise Possible errors: ISO_NULL_POINTER, if parent or name are NULL ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists

Definition at line 55 of file tree.c.

References Iso_Node::gid, Iso_Node::hidden, iso_dir_exists(), iso_dir_insert(), ISO_NODE_NAME_NOT_UNIQUE, iso_node_new_dir(), iso_node_set_atime(), iso_node_set_ctime(), iso_node_set_gid(), iso_node_set_hidden(), iso_node_set_mtime(), iso_node_set_permissions(), iso_node_set_uid(), iso_nowtime(), ISO_NULL_POINTER, ISO_REPLACE_NEVER, Iso_Node::mode, Iso_Dir::node, and Iso_Node::uid.

Referenced by iso_image_add_new_dir(), iso_tree_clone_dir(), and make_reloc_dir_if_needed().

◆ iso_tree_add_new_file()

int iso_tree_add_new_file ( IsoDir parent,
const char *  name,
IsoStream stream,
IsoFile **  file 
)

Add a new regular file to the iso tree. Permissions are set to 0444, owner and hidden atts are taken from parent. You can modify any of them later.

Parameters
parentthe dir where the new file will be created
namename for the new file. If a node with same name already exists on parent, this functions fails with ISO_NODE_NAME_NOT_UNIQUE.
streamIsoStream for the contents of the file
fileplace where to store a pointer to the newly created file. No extra ref is added, so you will need to call iso_node_ref() if you really need it. You can pass NULL in this parameter if you don't need the pointer
Returns
number of nodes in parent if success, < 0 otherwise Possible errors: ISO_NULL_POINTER, if parent, name or dest are NULL ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists ISO_OUT_OF_MEM
Since
0.6.4

Definition at line 334 of file tree.c.

References Iso_Node::gid, Iso_Node::hidden, iso_dir_exists(), iso_dir_insert(), ISO_NODE_NAME_NOT_UNIQUE, iso_node_new_file(), iso_node_set_atime(), iso_node_set_ctime(), iso_node_set_gid(), iso_node_set_hidden(), iso_node_set_mtime(), iso_node_set_permissions(), iso_node_set_uid(), iso_nowtime(), ISO_NULL_POINTER, ISO_REPLACE_NEVER, Iso_Dir::node, and Iso_Node::uid.

Referenced by iso_image_add_new_file(), and iso_tree_clone_file().

◆ iso_tree_add_new_node()

int iso_tree_add_new_node ( IsoImage image,
IsoDir parent,
const char *  name,
const char *  path,
IsoNode **  node 
)

This is a more versatile form of iso_tree_add_node which allows to set the node name in ISO image already when it gets added.

Add a new node to the image tree, from an existing file, and with the given name, that must not exist on dir.

Parameters
imageThe image
parentThe directory in the image tree where the node will be added.
nameThe leaf name that the node will have on image, possibly truncated according to iso_image_set_truncate_mode(). Its directory path depends on the parent node.
pathThe absolute path of the file in the local filesystem.
nodeplace where to store a pointer to the newly added file. No extra ref is added, so you will need to call iso_node_ref() if you really need it. You can pass NULL in this parameter if you don't need the pointer.
Returns
number of nodes in parent if success, < 0 otherwise Possible errors: ISO_NULL_POINTER, if image, parent or path are NULL ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists ISO_OUT_OF_MEM ISO_RR_NAME_TOO_LONG
Since
0.6.4

Definition at line 621 of file tree.c.

References Iso_Image::builder, Iso_Node_Builder::create_node, Iso_Image::fs, iso_filesystem::get_by_path, iso_dir_exists(), iso_dir_insert(), iso_file_source_unref(), iso_image_truncate_name(), ISO_NODE_NAME_NOT_UNIQUE, ISO_NULL_POINTER, and ISO_REPLACE_NEVER.

Referenced by Xorriso_tree_graft_node().

◆ iso_tree_add_new_special()

int iso_tree_add_new_special ( IsoDir parent,
const char *  name,
mode_t  mode,
dev_t  dev,
IsoSpecial **  special 
)

Add a new special file to the directory tree. 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.

Parameters
parentthe dir where the new special file will be created
namename for the new special file. If a node with same name already exists on parent, this functions fails with ISO_NODE_NAME_NOT_UNIQUE.
modefile 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.
devdevice ID, equivalent to the st_rdev field in man 2 stat.
specialplace where to store a pointer to the newly created special file. No extra ref is added, so you will need to call iso_node_ref() if you really need it. You can pass NULL in this parameter if you don't need the pointer.
Returns
number of nodes in parent if success, < 0 otherwise Possible errors: ISO_NULL_POINTER, if parent, name or dest are NULL ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists ISO_OUT_OF_MEM

Definition at line 243 of file tree.c.

References Iso_Node::gid, Iso_Node::hidden, iso_dir_exists(), iso_dir_insert(), ISO_NODE_NAME_NOT_UNIQUE, iso_node_new_special(), iso_node_set_atime(), iso_node_set_ctime(), iso_node_set_gid(), iso_node_set_hidden(), iso_node_set_mtime(), iso_node_set_uid(), iso_nowtime(), ISO_NULL_POINTER, ISO_REPLACE_NEVER, ISO_WRONG_ARG_VALUE, Iso_Dir::node, and Iso_Node::uid.

Referenced by iso_image_add_new_special(), and iso_tree_clone_special().

◆ iso_tree_add_new_symlink()

int iso_tree_add_new_symlink ( IsoDir parent,
const char *  name,
const char *  dest,
IsoSymlink **  link 
)

Add a new symlink to the directory tree. Permissions are set to 0777, owner and hidden atts are taken from parent. You can modify any of them later.

Parameters
parentthe dir where the new symlink will be created
namename for the new dir. If a node with same name already exists on parent, this functions fails with ISO_NODE_NAME_NOT_UNIQUE.
destdestination of the link
linkplace where to store a pointer to the newly created link. No extra ref is added, so you will need to call iso_node_ref() if you really need it. You can pass NULL in this parameter if you don't need the pointer
Returns
number of nodes in parent if success, < 0 otherwise Possible errors: ISO_NULL_POINTER, if parent, name or dest are NULL ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists ISO_OUT_OF_MEM

Definition at line 140 of file tree.c.

References Iso_Node::gid, Iso_Node::hidden, iso_dir_exists(), iso_dir_insert(), ISO_NODE_NAME_NOT_UNIQUE, iso_node_new_symlink(), iso_node_set_atime(), iso_node_set_ctime(), iso_node_set_gid(), iso_node_set_hidden(), iso_node_set_mtime(), iso_node_set_permissions(), iso_node_set_uid(), iso_nowtime(), ISO_NULL_POINTER, ISO_REPLACE_NEVER, Iso_Dir::node, and Iso_Node::uid.

Referenced by iso_image_add_new_symlink(), and iso_tree_clone_symlink().

◆ iso_tree_add_node()

int iso_tree_add_node ( IsoImage image,
IsoDir parent,
const char *  path,
IsoNode **  node 
)

Add a new node to the image tree, from an existing file.

TODO comment Builder and Filesystem related issues when exposing both

All attributes will be taken from the source file. The appropriate file type will be created.

Parameters
imageThe image
parentThe directory in the image tree where the node will be added.
pathThe absolute path of the file in the local filesystem. The node will have the same leaf name as the file on disk, possibly truncated according to iso_image_set_truncate_mode(). Its directory path depends on the parent node.
nodeplace where to store a pointer to the newly added file. No extra ref is added, so you will need to call iso_node_ref() if you really need it. You can pass NULL in this parameter if you don't need the pointer.
Returns
number of nodes in parent if success, < 0 otherwise Possible errors: ISO_NULL_POINTER, if image, parent or path are NULL ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists ISO_OUT_OF_MEM ISO_RR_NAME_TOO_LONG
Since
0.6.2

Definition at line 598 of file tree.c.

References Iso_Image::builder, Iso_Image::fs, iso_filesystem::get_by_path, iso_file_source_unref(), ISO_NULL_POINTER, and iso_tree_add_node_builder().

◆ iso_tree_add_node_builder()

static int iso_tree_add_node_builder ( IsoImage image,
IsoDir parent,
IsoFileSource src,
IsoNodeBuilder builder,
IsoNode **  node 
)
static

◆ iso_tree_clone()

int iso_tree_clone ( IsoNode node,
IsoDir new_parent,
char *  new_name,
IsoNode **  new_node,
int  flag 
)
                       *** Deprecated ***
              use iso_image_tree_clone() instead

Create a copy of the given node under a different path without taking into respect name truncation mode of an IsoImage.

Parameters
nodeThe node to be cloned.
new_parentThe existing directory node where to insert the cloned node.
new_nameThe name for the cloned node. It must not yet exist in new_parent, unless it is a directory and node is a directory and flag bit0 is set.
new_nodeWill return a pointer (without reference) to the newly created clone.
flagBitfield for control purposes. Submit any undefined bits as 0. bit0= Merge directories rather than returning ISO_NODE_NAME_NOT_UNIQUE. This will not allow to overwrite any existing node. Attributes of existing directories will not be overwritten.
Returns
<0 means error, 1 = new node created, 2 = if flag bit0 is set: new_node is a directory which already existed.
Since
1.0.2

Definition at line 1553 of file tree.c.

References iso_tree_clone_trunc().

Referenced by iso_tree_clone_dir().

◆ iso_tree_clone_dir()

static int iso_tree_clone_dir ( IsoDir old_dir,
IsoDir new_parent,
char *  new_name,
IsoNode **  new_node,
int  flag 
)
static

◆ iso_tree_clone_file()

static int iso_tree_clone_file ( IsoFile old_file,
IsoDir new_parent,
char *  new_name,
IsoNode **  new_node,
int  flag 
)
static

◆ iso_tree_clone_special()

static int iso_tree_clone_special ( IsoSpecial node,
IsoDir new_parent,
char *  new_name,
IsoNode **  new_node,
int  flag 
)
static

◆ iso_tree_clone_symlink()

static int iso_tree_clone_symlink ( IsoSymlink node,
IsoDir new_parent,
char *  new_name,
IsoNode **  new_node,
int  flag 
)
static

◆ iso_tree_clone_trunc()

int iso_tree_clone_trunc ( IsoNode node,
IsoDir new_parent,
char *  new_name_in,
IsoNode **  new_node,
int  truncate_length,
int  flag 
)

◆ iso_tree_copy_node_attr()

static int iso_tree_copy_node_attr ( IsoNode old_node,
IsoNode new_node,
int  flag 
)
static

◆ iso_tree_get_follow_symlinks()

int iso_tree_get_follow_symlinks ( IsoImage image)

Get current setting for follow_symlinks.

See also
iso_tree_set_follow_symlinks

Definition at line 410 of file tree.c.

References Iso_Image::follow_symlinks.

Referenced by default_create_node().

◆ iso_tree_get_ignore_hidden()

int iso_tree_get_ignore_hidden ( IsoImage image)

Get current setting for ignore_hidden.

See also
iso_tree_set_ignore_hidden

Definition at line 429 of file tree.c.

References Iso_Image::ignore_hidden.

◆ iso_tree_get_ignore_special()

int iso_tree_get_ignore_special ( IsoImage image)

Get current setting for ignore_special.

See also
iso_tree_set_ignore_special

Definition at line 466 of file tree.c.

References Iso_Image::ignore_special.

◆ iso_tree_get_node_of_block()

◆ iso_tree_get_node_path()

char* iso_tree_get_node_path ( IsoNode node)

Get the absolute path on image of the given node.

Returns
The path on the image, that must be freed when no more needed. If the given node is not added to any image, this returns NULL.
Since
0.6.4

Definition at line 1247 of file tree.c.

References iso_tree_get_node_path(), Iso_Node::name, and Iso_Node::parent.

Referenced by create_file_src(), create_node(), create_tree(), dir_update_size(), iso_analyze_alpha_boot(), iso_analyze_hppa(), iso_analyze_mips(), iso_analyze_mipsel(), iso_eltorito_report(), iso_impsysa_report(), iso_impsysa_report_blockpath(), and iso_tree_get_node_path().

◆ iso_tree_get_replace_mode()

enum iso_replace_mode iso_tree_get_replace_mode ( IsoImage image)

Get current setting for replace_mode.

See also
iso_tree_set_replace_mode
Since
0.6.2

Definition at line 434 of file tree.c.

References Iso_Image::replace.

◆ iso_tree_path_to_node()

int iso_tree_path_to_node ( IsoImage image,
const char *  path,
IsoNode **  node 
)
                       *** Deprecated ***
         In most cases use iso_image_path_to_node() instead

Locate a node by its absolute path on image without taking into respect name truncation mode of the image.

Parameters
imageThe image to which the node belongs.
pathFile path beginning at the root directory of image. No truncation will happen.
nodeLocation for a pointer to the node, it will be filled with NULL if the given path does not exists on image. See iso_image_path_to_node().
Returns
1 found, 0 not found, < 0 error
Since
0.6.2

Definition at line 1237 of file tree.c.

References iso_tree_path_to_node_flag().

Referenced by boot_nodes_from_iso_path(), create_image(), hppa_palo_set_path(), iso_image_set_boot_image(), and Xorriso_node_from_path().

◆ iso_tree_path_to_node_flag()

int iso_tree_path_to_node_flag ( IsoImage image,
const char *  path,
IsoNode **  node,
int  flag 
)

◆ iso_tree_remove_exclude()

int iso_tree_remove_exclude ( IsoImage image,
const char *  path 
)

Remove a previously added exclude.

See also
iso_tree_add_exclude
Returns
1 on success, 0 exclude do not exists, < 0 on error

Definition at line 528 of file tree.c.

References Iso_Image::excludes, ISO_NULL_POINTER, ISO_SUCCESS, and Iso_Image::nexcludes.

◆ iso_tree_resolve_symlink()

int iso_tree_resolve_symlink ( IsoImage img,
IsoSymlink sym,
IsoNode **  res,
int *  depth,
int  flag 
)

Get the destination node of a symbolic link within the IsoImage.

Parameters
imgThe image wherein to try resolving the link.
symThe symbolic link node which to resolve.
resWill return the found destination node, in case of success. Call iso_node_ref() / iso_node_unref() if you intend to use the node over API calls which might in any event delete it.
depthPrevents endless loops. Submit as 0.
flagBitfield for control purposes. Submit 0 for now.
Returns
1 on success, < 0 on failure, especially ISO_DEEP_SYMLINK and ISO_DEAD_SYMLINK
Since
1.2.4

Definition at line 1578 of file tree.c.

References Iso_Dir::children, Iso_Symlink::dest, ISO_DEAD_SYMLINK, ISO_DEEP_SYMLINK, ISO_SUCCESS, iso_tree_resolve_symlink(), LIBISO_DIR, LIBISO_MAX_LINK_DEPTH, LIBISO_SYMLINK, Iso_Node::name, Iso_Node::next, Iso_Dir::node, Iso_Symlink::node, Iso_Node::parent, Iso_Image::root, and Iso_Node::type.

Referenced by iso_tree_resolve_symlink(), and update_symlink().

◆ iso_tree_set_follow_symlinks()

void iso_tree_set_follow_symlinks ( IsoImage image,
int  follow 
)

Set whether to follow or not symbolic links when added a file from a source to IsoImage.

Definition at line 400 of file tree.c.

References Iso_Image::follow_symlinks.

◆ iso_tree_set_ignore_hidden()

void iso_tree_set_ignore_hidden ( IsoImage image,
int  skip 
)

Set whether to skip or not hidden files when adding a directory recursibely. Default behavior is to not ignore them, i.e., to add hidden files to image.

Definition at line 419 of file tree.c.

References Iso_Image::ignore_hidden.

◆ iso_tree_set_ignore_special()

void iso_tree_set_ignore_special ( IsoImage image,
int  skip 
)

Set whether to skip or not special files. Default behavior is to not skip them. Note that, despite of this setting, special files won't never be added to an image unless RR extensions were enabled.

Parameters
skipBitmask to determine what kind of special files will be skipped: bit0: ignore FIFOs bit1: ignore Sockets bit2: ignore char devices bit3: ignore block devices

Definition at line 456 of file tree.c.

References Iso_Image::ignore_special.

◆ iso_tree_set_replace_mode()

void iso_tree_set_replace_mode ( IsoImage image,
enum iso_replace_mode  mode 
)

Set the replace mode, that defines the behavior of libisofs when adding a node whit the same name that an existent one, during a recursive directory addition.

Since
0.6.2

Definition at line 434 of file tree.c.

◆ iso_tree_set_report_callback()

void iso_tree_set_report_callback ( IsoImage image,
int(*)(IsoImage *, IsoFileSource *)  report 
)

Set a callback function that libisofs will call for each file that is added to the given image by a recursive addition function. This includes image import.

Parameters
reportpointer to a function that will be called just before a file will be added to the image. You can control whether the file will be in fact added or ignored. This function should return 1 to add the file, 0 to ignore it and continue, < 0 to abort the process NULL is allowed if you don't want any callback.

Definition at line 484 of file tree.c.

References Iso_Image::report.

Referenced by isoburn_read_image().

◆ make_incrementable_name()

static int make_incrementable_name ( char **  name,
char **  unique_name,
int *  low_pos,
int *  rollover_carry,
int *  pre_check 
)
static

Definition at line 871 of file tree.c.

References insert_underscores(), and LIBISO_ALLOC_MEM.

Referenced by make_really_unique_name().

◆ make_really_unique_name()

static int make_really_unique_name ( IsoDir parent,
char **  name,
char **  unique_name,
IsoNode ***  pos,
int  flag 
)
static