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)  

ecma119_tree.c File Reference
#include "libisofs.h"
#include "ecma119_tree.h"
#include "ecma119.h"
#include "node.h"
#include "util.h"
#include "filesrc.h"
#include "messages.h"
#include "image.h"
#include "stream.h"
#include "eltorito.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
Include dependency graph for ecma119_tree.c:

Go to the source code of this file.

Functions

int iso_get_ecma119_name (IsoWriteOpts *opts, char *input_charset, int imgid, char *node_name, enum IsoNodeType node_type, char **name, int flag)
 
static int get_iso_name (Ecma119Image *img, IsoNode *iso, char **name)
 
int ecma119_is_dedicated_reloc_dir (Ecma119Image *img, Ecma119Node *node)
 
static int create_ecma119_node (Ecma119Image *img, IsoNode *iso, Ecma119Node **node)
 
static int create_dir (Ecma119Image *img, IsoDir *iso, Ecma119Node **node)
 
static int create_file_src (Ecma119Image *img, IsoFile *iso, IsoFileSrc **src)
 
static int create_file (Ecma119Image *img, IsoFile *iso, Ecma119Node **node)
 
static int create_boot_cat (Ecma119Image *img, IsoBoot *iso, Ecma119Node **node)
 
static int create_symlink (Ecma119Image *img, IsoSymlink *iso, Ecma119Node **node)
 
static int create_special (Ecma119Image *img, IsoSpecial *iso, Ecma119Node **node)
 
void ecma119_node_free (Ecma119Node *node)
 
static int add_to_hidden_list (Ecma119Image *image, IsoFileSrc *src)
 
int iso_filesrc_list_destroy (struct iso_filesrc_list_item **start_item)
 
static int create_tree (Ecma119Image *image, IsoNode *iso, Ecma119Node **tree, int depth, int pathlen, int flag)
 
static int cmp_node_name (const void *f1, const void *f2)
 
static void sort_tree (Ecma119Node *root)
 
static int mangle_single_dir (Ecma119Image *img, Ecma119Node *dir, int max_file_len, int max_dir_len)
 
static int mangle_dir (Ecma119Image *img, Ecma119Node *dir, int max_file_len, int max_dir_len)
 
static int mangle_tree (Ecma119Image *img, Ecma119Node *dir, int recurse)
 
static int create_placeholder (Ecma119Node *parent, Ecma119Node *real, Ecma119Node **node)
 
static size_t max_child_name_len (Ecma119Node *dir)
 
static int reparent (Ecma119Node *child, Ecma119Node *parent)
 
static int reorder_tree (Ecma119Image *img, Ecma119Node *dir, int dir_level, int dir_pathlen)
 
static int make_node_array (Ecma119Image *img, Ecma119Node *dir, Ecma119Node **nodes, size_t nodes_size, size_t *node_count, int flag)
 
static int ecma119_node_cmp_flag (const void *v1, const void *v2, int flag)
 
static int ecma119_node_cmp_hard (const void *v1, const void *v2)
 
static int ecma119_node_cmp_nohard (const void *v1, const void *v2)
 
static int family_set_ino (Ecma119Image *img, Ecma119Node **nodes, size_t family_start, size_t next_family, ino_t img_ino, ino_t prev_ino, int flag)
 
static int match_hardlinks (Ecma119Image *img, Ecma119Node *dir, int flag)
 
int ecma119_tree_create (Ecma119Image *img)
 
static Ecma119Nodesearch_iso_node (Ecma119Node *root, IsoNode *node)
 
Ecma119Nodeecma119_search_iso_node (Ecma119Image *img, IsoNode *node)
 

Function Documentation

◆ add_to_hidden_list()

static int add_to_hidden_list ( Ecma119Image image,
IsoFileSrc src 
)
static

◆ cmp_node_name()

static int cmp_node_name ( const void *  f1,
const void *  f2 
)
static

Compare the iso name of two ECMA-119 nodes

Definition at line 591 of file ecma119_tree.c.

References ecma119_node::iso_name.

Referenced by mangle_single_dir(), and sort_tree().

◆ create_boot_cat()

static int create_boot_cat ( Ecma119Image img,
IsoBoot iso,
Ecma119Node **  node 
)
static

Create a new ECMA-119 node representing a regular file from an El-Torito boot catalog

Definition at line 292 of file ecma119_tree.c.

References create_ecma119_node(), ECMA119_FILE, and el_torito_catalog_file_src_create().

Referenced by create_tree().

◆ create_dir()

static int create_dir ( Ecma119Image img,
IsoDir iso,
Ecma119Node **  node 
)
static

Create a new ECMA-119 node representing a directory from a iso directory node.

Definition at line 201 of file ecma119_tree.c.

