Compare commits

...

12 Commits

Author SHA1 Message Date
Thomas Schmitt 78708015af Improved warning messages about symbolic links and special files in ISO 9660:1999 tree 2024-05-19 18:35:40 +02:00
Thomas Schmitt 57fcd4bfbb Fixed assessment of MIPS boot equipment which was broken by commit 405f0f0 2024-05-18 21:29:32 +02:00
Thomas Schmitt 483a68aaf2 Avoided use of uninitialized variables which was introduced by commit d9c548d 2024-05-18 13:42:37 +02:00
Thomas Schmitt 8ffd3b381b Clarified the API description of NULL data in iso_write_opts_set_system_area() 2024-05-12 21:56:15 +02:00
Thomas Schmitt d9c548dbfc 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. 2024-05-12 13:56:29 +02:00
Thomas Schmitt 8ed27c6255 Enabled up to 8 appended GPT partitions and improved their number mapping 2024-05-10 17:25:07 +02:00
Thomas Schmitt 405f0f04d4 Improved size estimation and property assessment of El Torito hidden boot images 2023-11-20 11:42:41 +01:00
Thomas Schmitt 8a8439768c Clarified in the description of iso_image_set_boot_image() the meaning of pseudo-path parameters "start" and "size" 2023-11-20 09:15:18 +01:00
Thomas Schmitt 9ec998f9fc Updated copyright year in README 2023-06-09 19:57:42 +02:00
Thomas Schmitt 8a4f1f88ae Explicitely included unistd.h in all source file which use ssize_t 2023-06-09 19:54:50 +02:00
Thomas Schmitt 09ec2fa4b7 Bug fix: On non-GNU/Linux systems ssize_t was not defined in rockridge.h . Report and fix proposal by Rui Chen. 2023-06-09 19:48:54 +02:00
Thomas Schmitt 5a867c43ab Version leap to 1.5.7 2023-06-07 19:10:34 +02:00
19 changed files with 530 additions and 134 deletions

View File

@ -1,3 +1,13 @@
git clone git@dev.lovelyhq.com:libburnia/libisofs.git
(to become libisofs-1.5.8 or higher)
===============================================================================
- no novelties yet -
libisofs-1.5.6.pl01.tar.gz Fri Jun 09 2023
===============================================================================
* Bug fix: On non-GNU/Linux systems ssize_t was not defined in rockridge.h .
Report and fix proposal by Rui Chen
libisofs-1.5.6.tar.gz Wed Jun 07 2023
===============================================================================
* Bug fix: iso_write_opts_set_part_like_isohybrid() did not cause a MBR
@ -17,7 +27,6 @@ libisofs-1.5.6.tar.gz Wed Jun 07 2023
Proof-of-concept by Ivan Shmakov.
* New API call iso_write_opts_set_max_ce_entries()
libisofs-1.5.4.tar.gz Sat Jan 30 2021
===============================================================================
* Bug fix: Large amounts of AAIP data or many long file names could cause with

2
README
View File

@ -5,7 +5,7 @@
Released under GNU General Public License version 2 or later.
See COPYING file for details.
Copyright (C) 2008 - 2021 Vreixo Formoso,
Copyright (C) 2008 - 2023 Vreixo Formoso,
Mario Danic,
Vladimir Serbinenko,
Thomas Schmitt

View File

