Coordinated appending of partition images with situations other than

isohybrid MBR production or partition offset.
This commit is contained in:
Thomas Schmitt 2010-10-19 10:14:26 +02:00
parent b58d1e28ef
commit 1f486fd78b
4 changed files with 33 additions and 7 deletions

View File

@ -1615,6 +1615,11 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *opts, Ecma119Image **img)
} else {
system_area_options = opts->system_area_options & 0xfc;
}
if ((system_area_options & 0xfc) != 0)
for (i = 0; i < 4; i++)
if (opts->appended_partitions[i] != NULL)
return ISO_NON_MBR_SYS_AREA;
target->system_area_data = NULL;
if (system_area != NULL) {
target->system_area_data = calloc(32768, 1);

View File

@ -6359,6 +6359,10 @@ int iso_md5_match(char first_md5[16], char second_md5[16]);
/** Cannot open data file for appended partition (FAILURE, HIGH, -370) */
#define ISO_BAD_PARTITION_FILE 0xE830FE8E
/** May not combine appended partition with non-MBR system area
(FAILURE, HIGH, -371) */
#define ISO_NON_MBR_SYS_AREA 0xE830FE8D
/* Internal developer note:
Place new error codes directly above this comment.

View File

@ -357,6 +357,8 @@ const char *iso_error_to_msg(int errcode)
return "Partition number out of range";
case ISO_BAD_PARTITION_FILE:
return "Cannot open data file for appended partition";
case ISO_NON_MBR_SYS_AREA:
return "May not combine appended partition with non-MBR system area";
default:
return "Unknown error";
}

View File

@ -436,8 +436,9 @@ static int make_mips_volume_header(Ecma119Image *t, uint8_t *buf, int flag)
doc/boot_sectors.txt section "MIPS Little Endian" which was derived
by Thomas Schmitt from
cdrkit-1.1.10/genisoimage/boot-mipsel.c by Steve McIntyre which is based
on work of Florian Lohoff and Thiemo Seufer, and from <elf.h> by Free
Software Foundation, Inc.
on work of Florian Lohoff and Thiemo Seufer,
and from <elf.h> by Free Software Foundation, Inc.
Both functions are entirely under copyright (C) 2010 Thomas Schmitt.
*/
@ -566,7 +567,7 @@ static int make_mipsel_boot_block(Ecma119Image *t, uint8_t *buf, int flag)
int iso_write_system_area(Ecma119Image *t, uint8_t *buf)
{
int ret, int_img_blocks, sa_type, i;
int ret, int_img_blocks, sa_type, i, will_append = 0;
uint32_t img_blocks;
if ((t == NULL) || (buf == NULL)) {
@ -577,6 +578,12 @@ int iso_write_system_area(Ecma119Image *t, uint8_t *buf)
memset(buf, 0, 16 * BLOCK_SIZE);
sa_type = (t->system_area_options >> 2) & 0x3f;
for (i = 0; i < 4; i++)
if (t->appended_partitions[i] != NULL) {
will_append = 1;
break;
}
img_blocks = t->curblock;
if (t->system_area_data != NULL) {
/* Write more or less opaque boot image */
@ -627,12 +634,20 @@ int iso_write_system_area(Ecma119Image *t, uint8_t *buf)
ret = make_mipsel_boot_block(t, buf, 0);
if (ret != ISO_SUCCESS)
return ret;
} else if(t->partition_offset > 0 && sa_type == 0) {
} else if ((t->partition_offset > 0 || will_append) && sa_type == 0) {
/* Write a simple partition table. */
ret = make_grub_msdos_label(img_blocks, t->partition_secs_per_head,
t->partition_heads_per_cyl, buf, 2);
if (ret != ISO_SUCCESS) /* error should never happen */
return ISO_ASSERT_FAILURE;
if (t->partition_offset == 0) {
/* Re-write partion entry 1 : start at 0, type Linux */
ret = write_mbr_partition_entry(1, 0x83, 0, img_blocks,
t->partition_secs_per_head, t->partition_heads_per_cyl,
buf, 0);
if (ret < 0)
return ret;
}
}
if (t->partition_offset > 0 && sa_type == 0) {