References ecma119_dir_info::children, create_ecma119_node(), ECMA119_DIR, ISO_OUT_OF_MEM, ISO_SUCCESS, ecma119_dir_info::nchildren, and Iso_Dir::nchildren.

Referenced by create_tree().

◆ create_ecma119_node()

static int create_ecma119_node ( Ecma119Image img,
IsoNode iso,
Ecma119Node **  node 
)
static

◆ create_file()

static int create_file ( Ecma119Image img,
IsoFile iso,
Ecma119Node **  node 
)
static

Create a new ECMA-119 node representing a regular file from a iso file node.

Definition at line 263 of file ecma119_tree.c.

References create_ecma119_node(), create_file_src(), and ECMA119_FILE.

Referenced by create_tree().

◆ create_file_src()

◆ create_placeholder()

static int create_placeholder ( Ecma119Node parent,
Ecma119Node real,
Ecma119Node **  node 
)
static

Create a new ECMA-119 node representing a placeholder for a relocated dir.

See IEEE P1282, section 4.1.5 for details

Definition at line 900 of file ecma119_tree.c.

References ECMA119_PLACEHOLDER, ecma119_node::info, ecma119_node::ino, ecma119_node::iso_name, iso_node_ref(), ISO_OUT_OF_MEM, ISO_SUCCESS, ecma119_node::nlink, ecma119_node::node, ecma119_node::parent, ecma119_node::real_me, and ecma119_node::type.

Referenced by reparent().

◆ create_special()

static int create_special ( Ecma119Image img,
IsoSpecial iso,
Ecma119Node **  node 
)
static

Create a new ECMA-119 node representing a special file.

Definition at line 337 of file ecma119_tree.c.

References create_ecma119_node(), ECMA119_SPECIAL, and ISO_SUCCESS.

Referenced by create_tree().

◆ create_symlink()

static int create_symlink ( Ecma119Image img,
IsoSymlink iso,
Ecma119Node **  node 
)
static

Create a new ECMA-119 node representing a symbolic link from a iso symlink node.

Definition at line 321 of file ecma119_tree.c.

References create_ecma119_node(), ECMA119_SYMLINK, and ISO_SUCCESS.

Referenced by create_tree().

◆ create_tree()

◆ ecma119_is_dedicated_reloc_dir()

int ecma119_is_dedicated_reloc_dir ( Ecma119Image img,
Ecma119Node node 
)

Tell whether node is a dedicated relocation directory which only contains relocated directories.

Definition at line 170 of file ecma119_tree.c.

References ecma119_image::opts, ecma119_image::partition_root, ecma119_image::root, iso_write_opts::rr_reloc_flags, and ecma119_image::rr_reloc_node.

Referenced by reorder_tree(), rrip_calc_len(), and rrip_get_susp_fields().

◆ ecma119_node_cmp_flag()

static int ecma119_node_cmp_flag ( const void *  v1,
const void *  v2,
int  flag 
)
static

Definition at line 1125 of file ecma119_tree.c.

References iso_node_cmp_flag(), and ecma119_node::node.

Referenced by ecma119_node_cmp_hard(), and ecma119_node_cmp_nohard().

◆ ecma119_node_cmp_hard()

static int ecma119_node_cmp_hard ( const void *  v1,
const void *  v2 
)
static

Definition at line 1140 of file ecma119_tree.c.

References ecma119_node_cmp_flag().

Referenced by match_hardlinks().

◆ ecma119_node_cmp_nohard()

static int ecma119_node_cmp_nohard ( const void *  v1,
const void *  v2 
)
static

Definition at line 1146 of file ecma119_tree.c.

References ecma119_node_cmp_flag().

Referenced by match_hardlinks().

◆ ecma119_node_free()

void ecma119_node_free ( Ecma119Node node)

◆ ecma119_search_iso_node()

Ecma119Node* ecma119_search_iso_node ( Ecma119Image img,
IsoNode node 
)

Search the tree for a certain IsoNode and return its owning Ecma119Node or NULL.

Definition at line 1315 of file ecma119_tree.c.

References ecma119_image::root, and search_iso_node().

Referenced by boot_nodes_from_iso_path().

◆ ecma119_tree_create()

◆ family_set_ino()

static int family_set_ino ( Ecma119Image img,
Ecma119Node **  nodes,
size_t  family_start,
size_t  next_family,
ino_t  img_ino,
ino_t  prev_ino,
int  flag 
)
static

◆ get_iso_name()

static int get_iso_name ( Ecma119Image img,
IsoNode iso,
char **  name 
)
static

◆ iso_filesrc_list_destroy()

int iso_filesrc_list_destroy ( struct iso_filesrc_list_item **  start_item)

Definition at line 385 of file ecma119_tree.c.

References ISO_SUCCESS, LIBISO_FREE_MEM, and iso_filesrc_list_item::next.

Referenced by ecma119_image_free().

◆ iso_get_ecma119_name()

