diff --git a/libisofs/ecma119_tree.c b/libisofs/ecma119_tree.c index 10f792c..7d6fc44 100644 --- a/libisofs/ecma119_tree.c +++ b/libisofs/ecma119_tree.c @@ -925,10 +925,31 @@ int ecma119_node_cmp(const void *v1, const void *v2) ret1 = iso_file_src_cmp(n2->info.file, n2->info.file); return ret1; - /* >>> Create means to inquire ECMA119_SYMLINK and ECMA119_SPECIAL - for their original fs,dev,ino tuple */ - } else { +#ifdef Libisofs_hardlink_matcheR + } else if (n1->type == ECMA119_SYMLINK) { + IsoSymlink *t1, *t2; + + t1 = (IsoSymlink *) (n1->node); + t2 = (IsoSymlink *) (n2->node); + return (t1->fs_id < t2->fs_id ? -1 : t1->fs_id > t2->fs_id ? 1 : + t1->st_dev < t2->st_dev ? -1 : t1->st_dev > t2->st_dev ? 1 : + t1->st_ino < t2->st_ino ? -1 : t1->st_ino > t2->st_ino ? 1 : + t1->fs_id || t1->st_dev || t1->st_ino ? 0 : (v1 < v2 ? -1 : 1)); + + } else if (n1->type == ECMA119_SPECIAL) { + IsoSpecial *t1, *t2; + + t1 = (IsoSpecial *) (n1->node); + t2 = (IsoSpecial *) (n2->node); + return (t1->fs_id < t2->fs_id ? -1 : t1->fs_id > t2->fs_id ? 1 : + t1->st_dev < t2->st_dev ? -1 : t1->st_dev > t2->st_dev ? 1 : + t1->st_ino < t2->st_ino ? -1 : t1->st_ino > t2->st_ino ? 1 : + t1->fs_id || t1->st_dev || t1->st_ino ? 0 : (v1 < v2 ? -1 : 1)); + +#endif /* Libisofs_hardlink_matcheR */ + + } else { return (v1 < v2 ? -1 : 1); /* case v1 == v2 is handled above */ } return 0; diff --git a/libisofs/fs_image.c b/libisofs/fs_image.c index d09d1e0..1a64551 100644 --- a/libisofs/fs_image.c +++ b/libisofs/fs_image.c @@ -2744,6 +2744,13 @@ int image_builder_create_node(IsoNodeBuilder *builder, IsoImage *image, } link->dest = strdup(dest); link->node.type = LIBISO_SYMLINK; + +#ifdef Libisofs_hardlink_matcheR + link->fs_id = ISO_IMAGE_FS_ID; + link->st_dev = info.st_dev; + link->st_ino = info.st_ino; +#endif + new = (IsoNode*) link; new->refcount = 0; } @@ -2762,6 +2769,13 @@ int image_builder_create_node(IsoNodeBuilder *builder, IsoImage *image, } special->dev = info.st_rdev; special->node.type = LIBISO_SPECIAL; + +#ifdef Libisofs_hardlink_matcheR + special->fs_id = ISO_IMAGE_FS_ID; + special->st_dev = info.st_dev; + special->st_ino = info.st_ino; +#endif + new = (IsoNode*) special; new->refcount = 0; } diff --git a/libisofs/libisofs.h b/libisofs/libisofs.h index 12fb75c..74eb538 100644 --- a/libisofs/libisofs.h +++ b/libisofs/libisofs.h @@ -5333,7 +5333,7 @@ struct burn_source { /* Experiment: Ignore PX inode numbers, have boot image inode number counted by fs_give_ino_number() - Overridden if Libisofs_hardlink_prooF is defined. + <<< Overridden if Libisofs_hardlink_prooF is defined. */ #define Libisofs_new_fs_image_inO yes @@ -5341,18 +5341,12 @@ struct burn_source { /* Experiment: Revoke Ticket 144, use data file LBAs again. (will work only if not Libisofs_new_fs_image_inO) + + <<< Overridden if Libisofs_hardlink_prooF is defined. + #define Libisofs_ino_from_lbA yes */ -/* Experiment: Regarding (fs_id == 0 && dev_id == 0 && ino_id == 0) - as always unique. - WAS DANGEROUS: In a previous experiment iso_rbtree_insert() needed equality. - Now i changed the test in there, so that identical IsoFileSrc - objects are considered equal regardless of their id. - STILL UNTESTED. - - #define Libisofs_file_src_cmp_non_zerO yes -*/ /* Experiment: Write obsolete RR entries with Rock Ridge. I suspect Solaris wants to see them. diff --git a/libisofs/node.c b/libisofs/node.c index 9d16fc2..d30a1fc 100644 --- a/libisofs/node.c +++ b/libisofs/node.c @@ -1309,6 +1309,13 @@ int iso_node_new_symlink(char *name, char *dest, IsoSymlink **link) new->node.name = name; new->dest = dest; new->node.mode = S_IFLNK; + +#ifdef Libisofs_hardlink_matcheR + new->fs_id = 0; + new->st_dev = 0; + new->st_ino = 0; +#endif + *link = new; return ISO_SUCCESS; } @@ -1341,6 +1348,12 @@ int iso_node_new_special(char *name, mode_t mode, dev_t dev, new->node.mode = mode; new->dev = dev; +#ifdef Libisofs_hardlink_matcheR + new->fs_id = 0; + new->st_dev = 0; + new->st_ino = 0; +#endif + *special = new; return ISO_SUCCESS; } @@ -2286,7 +2299,16 @@ int iso_node_get_id(IsoNode *node, unsigned int *fs_id, dev_t *dev_id, goto no_id; } return 1; + +#ifdef Libisofs_hardlink_matcheR + + /* >>> check for id tuples of LIBISO_SYMLINK and LIBISO_SPECIAL */; + +#endif + } + + ret = 0; no_id:; *fs_id = 0; @@ -2338,6 +2360,14 @@ int iso_node_set_ino(IsoNode *node, ino_t ino, int flag) ret = iso_stream_set_image_ino(file->stream, ino, 0); if (ret < 0 || ret == 1) return ret; + +#ifdef Libisofs_hardlink_matcheR + + /* >>> check for id tuples of LIBISO_SYMLINK and LIBISO_SPECIAL : + if fs_id = ISO_IMAGE_FS_ID then overwite .st_ino */; + +#endif + } ret = iso_node_set_ino_xinfo(node, ino, 0); if (ret < 0) diff --git a/libisofs/node.h b/libisofs/node.h index a5cd1b6..72a0dd2 100644 --- a/libisofs/node.h +++ b/libisofs/node.h @@ -122,7 +122,7 @@ struct Iso_File * Higher weighting files are written at the beginning of image */ int sort_weight; - IsoStream *stream; + IsoStream *stream; /* Knows fs_id, st_dev, and st_ino */ }; struct Iso_Symlink @@ -130,12 +130,34 @@ struct Iso_Symlink IsoNode node; char *dest; + +#ifdef Libisofs_hardlink_matcheR + /* If the IsoNode represents an object in an existing filesystem then + the following three numbers should unique identify it. + (0,0,0) will always be taken as unique. + */ + unsigned int fs_id; + dev_t st_dev; + ino_t st_ino; +#endif + }; struct Iso_Special { IsoNode node; dev_t dev; + +#ifdef Libisofs_hardlink_matcheR + /* If the IsoNode represents an object in an existing filesystem then + the following three numbers should unique identify it. + (0,0,0) will always be taken as unique. + */ + unsigned int fs_id; + dev_t st_dev; + ino_t st_ino; +#endif + }; struct iso_dir_iter_iface diff --git a/libisofs/stream.c b/libisofs/stream.c index e2173fa..79935f3 100644 --- a/libisofs/stream.c +++ b/libisofs/stream.c @@ -742,15 +742,6 @@ int iso_stream_cmp_ino(IsoStream *s1, IsoStream *s2, int flag) } iso_stream_get_id(s1, &fs_id1, &dev_id1, &ino_id1); iso_stream_get_id(s2, &fs_id2, &dev_id2, &ino_id2); - -#ifdef Libisofs_file_src_cmp_non_zerO - if (fs_id1 == 0 && dev_id1 == 0 && ino_id1 == 0) { - return -1; - } else if (fs_id2 == 0 && dev_id2 == 0 && ino_id2 == 0) - return 1; - } -#endif - if (fs_id1 < fs_id2) { return -1; } else if (fs_id1 > fs_id2) { @@ -773,5 +764,12 @@ int iso_stream_cmp_ino(IsoStream *s1, IsoStream *s2, int flag) } else if (size1 > size2) { return 1; } + +#ifdef Libisofs_hardlink_matcheR + if (fs_id1 == 0 && dev_id1 == 0 && ino_id1 == 0) { + return (s1 < s2 ? -1 : 1); + } +#endif + return 0; }