|
|
|
@ -18,6 +18,12 @@ static size_t calc_dirent_len(struct ecma119_tree_node *n)
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Replace the file permissions and user/group id of an ECMA-119 node.
|
|
|
|
|
* This is used when a replace mode is selected, i.e., when we want to
|
|
|
|
|
* create a disc where the mode of each file or directory will be
|
|
|
|
|
* different than the mode in the original source.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
replace_node_mode(struct ecma119_write_target *t, struct stat *st)
|
|
|
|
|
{
|
|
|
|
@ -65,6 +71,19 @@ replace_node_mode(struct ecma119_write_target *t, struct stat *st)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates a new ECMA-119 node from the given iso tree node, and initializes
|
|
|
|
|
* the fields that are common to all kind of nodes (dir, reg file, symlink...).
|
|
|
|
|
*
|
|
|
|
|
* @param t
|
|
|
|
|
* The options for the ECMA-119 tree that is being created
|
|
|
|
|
* @param parent
|
|
|
|
|
* The parent of the node, or NULL if it's the root.
|
|
|
|
|
* @param iso
|
|
|
|
|
* The node from which this function creates a ECMA-119 node
|
|
|
|
|
* @return
|
|
|
|
|
* The created node.
|
|
|
|
|
*/
|
|
|
|
|
static struct ecma119_tree_node*
|
|
|
|
|
create_ecma119_node(struct ecma119_write_target *t,
|
|
|
|
|
struct ecma119_tree_node *parent,
|
|
|
|
@ -92,13 +111,22 @@ create_ecma119_node(struct ecma119_write_target *t,
|
|
|
|
|
iso_name(iso->name, t->input_charset)
|
|
|
|
|
) : NULL;
|
|
|
|
|
ret->dirent_len = calc_dirent_len(ret);
|
|
|
|
|
|
|
|
|
|
/* iso node keeps the same file attribs as the original file. */
|
|
|
|
|
ret->attrib = iso->attrib;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* When using RR extension and replace mode, we will replace the
|
|
|
|
|
* permissions and uid/gid of each file with those previously selected
|
|
|
|
|
* by the user.
|
|
|
|
|
*/
|
|
|
|
|
if ( t->rockridge && t->replace_mode )
|
|
|
|
|
replace_node_mode(t, &ret->attrib);
|
|
|
|
|
|
|
|
|
|
if (!iso->name)
|
|
|
|
|
ret->full_name = NULL;
|
|
|
|
|
else if ( strcmp(t->input_charset,t->ouput_charset) )
|
|
|
|
|
/* convert the file name charset */
|
|
|
|
|
ret->full_name = convert_str(iso->name, t->input_charset,
|
|
|
|
|
t->ouput_charset);
|
|
|
|
|
else
|
|
|
|
@ -108,6 +136,10 @@ create_ecma119_node(struct ecma119_write_target *t,
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new ECMA-119 node representing a directory from a iso directory
|
|
|
|
|
* node.
|
|
|
|
|
*/
|
|
|
|
|
static struct ecma119_tree_node*
|
|
|
|
|
create_dir(struct ecma119_write_target *t,
|
|
|
|
|
struct ecma119_tree_node *parent,
|
|
|
|
@ -127,6 +159,10 @@ create_dir(struct ecma119_write_target *t,
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new ECMA-119 node representing a regular file from a iso file
|
|
|
|
|
* node.
|
|
|
|
|
*/
|
|
|
|
|
static struct ecma119_tree_node*
|
|
|
|
|
create_file(struct ecma119_write_target *t,
|
|
|
|
|
struct ecma119_tree_node *parent,
|
|
|
|
@ -143,6 +179,10 @@ create_file(struct ecma119_write_target *t,
|
|
|
|
|
/* get iso_file struct */
|
|
|
|
|
file = iso_file_table_lookup(t->file_table, iso);
|
|
|
|
|
if ( file == NULL ) {
|
|
|
|
|
/*
|
|
|
|
|
* If the file is not already added to the disc, we add it now
|
|
|
|
|
* to the file table, and get a new inode number for it.
|
|
|
|
|
*/
|
|
|
|
|
file = iso_file_new(iso);
|
|
|
|
|
iso_file_table_add_file(t->file_table, file);
|
|
|
|
|
file->ino = ++t->ino;
|
|
|
|
@ -157,6 +197,12 @@ create_file(struct ecma119_write_target *t,
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new ECMA-119 node representing a placeholder for a relocated
|
|
|
|
|
* dir.
|
|
|
|
|
*
|
|
|
|
|
* See IEEE P1282, section 4.1.5 for details
|
|
|
|
|
*/
|
|
|
|
|
static struct ecma119_tree_node*
|
|
|
|
|
create_placeholder(struct ecma119_write_target *t,
|
|
|
|
|
struct ecma119_tree_node *parent,
|
|
|
|
@ -191,6 +237,10 @@ create_placeholder(struct ecma119_write_target *t,
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new ECMA-119 node representing a symbolic link from a iso symlink
|
|
|
|
|
* node.
|
|
|
|
|
*/
|
|
|
|
|
static struct ecma119_tree_node*
|
|
|
|
|
create_symlink(struct ecma119_write_target *t,
|
|
|
|
|
struct ecma119_tree_node *parent,
|
|
|
|
@ -212,6 +262,14 @@ create_symlink(struct ecma119_write_target *t,
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new ECMA-119 node representing a boot catalog. This is like a
|
|
|
|
|
* regular file, but its contents are taken from a El-Torito boot catalog,
|
|
|
|
|
* and not from a file in the local filesystem.
|
|
|
|
|
*
|
|
|
|
|
* See "El Torito" Bootable CD-ROM Format Specification Version 1.0 for
|
|
|
|
|
* more details.
|
|
|
|
|
*/
|
|
|
|
|
static struct ecma119_tree_node*
|
|
|
|
|
create_boot_catalog(struct ecma119_write_target *t,
|
|
|
|
|
struct ecma119_tree_node *parent,
|
|
|
|
@ -239,6 +297,11 @@ create_boot_catalog(struct ecma119_write_target *t,
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new ECMA-119 node that corresponds to the given iso tree node.
|
|
|
|
|
* If that node is a dir, this function recurses over all their children,
|
|
|
|
|
* thus creating a ECMA-119 tree whose root is the given iso dir.
|
|
|
|
|
*/
|
|
|
|
|
static struct ecma119_tree_node*
|
|
|
|
|
create_tree(struct ecma119_write_target *t,
|
|
|
|
|
struct ecma119_tree_node *parent,
|
|
|
|
@ -316,6 +379,12 @@ max_child_name_len(struct ecma119_tree_node *root)
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
reparent(struct ecma119_tree_node *child,
|
|
|
|
|
struct ecma119_tree_node *parent)
|
|
|
|
@ -350,6 +419,8 @@ reparent(struct ecma119_tree_node *child,
|
|
|
|
|
* 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 (see ECMA-119,
|
|
|
|
|
* 6.8.2.1).
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
reorder_tree(struct ecma119_write_target *t,
|
|
|
|
@ -400,6 +471,9 @@ reorder_tree(struct ecma119_write_target *t,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Compare the iso name of two ECMA-119 nodes
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
cmp_node(const void *f1, const void *f2)
|
|
|
|
|
{
|
|
|
|
@ -408,6 +482,10 @@ cmp_node(const void *f1, const void *f2)
|
|
|
|
|
return strcmp(f->iso_name, g->iso_name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sorts a the children of each directory in the ECMA-119 tree represented
|
|
|
|
|
* by \p root, acording to the order specified in ECMA-119, section 9.3.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
sort_tree(struct ecma119_tree_node *root)
|
|
|
|
|
{
|
|
|
|
@ -470,6 +548,10 @@ mangle_name(char **name, int num_change, int level, int seq_num)
|
|
|
|
|
sprintf(*name, fmt, base, seq_num, ext);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Ensures that the ISO name of each children of the given dir is unique,
|
|
|
|
|
* changing some of them if needed.
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
mangle_all(struct ecma119_tree_node *dir)
|
|
|
|
|
{
|
|
|
|
|