From d9c548dbfcfec03264b5a0364116b200d468385a Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Sun, 12 May 2024 13:56:29 +0200 Subject: [PATCH] Bug fix: File path of imported BIOS boot image was forgotten when it gets overwritten by a file of the same name. Thanks Brian C. Lane. --- libisofs/eltorito.c | 4 +- libisofs/eltorito.h | 5 +- libisofs/fs_image.c | 112 +++++++++++++++++++++++++++++++++++------ libisofs/image.c | 20 ++++++-- libisofs/image.h | 8 ++- libisofs/libisofs.h | 58 +++++++++++---------- libisofs/system_area.c | 24 +++++++++ libisofs/system_area.h | 19 +++++++ 8 files changed, 203 insertions(+), 47 deletions(-) diff --git a/libisofs/eltorito.c b/libisofs/eltorito.c index 7ba3ae9..6cd6b52 100644 --- a/libisofs/eltorito.c +++ b/libisofs/eltorito.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2007 Vreixo Formoso - * Copyright (c) 2010 - 2016 Thomas Schmitt + * Copyright (c) 2010 - 2024 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 @@ -845,6 +845,8 @@ void el_torito_boot_catalog_free(struct el_torito_boot_catalog *cat) continue; if ((IsoNode*)image->image != NULL) iso_node_unref((IsoNode*)image->image); + if (image->image_path != NULL) + free(image->image_path); free(image); } if ((IsoNode*)cat->node != NULL) diff --git a/libisofs/eltorito.h b/libisofs/eltorito.h index 60c6c0b..66f579d 100644 --- a/libisofs/eltorito.h +++ b/libisofs/eltorito.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2007 Vreixo Formoso - * Copyright (c) 2010 - 2018 Thomas Schmitt + * Copyright (c) 2010 - 2024 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 @@ -53,6 +53,9 @@ struct el_torito_boot_catalog { struct el_torito_boot_image { IsoFile *image; + /* Path of image at the time of ISO image loading (NULL = hidden image) */ + char *image_path; + /* Overrides .image if >= 0 : array index of appended partition */ int appended_idx; uint32_t appended_start; /* In blocks of 2048 bytes */ diff --git a/libisofs/fs_image.c b/libisofs/fs_image.c index f27d61e..302a7ac 100644 --- a/libisofs/fs_image.c +++ b/libisofs/fs_image.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2007 Vreixo Formoso - * Copyright (c) 2009 - 2023 Thomas Schmitt + * Copyright (c) 2009 - 2024 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 @@ -4143,12 +4143,14 @@ ex:; static int iso_analyze_mbr(IsoImage *image, IsoDataSource *src, int flag) { - int sub_type = 2, ret, is_isohybrid = 0, is_grub2_mbr = 0; + int sub_type = 2, ret, i, is_isohybrid = 0, is_grub2_mbr = 0; int is_protective_label = 0; + uint32_t next_above = 0; uint64_t part2_start; char *sad; struct iso_imported_sys_area *sai; struct iso_mbr_partition_request *part; + IsoNode *node; sad = image->system_area_data; sai = image->imported_sa_info; @@ -4167,6 +4169,17 @@ int iso_analyze_mbr(IsoImage *image, IsoDataSource *src, int flag) goto ex; } + /* Possibly obtain ISO paths of MBR partition content */ + for (i = 0; i < sai->mbr_req_count; i++) { + part = sai->mbr_req[i]; + if (part->block_count == 0 || part->image_path != NULL) + continue; + ret = iso_tree_get_node_of_block(image, NULL, part->start_block / 4, + &node, &next_above, 0); + if (ret > 0) + part->image_path = iso_tree_get_node_path(node); + } + ret = iso_analyze_isohybrid(image, 0); if (ret < 0) goto ex; @@ -4477,15 +4490,17 @@ ex: } /* @param flag bit0= Pre-run: Only assess partition table. - (Yet without effect, because nothing else is done) */ static int iso_analyze_gpt(IsoImage *image, IsoDataSource *src, int flag) { int ret, i, j; uint64_t start_block, block_count, flags, end_block, j_end, j_start; + uint32_t next_above; uint8_t *part; struct iso_imported_sys_area *sai; + struct iso_gpt_partition_request *gpt_entry; + IsoNode *node; sai = image->imported_sa_info; @@ -4566,6 +4581,21 @@ int iso_analyze_gpt(IsoImage *image, IsoDataSource *src, int flag) } } + if (flag & 1) + return 1; + + /* Possibly obtain ISO paths of GPT partition content */ + for (i = 0; i < sai->gpt_req_count; i++) { + gpt_entry = sai->gpt_req[i]; + if (gpt_entry->block_count == 0 || gpt_entry->image_path != NULL) + continue; + ret = iso_tree_get_node_of_block(image, NULL, + (uint32_t) (gpt_entry->start_block / 4), + &node, &next_above, 0); + if (ret > 0) + gpt_entry->image_path = iso_tree_get_node_path(node); + } + return 1; } @@ -4592,15 +4622,16 @@ int iso_analyze_apm_head(IsoImage *image, IsoDataSource *src, int flag) } /* @param flag bit0= Pre-run: Only assess partition table. - (Yet without effect, because nothing else is done) */ static int iso_analyze_apm(IsoImage *image, IsoDataSource *src, int flag) { int ret, i; - uint32_t map_entries, start_block, block_count, flags; + uint32_t map_entries, start_block, block_count, flags, next_above; char *sad, *part, name[33], type_string[33]; struct iso_imported_sys_area *sai; + struct iso_apm_partition_request *apm_entry; + IsoNode *node; sai = image->imported_sa_info; sad = image->system_area_data; @@ -4645,6 +4676,22 @@ int iso_analyze_apm(IsoImage *image, IsoDataSource *src, int flag) } } } + + if (flag & 1) + return 1; + + /* Possibly obtain ISO paths of APM partition content */ + for (i = 0; i < sai->apm_req_count; i++) { + apm_entry = sai->apm_req[i]; + if (apm_entry->block_count == 0 || apm_entry->image_path != NULL) + continue; + ret = iso_tree_get_node_of_block(image, NULL, + (uint32_t) (apm_entry->start_block / + (2048 / sai->apm_block_size)), + &node, &next_above, 0); + if (ret > 0) + apm_entry->image_path = iso_tree_get_node_path(node); + } return 1; } @@ -4868,6 +4915,7 @@ int iso_analyze_sun(IsoImage *image, IsoDataSource *src, int flag) if (ret > 0) { iso_node_ref(node); sai->sparc_core_node = (IsoFile *) node; + sai->sparc_core_node_path = iso_tree_get_node_path(node); } } else { sai->sparc_grub2_core_adr = 0; @@ -5326,8 +5374,12 @@ int iso_impsysa_report(IsoImage *image, struct iso_impsysa_result *target, if (part->block_count == 0) continue; sprintf(msg, "MBR partition path : %3d ", part->desired_slot); - iso_impsysa_report_blockpath(image, target, msg, - (uint32_t) (part->start_block / 4), 0); + if (part->image_path != NULL) { + iso_impsysa_report_text(target, msg, part->image_path, 0); + } else { + iso_impsysa_report_blockpath(image, target, msg, + (uint32_t) (part->start_block / 4), 0); + } } if (sai->prep_part_start > 0 && sai->prep_part_size > 0) { sprintf(msg, "PReP boot partition: %u %u", @@ -5392,11 +5444,17 @@ int iso_impsysa_report(IsoImage *image, struct iso_impsysa_result *target, sai->sparc_grub2_core_size); iso_impsysa_line(target, msg); if (sai->sparc_core_node != NULL) { - path = iso_tree_get_node_path((IsoNode *) sai->sparc_core_node); + if(sai->sparc_core_node_path != NULL) { + path = sai->sparc_core_node_path; + } else { + path = iso_tree_get_node_path( + (IsoNode *) sai->sparc_core_node); + } if (path != NULL) { sprintf(msg, "SPARC GRUB2 path : "); iso_impsysa_report_text(target, msg, path, 0); - free(path); + if (sai->sparc_core_node_path == NULL) + free(path); } } } @@ -5486,8 +5544,12 @@ int iso_impsysa_report(IsoImage *image, struct iso_impsysa_result *target, if (gpt_entry->block_count == 0) continue; sprintf(msg, "GPT partition path : %3d ", idx); - iso_impsysa_report_blockpath(image, target, msg, + if (gpt_entry->image_path != NULL) { + iso_impsysa_report_text(target, msg, gpt_entry->image_path, 0); + } else { + iso_impsysa_report_blockpath(image, target, msg, (uint32_t) (gpt_entry->start_block / 4), 0); + } } if (sai->apm_req_count > 0) { @@ -5512,10 +5574,14 @@ int iso_impsysa_report(IsoImage *image, struct iso_impsysa_result *target, if (apm_entry->block_count == 0) continue; sprintf(msg, "APM partition path : %3d ", idx); - iso_impsysa_report_blockpath(image, target, msg, + if (apm_entry->image_path != NULL) { + iso_impsysa_report_text(target, msg, apm_entry->image_path, 0); + } else { + iso_impsysa_report_blockpath(image, target, msg, (uint32_t) (apm_entry->start_block / (2048 / sai->apm_block_size)), 0); + } } ret = 1; @@ -5671,9 +5737,13 @@ int iso_eltorito_report(IsoImage *image, struct iso_impsysa_result *target, } for (i= 0; i < bootcat->num_bootimages; i++) { img = bootcat->bootimages[i]; - if (lba_mem[i] != 0xffffffff) { - sprintf(msg, "El Torito img path : %3d ", i + 1); + sprintf(msg, "El Torito img path : %3d ", i + 1); + if (img->image_path != NULL) { + iso_impsysa_report_text(target, msg, img->image_path, 0); + } else if (lba_mem[i] != 0xffffffff) { iso_impsysa_report_blockpath(image, target, msg, lba_mem[i], 1); + } + if (lba_mem[i] != 0xffffffff) { if (img->type == 4 && img->emul_hdd_size > 0) { sprintf(msg, "El Torito hdsiz/512: %3d %u", i + 1, (unsigned int) img->emul_hdd_size); @@ -6444,7 +6514,7 @@ int iso_image_import(IsoImage *image, IsoDataSource *src, struct el_torito_boot_catalog *oldbootcat; uint8_t *rpt; IsoFileSource *boot_src; - IsoNode *node; + IsoNode *node, *boot_image_node; char *old_checksum_array = NULL; char checksum_type[81]; uint32_t checksum_size, truncate_mode, truncate_length; @@ -6653,6 +6723,7 @@ int iso_image_import(IsoImage *image, IsoDataSource *src, goto import_revert; } boot_image->image = NULL; + boot_image->image_path = NULL; boot_image->bootable = data->boot_flags[idx] & 1; boot_image->type = data->media_types[idx]; boot_image->partition_type = data->partition_types[idx]; @@ -6781,6 +6852,19 @@ int iso_image_import(IsoImage *image, IsoDataSource *src, } } } + + /* Try to obtain boot image paths */ + for (idx = 0; idx < image->bootcat->num_bootimages; idx++) { + boot_image_node = + (IsoNode *) image->bootcat->bootimages[idx]->image; + if (boot_image_node == NULL) + continue; + if (image->bootcat->bootimages[idx]->image_path != NULL) + free(image->bootcat->bootimages[idx]->image_path); + image->bootcat->bootimages[idx]->image_path = + iso_tree_get_node_path(boot_image_node); + } + if (image->bootcat->node == NULL) { IsoNode *node; IsoBoot *bootcat; diff --git a/libisofs/image.c b/libisofs/image.c index adf7010..dc90e07 100644 --- a/libisofs/image.c +++ b/libisofs/image.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2007 Vreixo Formoso - * Copyright (c) 2009 - 2022 Thomas Schmitt + * Copyright (c) 2009 - 2024 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 @@ -17,6 +17,7 @@ #include "node.h" #include "messages.h" #include "eltorito.h" +#include "system_area.h" #include #include @@ -43,6 +44,7 @@ int iso_imported_sa_new(struct iso_imported_sys_area **boots, int flag) b->sparc_disc_label = NULL; b->sparc_core_node = NULL; + b->sparc_core_node_path = NULL; b->sparc_entries = NULL; b->hppa_cmdline = NULL; @@ -71,18 +73,27 @@ int iso_imported_sa_unref(struct iso_imported_sys_area **boots, int flag) return 2; if (b->mbr_req != NULL) { - for (i = 0; i < b->mbr_req_count; i++) + for (i = 0; i < b->mbr_req_count; i++) { + if (b->mbr_req[i] != NULL) + LIBISO_FREE_MEM(b->mbr_req[i]->image_path); LIBISO_FREE_MEM(b->mbr_req[i]); + } LIBISO_FREE_MEM(b->mbr_req); } if (b->apm_req != NULL) { - for (i = 0; i < b->apm_req_count; i++) + for (i = 0; i < b->apm_req_count; i++) { + if (b->apm_req[i] != NULL) + LIBISO_FREE_MEM(b->apm_req[i]->image_path); LIBISO_FREE_MEM(b->apm_req[i]); + } LIBISO_FREE_MEM(b->apm_req); } if (b->gpt_req != NULL) { - for (i = 0; i < b->gpt_req_count; i++) + for (i = 0; i < b->gpt_req_count; i++) { + if (b->gpt_req[i] != NULL) + LIBISO_FREE_MEM(b->gpt_req[i]->image_path); LIBISO_FREE_MEM(b->gpt_req[i]); + } LIBISO_FREE_MEM(b->gpt_req); } LIBISO_FREE_MEM(b->gpt_backup_comments); @@ -102,6 +113,7 @@ int iso_imported_sa_unref(struct iso_imported_sys_area **boots, int flag) LIBISO_FREE_MEM(b->sparc_disc_label); if (b->sparc_core_node != NULL) iso_node_unref((IsoNode *) b->sparc_core_node); + LIBISO_FREE_MEM(b->sparc_core_node_path); LIBISO_FREE_MEM(b->sparc_entries); LIBISO_FREE_MEM(b->hppa_cmdline); diff --git a/libisofs/image.h b/libisofs/image.h index 2e3e590..3c4a0d0 100644 --- a/libisofs/image.h +++ b/libisofs/image.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2007 Vreixo Formoso - * Copyright (c) 2009 - 2022 Thomas Schmitt + * Copyright (c) 2009 - 2024 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 @@ -418,6 +418,12 @@ struct iso_imported_sys_area { uint32_t sparc_grub2_core_size; IsoFile *sparc_core_node; + /* Only for representing the imported ISO: + Path of file which held the partition content. + NULL = no such file + */ + char *sparc_core_node_path; + /* see image.h : struct Iso_Image */ int hppa_hdrversion; char *hppa_cmdline; diff --git a/libisofs/libisofs.h b/libisofs/libisofs.h index 6d04b59..9952780 100644 --- a/libisofs/libisofs.h +++ b/libisofs/libisofs.h @@ -4,7 +4,7 @@ /* * Copyright (c) 2007-2008 Vreixo Formoso, Mario Danic - * Copyright (c) 2009-2023 Thomas Schmitt + * Copyright (c) 2009-2024 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 @@ -4465,8 +4465,8 @@ int iso_image_get_system_area(IsoImage *img, char data[32768], " gives partition number, status byte, type byte, start block,", \ " and number of blocks. 512 bytes per block.", \ " MBR partition path : X path", \ -" the path of a file in the ISO image which begins at the partition", \ -" start block of partition X.", \ +" the path of a file in the ISO image which began at the start block", \ +" of partition X when the ISO filesystem was imported.", \ " PReP boot partition: decimal decimal", \ " gives start block and size of a PReP boot partition in ISO 9660", \ " block units of 2048 bytes.", \ @@ -4532,8 +4532,8 @@ int iso_image_get_system_area(IsoImage *img, char data[32768], " GPT start and size : X decimal decimal", \ " start block and number of blocks of partition X. 512 bytes per block.", \ " GPT partition path : X path", \ -" the path of a file in the ISO image which begins at the partition", \ -" start block of partition X.", \ +" the path of a file in the ISO image which began at the start block", \ +" of partition X when the ISO filesystem was imported.", \ "" #define ISO_SYSAREA_REPORT_DOC_APM \ \ @@ -4553,8 +4553,8 @@ int iso_image_get_system_area(IsoImage *img, char data[32768], " APM start and size : X decimal decimal", \ " start block and number of blocks of partition X.", \ " APM partition path : X path", \ -" the path of a file in the ISO image which begins at the partition", \ -" start block of partition X.", \ +" the path of a file in the ISO image which began at the start block", \ +" of partition X when the ISO filesystem was imported.", \ "" #define ISO_SYSAREA_REPORT_DOC_MIPS \ \ @@ -4564,8 +4564,9 @@ int iso_image_get_system_area(IsoImage *img, char data[32768], " MIPS-BE boot entry : X upto8chr decimal decimal", \ " tells name, 512-byte block address, and byte count of boot entry X.", \ " MIPS-BE boot path : X path", \ -" tells the path to the boot image file in the ISO image which belongs", \ -" to the block address given by boot entry X.", \ +" tells the path to the boot image file in the ISO image which began", \ +" at the block address given by boot entry X when the ISO filesystem", \ +" was imported.", \ "", \ "If a DEC Boot Block for MIPS Little Endian is detected, there may be:", \ " MIPS-LE boot map : LoadAddr ExecAddr SegmentSize SegmentStart", \ @@ -4575,8 +4576,9 @@ int iso_image_get_system_area(IsoImage *img, char data[32768], " of the boot file. The first two are counted in bytes, the other two", \ " are counted in blocks of 512 bytes.", \ " MIPS-LE boot path : path", \ -" tells the path to the boot file in the ISO image which belongs to the", \ -" address given by SegmentStart.", \ +" tells the path to the boot image file in the ISO image which began", \ +" at the block address given by SegmentStart when the ISO filesystem", \ +" was imported.", \ " MIPS-LE elf offset : decimal", \ " tells the relative 512-byte block offset inside the boot file:", \ " SegmentStart - FileStartBlock", \ @@ -4600,8 +4602,8 @@ int iso_image_get_system_area(IsoImage *img, char data[32768], " SPARC GRUB2 core : decimal decimal", \ " tells byte address and byte count of the GRUB2 SPARC core file.", \ " SPARC GRUB2 path : path", \ -" tells the path to the data file in the ISO image which belongs to the", \ -" address given by core.", \ +" tells the path to the data file in the ISO image which began at the", \ +" address given by core when the ISO filesystem was imported.", \ "" #define ISO_SYSAREA_REPORT_DOC_HPPA \ \ @@ -4613,7 +4615,9 @@ int iso_image_get_system_area(IsoImage *img, char data[32768], " HP-PA boot files : ByteAddr ByteSize Path", \ " headline for human readers.", \ " HP-PA 32-bit kernel: decimal decimal path", \ -" tells start byte, byte count, and file path of the 32-bit kernel.", \ +" tells start byte and byte count of the 32-bit kernel and the path", \ +" to the data file in the ISO image which began at the start byte", \ +" when the ISO filesystem was imported.", \ " HP-PA 64-bit kernel: decimal decimal path", \ " tells the same for the 64-bit kernel.", \ " HP-PA ramdisk : decimal decimal path", \ @@ -4629,8 +4633,8 @@ int iso_image_get_system_area(IsoImage *img, char data[32768], " DEC Alpha ldr adr : decimal", \ " tells the start of the loader file in units of 512-byte blocks.", \ " DEC Alpha ldr path : path", \ -" tells the path of a file in the ISO image which starts at the loader", \ -" start address." +" tells the path to a file in the ISO image which began at the", \ +" loader start address when the ISO filesystem was imported." /** * Obtain an array of texts describing the detected properties of the @@ -4698,12 +4702,13 @@ int iso_image_report_system_area(IsoImage *image, "", \ "The following lines appear conditionally:", \ " El Torito cat path : iso_rr_path", \ -" tells the path to the data file in the ISO image which belongs to", \ -" the block address where the boot catalog starts.", \ +" tells the path to the data file in the ISO image which began at the", \ +" block address where the boot catalog starts when the ISO filesystem", \ +" was imported.", \ " (This line is not reported if no path points to that block.)", \ " El Torito img path : X iso_rr_path", \ -" tells the path to the data file in the ISO image which belongs to", \ -" the block address given by LBA of boot image X.", \ +" tells the path to the data file in the ISO image which began at the", \ +" LBA of boot image X when the ISO filesystem was imported.", \ " (This line is not reported if no path points to that block.)", \ " El Torito img opts : X word ... word", \ " tells the presence of extra features:", \ @@ -8565,15 +8570,16 @@ int iso_file_get_md5(IsoImage *image, IsoFile *file, char md5[16], int flag); int iso_file_make_md5(IsoFile *file, int flag); /** - * Check a data block whether it is a libisofs session checksum tag and - * eventually obtain its recorded parameters. These tags get written after - * volume descriptors, directory tree and checksum array and can be detected - * without loading the image tree. + * Check a data block whether it is a libisofs checksum tag and if so, obtain + * its recorded parameters. These tags get written after volume descriptors, + * directory tree and checksum array and can be detected without loading the + * image tree. * One may start reading and computing MD5 at the suspected image session - * start and look out for a session tag on the fly. See doc/checksum.txt . + * start and look out for a checksum tag on the fly. See doc/checksum.txt . * @param data * A complete and aligned data block read from an ISO image session. * @param tag_type + * Returns the tag type: * 0= no tag * 1= session tag * 2= superblock tag @@ -8593,7 +8599,7 @@ int iso_file_make_md5(IsoFile *file, int flag); * covered by parameter md5. * @param next_tag * Returns the predicted block address of the next tag. - * next_tag is valid only if not 0 and only with return values 2, 3, 4. + * next_tag is valid only if not 0 and only with tag types 2, 3, 4. * With tag types 2 and 3, reading shall go on sequentially and the MD5 * computation shall continue up to that address. * With tag type 4, reading shall resume either at LBA 32 for the first diff --git a/libisofs/system_area.c b/libisofs/system_area.c index 15f5833..6e97632 100644 --- a/libisofs/system_area.c +++ b/libisofs/system_area.c @@ -1053,6 +1053,7 @@ int iso_quick_apm_entry(struct iso_apm_partition_request **req_array, if (l > 0) memcpy((char *) entry->type, type, l); entry->req_status = 0; + entry->image_path = NULL; ret = iso_register_apm_entry(req_array, apm_req_count, entry, 0); free(entry); return ret; @@ -1099,6 +1100,7 @@ int iso_quick_gpt_entry(struct iso_gpt_partition_request **req_array, entry->flags = flags; memcpy(entry->name, name, 72); entry->req_status = 0; + entry->image_path = NULL; ret = iso_register_gpt_entry(req_array, gpt_req_count, entry, 0); free(entry); return ret; @@ -1128,6 +1130,7 @@ int iso_quick_mbr_entry(struct iso_mbr_partition_request **req_array, entry->type_byte = type_byte; entry->status_byte = status_byte; entry->desired_slot = desired_slot; + entry->image_path = NULL; ret = iso_register_mbr_entry(req_array, mbr_req_count, entry, 0); free(entry); return ret; @@ -2542,6 +2545,13 @@ int iso_register_apm_entry(struct iso_apm_partition_request **req_array, return ISO_OUT_OF_MEM; memcpy(entry, req, sizeof(struct iso_apm_partition_request)); + if (req->image_path != NULL) { + entry->image_path = strdup(req->image_path); + if (entry->image_path == NULL) { + LIBISO_FREE_MEM(entry); + return ISO_OUT_OF_MEM; + } + } req_array[*apm_req_count] = entry; (*apm_req_count)++; return ISO_SUCCESS; @@ -2561,6 +2571,13 @@ int iso_register_mbr_entry(struct iso_mbr_partition_request **req_array, return ISO_OUT_OF_MEM; memcpy(entry, req, sizeof(struct iso_mbr_partition_request)); + if (req->image_path != NULL) { + entry->image_path = strdup(req->image_path); + if (entry->image_path == NULL) { + LIBISO_FREE_MEM(entry); + return ISO_OUT_OF_MEM; + } + } req_array[*mbr_req_count] = entry; (*mbr_req_count)++; return ISO_SUCCESS; @@ -2579,6 +2596,13 @@ int iso_register_gpt_entry(struct iso_gpt_partition_request **req_array, return ISO_OUT_OF_MEM; memcpy(entry, req, sizeof(struct iso_gpt_partition_request)); + if (req->image_path != NULL) { + entry->image_path = strdup(req->image_path); + if (entry->image_path == NULL) { + LIBISO_FREE_MEM(entry); + return ISO_OUT_OF_MEM; + } + } req_array[*gpt_req_count] = entry; (*gpt_req_count)++; return ISO_SUCCESS; diff --git a/libisofs/system_area.h b/libisofs/system_area.h index 9060851..b8fe62c 100644 --- a/libisofs/system_area.h +++ b/libisofs/system_area.h @@ -104,6 +104,12 @@ struct iso_mbr_partition_request { */ int desired_slot; + /* Only when representing an imported partition: + Path of file in imported ISO which holds the partition content. + NULL = no such file + */ + char *image_path; + }; /* Copies the content of req and registers it in t.mbr_req[]. @@ -162,6 +168,13 @@ struct iso_apm_partition_request { bit0= this is an automatically placed filler partition */ uint32_t req_status; + + /* Only when representing an imported partition: + Path of file in imported ISO which holds the partition content. + NULL = no such file + */ + char *image_path; + }; /* Copies the content of req and registers it in t.apm_req[]. @@ -260,6 +273,12 @@ struct iso_gpt_partition_request { note is issued and the partition gets into the higher slot. */ int desired_slot; + + /* Only when representing an imported partition: + Path of file in imported ISO which holds the partition content. + NULL = no such file + */ + char *image_path; }; /* Copies the content of req and registers it in t.gpt_req[].