Enabled GPT type GUIDs with -append_partition, -boot_image any iso_mbr_part_type=, and -as mkisofs -iso_mbr_part_type

This commit is contained in:
2019-02-18 13:19:32 +01:00
parent caf38e81ae
commit fc71cec8f7
17 changed files with 469 additions and 230 deletions

View File

@ -1,7 +1,7 @@
/* xorriso - creates, loads, manipulates and burns ISO 9660 filesystem images.
Copyright 2007-2017 Thomas Schmitt, <scdbackup@gmx.net>
Copyright 2007-2019 Thomas Schmitt, <scdbackup@gmx.net>
Provided under GPL version 2 or later.
@ -295,9 +295,10 @@ ex:;
int Xorriso_option_append_partition(struct XorrisO *xorriso, char *partno_text,
char *type_text, char *image_path, int flag)
{
int partno = 0, type_code= -1, i;
int partno = 0, type_code= -1, i, guid_valid= 0, ret;
unsigned int unum;
char *tpt;
uint8_t guid[16];
static char *part_type_names[] = {"FAT12", "FAT16", "Linux", "", NULL};
static int part_type_codes[] = { 0x01, 0x06, 0x83, 0x00};
@ -314,6 +315,12 @@ int Xorriso_option_append_partition(struct XorrisO *xorriso, char *partno_text,
break;
if(part_type_names[i] != NULL)
type_code= part_type_codes[i];
if(type_code < 0) {
ret= Xorriso_parse_type_guid(xorriso, type_text, guid, &type_code, 0);
if(ret > 0)
guid_valid= 1;
}
if(type_code < 0) {
tpt= type_text;
if(strncmp(tpt, "0x", 2) == 0)
@ -325,7 +332,7 @@ int Xorriso_option_append_partition(struct XorrisO *xorriso, char *partno_text,
if(unum > 0xff) {
bad_type:;
sprintf(xorriso->info_text,
"-append_partition: Partition type '%s' is out of range (0x00...0xff)",
"-append_partition: Partition type '%s' is out of range (0x00...0xff or GUID)",
type_text);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
@ -341,6 +348,12 @@ bad_type:;
return(-1);
}
xorriso->appended_part_types[partno - 1]= type_code;
if(guid_valid) {
memcpy(xorriso->appended_part_type_guids[partno - 1], guid, 16);
xorriso->appended_part_gpt_flags[partno - 1]|= 1;
} else {
xorriso->appended_part_gpt_flags[partno - 1]&= ~1;
}
return(1);
}
@ -683,7 +696,7 @@ int Xorriso_option_boot_image(struct XorrisO *xorriso, char *form,
char *treatment, int flag)
{
int was_ok= 1, ret, isolinux_grub= 0, count, bin_count, parm_len;
int palohdrversion;
int palohdrversion, type_code;
unsigned int u;
char *formpt, *treatpt, *eff_path= NULL, *eqpt, parm[20];
uint8_t sn[8];
@ -1097,6 +1110,7 @@ treatment_patch:;
} else if(strncmp(treatpt, "iso_mbr_part_type=", 18) == 0) {
ret= 256;
xorriso->iso_mbr_part_flag&= ~1;
if(strncmp(treatpt + 18, "default", 2) == 0) {
ret= -1;
} else if(strncmp(treatpt + 18, "0x", 2) == 0) {
@ -1104,8 +1118,16 @@ treatment_patch:;
sscanf(treatpt + 20, "%x", &u);
ret= u;
} else {
sscanf(treatpt + 18, "%d", &ret);
ret= Xorriso_parse_type_guid(xorriso, treatpt + 18,
xorriso->iso_gpt_type_guid, &type_code, 0);
if(ret > 0) {
ret= type_code;
xorriso->iso_mbr_part_flag|= 1;
} else {
sscanf(treatpt + 18, "%d", &ret);
}
}
if(ret < -1 || ret > 0xff) {
sprintf(xorriso->info_text,
"-boot_image %s : iso_mbr_part_type='%s' wrong (\"default\", 0 ... 255, 0x00 ... 0xff)",