From c17ba1980ac7e4eb7a419b7ecf18df96309d1b37 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Tue, 27 May 2014 21:31:53 +0200 Subject: [PATCH] Clarified which inode is local ino_t and which is Rock Ridge uint32_t. --- libisofs/ecma119_tree.c | 5 +++++ libisofs/ecma119_tree.h | 6 ++---- libisofs/eltorito.c | 3 ++- libisofs/fs_image.c | 4 ++-- libisofs/image.c | 13 +++++++------ libisofs/image.h | 14 ++++++++------ 6 files changed, 26 insertions(+), 19 deletions(-) diff --git a/libisofs/ecma119_tree.c b/libisofs/ecma119_tree.c index fb5b84b..ec4c9d1 100644 --- a/libisofs/ecma119_tree.c +++ b/libisofs/ecma119_tree.c @@ -1122,6 +1122,11 @@ int family_set_ino(Ecma119Image *img, Ecma119Node **nodes, size_t family_start, */ if (img_ino == prev_ino) img_ino = 0; + + /* Accept only if it is within the 32 bit range. */ + if (((uint64_t) img_ino) > 0xffffffff) + img_ino = 0; + } if (img_ino == 0) { img_ino = img_give_ino_number(img->image, 0); diff --git a/libisofs/ecma119_tree.h b/libisofs/ecma119_tree.h index 480411f..d90cca8 100644 --- a/libisofs/ecma119_tree.h +++ b/libisofs/ecma119_tree.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2007 Vreixo Formoso - * 2012 Thomas Schmitt + * 2012 - 2014 Thomas Schmitt * * This file is part of the libisofs project; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 2 @@ -64,9 +64,7 @@ struct ecma119_node IsoNode *node; /*< reference to the iso node */ - /* >>> ts A90501 : Shouldn't this be uint32_t - as this is what PX will take ? */ - ino_t ino; + uint32_t ino; nlink_t nlink; diff --git a/libisofs/eltorito.c b/libisofs/eltorito.c index 0f6e2ee..883a4c6 100644 --- a/libisofs/eltorito.c +++ b/libisofs/eltorito.c @@ -955,7 +955,8 @@ int catalog_is_repeatable(IsoStream *stream) /** * fs_id will be the id reserved for El-Torito * dev_id will be 0 for catalog, 1 for boot image (if needed) - * we leave ino_id for future use when we support multiple boot images + * ino_id 0 is supposed to be unique. At write time it will get assigned + * an automatic file serial number in the ISO, if needed. */ static void catalog_get_id(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id, diff --git a/libisofs/fs_image.c b/libisofs/fs_image.c index 2fa6400..f20daad 100644 --- a/libisofs/fs_image.c +++ b/libisofs/fs_image.c @@ -320,8 +320,8 @@ typedef struct /* Whether inode numbers from PX entries shall be discarded */ unsigned int make_new_ino : 1 ; - /* Inode number generator counter */ - ino_t inode_counter; + /* Inode number generator counter. 32 bit because for Rock Ridge PX. */ + uint32_t inode_counter; /* PX inode number status bit0= there were nodes with PX inode numbers diff --git a/libisofs/image.c b/libisofs/image.c index c619489..8f02bee 100644 --- a/libisofs/image.c +++ b/libisofs/image.c @@ -674,7 +674,8 @@ ex:; /** - * A global counter for inode numbers for the ISO image filesystem. + * A global counter for Rock Ridge inode numbers in the ISO image filesystem. + * * On image import it gets maxed by the eventual inode numbers from PX * entries. Up to the first 32 bit rollover it simply increments the counter. * After the first rollover it uses a look ahead bitmap which gets filled @@ -684,13 +685,13 @@ ex:; * @param image The image where the number shall be used * @param flag bit0= reset count (Caution: image must get new inos then) * @return - * Since ino_t 0 is used as default and considered self-unique, + * Since 0 is used as default and considered self-unique, * the value 0 should only be returned in case of error. */ -ino_t img_give_ino_number(IsoImage *image, int flag) +uint32_t img_give_ino_number(IsoImage *image, int flag) { int ret; - ino_t new_ino, ino_idx; + uint64_t new_ino, ino_idx; static uint64_t limit = 0xffffffff; if (flag & 1) { @@ -700,10 +701,10 @@ ino_t img_give_ino_number(IsoImage *image, int flag) image->used_inodes = NULL; image->used_inodes_start = 0; } - new_ino = image->inode_counter + 1; + new_ino = ((uint64_t) image->inode_counter) + 1; if (image->used_inodes == NULL) { if (new_ino > 0 && new_ino <= limit) { - image->inode_counter = new_ino; + image->inode_counter = (uint32_t) new_ino; return image->inode_counter; } } diff --git a/libisofs/image.h b/libisofs/image.h index 79db9a7..d7bd113 100644 --- a/libisofs/image.h +++ b/libisofs/image.h @@ -171,18 +171,20 @@ struct Iso_Image * Inode number management. inode_counter is taken over from * IsoImageFilesystem._ImageFsData after image import. * It is to be used with img_give_ino_number() - */ - ino_t inode_counter; + * This is a Rock Ridge file serial number. Thus 32 bit. + */ + uint32_t inode_counter; /* * A bitmap of used inode numbers in an interval beginning at * used_inodes_start and holding ISO_USED_INODE_RANGE bits. * If a bit is set, then the corresponding inode number is occupied. * This interval is kept around inode_counter and eventually gets * advanced by ISO_USED_INODE_RANGE numbers in a tree traversal - * done by img_collect_inos(). + * done by img_collect_inos(). The value will stay in the 32 bit range, + * although used_inodes_start is 64 bit to better handle rollovers. */ uint8_t *used_inodes; - ino_t used_inodes_start; + uint64_t used_inodes_start; /** * Array of MD5 checksums as announced by xattr "isofs.ca" of the @@ -236,10 +238,10 @@ int img_collect_inos(IsoImage *image, IsoDir *dir, int flag); * @param image The image where the number shall be used * @param flag bit0= reset count (Caution: image must get new inos then) * @return - * Since ino_t 0 is used as default and considered self-unique, + * Since 0 is used as default and considered self-unique, * the value 0 should only be returned in case of error. */ -ino_t img_give_ino_number(IsoImage *image, int flag); +uint32_t img_give_ino_number(IsoImage *image, int flag); /* @param flag bit0= overwrite any ino, else only ino == 0 bit1= install inode with non-data, non-directory files