|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
|
|
|
|
|
/* xorriso - creates, loads, manipulates and burns ISO 9660 filesystem images.
|
|
|
|
|
|
|
|
|
|
Copyright 2007-2019 Thomas Schmitt, <scdbackup@gmx.net>
|
|
|
|
|
Copyright 2007-2020 Thomas Schmitt, <scdbackup@gmx.net>
|
|
|
|
|
|
|
|
|
|
Provided under GPL version 2 or later.
|
|
|
|
|
|
|
|
|
@ -1538,11 +1538,22 @@ int Xorriso_add_intvl_adr(struct XorrisO *xorriso, char *buf,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Xorriso_add_offset_size(struct XorrisO *xorriso, char *buf,
|
|
|
|
|
off_t byte_offset, off_t byte_size, int flag)
|
|
|
|
|
{
|
|
|
|
|
strcat(buf, " ");
|
|
|
|
|
Sfile_off_t_text(buf + strlen(buf), byte_offset, 0);
|
|
|
|
|
strcat(buf, " ");
|
|
|
|
|
Sfile_off_t_text(buf + strlen(buf), byte_size, 0);
|
|
|
|
|
return(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct elto_img_par {
|
|
|
|
|
int n, ldsiz, boot_info_table, grub2_boot_info;
|
|
|
|
|
int do_gpt_basdat, do_gpt_hfsplus, do_apm_hfsplus;
|
|
|
|
|
unsigned int ld_seg, hdpt, platform_id;
|
|
|
|
|
unsigned long int lba;
|
|
|
|
|
unsigned long int lba, extract_size;
|
|
|
|
|
char pltf[8], b[8], emul[8], boot_image_type[16];
|
|
|
|
|
char *path, *id_string, *sel_crit;
|
|
|
|
|
};
|
|
|
|
@ -1644,11 +1655,14 @@ ex:;
|
|
|
|
|
|
|
|
|
|
/* @param flag bit0= do not record but only count
|
|
|
|
|
bit1= as_mkisofs
|
|
|
|
|
bit2= no sorry messages
|
|
|
|
|
*/
|
|
|
|
|
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, int flag)
|
|
|
|
|
char **cmds, int *cmd_count,
|
|
|
|
|
char **boot_imgs, int *boot_img_count,
|
|
|
|
|
int flag)
|
|
|
|
|
{
|
|
|
|
|
int ret= 0, i, num_count, mkisofs, line_count, idx, et_idx, isohybrid= 0;
|
|
|
|
|
int ptype, gpt_idx, j, pad, mbr_idx;
|
|
|
|
@ -1664,16 +1678,17 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
|
|
|
|
|
|
|
|
|
int iso_mbr_part_type= -1, iso_gpt_part_idx= -1;
|
|
|
|
|
unsigned int prev_pltf= 0;
|
|
|
|
|
unsigned long int sa_options= 0, partno, id_tag, perms, start_cyl, num_blocks;
|
|
|
|
|
unsigned long int part_status, part_type, start_block, partition_offset= 0;
|
|
|
|
|
uint32_t high_block= 0;
|
|
|
|
|
unsigned long int sa_options= 0, partno, id_tag, perms, start_cyl;
|
|
|
|
|
unsigned long int part_status, part_type, mbr_start_block, mbr_num_blocks;
|
|
|
|
|
unsigned long int partition_offset= 0;
|
|
|
|
|
uint32_t high_block= 0, indev_blocks;
|
|
|
|
|
char name[24], *textpt, *contentpt, *buf= NULL, part_type_text[37];
|
|
|
|
|
char **lines= NULL;
|
|
|
|
|
double num[8];
|
|
|
|
|
char *cat_path= "";
|
|
|
|
|
struct elto_img_par *et_imgs= NULL;
|
|
|
|
|
int elto_count= 0;
|
|
|
|
|
uint32_t img_blocks= 0, mbr_parts_end= 0, iso_part_blocks;
|
|
|
|
|
uint32_t mbr_parts_end= 0, extract_size;
|
|
|
|
|
struct FindjoB *job= NULL;
|
|
|
|
|
struct stat dir_stbuf;
|
|
|
|
|
IsoImage *image;
|
|
|
|
@ -1681,7 +1696,8 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
|
|
|
|
char **app_pseudo_paths= NULL;
|
|
|
|
|
struct tm tm_erg;
|
|
|
|
|
int was_force_bootable= 0, have_mbr_force_bootable= 0;
|
|
|
|
|
uint64_t gpt_bheader_block= 0;
|
|
|
|
|
uint64_t gpt_bheader_block= 0, start_block, num_blocks;
|
|
|
|
|
uint64_t img_blocks= 0, iso_part_blocks;
|
|
|
|
|
|
|
|
|
|
struct mbr_par {
|
|
|
|
|
uint8_t ptype;
|
|
|
|
@ -1714,14 +1730,26 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
|
|
|
|
|
|
|
|
|
#define Xorriso_record_cmd_linE { \
|
|
|
|
|
ret= Xorriso_record_cmd_line(xorriso, buf, cmds, cmd_count, flag & 1); \
|
|
|
|
|
buf[0]= 0; \
|
|
|
|
|
if(ret <= 0) \
|
|
|
|
|
goto ex; \
|
|
|
|
|
}
|
|
|
|
|
#define Xorriso_record_boot_imglinE { \
|
|
|
|
|
ret= Xorriso_record_cmd_line(xorriso, buf, boot_imgs, boot_img_count, \
|
|
|
|
|
flag & 1); \
|
|
|
|
|
buf[0]= 0; \
|
|
|
|
|
if(ret <= 0) \
|
|
|
|
|
goto ex; \
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 2 exp 19 blocks = 1 GiB */
|
|
|
|
|
#define Xorriso_max_endless_uefi_sizE (1 << 19)
|
|
|
|
|
|
|
|
|
|
mkisofs= !!(flag & 2);
|
|
|
|
|
imported_iso= (!mkisofs) << 30;
|
|
|
|
|
|
|
|
|
|
*cmd_count= 0;
|
|
|
|
|
*boot_img_count= 0;
|
|
|
|
|
line_count= et_line_count + sa_line_count;
|
|
|
|
|
if(line_count <= 0)
|
|
|
|
|
{ret= 1; goto ex;}
|
|
|
|
@ -1780,7 +1808,7 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
|
|
|
|
if(ret < 0)
|
|
|
|
|
goto ex;
|
|
|
|
|
if(ret == 0)
|
|
|
|
|
high_block = img_blocks - 1;
|
|
|
|
|
high_block = img_blocks / 4 - 1;
|
|
|
|
|
|
|
|
|
|
if(elto_count > 0) {
|
|
|
|
|
Xorriso_alloc_meM(et_imgs, struct elto_img_par, elto_count);
|
|
|
|
@ -1869,6 +1897,12 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
|
|
|
|
if(strcmp(name, "El Torito cat path :") == 0) {
|
|
|
|
|
cat_path= textpt;
|
|
|
|
|
|
|
|
|
|
} else if(strcmp(name, "El Torito catalog :") == 0) {
|
|
|
|
|
strcpy(buf, "eltorito_catalog.img/");
|
|
|
|
|
Xorriso_add_offset_size(xorriso, buf, ((off_t) num[0]) * 2048,
|
|
|
|
|
((off_t) num[1]) * 2048, 0);
|
|
|
|
|
Xorriso_record_boot_imglinE
|
|
|
|
|
|
|
|
|
|
} else if(strcmp(name, "El Torito boot img :") == 0) {
|
|
|
|
|
/* Platform Id, bootability, emulation, load segment,
|
|
|
|
|
Hard disk emulation partition type, Load size
|
|
|
|
@ -1895,10 +1929,22 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
|
|
|
|
et_imgs[idx].path= et_imgs[idx].id_string= et_imgs[idx].sel_crit= "";
|
|
|
|
|
et_imgs[idx].do_gpt_basdat= et_imgs[idx].do_gpt_hfsplus= 0;
|
|
|
|
|
et_imgs[idx].do_apm_hfsplus= 0;
|
|
|
|
|
et_imgs[idx].extract_size= (et_imgs[idx].ldsiz + 3) / 4;
|
|
|
|
|
|
|
|
|
|
} else if(strcmp(name, "El Torito img path :") == 0) {
|
|
|
|
|
idx= num[0] - 1;
|
|
|
|
|
et_imgs[idx].path= textpt;
|
|
|
|
|
ret= Xorriso_iso_lstat(xorriso, et_imgs[idx].path, &dir_stbuf, 0);
|
|
|
|
|
if(ret == 0) {
|
|
|
|
|
extract_size = (dir_stbuf.st_size + 2047) / 2048;
|
|
|
|
|
if(extract_size > et_imgs[idx].extract_size)
|
|
|
|
|
et_imgs[idx].extract_size= extract_size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if(strcmp(name, "El Torito img blks :") == 0) {
|
|
|
|
|
idx= num[0] - 1;
|
|
|
|
|
if(num[1] > et_imgs[idx].extract_size)
|
|
|
|
|
et_imgs[idx].extract_size= num[1];
|
|
|
|
|
|
|
|
|
|
} else if(strcmp(name, "El Torito img opts :") == 0) {
|
|
|
|
|
idx= num[0] - 1;
|
|
|
|
@ -1925,15 +1971,17 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
|
|
|
|
|
|
|
|
|
} else if(strcmp(name, "MBR partition :") == 0) {
|
|
|
|
|
sscanf(contentpt, "%lu 0x%lx 0x%lx %lu %lu",
|
|
|
|
|
&partno, &part_status, &part_type, &start_block, &num_blocks);
|
|
|
|
|
&partno, &part_status, &part_type, &mbr_start_block,
|
|
|
|
|
&mbr_num_blocks);
|
|
|
|
|
idx= partno - 1;
|
|
|
|
|
mbrpts[idx].ptype= part_type;
|
|
|
|
|
mbrpts[idx].start_block= start_block;
|
|
|
|
|
mbrpts[idx].block_count= num_blocks;
|
|
|
|
|
if(num_blocks > 0 && start_block + num_blocks > mbr_parts_end)
|
|
|
|
|
mbr_parts_end= start_block + num_blocks;
|
|
|
|
|
if(start_block == partition_offset * 4 &&
|
|
|
|
|
(start_block + num_blocks) >= high_block * 4 && iso_mbr_part_type < 0)
|
|
|
|
|
mbrpts[idx].start_block= mbr_start_block;
|
|
|
|
|
mbrpts[idx].block_count= mbr_num_blocks;
|
|
|
|
|
if(mbr_num_blocks > 0 && mbr_start_block + mbr_num_blocks > mbr_parts_end)
|
|
|
|
|
mbr_parts_end= mbr_start_block + mbr_num_blocks;
|
|
|
|
|
if(mbr_start_block == partition_offset * 4 &&
|
|
|
|
|
(mbr_start_block + mbr_num_blocks) >= high_block * 4 &&
|
|
|
|
|
iso_mbr_part_type < 0)
|
|
|
|
|
iso_mbr_part_type = part_type;
|
|
|
|
|
|
|
|
|
|
} else if(strcmp(name, "MBR partition path :") == 0) {
|
|
|
|
@ -2040,6 +2088,9 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
|
|
|
|
Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) 0, (uint64_t) 15, "s",
|
|
|
|
|
imported_iso | ptable_killer);
|
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
|
strcpy(buf, "mbr_code_isohybrid.img/");
|
|
|
|
|
Xorriso_add_offset_size(xorriso, buf, (off_t) 0, (off_t) 446, 0);
|
|
|
|
|
Xorriso_record_boot_imglinE
|
|
|
|
|
did_sysarea= 1;
|
|
|
|
|
}
|
|
|
|
|
if(strstr(textpt, "grub2-mbr") != NULL) {
|
|
|
|
@ -2050,6 +2101,9 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
|
|
|
|
Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) 0, (uint64_t) 15, "s",
|
|
|
|
|
imported_iso | ptable_killer);
|
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
|
strcpy(buf, "mbr_code_grub2.img/");
|
|
|
|
|
Xorriso_add_offset_size(xorriso, buf, (off_t) 0, (off_t) 446, 0);
|
|
|
|
|
Xorriso_record_boot_imglinE
|
|
|
|
|
did_sysarea= 1;
|
|
|
|
|
}
|
|
|
|
|
if(strstr(textpt, "protective-msdos-label") != NULL) {
|
|
|
|
@ -2100,16 +2154,18 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
|
|
|
|
|
|
|
|
|
} else if(strcmp(name, "MBR partition :") == 0) {
|
|
|
|
|
sscanf(contentpt, "%lu 0x%lx 0x%lx %lu %lu",
|
|
|
|
|
&partno, &part_status, &part_type, &start_block, &num_blocks);
|
|
|
|
|
if(num_blocks > 0 && part_type != 0x00 && part_type != 0xee &&
|
|
|
|
|
(iso_part_blocks <= start_block ||
|
|
|
|
|
&partno, &part_status, &part_type, &mbr_start_block,
|
|
|
|
|
&mbr_num_blocks);
|
|
|
|
|
if(mbr_num_blocks > 0 && part_type != 0x00 && part_type != 0xee &&
|
|
|
|
|
(iso_part_blocks <= mbr_start_block ||
|
|
|
|
|
(have_protective_msdos && img_blocks == mbr_parts_end &&
|
|
|
|
|
partno > 1))) {
|
|
|
|
|
if(!appended_as_gpt) {
|
|
|
|
|
sprintf(buf, "-append_partition %lu 0x%lx ", partno, part_type);
|
|
|
|
|
Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) start_block,
|
|
|
|
|
((uint64_t) start_block) + num_blocks - 1, "d",
|
|
|
|
|
imported_iso);
|
|
|
|
|
Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) mbr_start_block,
|
|
|
|
|
((uint64_t) mbr_start_block) + mbr_num_blocks - 1,
|
|
|
|
|
"d", imported_iso);
|
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
|
if(partno >= 1 && (int) partno <= mbr_count)
|
|
|
|
|
mbrpts[partno - 1].appended= 1;
|
|
|
|
|
|
|
|
|
@ -2118,21 +2174,36 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if(part_type == 0xef) {
|
|
|
|
|
sprintf(buf, "mbr_part%lu_efi.img/", partno);
|
|
|
|
|
Xorriso_add_offset_size(xorriso, buf, ((off_t) mbr_start_block) * 512,
|
|
|
|
|
((off_t) mbr_num_blocks) * 512, 0);
|
|
|
|
|
Xorriso_record_boot_imglinE
|
|
|
|
|
}
|
|
|
|
|
} else if(part_type == 0x41 && have_prep) {
|
|
|
|
|
if(mkisofs) {
|
|
|
|
|
sprintf(buf, "-prep-boot-part ");
|
|
|
|
|
} else {
|
|
|
|
|
sprintf(buf, "-boot_image any prep_boot_part=");
|
|
|
|
|
}
|
|
|
|
|
Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) start_block,
|
|
|
|
|
((uint64_t) start_block) + num_blocks - 1, "d",
|
|
|
|
|
imported_iso);
|
|
|
|
|
Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) mbr_start_block,
|
|
|
|
|
((uint64_t) mbr_start_block) + mbr_num_blocks - 1,
|
|
|
|
|
"d", imported_iso);
|
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
|
sprintf(buf, "mbr_part%lu_prep.img/", partno);
|
|
|
|
|
Xorriso_add_offset_size(xorriso, buf, ((off_t) mbr_start_block) * 512,
|
|
|
|
|
((off_t) mbr_num_blocks) * 512, 0);
|
|
|
|
|
Xorriso_record_boot_imglinE
|
|
|
|
|
} else if(part_type == 0xef) {
|
|
|
|
|
sprintf(buf, "mbr_part%lu_efi.img/", partno);
|
|
|
|
|
Xorriso_add_offset_size(xorriso, buf, ((off_t) mbr_start_block) * 512,
|
|
|
|
|
((off_t) mbr_num_blocks) * 512, 0);
|
|
|
|
|
Xorriso_record_boot_imglinE
|
|
|
|
|
}
|
|
|
|
|
if((part_status & 0x80) && !was_force_bootable) {
|
|
|
|
|
was_force_bootable= 1;
|
|
|
|
|
if(buf[0]) {
|
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
|
buf[0]= 0;
|
|
|
|
|
}
|
|
|
|
|
if(mkisofs)
|
|
|
|
|
sprintf(buf, "--mbr-force-bootable");
|
|
|
|
@ -2145,7 +2216,7 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
|
"Cannot make proposal to mark PReP partition by data file: ");
|
|
|
|
|
Text_shellsafe(textpt, xorriso->info_text, 1);
|
|
|
|
|
if(!(flag & 1))
|
|
|
|
|
if(!(flag & 5))
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
@ -2159,7 +2230,7 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
|
"Cannot make proposal to mark data file as MBR partition without being an El Torito boot image : ");
|
|
|
|
|
Text_shellsafe(textpt, xorriso->info_text, 1);
|
|
|
|
|
if(!(flag & 1))
|
|
|
|
|
if(!(flag & 5))
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
|
} else {
|
|
|
|
|
for(gpt_idx= 0; gpt_idx < gpt_count; gpt_idx++) {
|
|
|
|
@ -2171,7 +2242,7 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
|
"Cannot make proposal to mark data file as MBR partition without being in GPT : ");
|
|
|
|
|
Text_shellsafe(textpt, xorriso->info_text, 1);
|
|
|
|
|
if(!(flag & 1))
|
|
|
|
|
if(!(flag & 5))
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -2201,7 +2272,8 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
|
"Cannot make proposal to mark data file as GPT partition : ");
|
|
|
|
|
Text_shellsafe(textpt, xorriso->info_text, 1);
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
|
if(!(flag & 5))
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if(strcmp(name, "GPT start and size :") == 0) {
|
|
|
|
@ -2237,7 +2309,6 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
|
|
|
|
(uint64_t) (num[1] + num[2] - 1.0), "d",
|
|
|
|
|
imported_iso);
|
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
|
buf[0]= 0;
|
|
|
|
|
|
|
|
|
|
#ifdef Not_any_more_because_padding_is_now_after_partitions
|
|
|
|
|
appended_partition= 1;
|
|
|
|
@ -2264,7 +2335,6 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
|
|
|
|
else
|
|
|
|
|
sprintf(buf, "-boot_image any part_like_isohybrid=on");
|
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
|
buf[0]= 0;
|
|
|
|
|
part_like_isohybrid= 1;
|
|
|
|
|
appended_as_gpt= 0;
|
|
|
|
|
}
|
|
|
|
@ -2284,7 +2354,21 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
|
|
|
|
(uint64_t) (num[1] + num[2] - 1.0), "d",
|
|
|
|
|
imported_iso);
|
|
|
|
|
efi_boot_part= 2;
|
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(gpts[idx].ptype == 2 &&
|
|
|
|
|
(img_blocks / 2 > num[2] || num[1] >= img_blocks)) {
|
|
|
|
|
/* Obviously not a HFS+ tree covering the ISO */
|
|
|
|
|
sprintf(buf, "gpt_part%d_hfsplus.img/", idx + 1);
|
|
|
|
|
Xorriso_add_offset_size(xorriso, buf, ((off_t) num[1]) * 512,
|
|
|
|
|
((off_t) num[2]) * 512, 0);
|
|
|
|
|
Xorriso_record_boot_imglinE
|
|
|
|
|
} else if(gpts[idx].ptype == 3) {
|
|
|
|
|
sprintf(buf, "gpt_part%d_efi.img/", idx + 1);
|
|
|
|
|
Xorriso_add_offset_size(xorriso, buf, ((off_t) num[1]) * 512,
|
|
|
|
|
((off_t) num[2]) * 512, 0);
|
|
|
|
|
Xorriso_record_boot_imglinE
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if(strcmp(name, "APM block size :") == 0) {
|
|
|
|
@ -2326,7 +2410,6 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
|
|
|
|
else
|
|
|
|
|
sprintf(buf, "-hfsplus on");
|
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
|
buf[0]= 0;
|
|
|
|
|
|
|
|
|
|
/* Report commands for blessings and creator-type */
|
|
|
|
|
ret= Findjob_new(&job, "/", 0);
|
|
|
|
@ -2383,9 +2466,9 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
|
|
|
|
partno= id_tag= perms= num_blocks= 0;
|
|
|
|
|
start_cyl= 0xffffffff;
|
|
|
|
|
sscanf(contentpt, "%lu 0x%lx 0x%lx %lu %lu",
|
|
|
|
|
&partno, &id_tag, &perms, &start_cyl, &num_blocks);
|
|
|
|
|
&partno, &id_tag, &perms, &start_cyl, &mbr_num_blocks);
|
|
|
|
|
if(partno > 0 && partno < 9 && start_cyl == 0 &&
|
|
|
|
|
num_blocks >= img_blocks - 600 && num_blocks <= img_blocks &&
|
|
|
|
|
mbr_num_blocks >= img_blocks - 600 && mbr_num_blocks <= img_blocks &&
|
|
|
|
|
((partno == 1 && id_tag == 4) || (partno > 1 && id_tag == 2)))
|
|
|
|
|
full_sparc_part|= (1 << (partno - 1));
|
|
|
|
|
|
|
|
|
@ -2434,7 +2517,8 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
|
|
|
|
if(!have_alpha_ldr_path) {
|
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
|
"Cannot enable DEC Alpha boot loader because it is not a data file in the ISO filesystem");
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
|
if(!(flag & 5))
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if(strcmp(name, "DEC Alpha ldr path :") == 0) {
|
|
|
|
@ -2483,7 +2567,8 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
|
|
|
|
} else if(!cared_for_sparc) {
|
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
|
"Cannot enable SUN Disk Label because of non-trivial partition layout");
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
|
if(!(flag & 5))
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(have_sysarea && !did_sysarea) {
|
|
|
|
@ -2497,6 +2582,11 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
|
did_sysarea= 1;
|
|
|
|
|
}
|
|
|
|
|
if(have_sysarea) {
|
|
|
|
|
strcpy(buf, "systemarea.img/");
|
|
|
|
|
Xorriso_add_offset_size(xorriso, buf, (off_t) 0, (off_t) 16 * 2048, 0);
|
|
|
|
|
Xorriso_record_boot_imglinE
|
|
|
|
|
}
|
|
|
|
|
if(iso_mbr_part_type >= 0) {
|
|
|
|
|
if(mkisofs)
|
|
|
|
|
sprintf(buf, "-iso_mbr_part_type 0x%2.2x",
|
|
|
|
@ -2542,8 +2632,29 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
|
|
|
|
}
|
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
|
for(idx= 0; idx < elto_count; idx++) {
|
|
|
|
|
if(strcmp(et_imgs[idx].pltf, "UEFI") == 0 &&
|
|
|
|
|
et_imgs[idx].extract_size <= 0) {
|
|
|
|
|
ret= Xorriso_obtain_indev_readsize(xorriso, &indev_blocks, 0);
|
|
|
|
|
if(ret > 0) {
|
|
|
|
|
if(indev_blocks > et_imgs[idx].lba &&
|
|
|
|
|
indev_blocks - et_imgs[idx].lba <= Xorriso_max_endless_uefi_sizE)
|
|
|
|
|
et_imgs[idx].extract_size= indev_blocks - et_imgs[idx].lba;
|
|
|
|
|
}
|
|
|
|
|
if(et_imgs[idx].extract_size <= 0)
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
sprintf(buf, "eltorito_img%d_", idx + 1);
|
|
|
|
|
for(j= 0; j < 4 && et_imgs[idx].pltf[j] != 0; j++) {
|
|
|
|
|
buf[strlen(buf) + 1]= 0;
|
|
|
|
|
buf[strlen(buf)]= tolower(et_imgs[idx].pltf[j]);
|
|
|
|
|
}
|
|
|
|
|
strcat(buf, ".img/");
|
|
|
|
|
Xorriso_add_offset_size(xorriso, buf, ((off_t) et_imgs[idx].lba) * 2048,
|
|
|
|
|
((off_t) et_imgs[idx].extract_size) * 2048, 0);
|
|
|
|
|
Xorriso_record_boot_imglinE
|
|
|
|
|
|
|
|
|
|
if(et_imgs[idx].ld_seg != 0 && et_imgs[idx].ld_seg != 0x07c0) {
|
|
|
|
|
if(!(flag & 1)) {
|
|
|
|
|
if(!(flag & 5)) {
|
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
|
"Cannot enable EL Torito boot image #%d because its Load Segment is neither 0x0 nor 0x7c0",
|
|
|
|
|
idx + 1);
|
|
|
|
@ -2559,9 +2670,6 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
|
|
|
|
Xorriso_record_cmd_linE
|
|
|
|
|
}
|
|
|
|
|
if(et_imgs[idx].path[0] == 0) {
|
|
|
|
|
|
|
|
|
|
/* >>> need way to exploit El Torito img blks : */;
|
|
|
|
|
|
|
|
|
|
/* Check whether appended partition */;
|
|
|
|
|
for(i= 0; i < mbr_count; i++)
|
|
|
|
|
if((mbrpts[i].appended || !mbrpts[i].has_path) &&
|
|
|
|
@ -2613,8 +2721,15 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
|
|
|
|
et_imgs[idx].path= app_pseudo_paths[idx];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (et_imgs[idx].path[0] == 0) {
|
|
|
|
|
if(!(flag & 1)) {
|
|
|
|
|
|
|
|
|
|
/* >>> need way to exploit .extract_size by cutting out from ISO */;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (et_imgs[idx].path[0] == 0) {
|
|
|
|
|
if(!(flag & 5)) {
|
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
|
"Cannot enable EL Torito boot image #%d because it is not a data file in the ISO filesystem",
|
|
|
|
|
idx + 1);
|
|
|
|
@ -2727,7 +2842,7 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
|
|
|
|
}
|
|
|
|
|
after_el_torito:
|
|
|
|
|
|
|
|
|
|
if((apm_count > 0 && !cared_for_apm) && !(flag & 1)) {
|
|
|
|
|
if((apm_count > 0 && !cared_for_apm) && !(flag & 5)) {
|
|
|
|
|
sprintf(xorriso->info_text,
|
|
|
|
|
"Cannot make proposal to produce APM of loaded image");
|
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
|
|
|
|
@ -2764,19 +2879,24 @@ ex:
|
|
|
|
|
return(ret);
|
|
|
|
|
|
|
|
|
|
#undef Xorriso_record_cmd_linE
|
|
|
|
|
#undef Xorriso_record_boot_imglinE
|
|
|
|
|
#undef Xorriso_max_endless_uefi_sizE
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* @param flag bit0= currently not significant:
|
|
|
|
|
report is about El Torito rather than System Area
|
|
|
|
|
bit1= report -as mkisofs options
|
|
|
|
|
bit15= dispose cmds
|
|
|
|
|
bit1= report -as mkisofs options in cmds
|
|
|
|
|
bit2= no sorry messages
|
|
|
|
|
bit15= dispose cmds and boot_imgs
|
|
|
|
|
*/
|
|
|
|
|
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, int flag)
|
|
|
|
|
char ***cmds, int *cmd_count,
|
|
|
|
|
char ***boot_imgs, int *boot_img_count,
|
|
|
|
|
int flag)
|
|
|
|
|
{
|
|
|
|
|
int ret= 0, i;
|
|
|
|
|
|
|
|
|
@ -2788,20 +2908,29 @@ static int Xorriso_report_to_cmd(struct XorrisO *xorriso,
|
|
|
|
|
/* Count commands */
|
|
|
|
|
ret= Xorriso_scan_report_lines(xorriso, et_lines, et_line_count,
|
|
|
|
|
sa_lines, sa_line_count, *cmds, cmd_count,
|
|
|
|
|
1 | (flag & 2));
|
|
|
|
|
*boot_imgs, boot_img_count,
|
|
|
|
|
1 | (flag & 6));
|
|
|
|
|
if(ret <= 0)
|
|
|
|
|
goto ex;
|
|
|
|
|
|
|
|
|
|
if(*cmd_count <= 0)
|
|
|
|
|
if(*cmd_count <= 0 && *boot_img_count <= 0)
|
|
|
|
|
{ret= 2; goto ex;}
|
|
|
|
|
Xorriso_alloc_meM(*cmds, char *, *cmd_count);
|
|
|
|
|
for(i= 0; i < *cmd_count; i++)
|
|
|
|
|
(*cmds)[i]= NULL;
|
|
|
|
|
if(*cmd_count > 0) {
|
|
|
|
|
Xorriso_alloc_meM(*cmds, char *, *cmd_count);
|
|
|
|
|
for(i= 0; i < *cmd_count; i++)
|
|
|
|
|
(*cmds)[i]= NULL;
|
|
|
|
|
}
|
|
|
|
|
if(*boot_img_count > 0) {
|
|
|
|
|
Xorriso_alloc_meM(*boot_imgs, char *, *boot_img_count);
|
|
|
|
|
for(i= 0; i < *boot_img_count; i++)
|
|
|
|
|
(*boot_imgs)[i]= NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Record commands */
|
|
|
|
|
ret= Xorriso_scan_report_lines(xorriso, et_lines, et_line_count,
|
|
|
|
|
sa_lines, sa_line_count, *cmds, cmd_count,
|
|
|
|
|
flag & 2);
|
|
|
|
|
*boot_imgs, boot_img_count,
|
|
|
|
|
flag & 6);
|
|
|
|
|
if(ret <= 0)
|
|
|
|
|
goto ex;
|
|
|
|
|
|
|
|
|
@ -2815,6 +2944,13 @@ ex:
|
|
|
|
|
Xorriso_free_meM(*cmds);
|
|
|
|
|
*cmds= NULL;
|
|
|
|
|
}
|
|
|
|
|
if(*boot_imgs != NULL) {
|
|
|
|
|
for(i= 0; i < *boot_img_count; i++)
|
|
|
|
|
if((*boot_imgs)[i] != NULL)
|
|
|
|
|
Xorriso_free_meM((*boot_imgs)[i]);
|
|
|
|
|
Xorriso_free_meM(*boot_imgs);
|
|
|
|
|
*boot_imgs= NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return(ret);
|
|
|
|
|
}
|
|
|
|
@ -2839,8 +2975,9 @@ static void Xorriso_report_lines(struct XorrisO *xorriso,
|
|
|
|
|
int Xorriso_report_system_area(struct XorrisO *xorriso, char *form, int flag)
|
|
|
|
|
{
|
|
|
|
|
int ret, line_count, cmd_count= 0, et_line_count= 0, sa_line_count= 0;
|
|
|
|
|
int do_cmd= 0, as_mkisofs= 0, i, bin_count;
|
|
|
|
|
int do_cmd= 0, as_mkisofs= 0, i, bin_count, boot_img_count= 0;
|
|
|
|
|
char **lines = NULL, **et_lines= NULL, **sa_lines= NULL, **cmds= NULL;
|
|
|
|
|
char **boot_imgs= NULL;
|
|
|
|
|
uint8_t guid[16];
|
|
|
|
|
IsoImage *image;
|
|
|
|
|
|
|
|
|
@ -2885,10 +3022,12 @@ int Xorriso_report_system_area(struct XorrisO *xorriso, char *form, int flag)
|
|
|
|
|
if(do_cmd) {
|
|
|
|
|
ret= Xorriso_report_to_cmd(xorriso, et_lines, et_line_count,
|
|
|
|
|
sa_lines, sa_line_count, &cmds, &cmd_count,
|
|
|
|
|
&boot_imgs, &boot_img_count,
|
|
|
|
|
(flag & 1) | (as_mkisofs << 1));
|
|
|
|
|
if(ret <= 0)
|
|
|
|
|
goto ex;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if(strncmp(form, "gpt_crc_of:", 11) == 0 && !(flag & 1)) {
|
|
|
|
|
ret = Xorriso_gpt_crc(xorriso, form + 11, 0);
|
|
|
|
|
goto ex;
|
|
|
|
@ -2986,7 +3125,60 @@ int Xorriso_report_system_area(struct XorrisO *xorriso, char *form, int flag)
|
|
|
|
|
}
|
|
|
|
|
ret= 1;
|
|
|
|
|
ex:;
|
|
|
|
|
Xorriso_report_to_cmd(xorriso, NULL, 0, NULL, 0, &cmds, &cmd_count, 1 << 15);
|
|
|
|
|
Xorriso_report_to_cmd(xorriso, NULL, 0, NULL, 0, &cmds, &cmd_count,
|
|
|
|
|
&boot_imgs, &boot_img_count, 1 << 15);
|
|
|
|
|
if(et_lines != NULL)
|
|
|
|
|
iso_image_report_el_torito(NULL, &et_lines, &et_line_count, 1 << 15);
|
|
|
|
|
if(sa_lines != NULL)
|
|
|
|
|
iso_image_report_system_area(NULL, &sa_lines, &sa_line_count, 1 << 15);
|
|
|
|
|
return(ret);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* @param flag bit15= dispose imgs
|
|
|
|
|
*/
|
|
|
|
|
int Xorriso_list_boot_images(struct XorrisO *xorriso,
|
|
|
|
|
char ***imgs, int *img_count, int flag)
|
|
|
|
|
{
|
|
|
|
|
int ret, cmd_count= 0, et_line_count= 0, sa_line_count= 0, boot_img_count= 0;
|
|
|
|
|
char **et_lines= NULL, **sa_lines= NULL, **cmds= NULL, **boot_imgs= NULL;
|
|
|
|
|
IsoImage *image;
|
|
|
|
|
|
|
|
|
|
if(flag & (1 << 15)) {
|
|
|
|
|
boot_imgs= *imgs;
|
|
|
|
|
boot_img_count= *img_count;
|
|
|
|
|
Xorriso_report_to_cmd(xorriso, NULL, 0, NULL, 0, &cmds, &cmd_count,
|
|
|
|
|
&boot_imgs, &boot_img_count, 1 << 15);
|
|
|
|
|
*imgs= NULL;
|
|
|
|
|
*img_count= 0;
|
|
|
|
|
return(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*imgs= NULL;
|
|
|
|
|
*img_count= 0;
|
|
|
|
|
|
|
|
|
|
ret= Xorriso_get_volume(xorriso, &image, 0);
|
|
|
|
|
if(ret <= 0)
|
|
|
|
|
goto ex;
|
|
|
|
|
ret= iso_image_report_el_torito(image, &et_lines, &et_line_count, 0);
|
|
|
|
|
if(ret < 0)
|
|
|
|
|
goto ex;
|
|
|
|
|
ret= iso_image_report_system_area(image, &sa_lines, &sa_line_count, 0);
|
|
|
|
|
if(ret < 0)
|
|
|
|
|
goto ex;
|
|
|
|
|
ret= Xorriso_report_to_cmd(xorriso, et_lines, et_line_count,
|
|
|
|
|
sa_lines, sa_line_count, &cmds, &cmd_count,
|
|
|
|
|
&boot_imgs, &boot_img_count, 4);
|
|
|
|
|
if(ret <= 0)
|
|
|
|
|
goto ex;
|
|
|
|
|
*imgs= boot_imgs;
|
|
|
|
|
*img_count= boot_img_count;
|
|
|
|
|
boot_imgs= NULL;
|
|
|
|
|
boot_img_count= 0;
|
|
|
|
|
ret= 1;
|
|
|
|
|
ex:;
|
|
|
|
|
Xorriso_report_to_cmd(xorriso, NULL, 0, NULL, 0, &cmds, &cmd_count,
|
|
|
|
|
&boot_imgs, &boot_img_count, 1 << 15);
|
|
|
|
|
if(et_lines != NULL)
|
|
|
|
|
iso_image_report_el_torito(NULL, &et_lines, &et_line_count, 1 << 15);
|
|
|
|
|
if(sa_lines != NULL)
|
|
|
|
|