From 6fc3bb677746fb97a855feb85bd4a9c7a8e098dd Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Tue, 12 Jun 2012 21:16:56 +0200 Subject: [PATCH] New ystem area sub type CHRP with iso_write_opts_set_system_area() --- doc/boot_sectors.txt | 4 ++++ libisofs/ecma119.c | 7 ++++--- libisofs/libisofs.h | 14 +++++++++++--- libisofs/system_area.c | 17 ++++++++++++++--- 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/doc/boot_sectors.txt b/doc/boot_sectors.txt index 9935dd0..8e336c2 100644 --- a/doc/boot_sectors.txt +++ b/doc/boot_sectors.txt @@ -1416,5 +1416,9 @@ Involved -as mkisofs options: -efi-boot-part DISKFILE -prep-boot-part DISKFILE + +>>> What boots by what ? + + ------------------------------------------------------------------------------ diff --git a/libisofs/ecma119.c b/libisofs/ecma119.c index f1ab0e0..b33793f 100644 --- a/libisofs/ecma119.c +++ b/libisofs/ecma119.c @@ -3235,8 +3235,9 @@ int iso_write_opts_get_data_start(IsoWriteOpts *opts, uint32_t *data_start, * ISOLINUX boot image (see iso_image_set_boot_image()) and * only if not bit0 is set. * bit2-7= System area type - * 0= PC-BIOS DOS MBR - * 1= MIPS Big Endian Volume Header + * bit8-9= Only with System area type 0 = MBR + * Cylinder alignment mode + * bit10-13= System area sub type * @param flag bit0 = invalidate any attached system area data * same as data == NULL * bit1 = keep data unaltered @@ -3258,7 +3259,7 @@ int iso_write_opts_set_system_area(IsoWriteOpts *opts, char data[32768], memcpy(opts->system_area_data, data, 32768); } if (!(flag & 4)) - opts->system_area_options = options & 0x3ff; + opts->system_area_options = options & 0x3fff; return ISO_SUCCESS; } diff --git a/libisofs/libisofs.h b/libisofs/libisofs.h index fc2c149..8a40603 100644 --- a/libisofs/libisofs.h +++ b/libisofs/libisofs.h @@ -2145,12 +2145,20 @@ int iso_write_opts_set_fifo_size(IsoWriteOpts *opts, size_t fifo_size); * to 8. * This will overwrite the first 512 bytes of the submitted * bit8-9= Only with System area type 0 = MBR - * @since 1.0.4 - * Cylinder alignment mode eventually pads the image to make it - * end at a cylinder boundary. + * @since 1.0.4 + * Cylinder alignment mode eventually pads the image to make it + * end at a cylinder boundary. * 0 = auto (align if bit1) * 1 = always align to cylinder boundary * 2 = never align to cylinder boundary + * bit10-13= System area sub type + * @since 1.2.4 + * With type 0 = MBR: + * Gets overridden by bit0 and bit1. + * 0 = no particular sub type + * 1 = CHRP: A single MBR partition of type 0x96 covers the + * ISO image. Not compatible with any other feature + * which needs to have own MBR partition entries. * @param flag * bit0 = invalidate any attached system area data. Same as data == NULL * (This re-activates eventually loaded image System Area data. diff --git a/libisofs/system_area.c b/libisofs/system_area.c index 8193722..8c27565 100644 --- a/libisofs/system_area.c +++ b/libisofs/system_area.c @@ -2008,7 +2008,8 @@ static int partprepend_writer_compute_data_blocks(IsoImageWriter *writer) return ISO_ASSERT_FAILURE; t = writer->target; - /* >>> t->chrp_mark */; + if (t->efi_boot_partition != NULL || t->hfsplus || t->gpt_req_count > 0) + will_have_gpt = 1; if (t->efi_boot_partition != NULL) { ret = compute_partition_size(t->efi_boot_partition, @@ -2025,8 +2026,18 @@ static int partprepend_writer_compute_data_blocks(IsoImageWriter *writer) t->curblock += t->efi_boot_part_size; } - if (t->efi_boot_partition != NULL || t->hfsplus) - will_have_gpt = 1; + if ((((t->system_area_options >> 10) & 0xf) == 1) && + ((t->system_area_options >> 2) & 0x3f) == 0) { + /* CHRP is not compatible with any other partition in MBR */ + if (t->prep_partition != NULL || t->fat || will_have_gpt || + t->mbr_req_count > 0) + return ISO_BOOT_MBR_OVERLAP; + ret = iso_quick_mbr_entry(t, (uint32_t) 0, (uint32_t) 0, 0x96, 0); + if (ret < 0) + return ret; + return ISO_SUCCESS; + } + if (t->prep_partition != NULL) { ret = compute_partition_size(t->prep_partition, &(t->prep_part_size), 0);