Experiments about inode number generation for nodes out of the loaded

image.
This commit is contained in:
Thomas Schmitt 2009-03-07 08:28:35 +01:00
parent 32dc6dd041
commit 4f468171ad
3 changed files with 104 additions and 7 deletions

View File

@ -24,6 +24,12 @@ int iso_file_src_cmp(const void *n1, const void *n2)
dev_t dev_id1, dev_id2; dev_t dev_id1, dev_id2;
ino_t ino_id1, ino_id2; ino_t ino_id1, ino_id2;
#ifdef Libisofs_file_src_cmp_sizE
off_t size1, size2;
#endif /* Libisofs_file_src_cmp_sizE */
f1 = (const IsoFileSrc *)n1; f1 = (const IsoFileSrc *)n1;
f2 = (const IsoFileSrc *)n2; f2 = (const IsoFileSrc *)n2;
@ -40,9 +46,31 @@ int iso_file_src_cmp(const void *n1, const void *n2)
return -1; return -1;
} else if (dev_id1 < dev_id2) { } else if (dev_id1 < dev_id2) {
return 1; return 1;
#ifdef Libisofs_file_src_cmp_sizE
} else if (ino_id1 > ino_id2) {
return -1;
} else if (ino_id1 < ino_id2) {
return 1;
} else {
size1 = iso_stream_get_size(f1->stream);
size2 = iso_stream_get_size(f2->stream);
if (size1 < size2) {
return -1;
} else if (size1 > size2) {
return 1;
}
return 0;
#else /* Libisofs_file_src_cmp_sizE */
} else { } else {
/* files belong to same device in same fs */ /* files belong to same device in same fs */
return (ino_id1 < ino_id2) ? -1 : (ino_id1 > ino_id2) ? 1 : 0; return (ino_id1 < ino_id2) ? -1 : (ino_id1 > ino_id2) ? 1 : 0;
#endif /* ! Libisofs_file_src_cmp_sizE */
} }
} }
} }

View File

@ -241,6 +241,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 A90303 */
/* Inode number generator counter */
ino_t inode_counter;
} _ImageFsData; } _ImageFsData;
typedef struct image_fs_data ImageFileSourceData; typedef struct image_fs_data ImageFileSourceData;
@ -1013,6 +1017,31 @@ char *get_name(_ImageFsData *fsdata, const char *str, size_t len)
return name; return name;
} }
/* ts A90303 */
/**
* A global counter for default inode numbers for the ISO image filesystem.
* @param fs The filesystem where the number shall be used
* @param flag bit0= reset count
*/
static
ino_t fs_give_ino_number(IsoImageFilesystem *fs, int flag)
{
_ImageFsData *fsdata;
fsdata = (_ImageFsData*)fs->data;
if (flag & 1)
fsdata->inode_counter = 0;
fsdata->inode_counter++;
if (fsdata->inode_counter == 0) {
/* >>> raise alert because of inode rollover */;
}
return fsdata->inode_counter;
}
/** /**
* *
* @param src * @param src
@ -1460,6 +1489,18 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
return ISO_SUCCESS; return ISO_SUCCESS;
} }
#ifdef Libisofs_new_fs_image_inO
if (fsdata->rr != RR_EXT_112) {
if (fsdata->rr == 0) {
atts.st_nlink = 1;
}
}
atts.st_ino = fs_give_ino_number(fs, 0);
#else /* Libisofs_new_fs_image_inO */
/* ts Nov 25 2008: TODO /* ts Nov 25 2008: TODO
This seems not fully consistent with read_rr_PX() which decides This seems not fully consistent with read_rr_PX() which decides
by (px->len_sue[0] == 44) whether an inode number is present or not. by (px->len_sue[0] == 44) whether an inode number is present or not.
@ -1480,16 +1521,13 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
* It BREAKS POSIX SEMANTICS, but its suitable for our needs * It BREAKS POSIX SEMANTICS, but its suitable for our needs
*/ */
#ifndef Libisofs_ino_from_lbA
#define Libisofs_patch_ticket_144 yes #define Libisofs_patch_ticket_144 yes
#endif
#ifdef Libisofs_patch_ticket_144 #ifdef Libisofs_patch_ticket_144
/* Trying to ensure unique inode numbers */
{
static ino_t iso_global_inode= 0;
if(iso_global_inode <= 0) atts.st_ino = fs_give_ino_number(fs, 0);
iso_global_inode= 1;
atts.st_ino = iso_global_inode++;
}
#else #else
/* Ticket 144: This produces duplicate numbers with empty files. /* Ticket 144: This produces duplicate numbers with empty files.
*/ */
@ -1500,6 +1538,8 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
} }
} }
#endif /* ! Libisofs_new_fs_image_inO */
/* /*
* if we haven't RR extensions, or a needed TF time stamp is not present, * if we haven't RR extensions, or a needed TF time stamp is not present,
* we use plain iso recording time * we use plain iso recording time
@ -2586,7 +2626,17 @@ int create_boot_img_filesrc(IsoImageFilesystem *fs, IsoFileSource **src)
memset(&atts, 0, sizeof(struct stat)); memset(&atts, 0, sizeof(struct stat));
atts.st_mode = S_IFREG; atts.st_mode = S_IFREG;
#ifdef Libisofs_new_fs_image_inO
atts.st_ino = fs_give_ino_number(fs, 0);
#else /* Libisofs_new_fs_image_inO */
atts.st_ino = fsdata->imgblock; /* not the best solution, but... */ atts.st_ino = fsdata->imgblock; /* not the best solution, but... */
#endif /* ! Libisofs_new_fs_image_inO */
atts.st_nlink = 1; atts.st_nlink = 1;
/* /*

View File

@ -4771,4 +4771,23 @@ struct burn_source {
#endif /* LIBISOFS_WITHOUT_LIBBURN */ #endif /* LIBISOFS_WITHOUT_LIBBURN */
/* Attempt to fix several issues about inode numbers from ISO images */
/* Experiment: Ignore PX inode numbers,
have boot image inode number counted by fs_give_ino_number()
*/
#define Libisofs_new_fs_image_inO yes
/* Experiment: Trying to avoid the risk of losing file content by duplicate
inodes. iso_file_src_cmp() shall compare sizes too.
*/
#define Libisofs_file_src_cmp_sizE yes
/* Experiment: Revoke Ticket 144, use data file LBAs again.
(will work only if not Libisofs_new_fs_image_inO
and wll only be safe with Libisofs_file_src_cmp_sizE)
#define Libisofs_ino_from_lbA yes
*/
#endif /*LIBISO_LIBISOFS_H_*/ #endif /*LIBISO_LIBISOFS_H_*/