From e12d409b80635ecca935b29aec58d89f4868a810 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Sun, 24 May 2009 18:22:02 +0200 Subject: [PATCH] Made sure that IsoStream from old image are equivalent only if their data extents have same LBAs and sizes. --- libisofs/fs_image.c | 27 +++++++++++++++++++++++++++ libisofs/fsource.h | 7 +++++++ libisofs/libisofs.h | 2 +- libisofs/stream.c | 12 ++++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/libisofs/fs_image.c b/libisofs/fs_image.c index 1a64551..ead3f7a 100644 --- a/libisofs/fs_image.c +++ b/libisofs/fs_image.c @@ -3510,3 +3510,30 @@ int iso_file_get_old_image_sections(IsoFile *file, int *section_count, } return 0; } + +/* ts A90524 */ +/* Rank two IsoFileSource by their eventual old image LBAs. + Other IsoFileSource classes will be ranked only roughly. +*/ +int iso_ifs_sections_cmp(IsoFileSource *s1, IsoFileSource *s2, int flag) +{ + int i; + ImageFileSourceData *d1, *d2; + + if (s1->class != s2->class) + return (s1->class < s2->class ? -1 : 1); + if (s1->class != &ifs_class) + return(0); + + d1= s1->data; + d2= s2->data; + for (i = 0; i < d1->nsections; i++) { + if (i >= d2->nsections) + return 1; + if (d1->sections[i].block != d2->sections[i].block) + return (d1->sections[i].block < d2->sections[i].block ? -1 : 1); + if (d1->sections[i].size != d2->sections[i].size) + return (d1->sections[i].size < d2->sections[i].size ? -1 : 1); + } + return(0); +} diff --git a/libisofs/fsource.h b/libisofs/fsource.h index 1ee8b18..aa91e0e 100644 --- a/libisofs/fsource.h +++ b/libisofs/fsource.h @@ -30,4 +30,11 @@ */ int iso_local_filesystem_new(IsoFilesystem **fs); + +/* ts A90524 */ +/* Rank two IsoFileSource by their eventual old image LBAs. + Other IsoFileSource classes will be ranked only roughly. +*/ +int iso_ifs_sections_cmp(IsoFileSource *s1, IsoFileSource *s2, int flag); + #endif /*LIBISO_FSOURCE_H_*/ diff --git a/libisofs/libisofs.h b/libisofs/libisofs.h index b68136d..038a08a 100644 --- a/libisofs/libisofs.h +++ b/libisofs/libisofs.h @@ -2640,7 +2640,7 @@ int iso_node_remove(IsoNode *node); * If node is the root node, the same node will be returned as its parent. * * This returns NULL if the node doesn't pertain to any tree - * (it was removed/take). + * (it was removed/taken). * * @since 0.6.2 */ diff --git a/libisofs/stream.c b/libisofs/stream.c index 30e52a3..c2f5187 100644 --- a/libisofs/stream.c +++ b/libisofs/stream.c @@ -737,6 +737,7 @@ int iso_stream_cmp_ino(IsoStream *s1, IsoStream *s2, int flag) dev_t dev_id1, dev_id2; ino_t ino_id1, ino_id2; off_t size1, size2; + FSrcStreamData *fssd1, *fssd2; /* <<< */ static int report_counter = 0; @@ -802,6 +803,17 @@ int iso_stream_cmp_ino(IsoStream *s1, IsoStream *s2, int flag) return 1; } + if (s1->class != s2->class) + return (s1->class < s2->class ? -1 : 1); + if (s1->class == &fsrc_stream_class) { + /* Compare eventual image data section LBA and sizes */ + fssd1= (FSrcStreamData *) s1->data; + fssd2= (FSrcStreamData *) s2->data; + ret = iso_ifs_sections_cmp(fssd1->src, fssd2->src, 0); + if (ret != 0) + return ret; + } + #ifdef Libisofs_hardlink_matcheR if (fs_id1 == 0 && dev_id1 == 0 && ino_id1 == 0) { return (s1 < s2 ? -1 : 1);