Bug fix: -boot_image and -append_partition were not perceived as image manipulation which makes production of an ISO image worthwhile. Thanks Cameron Seader.

This commit is contained in:
Thomas Schmitt 2023-08-06 15:24:28 +02:00
parent 1a44cbda91
commit f3af549e92
2 changed files with 88 additions and 6 deletions

View File

@ -295,7 +295,8 @@ 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, guid_valid= 0, ret;
int partno = 0, type_code= -1, i, guid_valid= 0, ret, set_changed= 0;
int disable= 0;
unsigned int unum;
char *tpt;
uint8_t guid[16];
@ -340,20 +341,44 @@ bad_type:;
type_code= unum;
}
if(xorriso->appended_partitions[partno - 1] != NULL)
disable= (image_path[0] == 0);
set_changed= 1;
if(xorriso->appended_partitions[partno - 1] != NULL) {
if(strcmp(xorriso->appended_partitions[partno - 1], image_path) == 0)
set_changed= 0;
free(xorriso->appended_partitions[partno - 1]);
xorriso->appended_partitions[partno - 1]= NULL;
} else {
if(disable)
set_changed= 0;
}
if(disable)
goto work_done;
xorriso->appended_partitions[partno - 1]= strdup(image_path);
if(xorriso->appended_partitions[partno - 1] == NULL) {
Xorriso_no_malloc_memory(xorriso, NULL, 0);
return(-1);
}
if(xorriso->appended_part_types[partno - 1] != type_code)
set_changed= 1;
xorriso->appended_part_types[partno - 1]= type_code;
if(guid_valid) {
if(xorriso->appended_part_gpt_flags[partno - 1] & 1) {
if(memcmp(xorriso->appended_part_type_guids[partno - 1], guid, 16) != 0)
set_changed= 1;
} else {
set_changed= 1;
}
memcpy(xorriso->appended_part_type_guids[partno - 1], guid, 16);
xorriso->appended_part_gpt_flags[partno - 1]|= 1;
} else {
if(xorriso->appended_part_gpt_flags[partno - 1] & 1)
set_changed= 1;
xorriso->appended_part_gpt_flags[partno - 1]&= ~1;
}
work_done:;
if(set_changed)
Xorriso_set_change_pending(xorriso, 1);
return(1);
}
@ -715,7 +740,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, type_code;
int palohdrversion, type_code, is_change= 0;
unsigned int u;
char *formpt, *treatpt, *eff_path= NULL, *eqpt, parm[20];
uint8_t sn[8];
@ -745,6 +770,7 @@ cannot_keep_or_patch:;
xorriso->patch_isolinux_image= (xorriso->patch_isolinux_image & ~3) | 0;
xorriso->boot_image_bin_path[0]= 0;
xorriso->patch_system_area= 0;
is_change= 1;
} else if(strcmp(treatpt, "patch")==0) {
treatment_patch:;
@ -760,6 +786,7 @@ treatment_patch:;
xorriso->patch_system_area= 2;
else
xorriso->patch_system_area= 0;
is_change= 1;
} else if(strcmp(treatpt, "replay")==0) {
ret= Xorriso_report_system_area(xorriso, "cmd", 2);
@ -778,6 +805,7 @@ treatment_patch:;
if(ret <= 0)
goto ex;
}
is_change= 1;
} else if(strcmp(treatpt, "next") == 0) {
ret= Xorriso_attach_boot_image(xorriso, 0);
@ -804,18 +832,22 @@ treatment_patch:;
} else if(strcmp(treatpt, "cat_path=") == 0) {
xorriso->boot_image_cat_path[0] = 0;
is_change= 1;
} else if(strncmp(treatpt, "cat_path=", 9) == 0) {
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, treatpt + 9,
xorriso->boot_image_cat_path, 2);
if(ret <= 0)
goto ex;
is_change= 1;
} else if(strncmp(treatpt, "cat_hidden=", 11) == 0) {
ret= Xorriso__hide_mode(treatpt + 11, 0);
if(ret >= 0)
if(ret >= 0) {
is_change= 1;
xorriso->boot_image_cat_hidden= ret;
else
} else {
was_ok= 0;
}
} else if(strncmp(treatpt, "dir=", 4) == 0) {
if(strcmp(formpt, "isolinux")==0) {
@ -849,6 +881,7 @@ treatment_patch:;
xorriso->keep_boot_image= 0;
xorriso->patch_isolinux_image= (xorriso->patch_isolinux_image & ~3) | 1;
strcpy(xorriso->boot_image_bin_form, formpt);
is_change= 1;
{ret= 1; goto ex;}
} else if(strcmp(formpt, "grub") == 0) {
@ -857,6 +890,7 @@ treatment_patch:;
was_ok= 0;
strcpy(xorriso->boot_image_bin_form, formpt);
is_change= 1;
} else
was_ok= 0;
@ -864,6 +898,7 @@ treatment_patch:;
} else if(strcmp(treatpt, "bin_path=") == 0) {
xorriso->boot_image_bin_path[0] = 0;
xorriso->boot_efi_default= 0;
is_change= 1;
} else if(strncmp(treatpt, "bin_path=", 9) == 0) {
if(strncmp(treatpt + 9, "--interval:appended_partition_", 30) == 0) {
if(strlen(treatpt + 9) >= sizeof(xorriso->boot_image_bin_path)) {
@ -892,10 +927,12 @@ interval_text_long:;
} else
strcpy(xorriso->boot_image_bin_form, "any");
xorriso->boot_efi_default= 0;
is_change= 1;
} else if(strcmp(treatpt, "efi_path=") == 0) {
xorriso->boot_image_bin_path[0] = 0;
xorriso->boot_efi_default= 0;
is_change= 1;
} else if(strncmp(treatpt, "efi_path=", 9) == 0) {
if(strncmp(treatpt + 9, "--interval:appended_partition_", 30) == 0) {
if(strlen(treatpt + 9) >= sizeof(xorriso->boot_image_bin_path))
@ -909,6 +946,7 @@ interval_text_long:;
}
xorriso->keep_boot_image= 0;
xorriso->boot_efi_default= 1;
is_change= 1;
} else if(strncmp(treatpt, "mips_path=", 10) == 0) {
sprintf(eff_path, "-boot_image %s mips_path=", formpt);
@ -922,6 +960,7 @@ interval_text_long:;
ret= Xorriso_add_mips_boot_file(xorriso, eff_path, 0);
if(ret <= 0)
goto ex;
is_change= 1;
} else if(strncmp(treatpt, "mipsel_path=", 12) == 0) {
sprintf(eff_path, "-boot_image %s mipsel_path=", formpt);
@ -935,6 +974,7 @@ interval_text_long:;
ret= Xorriso_add_mips_boot_file(xorriso, eff_path, 2);
if(ret <= 0)
goto ex;
is_change= 1;
} else if(strcmp(treatpt, "mips_discard") == 0 ||
strcmp(treatpt, "mipsel_discard") == 0 ||
@ -945,6 +985,7 @@ interval_text_long:;
Xorriso_add_mips_boot_file(xorriso, "", 1); /* give up MIPS boot files */
Xorriso_set_hppa_boot_parm(xorriso, "", "", 1); /* give up HP-PA files */
Xorriso_set_alpha_boot(xorriso, "", 1); /* give up DEC Alpha loader */
is_change= 1;
} else if(strncmp(treatpt, "sparc_label=", 12) == 0) {
sprintf(eff_path, "-boot_image %s sparc_label=", formpt);
@ -954,12 +995,14 @@ interval_text_long:;
strncpy(xorriso->ascii_disc_label, treatpt + 12,
Xorriso_disc_label_sizE - 1);
xorriso->ascii_disc_label[Xorriso_disc_label_sizE - 1] = 0;
is_change= 1;
} else if(strncmp(treatpt, "grub2_sparc_core=", 17) == 0) {
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, treatpt + 17,
xorriso->grub2_sparc_core, 2);
if(ret <= 0)
goto ex;
is_change= 1;
} else if(strncmp(treatpt, "hppa_", 5) == 0) {
sprintf(eff_path, "-boot_image %s %s", formpt, treatpt);
@ -985,6 +1028,7 @@ interval_text_long:;
ret= Xorriso_set_hppa_boot_parm(xorriso, eqpt + 1, parm, 0);
if(ret <= 0)
goto ex;
is_change= 1;
} else if(strncmp(treatpt, "alpha_boot=", 11) == 0) {
sprintf(eff_path, "-boot_image %s %s", formpt, treatpt);
@ -994,6 +1038,7 @@ interval_text_long:;
ret = Xorriso_set_alpha_boot(xorriso, treatpt + 11, 0);
if(ret <= 0)
goto ex;
is_change= 1;
} else if(strncmp(treatpt, "boot_info_table=", 16)==0) {
if(strcmp(treatpt + 16, "off") == 0)
@ -1003,6 +1048,8 @@ interval_text_long:;
1 | (2 * (strcmp(treatpt, "grub") == 0));
else
was_ok= 0;
if(was_ok)
is_change= 1;
} else if(strncmp(treatpt, "grub2_boot_info=", 16)==0) {
if(strcmp(treatpt + 16, "off") == 0)
@ -1011,6 +1058,8 @@ interval_text_long:;
xorriso->patch_isolinux_image= xorriso->patch_isolinux_image | 512;
else
was_ok= 0;
if(was_ok)
is_change= 1;
} else if(strncmp(treatpt, "load_size=", 10) == 0) {
if(strcmp(treatpt + 10, "full") == 0) {
@ -1027,6 +1076,7 @@ interval_text_long:;
xorriso->boot_image_load_size= num;
}
xorriso->boot_img_size_default= 0;
is_change= 1;
} else if(strncmp(treatpt, "id_string=", 10) == 0) {
memset(xorriso->boot_id_string, 0, 29);
@ -1036,6 +1086,7 @@ interval_text_long:;
ret= 0;
if(ret <= 0)
strncpy((char *) xorriso->boot_id_string, treatpt + 10, 28);
is_change= 1;
} else if(strncmp(treatpt, "sel_crit=", 9) == 0) {
memset(xorriso->boot_selection_crit, 0, 21);
@ -1048,6 +1099,7 @@ interval_text_long:;
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
{ret= 0; goto ex;}
}
is_change= 1;
} else if(strncmp(treatpt, "system_area=", 12) == 0) {
if(strcmp(formpt, "isolinux")==0) {
@ -1066,6 +1118,7 @@ interval_text_long:;
xorriso->system_area_options&= ~0x4000;
if(strcmp(treatpt + 12, "/dev/zero") == 0)
xorriso->system_area_clear_loaded= 1;
is_change= 1;
} else if(strncmp(treatpt, "partition_table=", 16)==0) {
if(strcmp(treatpt + 16, "off") == 0) {
@ -1080,6 +1133,9 @@ interval_text_long:;
goto ex;
} else
was_ok= 0;
if(was_ok)
is_change= 1;
} else if(strncmp(treatpt, "partition_entry=", 16)==0) {
if(strcmp(formpt, "isolinux") != 0) {
sprintf(xorriso->info_text,
@ -1100,6 +1156,8 @@ interval_text_long:;
xorriso->patch_isolinux_image = (xorriso->patch_isolinux_image & ~0x1fc);
} else
was_ok= 0;
if(was_ok)
is_change= 1;
} else if(strncmp(treatpt, "partition_offset=", 17)==0) {
u= 0;
@ -1112,6 +1170,7 @@ interval_text_long:;
{ret= 0; goto ex;}
}
xorriso->partition_offset= u;
is_change= 1;
} else if(strncmp(treatpt, "appended_part_as=", 17) == 0) {
if(strcmp(treatpt + 17, "gpt") == 0) {
@ -1123,11 +1182,14 @@ interval_text_long:;
xorriso->appended_as_apm = 1;
} else
was_ok= 0;
if(was_ok)
is_change= 1;
} else if(strncmp(treatpt, "gpt_disk_guid=", 14) == 0) {
ret= Xorriso_parse_gpt_guid(xorriso, treatpt + 14, 0);
if(ret <= 0)
goto ex;
is_change= 1;
} else if(strncmp(treatpt, "part_like_isohybrid=", 20) == 0) {
if(strcmp(treatpt + 20, "on") == 0)
@ -1136,6 +1198,8 @@ interval_text_long:;
xorriso->part_like_isohybrid= 0;
else
was_ok= 0;
if(was_ok)
is_change= 1;
} else if(strncmp(treatpt, "iso_mbr_part_type=", 18) == 0) {
ret= 256;
@ -1165,6 +1229,7 @@ interval_text_long:;
{ret= 0; goto ex;}
}
xorriso->iso_mbr_part_type= ret;
is_change= 1;
} else if(strncmp(treatpt, "partition_hd_cyl=", 17)==0) {
u= 0;
@ -1176,6 +1241,7 @@ interval_text_long:;
{ret= 0; goto ex;}
}
xorriso->partition_heads_per_cyl= u;
is_change= 1;
} else if(strncmp(treatpt, "partition_sec_hd=", 17)==0) {
u= 0;
@ -1187,6 +1253,7 @@ interval_text_long:;
{ret= 0; goto ex;}
}
xorriso->partition_secs_per_head= u;
is_change= 1;
} else if(strncmp(treatpt, "partition_cyl_align=", 20)==0) {
if(strcmp(treatpt + 20, "auto") == 0)
@ -1207,6 +1274,7 @@ interval_text_long:;
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
{ret= 0; goto ex;}
}
is_change= 1;
} else if(strncmp(treatpt, "platform_id=", 12)==0) {
u= 256; /* intentionally too large */
@ -1222,6 +1290,7 @@ interval_text_long:;
{ret= 0; goto ex;}
}
xorriso->boot_platform_id= u;
is_change= 1;
} else if(strncmp(treatpt, "emul_type=", 10)==0) {
if(strcmp(treatpt + 10, "none") == 0 ||
@ -1242,6 +1311,7 @@ interval_text_long:;
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
{ret= 0; goto ex;}
}
is_change= 1;
} else if(strncmp(treatpt, "hfsplus_serial=", 15) == 0) {
ret= Hex_to_bin(treatpt + 15, 8, &bin_count, (unsigned char *) sn, 0);
@ -1257,6 +1327,7 @@ interval_text_long:;
} else {
memcpy(xorriso->hfsp_serial_number, sn, 8);
}
is_change= 1;
} else if(strncmp(treatpt, "hfsplus_block_size=", 19) == 0) {
u= 0;
@ -1271,6 +1342,7 @@ interval_text_long:;
ret= 0; goto ex;
}
xorriso->hfsp_block_size= u;
is_change= 1;
} else if(strncmp(treatpt, "apm_block_size=", 15) == 0) {
u= 0;
@ -1285,14 +1357,17 @@ interval_text_long:;
ret= 0; goto ex;
}
xorriso->apm_block_size= u;
is_change= 1;
} else if(strncmp(treatpt, "efi_boot_part=", 14) == 0) {
if(Sfile_str(xorriso->efi_boot_partition, treatpt + 14, 0) <= 0)
{ret= -1; goto ex;}
is_change= 1;
} else if(strncmp(treatpt, "prep_boot_part=", 15) == 0) {
if(Sfile_str(xorriso->prep_partition, treatpt + 15, 0) <= 0)
{ret= -1; goto ex;}
is_change= 1;
} else if(strncmp(treatpt, "chrp_boot_part=", 15) == 0) {
if(strcmp(treatpt + 15, "on") == 0) {
@ -1307,6 +1382,7 @@ interval_text_long:;
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
{ret= 0; goto ex;}
}
is_change= 1;
} else if(strncmp(treatpt, "isohybrid=", 10) == 0 &&
strcmp(formpt, "isolinux")==0) {
@ -1331,6 +1407,7 @@ interval_text_long:;
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "HINT", 0);
{ret= 0; goto ex;}
}
is_change= 1;
#else
@ -1375,6 +1452,7 @@ interval_text_long:;
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
{ret= 0; goto ex;}
}
is_change= 1;
} else if(strncmp(treatpt, "gpt_iso_bootable=", 17) == 0) {
if(strcmp(treatpt + 17, "off") == 0) {
@ -1388,6 +1466,7 @@ interval_text_long:;
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
{ret= 0; goto ex;}
}
is_change= 1;
} else if(strncmp(treatpt, "gpt_iso_not_ro=", 15) == 0) {
if(strcmp(treatpt + 15, "off") == 0) {
@ -1401,11 +1480,14 @@ interval_text_long:;
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
{ret= 0; goto ex;}
}
is_change= 1;
} else {
was_ok= 0;
}
if(is_change)
Xorriso_set_change_pending(xorriso, 1);
if(!was_ok) {
sprintf(xorriso->info_text, "Unrecognized options with -boot_image: %s %s",
form, treatment);

View File

@ -1 +1 @@
#define Xorriso_timestamP "2023.07.21.070020"
#define Xorriso_timestamP "2023.08.06.132334"