New report line with iso_image_report_el_torito() "El Torito hdsiz/512:"

This commit is contained in:
Thomas Schmitt 2018-11-05 14:06:09 +01:00
parent 241b9ea832
commit 01415ae208
3 changed files with 58 additions and 4 deletions

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2007 Vreixo Formoso * Copyright (c) 2007 Vreixo Formoso
* Copyright (c) 2010 - 2014 Thomas Schmitt * Copyright (c) 2010 - 2018 Thomas Schmitt
* *
* This file is part of the libisofs project; you can redistribute it and/or * 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 * modify it under the terms of the GNU General Public License version 2
@ -81,8 +81,15 @@ struct el_torito_boot_image {
* bit8= Mention in isohybrid Apple partition map * bit8= Mention in isohybrid Apple partition map
*/ */
unsigned int isolinux_options; unsigned int isolinux_options;
unsigned char type; /**< The type of image */
unsigned char type; /**< The type of image :
0=no emulation , 1=fd 1.2 MB , 2=fd 1.4 MB
3=fd 3.8 MB , 4=hdd (size in partition table)
*/
unsigned char partition_type; /**< type of partition for HD-emul images */ unsigned char partition_type; /**< type of partition for HD-emul images */
uint32_t emul_hdd_size; /* 512-bytes LBA after highest partition end from
HD-emul partition table
*/
uint16_t load_seg; /**< Load segment for the initial boot image. */ uint16_t load_seg; /**< Load segment for the initial boot image. */
uint16_t load_size; /**< Number of sectors to load. */ uint16_t load_size; /**< Number of sectors to load. */
int load_size_full; /* 1= override load_size by image size */ int load_size_full; /* 1= override load_size by image size */

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2007 Vreixo Formoso * Copyright (c) 2007 Vreixo Formoso
* Copyright (c) 2009 - 2016 Thomas Schmitt * Copyright (c) 2009 - 2018 Thomas Schmitt
* *
* This file is part of the libisofs project; you can redistribute it and/or * 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 * modify it under the terms of the GNU General Public License version 2
@ -4946,7 +4946,7 @@ void iso_impsysa_report_blockpath(IsoImage *image,
return; return;
size = next_above - start_block; size = next_above - start_block;
/* Replace in msg "path" by "blks", report number in bytes */ /* Replace in msg "path" by "blks", report number in blocks of 2048 */
cpt = strstr(msg, "path"); cpt = strstr(msg, "path");
if (cpt == NULL) if (cpt == NULL)
return; return;
@ -5352,6 +5352,35 @@ int iso_report_help(char **doc, char ***result, int *line_count, int flag)
return ISO_SUCCESS; return ISO_SUCCESS;
} }
static
uint32_t iso_impsysa_hdd_emul_size(IsoImage *image, IsoDataSource *src,
uint32_t lba, int flag)
{
uint32_t max_size = 0, start_lba, num_blocks;
int i, ret;
uint8_t *buffer = NULL;
/* Obtain first block of image */
LIBISO_ALLOC_MEM(buffer, uint8_t, 2048);
ret = src->read_block(src, lba, buffer);
if (ret < 0)
goto ex;
/* Check for magic number of MBR */
if (buffer[510] != 0x55 || buffer[511] != 0xaa)
goto ex;
for (i = 0; i < 4; i++) {
start_lba = iso_read_lsb(buffer + 454 + 16 * i, 4);
num_blocks = iso_read_lsb(buffer + 458 + 16 * i, 4);
if (start_lba + num_blocks > max_size)
max_size = start_lba + num_blocks;
}
ex:;
LIBISO_FREE_MEM(buffer);
return max_size;
}
static static
int iso_eltorito_report(IsoImage *image, struct iso_impsysa_result *target, int iso_eltorito_report(IsoImage *image, struct iso_impsysa_result *target,
int flag) int flag)
@ -5428,6 +5457,11 @@ int iso_eltorito_report(IsoImage *image, struct iso_impsysa_result *target,
if (lba_mem[i] != 0xffffffff) { if (lba_mem[i] != 0xffffffff) {
sprintf(msg, "El Torito img path : %3d ", i + 1); sprintf(msg, "El Torito img path : %3d ", i + 1);
iso_impsysa_report_blockpath(image, target, msg, lba_mem[i], 1); iso_impsysa_report_blockpath(image, target, msg, lba_mem[i], 1);
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);
iso_impsysa_line(target, msg);
}
} }
sprintf(msg, "El Torito img opts : %3d ", i + 1); sprintf(msg, "El Torito img opts : %3d ", i + 1);
if (img->seems_boot_info_table) if (img->seems_boot_info_table)
@ -5886,6 +5920,13 @@ int iso_image_import(IsoImage *image, IsoDataSource *src,
memcpy(boot_image->selection_crit, data->selection_crits, 20); memcpy(boot_image->selection_crit, data->selection_crits, 20);
boot_image->appended_idx = -1; boot_image->appended_idx = -1;
boot_image->appended_start = data->bootblocks[idx]; boot_image->appended_start = data->bootblocks[idx];
if (boot_image->type == 4) {
boot_image->emul_hdd_size = iso_impsysa_hdd_emul_size(
image, src,
data->bootblocks[idx], 0);
} else {
boot_image->emul_hdd_size = 0;
}
catalog->bootimages[catalog->num_bootimages] = boot_image; catalog->bootimages[catalog->num_bootimages] = boot_image;
boot_image = NULL; boot_image = NULL;

View File

@ -4440,6 +4440,12 @@ int iso_image_report_system_area(IsoImage *image,
" The boot image is supposed to end before the start block of any", \ " The boot image is supposed to end before the start block of any", \
" other entity of the ISO filesystem.", \ " other entity of the ISO filesystem.", \
" (This line is not reported if no limiting entity is found.)", \ " (This line is not reported if no limiting entity is found.)", \
" El Torito hdsiz/512: X decimal", \
" gives with a boot image of emulation type \"hd\" the lowest block", \
" number which is above any partition end in the boot image's MBR", \
" partition table. This can be considered the claimed size of the", \
" emulated hard disk given in blocks of 512 bytes.", \
" (This line is not reported if no partition is found in the image.)", \
"" ""
/** /**