13 #include "../config.h"
17 #include <sys/types.h>
64 return(gret>0 && sret>0);
78 "on attempt to attach volset to drive", 2);
108 sprintf(xorriso->
info_text,
"Failed to create new empty ISO image object");
138 "on attempt to record boot LBAs", 0);
145 &bootimg_node, &bootcat_node);
149 if(bootimg_node != NULL)
152 if(bootcat_node != NULL)
161 int ret, image_blocks;
169 "on attempt to perform -assert_volid", 0);
176 "-assert_volid: Cannot determine Volume Id at LBA %d.", msc1);
186 "-assert_volid: Volume id does not match pattern: ");
203 unsigned char buf[68];
204 void *data_stream= NULL;
214 if(buf[64] == 0xfb && buf[65] == 0xc0 && buf[66] == 0x78 && buf[67] == 0x70)
238 static const char *
un0(
const char *text)
247 char *pvd_time,
int flag)
253 strncpy(hr, pvd_time, 16);
255 sprintf(msg,
"%s %s\n", head, hr);
257 if(pvd_time[16] != 0) {
258 at= abs(pvd_time[16]);
259 sprintf(msg,
"%2.2s. Time Zone: %c%-2.2d:%-2.2d\n", head,
260 pvd_time[16] > 0 ?
'+' :
'-', at / 4, (at - (at / 4) * 4) * 15);
269 int ret, msc1= -1, msc2, i;
273 char *msg, block_head[8], *crt, *mdt, *ext, *eft;
287 for(i = msc1 + 16; i < msc1 + 32; i++) {
289 (off_t)
sizeof(block_head), &head_count, 2);
294 if(block_head[0] == 1 && strncmp(block_head + 1,
"CD001", 5) == 0)
298 sprintf(msg,
"PVD address : %ds\n", i);
305 sprintf(msg,
"Volume Set Id: %s\n", xorriso->
volset_id);
307 sprintf(msg,
"Publisher Id : %s\n", xorriso->
publisher);
309 sprintf(msg,
"Preparer Id : %s\n",
314 sprintf(msg,
"System Id : %s\n", xorriso->
system_id);
320 sprintf(msg,
"Biblio File : %s\n", xorriso->
biblio_file);
325 crt= mdt= ext= eft=
" ";
380 char *bin_path,
int platform_id,
381 int patch_isolinux,
int emul, off_t load_size,
382 unsigned char *id_string,
383 unsigned char *selection_crit,
char *form,
384 char *filter, FILE *fp,
int flag)
386 int is_default, no_defaults, i, is_default_id= 0, ret;
387 char *line, *bspec= NULL, zeros[28], *partition_entry;
393 no_defaults= flag & 1;
398 if((flag & 16) && bin_path[0] != 0) {
400 memset(zeros, 0, 28);
401 if(memcmp(id_string, zeros, 28) == 0 &&
402 memcmp(selection_crit, zeros, 20) == 0)
407 if(strcmp(form,
"isolinux") != 0 && strcmp(form,
"any") != 0)
409 else if(strcmp(bin_path,
"/isolinux.bin") == 0 &&
410 strcmp(cat_path,
"/boot.cat") == 0)
411 strcpy(bspec,
"dir=/");
412 else if(strcmp(bin_path,
"/isolinux/isolinux.bin") == 0 &&
413 strcmp(cat_path,
"/isolinux/boot.cat") == 0)
414 strcpy(bspec,
"dir=/isolinux");
416 "/boot/isolinux/isolinux.bin") == 0
418 "/boot/isolinux/boot.cat") == 0)
419 strcpy(bspec,
"dir=/boot/isolinux");
420 memset(zeros, 0, 28);
421 if(bspec[0] && platform_id == 0 && (patch_isolinux & 0x3ff) == 1 &&
422 load_size == 2048 && is_default_id && emul == 0) {
423 sprintf(line,
"-boot_image isolinux %s\n", bspec);
431 file_size= ((stbuf.st_size / (off_t) 512) +
432 !!(stbuf.st_size % (off_t) 512)) * 512;
436 if(platform_id == 0xef && (patch_isolinux & 0x3ff) == 0 &&
437 load_size / 512 ==
file_size && is_default_id && emul == 0) {
438 sprintf(line,
"-boot_image any efi_path=");
446 is_default= (bin_path[0] == 0) || (flag & 4);
447 sprintf(line,
"-boot_image %s bin_path=", form);
450 if(!(is_default && no_defaults))
453 is_default= (emul == 0);
454 sprintf(line,
"-boot_image %s emul_type=%s\n",
455 form, emul == 2 ?
"diskette" : emul == 1 ?
"hard_disk" :
"no_emulation");
456 if(!(is_default && no_defaults))
459 is_default= (platform_id == 0 || (flag & 4));
460 sprintf(line,
"-boot_image %s platform_id=0x%-2.2x\n", form, platform_id);
461 if(!(is_default && no_defaults))
464 is_default= ((patch_isolinux & 1) == 0 || bin_path[0] == 0 || (flag & 4));
465 sprintf(line,
"-boot_image %s boot_info_table=%s\n",
466 (patch_isolinux & 2) ?
"grub" : form,
467 (patch_isolinux & 1) ?
"on" :
"off");
468 if(!(is_default && no_defaults))
471 is_default= ((patch_isolinux & 512) == 0 || bin_path[0] == 0 || (flag & 4));
472 sprintf(line,
"-boot_image grub grub2_boot_info=%s\n",
473 (patch_isolinux & 512) ?
"on" :
"off");
474 if(!(is_default && no_defaults))
479 sprintf(line,
"-boot_image %s load_size=full", form);
481 is_default= (load_size == 2048 || (flag & 4));
482 sprintf(line,
"-boot_image %s load_size=%lu\n",
483 form, (
unsigned long) load_size);
485 if(!(is_default && no_defaults))
490 for(i= 0; i < 20; i++)
491 if(selection_crit[i])
493 sprintf(line,
"-boot_image %s sel_crit=", form);
494 for(i= 0; i < 20; i++)
495 sprintf(line + strlen(line),
"%-2.2X", (
unsigned int) selection_crit[i]);
497 if(!(is_default && no_defaults))
502 for(i= 0; i < 28; i++)
505 sprintf(line,
"-boot_image %s id_string=", form);
506 for(i= 0; i < 28; i++)
507 sprintf(line + strlen(line),
"%-2.2X", (
unsigned int) id_string[i]);
509 if(!(is_default && no_defaults))
514 if((patch_isolinux & 0x0fc) == (1 << 2))
515 partition_entry=
"gpt_basdat";
516 else if((patch_isolinux & 0x0fc) == (2 << 2))
517 partition_entry=
"gpt_hfsplus";
518 if(partition_entry[0]) {
519 sprintf(line,
"-boot_image isolinux partition_entry=%s\n", partition_entry);
523 if(patch_isolinux & (1 << 8)) {
524 sprintf(line,
"-boot_image isolinux partition_entry=apm_hfsplus\n");
528 if(is_default && !no_defaults) {
529 sprintf(line,
"-boot_image isolinux partition_entry=off\n");
541 char *filter, FILE *fp,
int flag)
548 sprintf(line,
"-boot_image any hppa_%s=", what);
561 char *filter, FILE *fp,
int flag)
563 int i, num_boots, sa_type;
564 char *paths[15], *line;
567 char *cmdline, *bootloader, *kernel_32, *kernel_64, *ramdisk;
573 sprintf(line,
"-boot_image any sparc_label=");
577 sprintf(line,
"-boot_image grub grub2_sparc_core=");
582 }
else if(sa_type == 1 || sa_type == 2) {
588 for(i= 0; i < num_boots; i++) {
589 sprintf(line,
"-boot_image any mips%s_path=", sa_type ==2 ?
"el" :
"");
596 }
else if(sa_type == 4 || sa_type == 5) {
598 &kernel_64, &ramdisk);
605 sprintf(num,
"%d", sa_type);
609 }
else if(sa_type == 6) {
611 if (ret == 1 && bootloader != NULL) {
612 sprintf(line,
"-boot_image any alpha_boot=");
628 char *filter, FILE *fp,
int flag)
630 int i, l, is_default;
633 sprintf(xorriso->
result_line,
"-boot_image any appended_part_as=%s\n",
635 if(!(is_default && (flag & 1)))
640 sprintf(xorriso->
result_line,
"-append_partition %d ", i + 1);
665 int ret, i, num_boots, hflag;
666 int is_default, no_defaults;
667 char *path= NULL, *form=
"any", *line, *hpt;
673 int platform_id, patch, load_size;
675 unsigned char id_string[29], sel_crit[21];
679 no_defaults= flag & 1;
682 "on attempt to print boot info", 2 | 16);
697 sprintf(line,
"-boot_image %s patch\n",
701 sprintf(line,
"-boot_image %s keep\n", form);
704 sprintf(line,
"-boot_image %s discard\n", form);
707 if(!(is_default && no_defaults))
709 goto report_open_item;
713 sprintf(line,
"-boot_image %s cat_path=", form);
716 if(!(is_default && no_defaults))
722 sprintf(line,
"-boot_image %s cat_hidden=%s\n", form, hpt);
724 if(!(is_default && no_defaults))
733 if(ret == 1 && num_boots > 0) {
734 for(i= 0; i < num_boots; i++) {
751 path, platform_id, patch, media_type,
752 load_size, id_string, sel_crit,
"any",
753 filter, fp, 16 | (flag & 3));
756 sprintf(line,
"-boot_image %s next\n", form);
773 for(i= 0; i < 20; i++)
777 for(i= 0; i < 28; i++)
793 filter, fp, hflag | (flag & 3));
805 if(bootnodes != NULL)
817 unsigned int platform_id;
821 sprintf(line + strlen(line),
822 " , platform_id=0x%-2.2X ", (
unsigned int) platform_id);
824 sprintf(line + strlen(line),
" , boot_info_table=on");
826 sprintf(line + strlen(line),
" , grub2_boot_info=on");
837 int ret, bin_path_valid= 0, i, num_boots, sa_count;
838 char *respt, *path= NULL, **sa_report= NULL, *sa_summary= NULL;
839 unsigned char *lb0= NULL;
844 IsoFile *bootimg_node, **bootnodes = NULL;
854 sprintf(respt,
"Boot record : (overridden by -boot_image any next)\n");
861 "on attempt to print boot info", 16);
869 sprintf(respt,
"Boot record : none\n");
876 if(ret > 0 && sa_report != NULL)
877 for(i= 0; i < sa_count; i++)
878 if(strncmp(sa_report[i],
"System area summary: ", 21) == 0) {
880 strcpy(sa_summary, sa_report[i] + 21);
883 if(sa_report != NULL)
890 if(sa_summary == NULL)
892 sprintf(respt,
"Boot record : (system area only) , %s\n", sa_summary);
905 sprintf(respt,
"Boot record : El Torito");
906 if(sa_summary != NULL)
907 sprintf(respt + strlen(respt),
" , %s", sa_summary);
915 sprintf(respt,
"Boot catalog : ");
919 sprintf(respt,
"Boot catalog : -not-found-at-load-time-\n");
924 sprintf(respt,
"Boot image : ");
927 sprintf(respt,
"Boot image : -not-found-at-load-time-");
929 sprintf(respt,
"Boot image : -not-found-any-more-by-lba=%d",
937 for(i= 1; i < num_boots; i++) {
940 sprintf(respt,
"Boot image : ");
943 sprintf(respt,
"Boot image : -not-found-any-more-");
953 if(bootnodes != NULL)
974 sprintf(xorriso->
info_text,
"No ISO image present.");
977 " No -dev, -indev, or -outdev selected.");
980 " Possible program error with drive '%s'.", xorriso->
indev);
989 return(*volume != NULL);
1028 char *adr_value,
char *cmd,
int flag)
1030 int ret, lba, track, session, params_flag= 0, is_safe= 0, is_extra_drive= 0;
1031 int give_up= 0, mount_chardev= 0,
status, aquire_flag= 0;
1032 char volid[33], *devadr, *mount_command= NULL, *adr_data= NULL, *adr_pt;
1033 char *dev_path, *libburn_adr= NULL;
1034 char *dpt, *sysname=
"";
1045 if(strcmp(dev,
"indev") == 0) {
1047 "on attempt to perform -mount \"indev\"", 0);
1050 dev_path= devadr= xorriso->
indev;
1051 if(strncmp(dev_path,
"stdio:", 6) == 0)
1053 else if(strncmp(dev_path,
"mmc:", 4) == 0)
1059 }
else if(strcmp(dev,
"outdev") == 0) {
1061 "on attempt to perform -mount \"outdev\"",
1065 dev_path= devadr= xorriso->
outdev;
1066 if(strncmp(dev_path,
"stdio:", 6) == 0)
1068 else if(strncmp(dev_path,
"mmc:", 4) == 0)
1077 if(strncmp(dev_path,
"stdio:", 6) == 0)
1079 else if(strncmp(dev_path,
"mmc:", 4) == 0)
1083 ret= stat(dev_path, &stbuf);
1085 sprintf(xorriso->
info_text,
"Cannot determine properties of file ");
1091 if(ret > 0 && strcmp(sysname,
"FreeBSD") == 0)
1093 if(!(S_ISREG(stbuf.st_mode) || (S_ISBLK(stbuf.st_mode) && !mount_chardev)
1094 || (S_ISCHR(stbuf.st_mode) && !mount_chardev))) {
1096 "File object is not suitable as mount device: ");
1103 if(strncmp(dev,
"mmc:", 4) == 0)
1110 if(ret == 0 && strncmp(dev,
"stdio:", 6) != 0 &&
1111 strncmp(dev,
"mmc:", 4) != 0)
1112 sprintf(libburn_adr,
"stdio:%s", dev);
1128 drive= dinfo[0].
drive;
1131 if(adr_mode == 4 && strlen(adr_pt) <= 80) {
1139 &session, volid, params_flag);
1143 if(((session <= 0 || track <= 0) && !(aquire_flag & 16)) || ret == 2) {
1145 "-mount : Given address does not point to an ISO 9660 session",
1149 if(strstr(devadr,
"stdio:") == devadr)
1151 if(strstr(devadr,
"mmc:") == devadr)
1154 mount_command, (flag & (2 | 4)) | ((flag & 4) << 1));
1160 if(is_extra_drive) {
1164 }
else if(give_up > 0 && !((flag & 1) || (xorriso->
mount_opts_flag & 1))) {
1171 sprintf(xorriso->
info_text,
"Volume id : ");
1176 sprintf(xorriso->
result_line,
"%s\n", mount_command);
1179 sprintf(xorriso->
info_text,
"Mount command: %s\n", mount_command);
1183 "-mount : Will not perform mount command which stems from command template.",
1185 sprintf(xorriso->
result_line,
"%s\n", mount_command);
1188 ret=
Xorriso_execv(xorriso, mount_command, 0, NULL,
"/bin:/sbin",
1189 NULL, NULL, NULL, &
status, 1);
1192 "-mount : mount command failed with exit value %d",
1193 (
int) WEXITSTATUS(
status));
1197 sprintf(xorriso->
info_text,
"\nMounted session %d of device ", session);
1199 dpt= strchr(cmd,
':');
1212 if(is_extra_drive && drive != NULL) {
1248 "There is already a boot image file registered.",
1258 "Error when adding MIPS boot file",
1278 par[0]= par[1]= par[2]= par[3]= par[4]= NULL;
1285 if(strcmp(what,
"cmdline") == 0) {
1287 }
else if(strcmp(what,
"bootloader") == 0) {
1289 }
else if(strcmp(what,
"kernel_32") == 0 || strcmp(what,
"kernel-32") == 0) {
1291 }
else if(strcmp(what,
"kernel_64") == 0 || strcmp(what,
"kernel-64") == 0) {
1293 }
else if(strcmp(what,
"ramdisk") == 0) {
1295 }
else if(strcmp(what,
"hdrversion") == 0) {
1296 if(strcmp(text,
"4") == 0) {
1299 }
else if(strcmp(text,
"5") == 0) {
1303 strcpy(xorriso->
info_text,
"Unsupported HP-PA PALO header version ");
1311 "HP-PA boot parameter name not recognized: hppa_");
1320 "Error when adding HP-PA boot parameter",
1346 "Error when adding DEC Alpha boot loader",
1358 int options,
char *cmd,
int flag)
1360 int old_type, old_options, new_options;
1361 static char *type_names[7] = {
1362 "MBR",
"MIPS Big Endian Volume Header",
"MIPS Little Endian Boot Block",
1363 "SUN Disk Label",
"HP-PA PALO v4",
"HP-PA PALO v5",
1364 "DEC Alpha SRM Boot Block"};
1365 static int num_names = 7;
1369 new_options= options & 0x3c03;
1375 if((old_type != 0 || old_options != 0) &&
1376 (old_type != sa_type || (old_options != 0 && old_options != new_options))){
1378 sprintf(xorriso->
info_text,
"%s : First sector already occupied by %s",
1379 cmd, old_type < num_names ?
1380 type_names[old_type] :
"other boot facility");
1381 if(old_type == 0 && (old_options & 2))
1382 strcat(xorriso->
info_text,
" for ISOLINUX isohybrid");
1384 strcat(xorriso->
info_text,
" for GRUB2 patching");
1385 if(old_type == 0 && (old_options & 1))
1386 strcat(xorriso->
info_text,
" with partition table");
1387 }
else if(old_type == 0 && (old_options & 1))
1388 strcat(xorriso->
info_text,
" for partition table");
1394 ((sa_type << 2) & 0xfc) | (options & 0x3c03);
1399 sprintf(xorriso->
info_text,
"Revokable by -boot_image any discard");
1400 else if(old_type == 1 || old_type == 2)
1401 sprintf(xorriso->
info_text,
"Revokable by -boot_image any mips_discard");
1402 else if(old_type == 3)
1403 sprintf(xorriso->
info_text,
"Revokable by -boot_image any sparc_discard");
1422 ret= fread(buf, 1, 32 * 1024, fp);
1425 "No bytes readable for GPT CRC from ");
1431 sprintf(xorriso->
result_line,
"0x%8.8x\n", (
unsigned int) crc);
1435 if(fp != NULL && fp != stdin)
1444 char *name,
char **contentpt,
1445 double *num,
int *num_count,
1446 char **textpt,
int flag)
1449 char *spt, *ept, *cpt;
1451 if(strlen(line) < 21) {
1454 "Undigestible report line with -report_* mode cmd: '%s'", line);
1460 strncpy(name, line, 20);
1463 for(spt= line + 20; *spt ==
' '; spt++);
1464 *textpt= *contentpt= spt;
1466 for(i= 0; i < num_limit; i++) {
1468 for(spt= *textpt; *spt ==
' '; spt++);
1473 for(ept= spt + 1; *ept !=
' ' && *ept != 0; ept++);
1477 for(cpt= spt; cpt < ept; cpt++)
1478 if(*cpt < '0' || *cpt >
'9')
1482 sscanf(spt,
"%lf", num + *num_count);
1487 for(; **textpt ==
' '; (*textpt)++);
1493 char **cmds,
int *cmd_count,
int flag)
1502 strcpy(cmds[*cmd_count], buf);
1516 uint64_t start_adr, uint64_t end_adr,
char *suffix,
1521 sprintf(buf + strlen(buf),
"--interval:%s:%.f%s-%.f%s:",
1522 ((flag & (1 << 30)) ?
"imported_iso" :
"local_fs"),
1523 (
double) start_adr, suffix, (
double) end_adr, suffix);
1525 strcat(buf,
"zero_mbrpt,");
1527 strcat(buf,
"zero_gpt,");
1529 strcat(buf,
"zero_apm,");
1530 if(buf[strlen(buf) - 1] ==
',')
1531 buf[strlen(buf) - 1] = 0;
1533 path= xorriso->
indev;
1534 if(strncmp(path,
"stdio:", 6) == 0)
1542 off_t byte_offset, off_t byte_size,
int flag)
1568 int *efi_boot_part,
int *first_efi,
1572 if(ptype == 1 || ptype == 3)
1577 }
else if(*first_efi && et_img->
platform_id == 0xef) {
1592 int elto_count,
char *path,
int ptype,
1593 int *found,
int *efi_boot_part,
1596 int first_efi= 1, et_idx, ret;
1598 for(et_idx= 0; et_idx < elto_count; et_idx++) {
1599 if(strcmp(et_imgs[et_idx].path, path) != 0)
1602 ptype, efi_boot_part, &first_efi, flag);
1607 if(et_idx < elto_count)
1617 int *found,
int flag)
1621 for(et_idx= 0; et_idx < elto_count; et_idx++)
1622 if(et_imgs[et_idx].lba == lba)
1625 if(et_idx < elto_count)
1636 struct stat dir_stbuf;
1646 NULL,
"/", &dir_stbuf, 0, 0);
1661 char **et_lines,
int et_line_count,
1662 char **sa_lines,
int sa_line_count,
1663 char **cmds,
int *cmd_count,
1664 char **boot_imgs,
int *boot_img_count,
1667 int ret= 0, i, num_count, mkisofs, line_count, idx, et_idx, isohybrid= 0;
1668 int ptype, gpt_idx, j, pad, mbr_idx;
1669 int efi_boot_part= 0, full_sparc_part= 0, have_sparc_part= 0, fe_dummy= 1;
1670 int appended_as_gpt= 0, have_prep= 0, did_sysarea= 0, cared_for_apm= 0;
1671 int cared_for_sparc= 0, have_hfsplus= 0;
1672 int have_sysarea= 0, ptable_killer, imported_iso, have_alpha_ldr_path= 0;
1673 int have_protective_msdos= 0, part_like_isohybrid= 0;
1675 #ifdef Not_any_more_because_padding_is_now_after_partitions
1676 int appended_partition= 0;
1679 int iso_mbr_part_type= -1, iso_gpt_part_idx= -1;
1680 unsigned int prev_pltf= 0;
1681 unsigned long int sa_options= 0, partno, id_tag, perms, start_cyl;
1682 unsigned long int part_status, part_type, mbr_start_block, mbr_num_blocks;
1683 unsigned long int partition_offset= 0;
1684 uint32_t high_block= 0, indev_blocks;
1685 char name[24], *textpt, *contentpt, *buf= NULL, part_type_text[37];
1693 struct stat dir_stbuf;
1695 char *volid, *crt, *mdt, *ext, *eft, uuid[17], *uuid_time;
1696 char **app_pseudo_paths= NULL;
1698 int was_force_bootable= 0, have_mbr_force_bootable= 0;
1699 uint64_t gpt_bheader_block= 0, start_block, num_blocks;
1700 uint64_t img_blocks= 0, iso_part_blocks;
1704 uint64_t start_block;
1705 uint64_t block_count;
1709 struct mbr_par *mbrpts= NULL;
1714 uint8_t type_guid[16];
1718 uint64_t start_block;
1719 uint64_t block_count;
1721 struct gpt_par *gpts= NULL;
1728 struct apm_par *apms= NULL;
1731 #define Xorriso_record_cmd_linE { \
1732 ret= Xorriso_record_cmd_line(xorriso, buf, cmds, cmd_count, flag & 1); \
1737 #define Xorriso_record_boot_imglinE { \
1738 ret= Xorriso_record_cmd_line(xorriso, buf, boot_imgs, boot_img_count, \
1746 #define Xorriso_max_endless_uefi_sizE (1 << 19)
1748 mkisofs= !!(flag & 2);
1749 imported_iso= (!mkisofs) << 30;
1753 line_count= et_line_count + sa_line_count;
1759 for(i= 0; i < et_line_count; i++)
1760 lines[i]= et_lines[i];
1761 for(i= 0; i < sa_line_count; i++)
1762 lines[i + et_line_count]= sa_lines[i];
1765 for(i= 0; i < line_count; i++) {
1767 num, &num_count, &textpt, 0);
1770 if(strcmp(name,
"System area options:") == 0) {
1771 sscanf(contentpt,
"%lx", &sa_options);
1773 }
else if(strcmp(name,
"System area summary:") == 0) {
1776 }
else if(strcmp(name,
"El Torito boot img :") == 0) {
1777 if(num[0] > elto_count)
1780 }
else if(strcmp(name,
"PReP boot partition:") == 0) {
1783 }
else if(strcmp(name,
"MBR partition :") == 0) {
1784 if(num[0] > mbr_count)
1786 if(strcmp(textpt,
"0x80 0x00 0 1") == 0)
1787 have_mbr_force_bootable= 1;
1789 }
else if(strcmp(name,
"GPT partition name :") == 0) {
1790 if(num[0] > gpt_count)
1793 }
else if(strcmp(name,
"APM partition name :") == 0) {
1794 if(num[0] > apm_count)
1797 }
else if(strcmp(name,
"ISO image size/512 :") == 0) {
1800 }
else if(strcmp(name,
"Partition offset :") == 0 &&
1801 (num[0] == 0 || num[0] == 16)) {
1802 partition_offset= num[0];
1811 high_block = img_blocks / 4 - 1;
1813 if(elto_count > 0) {
1815 for(et_idx= 0; et_idx < elto_count; et_idx++) {
1816 et_imgs[et_idx].
path= NULL;
1817 et_imgs[et_idx].
ldsiz= -1;
1820 for(i= 0; i < elto_count; i++)
1821 app_pseudo_paths[i]= NULL;
1822 for(i= 0; i < elto_count; i++) {
1824 app_pseudo_paths[i][0]= 0;
1831 for(gpt_idx= 0; gpt_idx < gpt_count; gpt_idx++)
1832 gpts[gpt_idx].path= NULL;
1836 for(i= 0; i < apm_count; i++)
1840 ptable_killer= (mbr_count > 0) | ((gpt_count > 0) << 1) |
1841 ((apm_count > 0) << 2);
1848 sprintf(buf,
"-V ");
1850 sprintf(buf,
"-volid ");
1859 if(ret <= 0 || strlen(crt) != 16) {
1861 if(!(ret <= 0 || strlen(mdt) != 16))
1865 for(j= 0; j < 16; j++) {
1868 }
else if(uuid_time[j] == 0) {
1871 }
else if(uuid_time[j] <
'0' || uuid_time[j] >
'9') {
1874 uuid[j]= uuid_time[j];
1879 if(!(ret <= 0 || strlen(uuid) != 16)) {
1881 sprintf(buf,
"--modification-date=");
1883 sprintf(buf,
"-volume_date uuid ");
1890 for(i= 0; i < line_count; i++) {
1893 num, &num_count, &textpt, 0);
1897 if(strcmp(name,
"El Torito cat path :") == 0) {
1900 }
else if(strcmp(name,
"El Torito catalog :") == 0) {
1901 strcpy(buf,
"eltorito_catalog.img/");
1903 ((off_t) num[1]) * 2048, 0);
1906 }
else if(strcmp(name,
"El Torito boot img :") == 0) {
1911 sscanf(contentpt,
"%d %s %s %s %x %x %d %lu",
1912 &(et_imgs[idx].n), et_imgs[idx].pltf, et_imgs[idx].b,
1913 et_imgs[idx].emul, &(et_imgs[idx].ld_seg), &(et_imgs[idx].hdpt),
1914 &(et_imgs[idx].ldsiz), &(et_imgs[idx].lba));
1915 if(strcmp(et_imgs[idx].pltf,
"BIOS") == 0)
1917 else if(strcmp(et_imgs[idx].pltf,
"PPC") == 0)
1919 else if(strcmp(et_imgs[idx].pltf,
"Mac") == 0)
1921 else if(strcmp(et_imgs[idx].pltf,
"UEFI") == 0)
1924 sscanf(et_imgs[idx].pltf,
"%x", &(et_imgs[idx].platform_id));
1926 strcpy(et_imgs[idx].boot_image_type,
"any");
1934 }
else if(strcmp(name,
"El Torito img path :") == 0) {
1936 et_imgs[idx].
path= textpt;
1939 extract_size = (dir_stbuf.st_size + 2047) / 2048;
1940 if(extract_size > et_imgs[idx].extract_size)
1944 }
else if(strcmp(name,
"El Torito img blks :") == 0) {
1946 if(num[1] > et_imgs[idx].extract_size)
1949 }
else if(strcmp(name,
"El Torito img opts :") == 0) {
1951 if(strstr(textpt,
"boot-info-table") != NULL)
1953 if(strstr(textpt,
"isohybrid-suitable") != NULL)
1954 strcpy(et_imgs[idx].boot_image_type,
"isolinux");
1955 if(strstr(textpt,
"grub2-boot-info") != NULL) {
1956 strcpy(et_imgs[idx].boot_image_type,
"grub");
1960 }
else if(strcmp(name,
"El Torito id string:") == 0) {
1964 }
else if(strcmp(name,
"El Torito sel crit :") == 0) {
1968 }
else if(strcmp(name,
"System area summary:") == 0) {
1969 if(strstr(textpt,
"protective-msdos-label") != NULL)
1970 have_protective_msdos= 1;
1972 }
else if(strcmp(name,
"MBR partition :") == 0) {
1973 sscanf(contentpt,
"%lu 0x%lx 0x%lx %lu %lu",
1974 &partno, &part_status, &part_type, &mbr_start_block,
1977 mbrpts[idx].ptype= part_type;
1978 mbrpts[idx].start_block= mbr_start_block;
1979 mbrpts[idx].block_count= mbr_num_blocks;
1980 if(mbr_num_blocks > 0 && mbr_start_block + mbr_num_blocks > mbr_parts_end)
1981 mbr_parts_end= mbr_start_block + mbr_num_blocks;
1982 if(mbr_start_block == partition_offset * 4 &&
1983 (mbr_start_block + mbr_num_blocks) >= high_block * 4 &&
1984 iso_mbr_part_type < 0)
1985 iso_mbr_part_type = part_type;
1987 }
else if(strcmp(name,
"MBR partition path :") == 0) {
1989 mbrpts[idx].has_path= 1;
1991 }
else if(strcmp(name,
"GPT lba range :") == 0) {
1992 gpt_bheader_block= num[2];
1994 }
else if(strcmp(name,
"GPT type GUID :") == 0) {
1996 if(strcmp(textpt,
"a2a0d0ebe5b9334487c068b6b72699c7") == 0)
1998 else if(strcmp(textpt,
"005346480000aa11aa1100306543ecac") == 0)
2000 else if(strcmp(textpt,
"28732ac11ff8d211ba4b00a0c93ec93b") == 0)
2006 }
else if(strcmp(name,
"GPT start and size :") == 0) {
2010 start_block= gpts[idx].start_block= num[1];
2011 num_blocks= gpts[idx].block_count= num[2];
2012 if(start_block == partition_offset * 4 &&
2013 (start_block + num_blocks) >= high_block * 4 &&
2014 iso_gpt_part_idx < 0)
2015 iso_gpt_part_idx= idx;
2017 }
else if(strcmp(name,
"GPT partition path :") == 0) {
2019 gpts[idx].has_path= 1;
2020 gpts[idx].path= textpt;
2022 }
else if(strcmp(name,
"GPT partition name :") == 0) {
2024 if(strstr(contentpt,
" 470061007000") != NULL)
2025 gpts[idx].is_gap= 1;
2027 }
else if(strcmp(name,
"APM partition name :") == 0) {
2029 if(strcmp(textpt,
"HFSPLUS_Hybrid") == 0)
2030 apms[idx].ptype|= 2;
2032 }
else if(strcmp(name,
"APM partition type :") == 0) {
2034 if(strcmp(textpt,
"Apple_HFS") == 0)
2035 apms[idx].ptype|= 1;
2037 }
else if(strcmp(name,
"APM partition path :") == 0) {
2039 apms[idx].path= textpt;
2041 }
else if(strcmp(name,
"DEC Alpha ldr path :") == 0) {
2042 have_alpha_ldr_path= 1;
2047 if(appended_as_gpt && !have_protective_msdos) {
2048 if(mbr_count != 1) {
2050 }
else if(mbrpts[0].ptype != 0xee || mbrpts[0].start_block != 1) {
2052 }
else if(gpt_bheader_block != mbrpts[0].block_count) {
2057 iso_part_blocks= img_blocks;
2058 for(mbr_idx = 0; mbr_idx < mbr_count; mbr_idx++) {
2059 if(mbrpts[mbr_idx].start_block == partition_offset * 4) {
2060 iso_part_blocks= mbrpts[mbr_idx].block_count + partition_offset * 4;
2066 for(i= 0; i < line_count; i++) {
2069 num, &num_count, &textpt, 0);
2073 if(strcmp(name,
"System area options:") == 0) {
2074 if((sa_options & 0x3c00) == 0x0400) {
2076 sprintf(buf,
"-chrp-boot-part ");
2078 sprintf(buf,
"-boot_image any chrp_boot_part=on ");
2081 }
else if(strcmp(name,
"System area summary:") == 0) {
2082 if(strstr(textpt,
"isohybrid") != NULL) {
2085 sprintf(buf,
"-isohybrid-mbr ");
2087 sprintf(buf,
"-boot_image isolinux system_area=");
2089 imported_iso | ptable_killer);
2091 strcpy(buf,
"mbr_code_isohybrid.img/");
2096 if(strstr(textpt,
"grub2-mbr") != NULL) {
2098 sprintf(buf,
"--grub2-mbr ");
2100 sprintf(buf,
"-boot_image grub grub2_mbr=");
2102 imported_iso | ptable_killer);
2104 strcpy(buf,
"mbr_code_grub2.img/");
2109 if(strstr(textpt,
"protective-msdos-label") != NULL) {
2111 sprintf(buf,
"--protective-msdos-label");
2113 sprintf(buf,
"-boot_image any partition_table=on");
2116 if(strstr(textpt,
"cyl-align-off") != NULL) {
2118 sprintf(buf,
"-partition_cyl_align off");
2120 sprintf(buf,
"-boot_image any partition_cyl_align=off");
2121 }
else if(strstr(textpt,
"cyl-align-all") != NULL) {
2123 sprintf(buf,
"-partition_cyl_align all");
2125 sprintf(buf,
"-boot_image any partition_cyl_align=all");
2126 }
else if(strstr(textpt,
"cyl-align-") != NULL) {
2128 sprintf(buf,
"-partition_cyl_align on");
2130 sprintf(buf,
"-boot_image any partition_cyl_align=on");
2134 }
else if(strcmp(name,
"Partition offset :") == 0 &&
2135 (num[0] == 0 || num[0] == 16)) {
2137 sprintf(buf,
"-partition_offset %.f", num[0]);
2139 sprintf(buf,
"-boot_image any partition_offset=%.f", num[0]);
2141 }
else if(strcmp(name,
"MBR heads per cyl :") == 0 &&
2142 (num[0] > 0 && num[0] <= 255)) {
2144 sprintf(buf,
"-partition_hd_cyl %.f", num[0]);
2146 sprintf(buf,
"-boot_image any partition_hd_cyl=%.f", num[0]);
2148 }
else if(strcmp(name,
"MBR secs per head :") == 0 &&
2149 (num[0] > 0 && num[0] <= 63)) {
2151 sprintf(buf,
"-partition_sec_hd %.f", num[0]);
2153 sprintf(buf,
"-boot_image any partition_sec_hd=%.f", num[0]);
2155 }
else if(strcmp(name,
"MBR partition :") == 0) {
2156 sscanf(contentpt,
"%lu 0x%lx 0x%lx %lu %lu",
2157 &partno, &part_status, &part_type, &mbr_start_block,
2159 if(mbr_num_blocks > 0 && part_type != 0x00 && part_type != 0xee &&
2160 (iso_part_blocks <= mbr_start_block ||
2161 (have_protective_msdos && img_blocks == mbr_parts_end &&
2163 if(!appended_as_gpt) {
2164 sprintf(buf,
"-append_partition %lu 0x%lx ", partno, part_type);
2166 ((uint64_t) mbr_start_block) + mbr_num_blocks - 1,
2169 if(partno >= 1 && (
int) partno <= mbr_count)
2170 mbrpts[partno - 1].appended= 1;
2172 #ifdef Not_any_more_because_padding_is_now_after_partitions
2173 appended_partition= 1;
2177 if(part_type == 0xef) {
2178 sprintf(buf,
"mbr_part%lu_efi.img/", partno);
2180 ((off_t) mbr_num_blocks) * 512, 0);
2183 }
else if(part_type == 0x41 && have_prep) {
2185 sprintf(buf,
"-prep-boot-part ");
2187 sprintf(buf,
"-boot_image any prep_boot_part=");
2190 ((uint64_t) mbr_start_block) + mbr_num_blocks - 1,
2193 sprintf(buf,
"mbr_part%lu_prep.img/", partno);
2195 ((off_t) mbr_num_blocks) * 512, 0);
2197 }
else if(part_type == 0xef) {
2198 sprintf(buf,
"mbr_part%lu_efi.img/", partno);
2200 ((off_t) mbr_num_blocks) * 512, 0);
2203 if((part_status & 0x80) && !was_force_bootable) {
2204 was_force_bootable= 1;
2209 sprintf(buf,
"--mbr-force-bootable");
2211 sprintf(buf,
"-boot_image any mbr_force_bootable=on");
2213 }
else if(strcmp(name,
"MBR partition path :") == 0) {
2215 if(mbrpts[idx].ptype == 0x41) {
2217 "Cannot make proposal to mark PReP partition by data file: ");
2224 if(mbrpts[idx].ptype == 0xef)
2228 &et_idx, &efi_boot_part, !!isohybrid);
2231 "Cannot make proposal to mark data file as MBR partition without being an El Torito boot image : ");
2236 for(gpt_idx= 0; gpt_idx < gpt_count; gpt_idx++) {
2237 if(gpts[gpt_idx].path != NULL)
2238 if(strcmp(gpts[gpt_idx].path, textpt) == 0)
2241 if(gpt_idx >= gpt_count) {
2243 "Cannot make proposal to mark data file as MBR partition without being in GPT : ");
2250 }
else if(strcmp(name,
"GPT disk GUID :") == 0) {
2254 }
else if(strcmp(name,
"GPT partition name :") == 0) {
2258 }
else if(strcmp(name,
"GPT partition GUID :") == 0) {
2262 }
else if(strcmp(name,
"GPT partition flags:") == 0) {
2266 }
else if(strcmp(name,
"GPT partition path :") == 0) {
2269 textpt, gpts[idx].ptype,
2270 &et_idx, &efi_boot_part, !!isohybrid);
2273 "Cannot make proposal to mark data file as GPT partition : ");
2279 }
else if(strcmp(name,
"GPT start and size :") == 0) {
2281 if(gpts[idx].ptype == 3)
2286 if(high_block * 4 < num[1] && num[2] > 0 && !gpts[idx].is_gap) {
2287 for(mbr_idx = 0; mbr_idx < mbr_count; mbr_idx++) {
2288 if(mbrpts[mbr_idx].start_block == num[1]) {
2289 if(mbrpts[mbr_idx].block_count != num[2] && !(flag & 1)) {
2291 "GPT partition %d has same start block as MBR partition %d but different block count (%.f <> %.f)",
2292 idx + 1, mbr_idx + 1, num[2],
2293 (
double) mbrpts[mbr_idx].block_count);
2300 if(mbr_idx >= mbr_count) {
2301 if(appended_as_gpt == 1) {
2305 sprintf(part_type_text,
"0x%lx", part_type);
2307 sprintf(buf,
"-append_partition %d %s ", idx + 1, part_type_text);
2309 (uint64_t) (num[1] + num[2] - 1.0),
"d",
2313 #ifdef Not_any_more_because_padding_is_now_after_partitions
2314 appended_partition= 1;
2320 if((mbr_count == 1 || (mbr_count == 2 && have_mbr_force_bootable)) &&
2321 mbrpts[0].ptype == 0xee && have_protective_msdos) {
2326 (
unsigned int) (num[1] / 4.0),
2330 if(!(et_imgs[et_idx].do_gpt_basdat ||
2331 et_imgs[et_idx].do_gpt_hfsplus ||
2332 part_like_isohybrid)) {
2334 sprintf(buf,
"-part_like_isohybrid");
2336 sprintf(buf,
"-boot_image any part_like_isohybrid=on");
2338 part_like_isohybrid= 1;
2343 gpts[idx].ptype, &efi_boot_part,
2347 }
else if(gpts[idx].ptype == 3 && gpts[idx].has_path == 0 &&
2348 img_blocks >= num[1] + num[2] && !efi_boot_part) {
2350 sprintf(buf,
"-efi-boot-part ");
2352 sprintf(buf,
"-boot_image any efi_boot_part=");
2354 (uint64_t) (num[1] + num[2] - 1.0),
"d",
2360 if(gpts[idx].ptype == 2 &&
2361 (img_blocks / 2 > num[2] || num[1] >= img_blocks)) {
2363 sprintf(buf,
"gpt_part%d_hfsplus.img/", idx + 1);
2365 ((off_t) num[2]) * 512, 0);
2367 }
else if(gpts[idx].ptype == 3) {
2368 sprintf(buf,
"gpt_part%d_efi.img/", idx + 1);
2370 ((off_t) num[2]) * 512, 0);
2374 }
else if(strcmp(name,
"APM block size :") == 0) {
2376 sprintf(buf,
"-apm-block-size %.f", num[0]);
2378 sprintf(buf,
"-boot_image any apm_block_size=%.f", num[0]);
2380 }
else if(strcmp(name,
"APM partition name :") == 0) {
2384 }
else if(strcmp(name,
"APM partition path :") == 0) {
2387 for(et_idx= 0; isohybrid && et_idx < elto_count; et_idx++)
2388 if(strcmp(et_imgs[et_idx].path, textpt) == 0) {
2389 if(apms[idx].ptype == 1) {
2396 }
else if(strcmp(name,
"APM start and size :") == 0) {
2399 if(num[1] + num[2] <= img_blocks && apms[idx].ptype == 3 &&
2400 apms[idx].path == NULL && !have_hfsplus) {
2409 sprintf(buf,
"-hfsplus");
2411 sprintf(buf,
"-hfsplus on");
2424 ret=
Xorriso_findi(xorriso, job, NULL, (off_t) 0, NULL,
"/",
2433 }
else if(strcmp(name,
"MIPS-BE boot path :") == 0) {
2435 sprintf(buf,
"-mips-boot ");
2437 sprintf(buf,
"-boot_image any mips_path=");
2440 }
else if(strcmp(name,
"MIPS-LE boot path :") == 0) {
2442 sprintf(buf,
"-mipsel-boot ");
2444 sprintf(buf,
"-boot_image any mipsel_path=");
2447 }
else if(strcmp(name,
"SUN SPARC disklabel:") == 0) {
2449 sprintf(buf,
"-sparc-label ");
2451 sprintf(buf,
"-boot_image any sparc_label=");
2454 }
else if(strcmp(name,
"SPARC GRUB2 path :") == 0) {
2456 sprintf(buf,
"-B ,");
2458 sprintf(buf,
"--grub2-sparc-core ");
2460 sprintf(buf,
"-boot_image grub grub2_sparc_core=");
2464 }
else if(strcmp(name,
"SUN SPARC partition:") == 0) {
2466 partno= id_tag= perms= num_blocks= 0;
2467 start_cyl= 0xffffffff;
2468 sscanf(contentpt,
"%lu 0x%lx 0x%lx %lu %lu",
2469 &partno, &id_tag, &perms, &start_cyl, &mbr_num_blocks);
2470 if(partno > 0 && partno < 9 && start_cyl == 0 &&
2471 mbr_num_blocks >= img_blocks - 600 && mbr_num_blocks <= img_blocks &&
2472 ((partno == 1 && id_tag == 4) || (partno > 1 && id_tag == 2)))
2473 full_sparc_part|= (1 << (partno - 1));
2475 }
else if(strcmp(name,
"PALO header version:") == 0) {
2477 sprintf(buf,
"-hppa-hdrversion %.f", num[0]);
2479 sprintf(buf,
"-boot_image any hppa_hdrversion=%.f", num[0]);
2481 }
else if(strcmp(name,
"HP-PA cmdline :") == 0) {
2483 sprintf(buf,
"-hppa-cmdline ");
2485 sprintf(buf,
"-boot_image any hppa_cmdline=");
2488 }
else if(strcmp(name,
"HP-PA 32-bit kernel:") == 0) {
2490 sprintf(buf,
"-hppa-kernel-32 ");
2492 sprintf(buf,
"-boot_image any hppa_kernel_32=");
2495 }
else if(strcmp(name,
"HP-PA 64-bit kernel:") == 0) {
2497 sprintf(buf,
"-hppa-kernel-64 ");
2499 sprintf(buf,
"-boot_image any hppa_kernel_64=");
2502 }
else if(strcmp(name,
"HP-PA ramdisk :") == 0) {
2504 sprintf(buf,
"-hppa-ramdisk ");
2506 sprintf(buf,
"-boot_image any hppa_ramdisk=");
2509 }
else if(strcmp(name,
"HP-PA bootloader :") == 0) {
2511 sprintf(buf,
"-hppa-bootloader ");
2513 sprintf(buf,
"-boot_image any hppa_bootloader=");
2516 }
else if(strcmp(name,
"DEC Alpha ldr adr :") == 0) {
2517 if(!have_alpha_ldr_path) {
2519 "Cannot enable DEC Alpha boot loader because it is not a data file in the ISO filesystem");
2524 }
else if(strcmp(name,
"DEC Alpha ldr path :") == 0) {
2526 sprintf(buf,
"-alpha-boot ");
2528 sprintf(buf,
"-boot_image any alpha_boot=");
2537 if(appended_as_gpt == 2) {
2539 sprintf(buf,
"-appended_part_as_gpt");
2541 sprintf(buf,
"-boot_image any appended_part_as=gpt");
2545 if(have_sparc_part) {
2546 if(full_sparc_part == 255) {
2548 sprintf(buf,
"-G ");
2553 sprintf(buf,
"-B ...");
2556 sprintf(buf,
"-boot_image any system_area=");
2561 for(i= 2; i <= 8; i++) {
2562 sprintf(buf,
"-append_partition %d 0x00 .", i);
2567 }
else if(!cared_for_sparc) {
2569 "Cannot enable SUN Disk Label because of non-trivial partition layout");
2574 if(have_sysarea && !did_sysarea) {
2577 sprintf(buf,
"-G ");
2579 sprintf(buf,
"-boot_image any system_area=");
2581 imported_iso | ptable_killer);
2586 strcpy(buf,
"systemarea.img/");
2590 if(iso_mbr_part_type >= 0) {
2592 sprintf(buf,
"-iso_mbr_part_type 0x%2.2x",
2593 (
unsigned int) iso_mbr_part_type);
2595 sprintf(buf,
"-boot_image any iso_mbr_part_type=0x%2.2x",
2596 (
unsigned int) iso_mbr_part_type);
2599 }
else if(iso_gpt_part_idx >= 0) {
2601 sprintf(buf,
"-iso_mbr_part_type ");
2603 sprintf(buf,
"-boot_image any iso_mbr_part_type=");
2612 goto after_el_torito;
2614 if(efi_boot_part == 1) {
2616 sprintf(buf,
"-efi-boot-part --efi-boot-image");
2618 sprintf(buf,
"-boot_image any efi_boot_part=--efi-boot-image");
2623 sprintf(buf,
"-c ");
2625 sprintf(buf,
"-boot_image any cat_path=");
2629 sprintf(buf,
"--boot-catalog-hide");
2631 sprintf(buf,
"-boot_image any cat_hidden=on");
2634 for(idx= 0; idx < elto_count; idx++) {
2635 if(strcmp(et_imgs[idx].pltf,
"UEFI") == 0 &&
2636 et_imgs[idx].extract_size <= 0) {
2639 if(indev_blocks > et_imgs[idx].lba &&
2643 if(et_imgs[idx].extract_size <= 0)
2646 sprintf(buf,
"eltorito_img%d_", idx + 1);
2647 for(j= 0; j < 4 && et_imgs[idx].
pltf[j] != 0; j++) {
2648 buf[strlen(buf) + 1]= 0;
2649 buf[strlen(buf)]= tolower(et_imgs[idx].pltf[j]);
2651 strcat(buf,
".img/");
2653 ((off_t) et_imgs[idx].extract_size) * 2048, 0);
2656 if(et_imgs[idx].ld_seg != 0 && et_imgs[idx].ld_seg != 0x07c0) {
2659 "Cannot enable EL Torito boot image #%d because its Load Segment is neither 0x0 nor 0x7c0",
2667 sprintf(buf,
"-eltorito-alt-boot");
2669 sprintf(buf,
"-boot_image any next");
2672 if(et_imgs[idx].path[0] == 0) {
2674 for(i= 0; i < mbr_count; i++)
2675 if((mbrpts[i].appended || !mbrpts[i].has_path) &&
2676 mbrpts[i].start_block == ((uint64_t) et_imgs[idx].lba) * 4 &&
2677 (mbrpts[i].block_count == (uint64_t) et_imgs[idx].ldsiz ||
2678 et_imgs[idx].ldsiz == 0 || et_imgs[idx].ldsiz == 1))
2680 if (i < mbr_count) {
2681 if(!mbrpts[i].appended) {
2682 mbrpts[i].appended= 1;
2683 if(!appended_as_gpt) {
2684 sprintf(buf,
"-append_partition %lu 0x%lx ", (
unsigned long) i + 1,
2685 (
unsigned long) mbrpts[i].ptype);
2687 (uint64_t) mbrpts[i].start_block,
2688 ((uint64_t) mbrpts[i].start_block) +
2689 mbrpts[i].block_count - 1,
2693 #ifdef Not_any_more_because_padding_is_now_after_partitions
2694 appended_partition= 1;
2700 sprintf(app_pseudo_paths[idx],
2701 "--interval:appended_partition_%d_start_%lus_size_%lud:all::",
2703 (
unsigned long) et_imgs[idx].lba,
2704 (
unsigned long) mbrpts[i].block_count);
2705 et_imgs[idx].
path= app_pseudo_paths[idx];
2707 if (et_imgs[idx].path[0] == 0 && efi_boot_part != 2) {
2708 for(i= 0; i < gpt_count; i++) {
2709 if(have_protective_msdos && (
2710 gpts[i].start_block == ((uint64_t) et_imgs[idx].lba) * 4 &&
2711 (gpts[i].block_count == (uint64_t) et_imgs[idx].ldsiz ||
2712 et_imgs[idx].ldsiz == 0 || et_imgs[idx].ldsiz == 1)))
2715 if (i < gpt_count) {
2716 sprintf(app_pseudo_paths[idx],
2717 "--interval:appended_partition_%d_start_%lus_size_%lud:all::",
2719 (
unsigned long) et_imgs[idx].lba,
2720 (
unsigned long) gpts[i].block_count);
2721 et_imgs[idx].
path= app_pseudo_paths[idx];
2725 if (et_imgs[idx].path[0] == 0) {
2731 if (et_imgs[idx].path[0] == 0) {
2734 "Cannot enable EL Torito boot image #%d because it is not a data file in the ISO filesystem",
2742 if(et_imgs[idx].platform_id != 0xef) {
2744 if(prev_pltf != et_imgs[idx].platform_id) {
2745 sprintf(buf,
"-eltorito-platform 0x%2.2x", et_imgs[idx].platform_id);
2749 sprintf(buf,
"-b ");
2751 sprintf(buf,
"-boot_image %s bin_path=", et_imgs[idx].boot_image_type);
2755 sprintf(buf,
"-e ");
2757 sprintf(buf,
"-boot_image %s efi_path=", et_imgs[idx].boot_image_type);
2762 sprintf(buf,
"-boot_image any platform_id=0x%2.2x",
2763 et_imgs[idx].platform_id);
2766 if(strcmp(et_imgs[idx].emul,
"none") == 0) {
2768 sprintf(buf,
"-no-emul-boot");
2770 sprintf(buf,
"-boot_image any emul_type=no_emulation");
2771 }
else if(strcmp(et_imgs[idx].emul,
"hd") == 0) {
2773 sprintf(buf,
"-hard-disk-boot");
2775 sprintf(buf,
"-boot_image any emul_type=hard_disk");
2780 sprintf(buf,
"-boot_image any emul_type=diskette");
2784 if(et_imgs[idx].ldsiz >= 0) {
2786 sprintf(buf,
"-boot-load-size %d", et_imgs[idx].ldsiz);
2788 sprintf(buf,
"-boot_image any load_size=%d", et_imgs[idx].ldsiz * 512);
2793 sprintf(buf,
"-boot-info-table");
2795 sprintf(buf,
"-boot_image any boot_info_table=on");
2798 if(et_imgs[idx].grub2_boot_info) {
2800 sprintf(buf,
"--grub2-boot-info");
2802 sprintf(buf,
"-boot_image grub grub2_boot_info=on");
2805 if(et_imgs[idx].id_string[0] != 0) {
2807 sprintf(buf,
"-eltorito-id ");
2809 sprintf(buf,
"-boot_image any id_string=");
2813 if(et_imgs[idx].sel_crit[0] != 0) {
2815 sprintf(buf,
"-eltorito-selcrit ");
2817 sprintf(buf,
"-boot_image any sel_crit=");
2821 if(et_imgs[idx].do_gpt_basdat) {
2823 sprintf(buf,
"-isohybrid-gpt-basdat");
2825 sprintf(buf,
"-boot_image isolinux partition_entry=gpt_basdat");
2828 if(et_imgs[idx].do_gpt_hfsplus) {
2830 sprintf(buf,
"-isohybrid-gpt-hfsplus");
2832 sprintf(buf,
"-boot_image isolinux partition_entry=gpt_hfsplus");
2835 if(et_imgs[idx].do_apm_hfsplus) {
2837 sprintf(buf,
"-isohybrid-apm-hfsplus");
2839 sprintf(buf,
"-boot_image isolinux partition_entry=apm_hfsplus");
2845 if((apm_count > 0 && !cared_for_apm) && !(flag & 5)) {
2847 "Cannot make proposal to produce APM of loaded image");
2851 #ifdef Not_any_more_because_padding_is_now_after_partitions
2853 if(appended_partition) {
2855 sprintf(buf,
"-no-pad");
2857 sprintf(buf,
"-padding 0");
2870 if(app_pseudo_paths != NULL) {
2871 for(i= 0; i < elto_count; i++)
2872 if(app_pseudo_paths[i] != NULL)
2881 #undef Xorriso_record_cmd_linE
2882 #undef Xorriso_record_boot_imglinE
2883 #undef Xorriso_max_endless_uefi_sizE
2895 char **et_lines,
int et_line_count,
2896 char **sa_lines,
int sa_line_count,
2897 char ***cmds,
int *cmd_count,
2898 char ***boot_imgs,
int *boot_img_count,
2903 if(flag & (1 << 15))
2910 sa_lines, sa_line_count, *cmds, cmd_count,
2911 *boot_imgs, boot_img_count,
2916 if(*cmd_count <= 0 && *boot_img_count <= 0)
2918 if(*cmd_count > 0) {
2920 for(i= 0; i < *cmd_count; i++)
2923 if(*boot_img_count > 0) {
2925 for(i= 0; i < *boot_img_count; i++)
2926 (*boot_imgs)[i]= NULL;
2931 sa_lines, sa_line_count, *cmds, cmd_count,
2932 *boot_imgs, boot_img_count,
2939 if(ret <= 0 || (flag & (1 << 15))) {
2941 for(i= 0; i < *cmd_count; i++)
2942 if((*cmds)[i] != NULL)
2947 if(*boot_imgs != NULL) {
2948 for(i= 0; i < *boot_img_count; i++)
2949 if((*boot_imgs)[i] != NULL)
2961 char **lines,
int line_count)
2965 for(i = 0; i < line_count ; i++) {
2977 int ret, line_count, cmd_count= 0, et_line_count= 0, sa_line_count= 0;
2978 int do_cmd= 0, as_mkisofs= 0, i, bin_count, boot_img_count= 0;
2979 char **lines = NULL, **et_lines= NULL, **sa_lines= NULL, **cmds= NULL;
2980 char **boot_imgs= NULL;
2984 if(strcmp(form,
"cmd") == 0 || strcmp(form,
"as_mkisofs") == 0 || (flag & 2))
2986 if(strcmp(form,
"as_mkisofs") == 0)
2989 if(strcmp(form,
"help") == 0) {
2997 "------------------------------------------------------------------------------\n");
3000 sprintf(xorriso->
result_line,
"With -report_el_torito \"plain\":\n");
3002 sprintf(xorriso->
result_line,
"With -report_system_area \"plain\":\n");
3005 "------------------------------------------------------------------------------\n");
3010 }
else if(strcmp(form,
"") == 0 || strcmp(form,
"plain") == 0 || do_cmd) {
3014 if(do_cmd || (flag & 1))
3018 if(do_cmd || !(flag & 1))
3024 sa_lines, sa_line_count, &cmds, &cmd_count,
3025 &boot_imgs, &boot_img_count,
3026 (flag & 1) | (as_mkisofs << 1));
3031 }
else if(strncmp(form,
"gpt_crc_of:", 11) == 0 && !(flag & 1)) {
3035 }
else if(strcmp(form,
"make_guid") == 0 && !(flag & 1)) {
3043 }
else if(strcmp(form,
"gpt_disk_guid") == 0 && !(flag & 1)) {
3050 for(i= 0; i < sa_line_count; i++) {
3051 if(strncmp(sa_lines[i],
"GPT disk GUID : ", 26) == 0) {
3052 ret=
Hex_to_bin(sa_lines[i] + 26, 16, &bin_count, guid, 0);
3053 if(ret < 0 || bin_count != 16)
3067 "%s form parameter not recognized: ",
3068 flag & 1 ?
"-report_el_torito" :
"-report_system_area");
3077 line_count= et_line_count;
3080 line_count= sa_line_count;
3083 if(lines == NULL || ret == 0) {
3085 strcpy(xorriso->
info_text,
"No El Torito information was loaded");
3087 strcpy(xorriso->
info_text,
"No System Area was loaded");
3091 if(line_count == 0) {
3093 strcpy(xorriso->
info_text,
"No El Torito information available");
3095 strcpy(xorriso->
info_text,
"System Area only contains 0-bytes");
3103 "-boot_image any discard -boot_image any system_area=/dev/zero",
3107 for(i= 0; i < cmd_count; i++) {
3113 "Replayed %d boot related commands", cmd_count);
3117 "No proposals available for boot related commands",
3129 &boot_imgs, &boot_img_count, 1 << 15);
3130 if(et_lines != NULL)
3132 if(sa_lines != NULL)
3141 char ***imgs,
int *img_count,
int flag)
3143 int ret, cmd_count= 0, et_line_count= 0, sa_line_count= 0, boot_img_count= 0;
3144 char **et_lines= NULL, **sa_lines= NULL, **cmds= NULL, **boot_imgs= NULL;
3147 if(flag & (1 << 15)) {
3149 boot_img_count= *img_count;
3151 &boot_imgs, &boot_img_count, 1 << 15);
3170 sa_lines, sa_line_count, &cmds, &cmd_count,
3171 &boot_imgs, &boot_img_count, 4);
3175 *img_count= boot_img_count;
3181 &boot_imgs, &boot_img_count, 1 << 15);
3182 if(et_lines != NULL)
3184 if(sa_lines != NULL)
int Xorriso_destroy_di_array(struct XorrisO *xorriso, int flag)
int Xorriso_destroy_hln_array(struct XorrisO *xorriso, int flag)
int isoburn_drive_aquire(struct burn_drive_info *drive_infos[], char *adr, int flag)
int isoburn_get_mount_params(struct burn_drive *d, int adr_mode, char *adr_value, int *lba, int *track, int *session, char volid[33], int flag)
int isoburn_read_iso_head(struct burn_drive *d, int lba, int *image_blocks, char *info, int flag)
void isoburn_drive_release(struct burn_drive *drive, int eject)
int Xorriso_afile_fopen(struct XorrisO *xorriso, char *filename, char *mode, FILE **ret_fp, int flag)
int Xorriso_make_mount_cmd(struct XorrisO *xorriso, char *cmd, int lba, int track, int session, char *volid, char *devadr, char result[4096], int flag)
int burn_drive_convert_fs_adr(char *path, char adr[])
void burn_drive_info_free(struct burn_drive_info drive_infos[])
int Xorriso_toc_line(struct XorrisO *xorriso, int flag)
int Xorriso_msinfo(struct XorrisO *xorriso, int *msc1, int *msc2, int flag)
int Xorriso_obtain_indev_readsize(struct XorrisO *xorriso, uint32_t *blocks, int flag)
int Xorriso_get_drive_handles(struct XorrisO *xorriso, struct burn_drive_info **dinfo, struct burn_drive **drive, char *attempt, int flag)
int Xorriso_toc(struct XorrisO *xorriso, int flag)
int Xorriso_give_up_drive(struct XorrisO *xorriso, int flag)
int iso_image_get_all_boot_imgs(IsoImage *image, int *num_boots, ElToritoBootImage ***boots, IsoFile ***bootnodes, int flag)
int el_torito_get_boot_platform_id(ElToritoBootImage *bootimg)
int el_torito_get_boot_media_type(ElToritoBootImage *bootimg, enum eltorito_boot_media_type *media_type)
int iso_image_get_boot_image(IsoImage *image, ElToritoBootImage **boot, IsoFile **imgnode, IsoBoot **catnode)
int el_torito_get_selection_crit(ElToritoBootImage *bootimg, uint8_t crit[20])
int el_torito_get_id_string(ElToritoBootImage *bootimg, uint8_t id_string[28])
int el_torito_get_isolinux_options(ElToritoBootImage *bootimg, int flag)
int el_torito_seems_boot_info_table(ElToritoBootImage *bootimg, int flag)
int el_torito_get_load_size(ElToritoBootImage *bootimg)
static off_t file_size(struct burn_source *source)
int Findjob_set_action_target(struct FindjoB *o, int action, char *target, int flag)
int Findjob_set_action_type(struct FindjoB *o, int action, int type, int flag)
int Findjob_destroy(struct FindjoB **o, int flag)
int Findjob_new(struct FindjoB **o, char *start_path, int flag)
int Findjob_get_last_data_file_block(struct FindjoB *o, uint32_t *lba, int flag)
int iso_image_report_el_torito(IsoImage *image, char ***reply, int *line_count, int flag)
int iso_image_report_system_area(IsoImage *image, char ***result, int *line_count, int flag)
int iso_image_add_mips_boot_file(IsoImage *image, char *path, int flag)
void iso_image_unref(IsoImage *image)
int iso_image_set_hppa_palo(IsoImage *img, char *cmdline, char *bootloader, char *kernel_32, char *kernel_64, char *ramdisk, int flag)
int iso_image_get_pvd_times(IsoImage *image, char **creation_time, char **modification_time, char **expiration_time, char **effective_time)
int iso_image_get_hppa_palo(IsoImage *img, char **cmdline, char **bootloader, char **kernel_32, char **kernel_64, char **ramdisk)
int iso_image_get_session_md5(IsoImage *image, uint32_t *start_lba, uint32_t *end_lba, char md5[16], int flag)
int iso_image_give_up_mips_boot(IsoImage *image, int flag)
int iso_image_get_alpha_boot(IsoImage *img, char **boot_loader_path)
const char * iso_image_get_volume_id(const IsoImage *image)
void iso_image_set_volume_id(IsoImage *image, const char *volume_id)
const char * iso_image_get_data_preparer_id(const IsoImage *image)
void iso_image_set_ignore_aclea(IsoImage *image, int what)
int iso_image_get_mips_boot_files(IsoImage *image, char *paths[15], int flag)
int iso_image_set_alpha_boot(IsoImage *img, char *boot_loader_path, int flag)
void burn_preset_device_open(int exclusive, int blocking, int abort_on_busy)
int Xorriso_update_volid(struct XorrisO *xorriso, int flag)
int Xorriso_set_hppa_boot_parm(struct XorrisO *xorriso, char *text, char *what, int flag)
int Xorriso_set_ignore_aclea(struct XorrisO *xorriso, int flag)
int Xorriso_set_volid(struct XorrisO *xorriso, char *volid, int flag)
int Xorriso_boot_item_status(struct XorrisO *xorriso, char *cat_path, char *bin_path, int platform_id, int patch_isolinux, int emul, off_t load_size, unsigned char *id_string, unsigned char *selection_crit, char *form, char *filter, FILE *fp, int flag)
int Xorriso_set_change_pending(struct XorrisO *xorriso, int flag)
#define Xorriso_record_cmd_linE
static int Xorriso_report_to_cmd(struct XorrisO *xorriso, char **et_lines, int et_line_count, char **sa_lines, int sa_line_count, char ***cmds, int *cmd_count, char ***boot_imgs, int *boot_img_count, int flag)
int Xorriso_boot_image_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
int Xorriso_boot_status_non_mbr(struct XorrisO *xorriso, IsoImage *image, char *filter, FILE *fp, int flag)
int Xorriso__append_boot_params(char *line, ElToritoBootImage *bootimg, int flag)
int Xorriso_get_volid(struct XorrisO *xorriso, char volid[33], int flag)
static int Xorriso_scan_report_lines(struct XorrisO *xorriso, char **et_lines, int et_line_count, char **sa_lines, int sa_line_count, char **cmds, int *cmd_count, char **boot_imgs, int *boot_img_count, int flag)
int Xorriso_report_system_area(struct XorrisO *xorriso, char *form, int flag)
int Xorriso_add_offset_size(struct XorrisO *xorriso, char *buf, off_t byte_offset, off_t byte_size, int flag)
int Xorriso_status_hppa(struct XorrisO *xorriso, char *what, char *value, char *filter, FILE *fp, int flag)
int Xorriso_record_cmd_line(struct XorrisO *xorriso, char *buf, char **cmds, int *cmd_count, int flag)
int Xorriso_change_is_pending(struct XorrisO *xorriso, int flag)
static int Xorriso_report_pvd_time(struct XorrisO *xorriso, char *head, char *pvd_time, int flag)
int Xorriso_create_empty_iso(struct XorrisO *xorriso, int flag)
int Xorriso_show_boot_info(struct XorrisO *xorriso, int flag)
static int Xorriso_search_eltorito_path(struct XorrisO *xorriso, struct elto_img_par *et_imgs, int elto_count, char *path, int ptype, int *found, int *efi_boot_part, int flag)
static int Xorriso_search_eltorito_lba(struct XorrisO *xorriso, struct elto_img_par *et_imgs, int elto_count, unsigned int lba, int *found, int flag)
int Xorriso_gpt_crc(struct XorrisO *xorriso, char *path, int flag)
int Xorriso_is_isohybrid(struct XorrisO *xorriso, IsoFile *bootimg_node, int flag)
static int Xorriso_split_report_line(struct XorrisO *xorriso, char *line, int num_limit, char *name, char **contentpt, double *num, int *num_count, char **textpt, int flag)
int Xorriso_append_part_status(struct XorrisO *xorriso, IsoImage *image, char *filter, FILE *fp, int flag)
int Xorriso_mount(struct XorrisO *xorriso, char *dev, int adr_mode, char *adr_value, char *cmd, int flag)
int Xorriso_assert_volid(struct XorrisO *xorriso, int msc1, int flag)
int Xorriso_image_has_md5(struct XorrisO *xorriso, int flag)
int Xorriso_pvd_info(struct XorrisO *xorriso, int flag)
int Xorriso_highest_data_block(struct XorrisO *xorriso, uint32_t *high_block, int flag)
int Xorriso_set_alpha_boot(struct XorrisO *xorriso, char *path, int flag)
int Xorriso_list_boot_images(struct XorrisO *xorriso, char ***imgs, int *img_count, int flag)
#define Xorriso_record_boot_imglinE
int Xorriso_add_mips_boot_file(struct XorrisO *xorriso, char *path, int flag)
int Xorriso_coordinate_system_area(struct XorrisO *xorriso, int sa_type, int options, char *cmd, int flag)
static const char * un0(const char *text)
int Xorriso_record_boot_info(struct XorrisO *xorriso, int flag)
static void Xorriso_report_lines(struct XorrisO *xorriso, char **lines, int line_count)
static int Xorriso_register_eltorito_gpt(struct XorrisO *xorriso, struct elto_img_par *et_img, int ptype, int *efi_boot_part, int *first_efi, int flag)
int Xorriso_add_intvl_adr(struct XorrisO *xorriso, char *buf, uint64_t start_adr, uint64_t end_adr, char *suffix, int flag)
#define Xorriso_max_endless_uefi_sizE
int Xorriso_get_volume(struct XorrisO *xorriso, IsoImage **volume, int flag)
int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job, void *boss_iter, off_t boss_mem, void *dir_node_generic, char *dir_path, struct stat *dir_stbuf, int depth, int flag)
int Xorriso__file_start_lba(IsoNode *node, int *lba, int flag)
int Xorriso_iso_lstat(struct XorrisO *xorriso, char *path, struct stat *stbuf, int flag)
int Xorriso_path_from_node(struct XorrisO *xorriso, IsoNode *in_node, char path[4096], int flag)
int Xorriso_path_from_lba(struct XorrisO *xorriso, IsoNode *node, int lba, char path[4096], int flag)
int isoburn_ropt_destroy(struct isoburn_read_opts **o, int flag)
int isoburn_ropt_set_data_cache(struct isoburn_read_opts *o, int cache_tiles, int tile_blocks, int flag)
int isoburn_ropt_new(struct isoburn_read_opts **new_o, int flag)
int isoburn_ropt_set_extensions(struct isoburn_read_opts *o, int ext)
int isoburn_ropt_set_input_charset(struct isoburn_read_opts *o, char *input_charset)
int isoburn_ropt_set_truncate_mode(struct isoburn_read_opts *o, int mode, int length)
int isoburn_set_read_pacifier(struct burn_drive *drive, int(*read_pacifier)(IsoImage *, IsoFileSource *), void *read_handle)
int isoburn_read_image(struct burn_drive *d, struct isoburn_read_opts *read_opts, IsoImage **image)
IsoImage * isoburn_get_attached_image(struct burn_drive *d)
int Xorriso_report_iso_error(struct XorrisO *xorriso, char *victim, int iso_error_code, char msg_text[], int os_errno, char min_severity[], int flag)
int Xorriso_format_guid(struct XorrisO *xorriso, uint8_t guid[16], char *line, int flag)
int Xorriso_make_guid(struct XorrisO *xorriso, char *line, int flag)
int Xorriso_process_msg_queues(struct XorrisO *xorriso, int flag)
int burn_read_data(struct burn_drive *d, off_t byte_address, char data[], off_t data_size, off_t *data_count, int flag)
#define BURN_DRIVE_ADR_LEN
#define isoburn_ropt_pretend_blank
@ ELTORITO_HARD_DISC_EMUL
uint32_t iso_crc32_gpt(unsigned char *data, int count, int flag)
int Xorriso__bourne_to_reg(char bourne_expr[], char reg_expr[], int flag)
int Sregex_match(char *pattern, char *text, int flag)
char * Text_shellsafe(char *in_text, char *out_text, int flag)
int Xorriso__format_guid(uint8_t guid[16], char *text, int flag)
char * Xorriso__hide_mode_text(int hide_mode, int flag)
int Hex_to_bin(char *hex, int bin_size, int *bin_count, unsigned char *bin_data, int flag)
int System_uname(char **sysname, char **release, char **version, char **machine, int flag)
int Decode_ecma119_format(struct tm *erg, char *text, int flag)
int Xorriso_execute_option(struct XorrisO *xorriso, char *line, int flag)
int Xorriso_execv(struct XorrisO *xorriso, char *cmd, int in_argc, char **in_argv, char *env_path, int *stdin_pipe, int *stdout_pipe, pid_t *forked_pid, int *status, int flag)
int Xorriso_iso_file_open(struct XorrisO *xorriso, char *pathname, void *node_pt, void **stream, int flag)
int Xorriso_iso_file_close(struct XorrisO *xorriso, void **stream, int flag)
int Xorriso_iso_file_read(struct XorrisO *xorriso, void *stream, char *buf, int count, int flag)
int Sfile_off_t_text(char text[80], off_t num, int flag)
#define Xorriso_free_meM(pt)
#define Xorriso_alloc_meM(pt, typ, count)
unsigned char boot_id_string[29]
int boot_image_cat_hidden
char boot_image_bin_form[16]
uint8_t appended_part_gpt_flags[8]
int linux_scsi_dev_family
char boot_image_cat_path[4096]
char result_line[10 *4096]
int volset_change_pending
char loaded_boot_cat_path[4096]
struct SectorbitmaP * in_sector_map
unsigned char boot_selection_crit[21]
char * appended_partitions[8]
uint8_t appended_part_type_guids[8][16]
char ascii_disc_label[129]
char system_area_disk_path[4096]
int system_area_clear_loaded
char boot_image_bin_path[4096]
off_t boot_image_load_size
char assert_volid_sev[80]
char grub2_sparc_core[4096]
uint8_t appended_part_types[8]
struct burn_drive * drive
enum burn_disc_status status
unsigned long int extract_size
int Xorriso_msgs_submit(struct XorrisO *xorriso, int error_code, char msg_text[], int os_errno, char severity[], int flag)
int Xorriso_no_findjob(struct XorrisO *xorriso, char *cmd, int flag)
int Xorriso_info(struct XorrisO *xorriso, int flag)
int Xorriso_status_result(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
int Xorriso_result(struct XorrisO *xorriso, int flag)
int Xorriso_parse_guid(struct XorrisO *xorriso, char *text, uint8_t guid[16], int flag)
#define Xorriso_max_appended_partitionS