From da2c0520cca67a61c74fea9729f06f6f3cdedd1d Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Tue, 20 Apr 2010 16:23:17 +0200 Subject: [PATCH] Changed new API call from iso_image_set_boot_platform_id() to el_torito_set_boot_platform_id(). Introduced new API call iso_image_set_boot_catalog_weight(). --- libisofs/eltorito.c | 18 +++++++++++++----- libisofs/eltorito.h | 9 +++++++-- libisofs/libisofs.h | 36 +++++++++++++++++++++++++++--------- libisofs/node.c | 1 + 4 files changed, 48 insertions(+), 16 deletions(-) diff --git a/libisofs/eltorito.c b/libisofs/eltorito.c index 18e0637..734d480 100644 --- a/libisofs/eltorito.c +++ b/libisofs/eltorito.c @@ -56,6 +56,13 @@ struct hard_disc_mbr { uint8_t sign2; }; +/* API */ +int el_torito_set_boot_platform_id(ElToritoBootImage *bootimg, uint8_t id) +{ + bootimg->platform_id = id; + return 1; +} + /** * Sets the load segment for the initial boot image. This is only for * no emulation boot images, and is a NOP for other image types. @@ -339,6 +346,7 @@ int create_image(IsoImage *image, const char *image_path, boot->partition_type = partition_type; boot->load_seg = 0; boot->load_size = load_sectors; + boot->platform_id = 0; /* 80x86 */ if (bootimg) { *bootimg = boot; @@ -418,7 +426,7 @@ int iso_image_set_boot_image(IsoImage *image, const char *image_path, } catalog->image = boot_image; catalog->node = cat_node; - catalog->platform_id = 0; /* Default is 80x86 */ + catalog->sort_weight = 1000; /* slightly high */ iso_node_ref((IsoNode*)cat_node); image->bootcat = catalog; @@ -521,11 +529,11 @@ void iso_image_remove_boot_image(IsoImage *image) } /* API */ -int iso_image_set_boot_platform_id(IsoImage *image, uint8_t id) +int iso_image_set_boot_catalog_weight(IsoImage *image, int sort_weight) { if (image->bootcat == NULL) return 0; - image->bootcat->platform_id = id; + image->bootcat->sort_weight = sort_weight; return 1; } @@ -735,7 +743,7 @@ int catalog_stream_new(Ecma119Image *target, IsoStream **stream) /* fill data */ data->target = target; data->offset = -1; - data->platform_id = target->catalog->platform_id; + data->platform_id = target->catalog->image->platform_id; str->refcount = 1; str->data = data; @@ -777,7 +785,7 @@ int el_torito_catalog_file_src_create(Ecma119Image *target, IsoFileSrc **src) file->checksum_index = 0; file->nsections = 1; file->sections = calloc(1, sizeof(struct iso_file_section)); - file->sort_weight = 1000; /* slightly high */ + file->sort_weight = target->catalog->sort_weight; file->stream = stream; ret = iso_file_src_add(target, file, src); diff --git a/libisofs/eltorito.h b/libisofs/eltorito.h index 59800e9..b0078ba 100644 --- a/libisofs/eltorito.h +++ b/libisofs/eltorito.h @@ -32,8 +32,8 @@ struct el_torito_boot_catalog { struct el_torito_boot_image *image; /* default boot image */ /* ts B00419 */ - /* Byte 1 of Validation Entry: 0= 80x86, 1= PowerPC, 2= Mac, 0xef= EFI */ - uint8_t platform_id; + /* Weight value for image sorting */ + int sort_weight; /* >>> ts B00419 : List of further boot images */ @@ -54,6 +54,11 @@ struct el_torito_boot_image { unsigned char partition_type; /**< type of partition for HD-emul images */ short load_seg; /**< Load segment for the initial boot image. */ short load_size; /**< Number of sectors to load. */ + + /* ts B00419 */ + /* Byte 1 of Validation Entry or Section Header Entry: + 0= 80x86, 1= PowerPC, 2= Mac, 0xef= EFI */ + uint8_t platform_id; }; /** El-Torito, 2.1 */ diff --git a/libisofs/libisofs.h b/libisofs/libisofs.h index 758a700..7a8b8aa 100644 --- a/libisofs/libisofs.h +++ b/libisofs/libisofs.h @@ -2378,25 +2378,42 @@ int iso_image_get_boot_image(IsoImage *image, ElToritoBootImage **boot, void iso_image_remove_boot_image(IsoImage *image); /** - * Sets the platform ID of the boot catalog that is attached to an IsoImage. + * Sets the sort weight of the boot catalog that is attached to an IsoImage. * - * A boot catalog gets attached by iso_image_set_boot_image() and removed - * by iso_image_remove_boot_image(). It is described in El Torito specs. - * Platform ID is byte 1 of the Validation Entry, i.e. byte 1 of the boot - * catalog record. + * For the meaning of sort weights see iso_node_set_sort_weight(). + * That function cannot be applied to the emerging boot catalog because + * it is not represented by an IsoNode. * * @param image * The image to manipulate. + * @param sort_weight + * The larger this value, the lower will be the block address of the + * boot catalog record. + * @return + * 0= no boot catalog attached , 1= ok , <0 = error + * + * @since 0.6.32 + */ +int iso_image_set_boot_catalog_weight(IsoImage *image, int sort_weight); + +/** + * Sets the platform ID of the boot image. + * + * The Platform ID gets written into the boot catalog at byte 1 of the + * Validation Entry, or at byte 1 of a Section Header Entry. + * + * @param bootimg + * The image to manipulate. * @param id * A Platform ID as of * El Torito 1.0 : 0x00= 80x86, 0x01= PowerPC, 0x02= Mac * Others : 0xef= EFI * @return - * 0= no boot catalog attached , 1= ok , <0 = error + * 1 ok , <=0 error * * @since 0.6.32 */ -int iso_image_set_boot_platform_id(IsoImage *image, uint8_t id); +int el_torito_set_boot_platform_id(ElToritoBootImage *bootimg, uint8_t id); /** * Sets the load segment for the initial boot image. This is only for @@ -3173,8 +3190,8 @@ const char *iso_symlink_get_dest(const IsoSymlink *link); int iso_symlink_set_dest(IsoSymlink *link, const char *dest); /** - * Sets the order in which a node will be written on image. High weihted files - * will be written first, so in a disc them will be written near the center. + * Sets the order in which a node will be written on image. The data content + * of files with high weight will be written to low block addresses. * * @param node * The node which weight will be changed. If it's a dir, this function @@ -3183,6 +3200,7 @@ int iso_symlink_set_dest(IsoSymlink *link, const char *dest); * @param w * The weight as a integer number, the greater this value is, the * closer from the begining of image the file will be written. + * Default value at IsoNode creation is 0. * * @since 0.6.2 */ diff --git a/libisofs/node.c b/libisofs/node.c index 7149398..4d1737d 100644 --- a/libisofs/node.c +++ b/libisofs/node.c @@ -1284,6 +1284,7 @@ int iso_node_new_file(char *name, IsoStream *stream, IsoFile **file) new->node.type = LIBISO_FILE; new->node.name = name; new->node.mode = S_IFREG; + new->sort_weight = 0; new->stream = stream; *file = new;