int iso_get_ecma119_name ( IsoWriteOpts opts,
char *  input_charset,
int  imgid,
char *  node_name,
enum IsoNodeType  node_type,
char **  name,
int  flag 
)

◆ make_node_array()

static int make_node_array ( Ecma119Image img,
Ecma119Node dir,
Ecma119Node **  nodes,
size_t  nodes_size,
size_t *  node_count,
int  flag 
)
static

◆ mangle_dir()

static int mangle_dir ( Ecma119Image img,
Ecma119Node dir,
int  max_file_len,
int  max_dir_len 
)
static

◆ mangle_single_dir()

static int mangle_single_dir ( Ecma119Image img,
Ecma119Node dir,
int  max_file_len,
int  max_dir_len 
)
static

Ensures that the ISO name of each children of the given dir is unique, changing some of them if needed. It also ensures that resulting filename is always <= than given max_name_len, including extension. If needed, the extension will be reduced, but never under 3 characters.

Definition at line 625 of file ecma119_tree.c.

References iso_write_opts::allow_dir_id_ext, ecma119_dir_info::children, cmp_node_name(), ecma119_node::dir, ECMA119_DIR, Iso_Image::id, ecma119_image::image, ecma119_node::info, int_pow(), ISO_ERROR, iso_htable_add(), iso_htable_create(), iso_htable_destroy(), iso_htable_get(), iso_htable_remove_ptr(), ISO_MANGLE_TOO_MUCH_FILES, iso_msg_debug(), iso_msg_submit(), ecma119_node::iso_name, ISO_NAME_NEEDS_TRANSL, ISO_OUT_OF_MEM, iso_str_hash(), ISO_SUCCESS, ecma119_dir_info::nchildren, ecma119_image::opts, and iso_write_opts::untranslated_name_len.

Referenced by mangle_dir(), and mangle_tree().

◆ mangle_tree()

◆ match_hardlinks()

◆ max_child_name_len()

static size_t max_child_name_len ( Ecma119Node dir)
static

◆ reorder_tree()

static int reorder_tree ( Ecma119Image img,
Ecma119Node dir,
int  dir_level,
int  dir_pathlen 
)
static

Reorder the tree, if necessary, to ensure that

  • the depth is at most 8
  • each path length is at most 255 characters This restriction is imposed by ECMA-119 specification (ECMA-119, 6.8.2.1).
Parameters
dirDir we are currently processing
levelLevel of the directory in the hierarchy
pathlenLength of the path until dir, including it
Returns
1 success, < 0 error

Definition at line 1003 of file ecma119_tree.c.

References ecma119_dir_info::children, ecma119_node::dir, ECMA119_DIR, ecma119_is_dedicated_reloc_dir(), ecma119_image::eff_partition_offset, ecma119_node::info, ecma119_node::iso_name, ISO_SUCCESS, max_child_name_len(), ecma119_dir_info::nchildren, ecma119_image::opts, ecma119_image::partition_root, reparent(), ecma119_image::root, iso_write_opts::rr_reloc_dir, ecma119_image::rr_reloc_node, and ecma119_node::type.

Referenced by ecma119_tree_create().

◆ reparent()

static int reparent ( Ecma119Node child,
Ecma119Node parent 
)
static

Relocates a directory, as specified in Rock Ridge Specification (see IEEE P1282, section 4.1.5). This is needed when the number of levels on a directory hierarchy exceeds 8, or the length of a path is higher than 255 characters, as specified in ECMA-119, section 6.8.2.1

Definition at line 952 of file ecma119_tree.c.

References ecma119_dir_info::children, create_placeholder(), ecma119_node::dir, ecma119_node::info, ISO_ASSERT_FAILURE, ISO_SUCCESS, ecma119_dir_info::nchildren, ecma119_node::parent, and ecma119_dir_info::real_parent.

Referenced by reorder_tree().

◆ search_iso_node()

static Ecma119Node* search_iso_node ( Ecma119Node root,
IsoNode node 
)
static

Search the tree for a certain IsoNode and return its owning Ecma119Node or NULL.

Definition at line 1298 of file ecma119_tree.c.

References ecma119_dir_info::children, ecma119_node::dir, ECMA119_DIR, ecma119_node::info, ecma119_dir_info::nchildren, ecma119_node::node, and ecma119_node::type.

Referenced by ecma119_search_iso_node().

◆ sort_tree()

static void sort_tree ( Ecma119Node root)
static

Sorts a the children of each directory in the ECMA-119 tree represented by root, according to the order specified in ECMA-119, section 9.3.

Definition at line 603 of file ecma119_tree.c.

References ecma119_dir_info::children, cmp_node_name(), ecma119_node::dir, ECMA119_DIR, ecma119_node::info, ecma119_dir_info::nchildren, and ecma119_node::type.

Referenced by ecma119_tree_create().