New API call iso_read_opts_set_new_inos()

This commit is contained in:
Thomas Schmitt 2009-05-01 15:00:43 +02:00
parent 95381ce258
commit 1218e6e32d
2 changed files with 58 additions and 17 deletions

View File

@ -63,6 +63,13 @@ struct iso_read_opts
unsigned int noiso1999 : 1; /*< Do not read ISO 9660:1999 enhanced tree */ unsigned int noiso1999 : 1; /*< Do not read ISO 9660:1999 enhanced tree */
unsigned int noaaip : 1; /* Do not read AAIP extension for xattr and ACL */ unsigned int noaaip : 1; /* Do not read AAIP extension for xattr and ACL */
/* ts A90425 */
/**
* Hand out new inode numbers and overwrite eventually read PX inode
* numbers. This will split apart any hardlinks.
*/
unsigned int make_new_ino : 1 ;
/** /**
* When both Joliet and RR extensions are present, the RR tree is used. * When both Joliet and RR extensions are present, the RR tree is used.
* If you prefer using Joliet, set this to 1. * If you prefer using Joliet, set this to 1.
@ -89,13 +96,6 @@ struct iso_read_opts
*/ */
int auto_input_charset; int auto_input_charset;
/* ts A90425 */
/**
* Hand out new inode numbers and overwrite eventually read PX inode
* numbers. This will split apart any hardlinks.
*/
int make_new_ino : 1 ;
}; };
/** /**
@ -270,6 +270,10 @@ typedef struct
uint32_t imgblock; /**< Block for El-Torito boot image */ uint32_t imgblock; /**< Block for El-Torito boot image */
uint32_t catblock; /**< Block for El-Torito catalog */ uint32_t catblock; /**< Block for El-Torito catalog */
/* ts A90501 */
/* Whether inode numbers from PX entries shall be discarded */
unsigned int make_new_ino : 1 ;
/* Inode number generator counter */ /* Inode number generator counter */
ino_t inode_counter; ino_t inode_counter;
@ -2334,6 +2338,7 @@ int iso_image_filesystem_new(IsoDataSource *src, struct iso_read_opts *opts,
data->msgid = msgid; data->msgid = msgid;
data->aaip_load = !opts->noaaip; data->aaip_load = !opts->noaaip;
data->aaip_version = -1; data->aaip_version = -1;
data->make_new_ino = opts->make_new_ino;
data->inode_counter = 0; data->inode_counter = 0;
data->px_ino_status = 0; data->px_ino_status = 0;
@ -2585,6 +2590,7 @@ int image_builder_create_node(IsoNodeBuilder *builder, IsoImage *image,
IsoNode *new; IsoNode *new;
char *name; char *name;
ImageFileSourceData *data; ImageFileSourceData *data;
_ImageFsData *fsdata;
#ifdef Libisofs_with_zliB #ifdef Libisofs_with_zliB
/* Intimate friendship with this function in filters/zisofs.c */ /* Intimate friendship with this function in filters/zisofs.c */
@ -2599,6 +2605,7 @@ int image_builder_create_node(IsoNodeBuilder *builder, IsoImage *image,
} }
data = (ImageFileSourceData*)src->data; data = (ImageFileSourceData*)src->data;
fsdata = data->fs->data;
name = iso_file_source_get_name(src); name = iso_file_source_get_name(src);
@ -2613,7 +2620,6 @@ int image_builder_create_node(IsoNodeBuilder *builder, IsoImage *image,
case S_IFREG: case S_IFREG:
{ {
/* source is a regular file */ /* source is a regular file */
_ImageFsData *fsdata = data->fs->data;
/* El-Torito images have only one section */ /* El-Torito images have only one section */
if (fsdata->eltorito && data->sections[0].block == fsdata->catblock) { if (fsdata->eltorito && data->sections[0].block == fsdata->catblock) {
@ -2788,7 +2794,8 @@ int image_builder_create_node(IsoNodeBuilder *builder, IsoImage *image,
/* ts A90428 */ /* ts A90428 */
/* Attach ino as xinfo if valid and no IsoStream is involved */ /* Attach ino as xinfo if valid and no IsoStream is involved */
if (info.st_ino != 0 && (info.st_mode & S_IFMT) != S_IFREG) { if (info.st_ino != 0 && (info.st_mode & S_IFMT) != S_IFREG &&
!fsdata->make_new_ino) {
ret = iso_node_set_ino(new, info.st_ino, 0); ret = iso_node_set_ino(new, info.st_ino, 0);
if (ret < 0) if (ret < 0)
goto failure; goto failure;
@ -2940,7 +2947,7 @@ int iso_image_import(IsoImage *image, IsoDataSource *src,
struct iso_read_opts *opts, struct iso_read_opts *opts,
IsoReadImageFeatures **features) IsoReadImageFeatures **features)
{ {
int ret; int ret, hflag;
IsoImageFilesystem *fs; IsoImageFilesystem *fs;
IsoFilesystem *fsback; IsoFilesystem *fsback;
IsoNodeBuilder *blback; IsoNodeBuilder *blback;
@ -3049,11 +3056,14 @@ int iso_image_import(IsoImage *image, IsoDataSource *src,
/* ts A90426 */ /* ts A90426 */
if ((data->px_ino_status & (2 | 4 | 8)) || opts->make_new_ino) { if ((data->px_ino_status & (2 | 4 | 8)) || opts->make_new_ino) {
/* Attach new inode numbers to any node which doe not have one, /* Attach new inode numbers to any node which does not have one,
resp. to all nodes in case of opts->make_new_ino resp. to all nodes in case of opts->make_new_ino
*/ */
ret = img_make_inos(image, image->root, if (opts->make_new_ino)
8 | 4 | 2 | !!opts->make_new_ino); hflag = 1; /* Equip all data files with new unique inos */
else
hflag = 2 | 4 | 8; /* Equip any file type if it has ino == 0 */
ret = img_make_inos(image, image->root, hflag);
if (ret < 0) { if (ret < 0) {
iso_node_builder_unref(image->builder); iso_node_builder_unref(image->builder);
goto import_revert; goto import_revert;
@ -3293,6 +3303,16 @@ int iso_read_opts_set_no_aaip(IsoReadOpts *opts, int noaaip)
return ISO_SUCCESS; return ISO_SUCCESS;
} }
int iso_read_opts_set_new_inos(IsoReadOpts *opts, int new_inos)
{
if (opts == NULL) {
return ISO_NULL_POINTER;
}
opts->make_new_ino = new_inos ? 1 : 0;
return ISO_SUCCESS;
}
int iso_read_opts_set_preferjoliet(IsoReadOpts *opts, int preferjoliet) int iso_read_opts_set_preferjoliet(IsoReadOpts *opts, int preferjoliet)
{ {
if (opts == NULL) { if (opts == NULL) {

View File

@ -1653,13 +1653,34 @@ int iso_read_opts_set_no_iso1999(IsoReadOpts *opts, int noiso1999);
* (e.g. the local POSIX filesystem) see iso_image_set_ignore_aclea(). * (e.g. the local POSIX filesystem) see iso_image_set_ignore_aclea().
* For eventual writing of this information see iso_write_opts_set_aaip(). * For eventual writing of this information see iso_write_opts_set_aaip().
* *
* @param noaaip 1 = do not read AAIP information * @param noaaip
* 0 = read AAIP information if available * 1 = Do not read AAIP information
* All other values are reserved. * 0 = Read AAIP information if available
* All other values are reserved.
* @since 0.6.14 * @since 0.6.14
*/ */
int iso_read_opts_set_no_aaip(IsoReadOpts *opts, int noaaip); int iso_read_opts_set_no_aaip(IsoReadOpts *opts, int noaaip);
/**
* Control discarding of eventual inode numbers from existing images.
* Such numbers may come from RRIP 1.12 entries PX. If not discarded they
* get written unchanged when the file object gets written into an ISO image.
* If this inode number is missing with a file in the imported image,
* or if it has been discarded during image reading, then a unique inode number
* will be generated at some time before the file gets written into an ISO
* image.
* Two image nodes which have the same inode number represent two hardlinks
* of the same file object. So discarding the numbers splits hardlinks.
*
* @param new_inos
* 1 = Discard imported inode numbers and finally hand out a unique new
* one to each single file before it gets written into an ISO image.
* 0 = Keep eventual inode numbers from PX entries.
* All other values are reserved.
* @since 0.6.20
*/
int iso_read_opts_set_new_inos(IsoReadOpts *opts, int new_inos);
/** /**
* Whether to prefer Joliet over RR. libisofs usually prefers RR over * Whether to prefer Joliet over RR. libisofs usually prefers RR over
* Joliet, as it give us much more info about files. So, if both extensions * Joliet, as it give us much more info about files. So, if both extensions
@ -5285,7 +5306,7 @@ struct burn_source {
/* ---------------------------- Experiments ---------------------------- */ /* ---------------------------- Experiments ---------------------------- */
/* Hardlinks : During image generation accompany the ree of IsoFileSrc /* Hardlinks : During image generation accompany the tree of IsoFileSrc
by a sorted structure of Ecma119Node. by a sorted structure of Ecma119Node.
The sorting order shall bring together candidates for being The sorting order shall bring together candidates for being
hardlink siblings resp. having identical content. hardlink siblings resp. having identical content.