@ -1,4 +1,4 @@
AC_INIT([libisofs], [1.5.6], [http://libburnia-project.org])
AC_INIT([libisofs], [1.5.7], [http://libburnia-project.org])
AC_PREREQ([2.50])
dnl AC_CONFIG_HEADER([config.h])
@ -41,7 +41,7 @@ dnl If LIBISOFS_*_VERSION changes, be sure to change AC_INIT above to match.
dnl
LIBISOFS_MAJOR_VERSION=1
LIBISOFS_MINOR_VERSION=5
LIBISOFS_MICRO_VERSION=6
LIBISOFS_MICRO_VERSION=7
LIBISOFS_VERSION=$LIBISOFS_MAJOR_VERSION.$LIBISOFS_MINOR_VERSION.$LIBISOFS_MICRO_VERSION
AC_SUBST(LIBISOFS_MAJOR_VERSION)

View File

@ -933,7 +933,7 @@ configure.ac
libisofs/libisofs.h
Version leap to 1.5.6
07 Jun 2023 []
07 Jun 2023 [170318c]
ChangeLog
libisofs/changelog.txt
Updated change log
@ -956,6 +956,36 @@ Updated change log
* Bug fix: Size of further CE area was calculated wrong if its CE entry ended
exactly at a block boundary
07 Jun 2023 [5a867c4]
configure.ac
libisofs/libisofs.h
Version leap to 1.5.7
[master: ][branch 1.5.6.pl01: ]
libisofs/rockridge.h
ChangeLog
libisofs/changelog.txt
Bug fix: On non-GNU/Linux systems ssize_t was not defined in rockridge.h .
Report and fix proposal by Rui Chen
------------------------------- release - libisofs-1.5.6.pl01 - 09 Jun 2023
* Bug fix: On non-GNU/Linux systems ssize_t was not defined in rockridge.h .
Report and fix proposal by Rui Chen
[]
libisofs/ecma119.c
libisofs/fs_image.c
libisofs/rockridge.c
libisofs/stream.c
[]
README
Updated copyright year in README
------------------------------------ release - libisofs-1.5.8 -
------------------------------------------------------------------------
Todo about iso_read_image_feature_named() :

View File

@ -41,6 +41,7 @@
#include <locale.h>
#include <langinfo.h>
#include <stdio.h>
#include <unistd.h>
#ifdef Xorriso_standalonE
@ -2763,6 +2764,8 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *in_opts, Ecma119Image **img)
target->joliet_ucs2_failures = 0;
target->joliet_symlinks = 0;
target->joliet_specials = 0;
target->iso1999_symlinks = 0;
target->iso1999_specials = 0;
/* If partitions get appended, then the backup GPT cannot be part of
the ISO filesystem.
@ -3302,6 +3305,16 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *in_opts, Ecma119Image **img)
"Number of special files omitted from Joliet tree: %lu",
target->joliet_specials);
}
if (target->iso1999_symlinks > 0) {
iso_msg_submit(target->image->id, ISO_FILE_IGNORED, 0,
"Number of symbolic links omitted from ISO 9660:1999 tree: %lu",
target->iso1999_symlinks);
}
if (target->iso1999_specials > 0) {
iso_msg_submit(target->image->id, ISO_FILE_IGNORED, 0,
"Number of special files omitted from ISO 9660:1999 tree: %lu",
target->iso1999_specials);
}
*img = target;
return ISO_SUCCESS;
@ -4692,6 +4705,9 @@ void iso_tell_max_part_range(IsoWriteOpts *opts,
if (sa_type == 3) { /* SUN Disk Label */
*first_partition = 2;
*last_partition = 8;
} else if(sa_type == 0 && opts->appended_as_gpt) {
*first_partition = 1;
*last_partition = 8;
} else {
*first_partition = 1;
*last_partition = 4;

View File

@ -933,6 +933,12 @@ struct ecma119_image
unsigned long joliet_symlinks;
unsigned long joliet_specials;
/* Count of symbolic links and special files which could not be represented
in ISO 9660:1999.
*/
unsigned long iso1999_symlinks;
unsigned long iso1999_specials;
};
#define BP(a,b) [(b) - (a) + 1]

View File

@ -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)

View File

@ -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 */

View File

@ -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
@ -36,6 +36,7 @@
#include <limits.h>
#include <stdio.h>
#include <ctype.h>
#include <unistd.h>
/* Enable this and write the correct absolute path into the include statement
@ -549,6 +550,10 @@ struct image_fs_data
};
static int iso_impsysa_reduce_next_above(IsoImage *image, uint32_t block,
uint32_t *next_above, int flag);
struct child_list
{
IsoFileSource *file;
@ -3597,6 +3602,8 @@ int create_boot_img_filesrc(IsoImageFilesystem *fs, IsoImage *image, int idx,
_ImageFsData *fsdata;
IsoFileSource *ifsrc = NULL;
ImageFileSourceData *ifsdata = NULL;
IsoNode *node;
uint32_t size, next_above = 0, start_block;
if (fs == NULL || fs->data == NULL || src == NULL) {
return ISO_NULL_POINTER;
@ -3610,12 +3617,32 @@ int create_boot_img_filesrc(IsoImageFilesystem *fs, IsoImage *image, int idx,
atts.st_nlink = 1;
/*
* Old comment from Vreixo Formoso:
* this is the greater problem. We don't know the size. For now, we
* just use a single block of data. In a future, maybe we could figure out
* a better idea. Another alternative is to use several blocks, that way
* is less probable that we throw out valid data.
*/
atts.st_size = (off_t)BLOCK_SIZE;
/* ts C31112 : Make use of size estimation "El Torito img blks :" */
/* (Code from iso_impsysa_report_blockpath() ) */
size = 1;
start_block = fsdata->bootblocks[idx];
iso_tree_get_node_of_block(image, NULL, start_block, &node, &next_above,
0);
ret = iso_impsysa_reduce_next_above(image, start_block, &next_above, 0);
if (ret >= 0) {
if (next_above != 0) {
/* It has to fit in a single extent */
if ((off_t) (next_above - start_block) * BLOCK_SIZE <
(off_t) 0xffffffff) {
size = next_above - start_block;
} else {
size = 0xffffffff / BLOCK_SIZE;
}
}
}
atts.st_size = (off_t) size * BLOCK_SIZE;
/* Fill last entries */
atts.st_dev = fsdata->id;
@ -3647,7 +3674,7 @@ int create_boot_img_filesrc(IsoImageFilesystem *fs, IsoImage *image, int idx,
ifsdata->info = atts;
ifsdata->name = NULL;
ifsdata->sections[0].block = fsdata->bootblocks[idx];
ifsdata->sections[0].size = BLOCK_SIZE;
ifsdata->sections[0].size = size * BLOCK_SIZE;
ifsdata->nsections = 1;
ifsrc->class = &ifs_class;
@ -3664,7 +3691,7 @@ boot_fs_cleanup: ;
}
/** ??? >>> ts B00428 : should the max size become public ? */
#define Libisofs_boot_image_max_sizE (4096*1024)
#define Libisofs_boot_info_image_max_sizE (4096*1024)
/** Guess which of the loaded boot images contain boot information tables.
Set boot->seems_boot_info_table accordingly.
@ -3692,7 +3719,7 @@ int iso_image_eval_boot_info_table(IsoImage *image, struct iso_read_opts *opts,
boot->seems_grub2_boot_info = 0;
boot->seems_isohybrid_capable = 0;
img_size = iso_file_get_size(boot_file);
if (img_size > Libisofs_boot_image_max_sizE || img_size < 64)
if (img_size > Libisofs_boot_info_image_max_sizE || img_size < 64)
continue;
img_lba = 0;
sections = NULL;
@ -4111,15 +4138,19 @@ ex:;
return ret;
}
/* @param flag bit0= Pre-run: Only assess partition table.
*/
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;
@ -4133,6 +4164,22 @@ int iso_analyze_mbr(IsoImage *image, IsoDataSource *src, int flag)
if (ret <= 0)
goto ex;
if((flag & 1)) {
ret= 1;
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;
@ -4442,6 +4489,8 @@ ex:
return ret;
}
/* @param flag bit0= Pre-run: Only assess partition table.
*/
static
int iso_analyze_gpt(IsoImage *image, IsoDataSource *src, int flag)
{
@ -4449,6 +4498,8 @@ int iso_analyze_gpt(IsoImage *image, IsoDataSource *src, int flag)
uint64_t start_block, block_count, flags, end_block, j_end, j_start;
uint8_t *part;
struct iso_imported_sys_area *sai;
struct iso_gpt_partition_request *gpt_entry;
IsoNode *node;
sai = image->imported_sa_info;
@ -4529,6 +4580,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, NULL, 0);
if (ret > 0)
gpt_entry->image_path = iso_tree_get_node_path(node);
}
return 1;
}
@ -4554,6 +4620,8 @@ int iso_analyze_apm_head(IsoImage *image, IsoDataSource *src, int flag)
return 1;
}
/* @param flag bit0= Pre-run: Only assess partition table.
*/
static
int iso_analyze_apm(IsoImage *image, IsoDataSource *src, int flag)
{
@ -4561,6 +4629,8 @@ int iso_analyze_apm(IsoImage *image, IsoDataSource *src, int flag)
uint32_t map_entries, start_block, block_count, flags;
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;
@ -4605,9 +4675,27 @@ 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, NULL, 0);
if (ret > 0)
apm_entry->image_path = iso_tree_get_node_path(node);
}
return 1;
}
/* @param flag bit0= Pre-run: Only assess partition table.
*/
static
int iso_analyze_mips(IsoImage *image, IsoDataSource *src, int flag)
{
@ -4676,11 +4764,13 @@ int iso_analyze_mips(IsoImage *image, IsoDataSource *src, int flag)
sai->mips_vd_entries[idx]->name[8] = 0;
sai->mips_vd_entries[idx]->boot_block = iso_read_msb(upart + 8, 4);
sai->mips_vd_entries[idx]->boot_bytes = iso_read_msb(upart + 12, 4);
if (!(flag & 1)) {
ret = iso_tree_get_node_of_block(image, NULL,
sai->mips_vd_entries[idx]->boot_block / 4,
&node, NULL, 0);
if (ret > 0)
sai->mips_boot_file_paths[idx] = iso_tree_get_node_path(node);
}
sai->num_mips_boot_files++;
}
if (sai->num_mips_boot_files > 0)
@ -4689,6 +4779,8 @@ int iso_analyze_mips(IsoImage *image, IsoDataSource *src, int flag)
return ret;
}
/* @param flag bit0= Pre-run: Only assess partition table.
*/
static
int iso_analyze_mipsel(IsoImage *image, IsoDataSource *src, int flag)
{
@ -4716,8 +4808,10 @@ int iso_analyze_mipsel(IsoImage *image, IsoDataSource *src, int flag)
sai->mipsel_e_entry = iso_read_lsb(usad + 20, 4);
sai->mipsel_p_filesz = iso_read_lsb(usad + 24, 4) * 512;
sai->mipsel_seg_start = iso_read_lsb(usad + 28, 4);
ret = iso_tree_get_node_of_block(image, NULL, sai->mipsel_seg_start / 4,
&node, NULL, 0);
if(!(flag & 1)) {
ret = iso_tree_get_node_of_block(image, NULL,
sai->mipsel_seg_start / 4, &node,
NULL, 0);
if (ret > 0) {
sai->mipsel_boot_file_path = iso_tree_get_node_path(node);
file = (IsoFile *) node;
@ -4731,12 +4825,15 @@ int iso_analyze_mipsel(IsoImage *image, IsoDataSource *src, int flag)
free(sections);
}
}
}
/* DEC Boot Block for MIPS Little Endian */
sai->system_area_options = (2 << 2);
return 1;
}
/* @param flag bit0= Pre-run: Only assess partition table.
*/
static
int iso_analyze_sun(IsoImage *image, IsoDataSource *src, int flag)
{
@ -4809,13 +4906,15 @@ int iso_analyze_sun(IsoImage *image, IsoDataSource *src, int flag)
sai->sparc_grub2_core_size + 2047) / 2048;
if (last_core_block > 0)
last_core_block--;
if (last_core_block > 17 && last_core_block < sai->image_size) {
if (last_core_block > 17 && last_core_block < sai->image_size &&
!(flag & 1)) {
ret = iso_tree_get_node_of_block(image, NULL,
(uint32_t) last_core_block, &node,
NULL, 0);
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;
@ -4828,6 +4927,8 @@ int iso_analyze_sun(IsoImage *image, IsoDataSource *src, int flag)
return 1;
}
/* @param flag bit0= Pre-run: Only assess partition table.
*/
static
int iso_analyze_hppa(IsoImage *image, IsoDataSource *src, int flag)
{
@ -4869,6 +4970,7 @@ int iso_analyze_hppa(IsoImage *image, IsoDataSource *src, int flag)
sai->hppa_ramdisk_len = iso_read_msb(usad + 20, 4);
adrs[3] = sai->hppa_bootloader_adr = iso_read_msb(usad + 240, 4);
sai->hppa_bootloader_len = iso_read_msb(usad + 244, 4);
if(!(flag & 1)) {
for (i = 0; i < 4; i++) {
paths[i] = NULL;
ret = iso_tree_get_node_of_block(image, NULL, adrs[i] / 2048,
@ -4880,6 +4982,7 @@ int iso_analyze_hppa(IsoImage *image, IsoDataSource *src, int flag)
sai->hppa_kernel_64 = paths[1];
sai->hppa_ramdisk = paths[2];
sai->hppa_bootloader = paths[3];
}
if (sai->hppa_hdrversion == 5)
sai->hppa_ipl_entry = iso_read_msb(usad + 248, 4);
@ -4890,6 +4993,8 @@ int iso_analyze_hppa(IsoImage *image, IsoDataSource *src, int flag)
return 1;
}
/* @param flag bit0= Pre-run: Only assess partition table.
*/
static
int iso_analyze_alpha_boot(IsoImage *image, IsoDataSource *src, int flag)
{
@ -4914,6 +5019,7 @@ int iso_analyze_alpha_boot(IsoImage *image, IsoDataSource *src, int flag)
sai->alpha_boot_image = NULL;
sai->alpha_boot_image_size = (uint64_t) iso_read_lsb64(usad + 480);
sai->alpha_boot_image_adr = (uint64_t) iso_read_lsb64(usad + 488);
if (!(flag & 1)) {
ret = iso_tree_get_node_of_block(image, NULL,
(uint32_t) (sai->alpha_boot_image_adr / 4),
&node, NULL, 0);
@ -4930,10 +5036,11 @@ int iso_analyze_alpha_boot(IsoImage *image, IsoDataSource *src, int flag)
return 0;
}
sai->alpha_boot_image = iso_tree_get_node_path(node);
} else if (strncmp(sad, "Linux/Alpha aboot for ISO filesystem.", 37) != 0
|| sad[37] != 0) {
} else if (strncmp(sad, "Linux/Alpha aboot for ISO filesystem.", 37)
!= 0 || sad[37] != 0) {
return 0; /* Want to see either boot file or genisoimage string */
}
}
sai->system_area_options = (6 << 2);
return 1;
}
@ -5015,6 +5122,8 @@ int iso_impsysa_reduce_next_above(IsoImage *image, uint32_t block,
struct iso_file_section *sections = NULL;
sai = image->imported_sa_info;
if (sai == NULL)
return 0;
/* PVD, path table, root directory of active and of first session */
for (i = 0; i < sai->num_meta_struct_blocks; i++)
@ -5065,7 +5174,7 @@ int iso_impsysa_reduce_next_above(IsoImage *image, uint32_t block,
iso_impsysa_reduce_na(block, next_above, sai->image_size);
return ISO_SUCCESS;
return 1;
}
/* @param flag bit0= try to estimate the size if no path is found
@ -5264,9 +5373,13 @@ 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);
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",
sai->prep_part_start, sai->prep_part_size);
@ -5330,10 +5443,16 @@ 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);
if (sai->sparc_core_node_path == NULL)
free(path);
}
}
@ -5424,9 +5543,13 @@ 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);
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) {
sprintf(msg, "APM : N Info");
@ -5450,11 +5573,15 @@ 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);
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;
ex:
@ -5609,9 +5736,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);
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);
@ -5803,6 +5934,9 @@ ex:
return ret;
}
/* @param flag bit0= Pre-run: Only assess partition tables. Do not refer to
loaded tree or El Torito boot equipment.
*/
static
int iso_analyze_system_area(IsoImage *image, IsoDataSource *src,
struct iso_read_opts *opts, uint32_t image_size,
@ -5824,48 +5958,50 @@ int iso_analyze_system_area(IsoImage *image, IsoDataSource *src,
image->imported_sa_info->image_size = image_size;
image->imported_sa_info->pvd_block = opts->block + 16;
ret = iso_analyze_mbr(image, src, 0);
ret = iso_analyze_mbr(image, src, flag & 1);
if (ret < 0)
goto ex;
ret = iso_analyze_gpt(image, src, 0);
ret = iso_analyze_gpt(image, src, flag & 1);
if (ret < 0)
goto ex;
ret = iso_analyze_apm(image, src, 0);
ret = iso_analyze_apm(image, src, flag & 1);
if (ret < 0)
goto ex;
sao = image->imported_sa_info->system_area_options;
sa_type = (sao >> 2) & 0x3f;
sa_sub = (sao >> 10) & 0xf;
if (sa_type == 0 && !((sao & 3) || sa_sub == 1 || sa_sub == 2)) {
ret = iso_analyze_mips(image, src, 0);
ret = iso_analyze_mips(image, src, flag & 1);
if (ret < 0)
goto ex;
if (ret == 0) {
ret = iso_analyze_mipsel(image, src, 0);
ret = iso_analyze_mipsel(image, src, flag & 1);
if (ret < 0)
goto ex;
}
if (ret == 0) {
ret = iso_analyze_sun(image, src, 0);
ret = iso_analyze_sun(image, src, flag & 1);
if (ret < 0)
goto ex;
}
}
if (sa_type == 0 && !((sao & 3) || sa_sub == 1)) {
/* HP-PA PALO v5 can look like generic MBR */
ret = iso_analyze_hppa(image, src, 0);
ret = iso_analyze_hppa(image, src, flag & 1);
if (ret < 0)
goto ex;
/* DEC Alpha has checksum bytes where MBR has its magic number */
if (ret == 0) {
ret = iso_analyze_alpha_boot(image, src, 0);
ret = iso_analyze_alpha_boot(image, src, flag & 1);
if (ret < 0)
goto ex;
}
}
if (!(flag & 1)) {
ret = iso_record_meta_struct_blocks(image, src, 0);
if (ret < 0)
goto ex;
}
ret = ISO_SUCCESS;
ex:;
@ -6377,7 +6513,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;
@ -6391,6 +6527,7 @@ int iso_image_import(IsoImage *image, IsoDataSource *src,
int features_allocated = 0;
static char *tree_loaded_names[3]= {"ISO9660", "Joliet", "ISO9660:1999"};
int root_has_aaip = 0, rrip_version_1_10;
unsigned long img_size;
if (image == NULL || src == NULL || opts == NULL) {
return ISO_NULL_POINTER;
@ -6545,6 +6682,27 @@ int iso_image_import(IsoImage *image, IsoDataSource *src,
}
}
/* Pre-assessment of System Area because image->imported_sa_info with
assessed partitions is needed in create_boot_img_filesrc().
Nevertheless, some properties can only be determined later, when
other image properties have been assessed. So there will be another
run of iso_analyze_system_area() without flag bit0 when more of the
imported image is known.
*/
if (opts->load_system_area && image->system_area_data != NULL &&
!(opts->read_features & 4)) {
/* Preliminary assessment. Not complete because some aspects of the
filesystem have not been loaded yet.
*/
ret = iso_analyze_system_area(image, src, opts, data->nblocks, 1);
if (ret < 0) {
iso_msg_submit(-1, ISO_SYSAREA_PROBLEMS, 0,
"Problem encountered during inspection of System Area:");
iso_msg_submit(-1, ISO_SYSAREA_PROBLEMS, 0,
iso_error_to_msg(ret));
}
}
/* if old image has el-torito, add a new catalog */
if (data->eltorito) {
@ -6564,6 +6722,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];
@ -6667,23 +6826,44 @@ int iso_image_import(IsoImage *image, IsoDataSource *src,
/* warn about hidden images */
if (!(opts->read_features & 4)) {
img_size = iso_file_get_size((IsoFile *) node);
if (image->bootcat->bootimages[idx]->platform_id == 0xef) {
iso_msg_submit(image->id, ISO_ELTO_EFI_HIDDEN, 0,
"Found hidden El-Torito image for EFI.");
iso_msg_submit(image->id, ISO_GENERAL_NOTE, 0,
"EFI image start and size: %lu * 2048 , %lu * 512",
"EFI image start and load size: %lu * 2048 , %lu * 512",
(unsigned long int)
image->bootcat->bootimages[idx]->appended_start,
(unsigned long int)
image->bootcat->bootimages[idx]->load_size);
iso_msg_submit(image->id, ISO_GENERAL_NOTE, 0,
"Roughly estimated EFI image size: %lu bytes",
img_size);
} else {
iso_msg_submit(image->id, ISO_EL_TORITO_HIDDEN, 0,
"Found hidden El-Torito image. Its size could not "
"be figured out, so image modify or boot image "
"patching may lead to bad results.");
"Found hidden El-Torito image for Non-EFI platform.",
img_size);
iso_msg_submit(image->id, ISO_EL_TORITO_HIDDEN, 0,
"Roughly estimated image size: %lu bytes",
img_size);
iso_msg_submit(image->id, ISO_EL_TORITO_HIDDEN, 0,
"Image modification or boot image patching may lead to bad results.");
}
}
}
/* 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;
@ -6925,6 +7105,9 @@ int iso_image_import(IsoImage *image, IsoDataSource *src,
if (ret < 0)
goto import_revert;
/* Second run of iso_analyze_system_area() after El Torito equipment and
file tree have been assessed
*/
if (opts->load_system_area && image->system_area_data != NULL &&
!(opts->read_features & 4)) {
ret = iso_analyze_system_area(image, src, opts, data->nblocks, 0);

View File

@ -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 <stdlib.h>
#include <string.h>
@ -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);

View File

@ -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;

View File

@ -251,14 +251,33 @@ int create_tree(Ecma119Image *t, IsoNode *iso, Iso1999Node **tree, int pathlen)
}
break;
case LIBISO_SYMLINK:
case LIBISO_SPECIAL:
{
t->iso1999_symlinks++;
if (t->iso1999_symlinks == 1) {
char *ipath = iso_tree_get_node_path(iso);
ret = iso_msg_submit(t->image->id, ISO_FILE_IGNORED, 0,
"Can't add %s to ISO 9660:1999 tree. This kind of files "
"can only be added to a Rock Ridget tree. Skipping.",
"Cannot add symbolic link %s to ISO 9660:1999 tree. Skipping.",
ipath);
free(ipath);
} else {
if (t->iso1999_symlinks == 2)
iso_msg_submit(t->image->id, ISO_FILE_IGNORED, 0,
"More symbolic links were omitted from ISO 9660:1999 tree.");
ret = 0;
}
break;
case LIBISO_SPECIAL:
t->iso1999_specials++;
if (t->iso1999_specials == 1) {
char *ipath = iso_tree_get_node_path(iso);
ret = iso_msg_submit(t->image->id, ISO_FILE_IGNORED, 0,
"Cannot add special file %s to ISO 9660:1999 tree. Skipping.",
ipath);
free(ipath);
} else {
if (t->iso1999_specials == 2)
iso_msg_submit(t->image->id, ISO_FILE_IGNORED, 0,
"More special files were omitted from ISO 9660:1999 tree.");
ret = 0;
}
break;
default:

View File

@ -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
@ -14,6 +14,8 @@
/* Important: If you add a public API function then add its name to file
libisofs/libisofs.ver
in the node LIBISOFS6_Major.Minor.Micro with the numbers of
the next release version.
*/
#ifdef __cplusplus
@ -94,7 +96,7 @@ extern "C" {
*/
#define iso_lib_header_version_major 1
#define iso_lib_header_version_minor 5
#define iso_lib_header_version_micro 6
#define iso_lib_header_version_micro 7
/**
* Get version of the libisofs library at runtime.
@ -249,7 +251,7 @@ enum IsoNodeType {
#define ISO_NODE(n) ((IsoNode*)n)
/**
* File section in an old image.
* File section in an imported or emerging image.
*
* @since 0.6.8
*/
@ -374,7 +376,7 @@ enum iso_replace_mode {
};
/**
* Options for image written.
* Options for image writing.
* @see iso_write_opts_new()
* @since 0.6.2
*/
@ -2196,7 +2198,10 @@ int iso_write_opts_set_fifo_size(IsoWriteOpts *opts, size_t fifo_size);
* @param opts
* The option set to be manipulated.
* @param data
* Either NULL or 32 kB of data. Do not submit less bytes !
* Either NULL or 32768 bytes of data. Do not submit less bytes !
* NULL means that the possibly imported System Area content of the
* possibly imported ISO image is to be re-used unchanged.
* Submit 32 KiB of 0-bytes to surely get an empty System Area written.
* @param options
* Can cause manipulations of submitted data before they get written:
* bit0= Only with System area type 0 = MBR
@ -2292,7 +2297,7 @@ int iso_write_opts_set_fifo_size(IsoWriteOpts *opts, size_t fifo_size);
* written.
* @param flag
* bit0 = invalidate any attached system area data. Same as data == NULL
* (This re-activates eventually loaded image System Area data.
* (This re-activates possibly loaded image System Area data.
* To erase those, submit 32 kB of zeros without flag bit0.)
* bit1 = keep data unaltered
* bit2 = keep options unaltered
@ -3821,9 +3826,13 @@ int iso_image_get_pvd_times(IsoImage *image,
* The absolute path of a IsoFile to be used as default boot image or
* --interval:appended_partition_$number[_start_$start_size_$size]:...
* if type is ELTORITO_NO_EMUL. $number gives the partition number.
* If _start_$start_size_$size is present, then it overrides the 2 KiB
* start block of the partition and the partition size counted in
* blocks of 512 bytes.
* If no partitition with the given $number was set by functions like
* iso_write_opts_set_partition_img() and if the optional image_path part
* "_start_$start_size_$size" is present, then $start gets read as 2 KiB
* start block of the interval and $size as number of blocks of 512 bytes.
* If this range of block addresses is below the address set by
* iso_write_opts_set_ms_block(), then that range gets marked as boot
* image. I.e. an old appended partition can be marked as boot image.
* @param type
* The boot media type. This can be one of 3 types:
* - ELTORITO_FLOPPY_EMUL.
@ -4459,8 +4468,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.", \
@ -4526,8 +4535,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 \
\
@ -4547,8 +4556,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 \
\
@ -4558,8 +4567,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", \
@ -4569,8 +4579,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", \
@ -4594,8 +4605,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 \
\
@ -4607,7 +4618,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", \
@ -4623,8 +4636,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
@ -4692,12 +4705,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:", \
@ -8559,15 +8573,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
@ -8587,7 +8602,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

View File

@ -15,6 +15,7 @@
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include "rockridge.h"
#include "node.h"

View File

@ -41,6 +41,9 @@
#include "ecma119.h"
/* For ssize_t */
#include <unistd.h>
#define SUSP_SIG(entry, a, b) ((entry->sig[0] == a) && (entry->sig[1] == b))

View File

@ -22,6 +22,7 @@
#include <string.h>
#include <limits.h>
#include <stdio.h>
#include <unistd.h>
#ifndef PATH_MAX

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2008 Vreixo Formoso
* Copyright (c) 2010 - 2022 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
@ -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;
@ -1735,11 +1738,13 @@ static int iso_write_gpt(Ecma119Image *t, uint32_t img_blocks, uint8_t *buf)
0x87, 0xc0, 0x68, 0xb6, 0xb7, 0x26, 0x99, 0xc7
};
uint8_t *wpt;
uint32_t p_arr_crc = 0;
uint64_t start_lba, end_lba, goal, part_end, next_end, backup_end_lba;
uint64_t eff_gpt_flags;
int ret, i, gap_counter = 0, up_to;
int ret, i, gap_counter = 0, up_to, slot, j, to_insert;
struct iso_gpt_partition_request *req;
char msg[81];
uint8_t gpt_name[72];
static uint8_t zero_uuid[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
static uint8_t *type_guid;
@ -1825,6 +1830,8 @@ static int iso_write_gpt(Ecma119Image *t, uint32_t img_blocks, uint8_t *buf)
return ISO_BOOT_TOO_MANY_GPT;
/* Write the GPT entries to buf */
wpt= buf + 512 * t->gpt_part_start;
slot= 1;
for (i = 0; i < t->gpt_req_count; i++) {
req = t->gpt_req[i];
start_lba = req->start_block;
@ -1835,11 +1842,38 @@ static int iso_write_gpt(Ecma119Image *t, uint32_t img_blocks, uint8_t *buf)
if (end_lba > backup_end_lba)
end_lba = backup_end_lba;
end_lba = end_lba - 1;
iso_write_gpt_entry(t, buf + 512 * t->gpt_part_start + 128 * i,
req->type_guid, req->partition_guid,
start_lba, end_lba, req->flags, req->name);
if (req->desired_slot > 0) {
to_insert= req->desired_slot - slot;
if (to_insert > 0 &&
slot - 1 + to_insert + t->gpt_req_count - i <=
(int) t->gpt_max_entries) {
/* There is need and room to insert empty partition entries */
for (j = 0; j < to_insert; j++) {
memset(wpt, 0, 128);
wpt+= 128;
slot++;
}
for (; i < (int) t->gpt_max_entries; i++)
if (!t->wthread_is_running) {
sprintf(msg,
"Inserted %d empty GPT slots before appended partition %d",
to_insert, req->desired_slot);
iso_msgs_submit(0, msg, 0, "DEBUG", 0);
}
} else if (slot != req->desired_slot) {
if (!t->wthread_is_running) {
sprintf(msg,
"Appended GPT partition becomes number %d instead of desired %d",
i + 1, req->desired_slot);
iso_msgs_submit(0, msg, 0, "NOTE", 0);
}
}
}
iso_write_gpt_entry(t, wpt, req->type_guid, req->partition_guid,
start_lba, end_lba, req->flags, req->name);
wpt+= 128;
slot++;
}
for (i= slot - 1; i < (int) t->gpt_max_entries; i++)
memset(buf + 512 * t->gpt_part_start + 128 * i, 0, 128);
p_arr_crc = iso_crc32_gpt((unsigned char *) buf + 512 * t->gpt_part_start,
@ -2511,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;
@ -2530,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;
@ -2548,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;
@ -2719,6 +2774,7 @@ int assess_appended_gpt(Ecma119Image *t, int flag)
};
static uint8_t zero_uuid[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int i, ret, do_apm = 0, do_gpt = 0, index, already_in_gpt = 0;
int first_partition, last_partition;
uint8_t gpt_name[72], *type_uuid;
char apm_type[33];
@ -2738,7 +2794,8 @@ int assess_appended_gpt(Ecma119Image *t, int flag)
return 2;
/* Represent appended partitions */
for (i = 0; i <= 3; i++) {
iso_tell_max_part_range(t->opts, &first_partition, &last_partition, 0);
for (i = first_partition - 1; i < last_partition; i++) {
if (t->opts->appended_partitions[i] == NULL)
continue;
if (do_apm) {
@ -2779,6 +2836,9 @@ int assess_appended_gpt(Ecma119Image *t, int flag)
(uint64_t) 0, gpt_name);
if (ret < 0)
return ret;
t->gpt_req[t->gpt_req_count - 1]->desired_slot = i + 1;
} else if(do_gpt) {
t->gpt_req[index]->desired_slot = i + 1;
}
}
return ISO_SUCCESS;

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2008 Vreixo Formoso
* Copyright (c) 2012 - 2019 Thomas Schmitt
* Copyright (c) 2012 - 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
@ -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[].
@ -251,6 +264,21 @@ struct iso_gpt_partition_request {
bit0= this is an automatically placed filler partition
*/
uint32_t req_status;
/* Desired partition number in emerging GPT: first = 1, no desire = 0
GPT partitions get sorted by start LBA. Gaps of uncovered blocks get
filled. If the resulting sequence positions the partition at a lower
slot than desired, then empty slots get inserted to match the desire.
If the sequence positions the partition at a higher slot, then a mere
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[].

View File

@ -1294,6 +1294,8 @@ ex:;
}
/* Note: No reference is taken to the found node.
Warning: Do not submit next_above uninitialized.
Submit NULL if next_above is not of interest.
@param flag bit0= recursion
*/
int iso_tree_get_node_of_block(IsoImage *image, IsoDir *dir, uint32_t block,