Avoided automatic MBR partition type 0x00 with iso_write_opts_set_part_like_isohybrid() if partitions do not overlap
This commit is contained in:
parent
011e2e85e6
commit
ad55ec78e4
@ -639,16 +639,17 @@ static uint32_t iso_make_mbr_id(Ecma119Image *t, int flag)
|
|||||||
* do not insert APM mockup head
|
* do not insert APM mockup head
|
||||||
* do not treat bytes before code as isohybrid MBR
|
* do not treat bytes before code as isohybrid MBR
|
||||||
* do not create MBR id
|
* do not create MBR id
|
||||||
|
* bit3= replace fs_type 0x00 by 0x17 if appropriate
|
||||||
*/
|
*/
|
||||||
int make_isolinux_mbr(uint32_t *img_blocks, Ecma119Image *t,
|
int make_isolinux_mbr(uint32_t *img_blocks, Ecma119Image *t,
|
||||||
int part_offset, int part_number, int fs_type,
|
int part_offset, int part_number, int fs_type,
|
||||||
uint8_t *buf, int flag)
|
uint8_t *buf, int flag)
|
||||||
{
|
{
|
||||||
uint32_t id, part, nominal_part_size;
|
uint32_t id, part, nominal_part_size, mbr_part_start;
|
||||||
off_t hd_img_blocks, hd_boot_lba;
|
off_t hd_img_blocks, hd_boot_lba;
|
||||||
char *wpt;
|
char *wpt, *fs_type_wpt = NULL;
|
||||||
uint32_t boot_lba;
|
uint32_t boot_lba;
|
||||||
int head_count, sector_count, ret;
|
int head_count, sector_count, ret, part_is_in_img = 0;
|
||||||
int gpt_count = 0, gpt_idx[128], apm_count = 0, gpt_cursor, i;
|
int gpt_count = 0, gpt_idx[128], apm_count = 0, gpt_cursor, i;
|
||||||
|
|
||||||
if (t->bootsrc[0] == NULL)
|
if (t->bootsrc[0] == NULL)
|
||||||
@ -730,6 +731,13 @@ int make_isolinux_mbr(uint32_t *img_blocks, Ecma119Image *t,
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Will this hit the part_number partition ? */
|
||||||
|
mbr_part_start = iso_read_lsb((uint8_t *) (wpt + 8), 4);
|
||||||
|
if (mbr_part_start > 0 &&
|
||||||
|
mbr_part_start < hd_img_blocks + part_offset)
|
||||||
|
part_is_in_img = 1;
|
||||||
|
|
||||||
wpt+= 16;
|
wpt+= 16;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -745,6 +753,7 @@ int make_isolinux_mbr(uint32_t *img_blocks, Ecma119Image *t,
|
|||||||
else
|
else
|
||||||
lsb_to_buf(&wpt, 0x80, 8, 0);
|
lsb_to_buf(&wpt, 0x80, 8, 0);
|
||||||
lba512chs_to_buf(&wpt, part_offset, head_count, sector_count);
|
lba512chs_to_buf(&wpt, part_offset, head_count, sector_count);
|
||||||
|
fs_type_wpt = wpt;
|
||||||
lsb_to_buf(&wpt, fs_type, 8, 0);
|
lsb_to_buf(&wpt, fs_type, 8, 0);
|
||||||
lba512chs_to_buf(&wpt, hd_img_blocks - 1, head_count, sector_count);
|
lba512chs_to_buf(&wpt, hd_img_blocks - 1, head_count, sector_count);
|
||||||
lsb_to_buf(&wpt, part_offset, 32, 0);
|
lsb_to_buf(&wpt, part_offset, 32, 0);
|
||||||
@ -759,6 +768,17 @@ int make_isolinux_mbr(uint32_t *img_blocks, Ecma119Image *t,
|
|||||||
*/
|
*/
|
||||||
lsb_to_buf(&wpt, 0xaa55, 16, 0);
|
lsb_to_buf(&wpt, 0xaa55, 16, 0);
|
||||||
|
|
||||||
|
/* Check whether automatically determined fs_type 0x00 can become 0x17 */
|
||||||
|
if ((flag & 8) && fs_type_wpt != NULL && fs_type == 0x00 &&
|
||||||
|
t->opts->iso_mbr_part_type != fs_type && !part_is_in_img) {
|
||||||
|
if (t->opts->iso_mbr_part_type >= 0 &&
|
||||||
|
t->opts->iso_mbr_part_type <= 255) {
|
||||||
|
lsb_to_buf(&fs_type_wpt, t->opts->iso_mbr_part_type, 8, 0);
|
||||||
|
} else {
|
||||||
|
lsb_to_buf(&fs_type_wpt, 0x17, 8, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2092,10 +2092,12 @@ int iso_write_system_area(Ecma119Image *t, uint8_t *buf, int flag)
|
|||||||
return ISO_ISOLINUX_CANT_PATCH;
|
return ISO_ISOLINUX_CANT_PATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gpt_count > 0 || apm_count > 0)
|
if (gpt_count > 0 || apm_count > 0) {
|
||||||
|
/* Decision can be revoked in make_isolinux_mbr if !do_isohybrid */
|
||||||
part_type = 0x00;
|
part_type = 0x00;
|
||||||
else
|
} else {
|
||||||
part_type = 0x17;
|
part_type = 0x17;
|
||||||
|
}
|
||||||
/* By tradition, real isohybrid insists in 0x00 if GPT or APM */
|
/* By tradition, real isohybrid insists in 0x00 if GPT or APM */
|
||||||
if (part_type != 0x00 || !do_isohybrid)
|
if (part_type != 0x00 || !do_isohybrid)
|
||||||
if (t->opts->iso_mbr_part_type >= 0 &&
|
if (t->opts->iso_mbr_part_type >= 0 &&
|
||||||
@ -2109,13 +2111,16 @@ int iso_write_system_area(Ecma119Image *t, uint8_t *buf, int flag)
|
|||||||
no_boot_mbr = 2;
|
no_boot_mbr = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* >>> ??? Why is partition_offset 0 here ?
|
/* ??? Why was partition_offset 0 here ?
|
||||||
It gets adjusted later by iso_offset_partition_start()
|
It gets adjusted later by iso_offset_partition_start()
|
||||||
Would it harm to give the real offset here ?
|
Does it harm to give the real offset here ?
|
||||||
*/;
|
Now this is really needed for checking whether partitions
|
||||||
|
are inside the ISO 9660 partition if !do_isohybrid
|
||||||
ret = make_isolinux_mbr(&img_blocks, t, 0, 1, part_type, buf,
|
*/
|
||||||
1 | no_boot_mbr | ((!do_isohybrid) << 2));
|
ret = make_isolinux_mbr(&img_blocks, t, t->opts->partition_offset * 4,
|
||||||
|
1, part_type, buf,
|
||||||
|
1 | no_boot_mbr | ((!do_isohybrid) << 2) |
|
||||||
|
((!do_isohybrid) << 3));
|
||||||
if (ret != 1)
|
if (ret != 1)
|
||||||
return ret;
|
return ret;
|
||||||
} else if (sa_type == 1) {
|
} else if (sa_type == 1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user