Emitting interval reader strings with -report_system_area cmd or as_mkisofs
This commit is contained in:
parent
f069bf4f2d
commit
8b4eca4391
@ -1485,6 +1485,30 @@ ex:;
|
||||
}
|
||||
|
||||
|
||||
/* @param flag bit0= zeroize MBR partition table
|
||||
bit1= zeroize GPT
|
||||
bit2= zeroize APM
|
||||
*/
|
||||
int Xorriso_add_intvl_adr(struct XorrisO *xorriso, char *buf,
|
||||
uint64_t start_adr, uint64_t end_adr, char *suffix,
|
||||
int flag)
|
||||
{
|
||||
sprintf(buf + strlen(buf), "--interval:local_fs:%.f%s-%.f%s:",
|
||||
(double) start_adr, suffix, (double) end_adr, suffix);
|
||||
if(flag & 1)
|
||||
strcat(buf, "zero_mbrpt,");
|
||||
if(flag & 2)
|
||||
strcat(buf, "zero_gpt,");
|
||||
if(flag & 4)
|
||||
strcat(buf, "zero_apm,");
|
||||
if(buf[strlen(buf) - 1] == ',')
|
||||
buf[strlen(buf) - 1] = 0;
|
||||
strcat(buf, ":");
|
||||
Text_shellsafe(xorriso->indev, buf, 1);
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
/* @param flag bit0= do not record but only count
|
||||
*/
|
||||
static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
||||
@ -1494,7 +1518,9 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
||||
{
|
||||
int ret= 0, i, num_count, mkisofs, line_count, idx, et_idx, isohybrid= 0;
|
||||
int efi_boot_part= 0, first_efi, full_sparc_part= 0, have_sparc_part= 0;
|
||||
int appended_as_gpt= 0;
|
||||
unsigned long int sa_options= 0, partno, id_tag, perms, start_cyl, num_blocks;
|
||||
unsigned long int part_status, part_type, start_block, have_prep= 0;
|
||||
char name[24], *textpt, *contentpt, *buf= NULL, *sa_summary= "";
|
||||
char **lines= NULL;
|
||||
double num[8];
|
||||
@ -1512,7 +1538,8 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
||||
uint32_t img_blocks= 0;
|
||||
|
||||
struct gpt_par {
|
||||
int ptype; /* 0= unknown, 1= gpt-basdat, 2=gpt-hfsplus */
|
||||
int ptype; /* 0= unknown, 1= gpt-basdat, 2=gpt-hfsplus, 3=EFI */
|
||||
int has_path;
|
||||
};
|
||||
struct gpt_par *gpts= NULL;
|
||||
int gpt_count= 0;
|
||||
@ -1522,6 +1549,7 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
||||
};
|
||||
struct apm_par *apms= NULL;
|
||||
int apm_count= 0;
|
||||
|
||||
#define Xorriso_record_cmd_linE { \
|
||||
ret= Xorriso_record_cmd_line(xorriso, buf, cmds, cmd_count, flag & 1); \
|
||||
if(ret <= 0) \
|
||||
@ -1558,6 +1586,9 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
||||
if(num[0] > elto_count)
|
||||
elto_count= num[0];
|
||||
|
||||
} else if(strcmp(name, "PReP boot partition:") == 0) {
|
||||
have_prep= 1;
|
||||
|
||||
} else if(strcmp(name, "GPT partition name :") == 0) {
|
||||
if(num[0] > gpt_count)
|
||||
gpt_count= num[0];
|
||||
@ -1646,9 +1677,22 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
||||
gpts[idx].ptype= 1; /* Basic data */
|
||||
else if(strcmp(textpt, "005346480000aa11aa1100306543ecac") == 0)
|
||||
gpts[idx].ptype= 2; /* HFS+ */
|
||||
else if(strcmp(textpt, "28732ac11ff8d211ba4b00a0c93ec93b") == 0)
|
||||
gpts[idx].ptype= 3; /* EFI System Partition */
|
||||
else
|
||||
gpts[idx].ptype= 0;
|
||||
|
||||
} else if(strcmp(name, "GPT start and size :") == 0) {
|
||||
idx= num[0] - 1;
|
||||
if(img_blocks <= num[1] && num[2] > 0)
|
||||
appended_as_gpt= 1;
|
||||
|
||||
/* >>> ??? can there be independent partitions inside the image ? */;
|
||||
|
||||
} else if(strcmp(name, "GPT partition path :") == 0) {
|
||||
idx= num[0] - 1;
|
||||
gpts[idx].has_path= 1;
|
||||
|
||||
} else if(strcmp(name, "APM partition type :") == 0) {
|
||||
idx= num[0] - 1;
|
||||
if(strcmp(textpt, "Apple_HFS") == 0)
|
||||
@ -1679,16 +1723,18 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
||||
if(strstr(textpt, "isohybrid") != NULL) {
|
||||
isohybrid= 1;
|
||||
if(mkisofs)
|
||||
sprintf(buf, "-isohybrid-mbr .");
|
||||
sprintf(buf, "-isohybrid-mbr ");
|
||||
else
|
||||
sprintf(buf, "-boot_image isolinux system_area=.");
|
||||
sprintf(buf, "-boot_image isolinux system_area=");
|
||||
Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) 0, (uint64_t) 15, "s", 7);
|
||||
Xorriso_record_cmd_linE
|
||||
}
|
||||
if(strstr(textpt, "grub2-mbr") != NULL) {
|
||||
if(mkisofs)
|
||||
sprintf(buf, "--grub2-mbr .");
|
||||
sprintf(buf, "--grub2-mbr ");
|
||||
else
|
||||
sprintf(buf, "-boot_image grub grub2_mbr=.");
|
||||
sprintf(buf, "-boot_image grub grub2_mbr=");
|
||||
Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) 0, (uint64_t) 15, "s", 7);
|
||||
Xorriso_record_cmd_linE
|
||||
}
|
||||
if(strstr(textpt, "protective-msdos-label") != NULL) {
|
||||
@ -1738,17 +1784,23 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
||||
sprintf(buf, "-boot_image any partition_sec_hd=%.f", num[0]);
|
||||
|
||||
} else if(strcmp(name, "MBR partition :") == 0) {
|
||||
|
||||
/* >>> ??? is this an independent partition ? */;
|
||||
|
||||
} else if(strcmp(name, "MBR partition path :") == 0) {
|
||||
|
||||
/* >>> ??? are there independent partition paths ? */;
|
||||
|
||||
} else if(strcmp(name, "PReP boot partition:") == 0) {
|
||||
|
||||
/* >>> -boot_image any prep_boot_part=
|
||||
needs opportunity to set a prep path in the input ISO */;
|
||||
sscanf(contentpt, "%lu 0x%lx 0x%lx %lu %lu",
|
||||
&partno, &part_status, &part_type, &start_block, &num_blocks);
|
||||
if(img_blocks <= start_block && num_blocks > 0) {
|
||||
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", 0);
|
||||
}
|
||||
} 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", 0);
|
||||
}
|
||||
|
||||
} else if(strcmp(name, "GPT disk GUID :") == 0) {
|
||||
|
||||
@ -1774,7 +1826,7 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
||||
if(strcmp(et_imgs[et_idx].path, textpt) != 0)
|
||||
continue;
|
||||
if(isohybrid) {
|
||||
if(gpts[idx].ptype == 1)
|
||||
if(gpts[idx].ptype == 1 || gpts[idx].ptype == 3)
|
||||
et_imgs[et_idx].do_gpt_basdat= 1;
|
||||
else if(gpts[idx].ptype == 2)
|
||||
et_imgs[et_idx].do_gpt_hfsplus= 1;
|
||||
@ -1787,7 +1839,36 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
||||
first_efi= 0;
|
||||
}
|
||||
|
||||
/* >>> ??? Are there independent GPT partition paths ? */;
|
||||
} else if(strcmp(name, "GPT start and size :") == 0) {
|
||||
idx= num[0] - 1;
|
||||
if(gpts[idx].ptype == 3)
|
||||
part_type= 0xef;
|
||||
else
|
||||
part_type= 0xcd;
|
||||
if(img_blocks <= num[1] && num[2] > 0) {
|
||||
if(appended_as_gpt == 1) {
|
||||
if(mkisofs)
|
||||
sprintf(buf, "-appended_part_as_gpt");
|
||||
else
|
||||
sprintf(buf, "-boot_image any appended_part_as=gpt");
|
||||
Xorriso_record_cmd_linE
|
||||
appended_as_gpt= 2;
|
||||
}
|
||||
sprintf(buf, "-append_partition %lu 0x%lx ", partno, part_type);
|
||||
Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) num[1],
|
||||
(uint64_t) (num[1] + num[2] - 1.0), "d", 0);
|
||||
|
||||
} else if(gpts[idx].ptype == 3 && gpts[idx].has_path == 0 &&
|
||||
img_blocks >= num[1] + num[2] && !efi_boot_part) {
|
||||
if(mkisofs)
|
||||
sprintf(buf, "-efi-boot-part ");
|
||||
else
|
||||
sprintf(buf, "-boot_image any efi_boot_part=");
|
||||
Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) num[1],
|
||||
(uint64_t) (num[1] + num[2] - 1.0), "d", 0);
|
||||
efi_boot_part= 2;
|
||||
|
||||
}
|
||||
|
||||
} else if(strcmp(name, "APM block size :") == 0) {
|
||||
if(mkisofs)
|
||||
@ -1809,6 +1890,11 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
||||
break;
|
||||
}
|
||||
|
||||
} else if(strcmp(name, "APM start and size :") == 0) {
|
||||
|
||||
/* >>> check for -hfsplus : APM inside ISO, type Apple_HFS,
|
||||
no path, isofs.hb and isofs.hx in image */;
|
||||
|
||||
} else if(strcmp(name, "MIPS-BE boot path :") == 0) {
|
||||
if(mkisofs)
|
||||
sprintf(buf, "-mips-boot ");
|
||||
@ -1908,12 +1994,14 @@ static int Xorriso_scan_report_lines(struct XorrisO *xorriso,
|
||||
if(have_sparc_part) {
|
||||
if(full_sparc_part == 255) {
|
||||
if(mkisofs) {
|
||||
sprintf(buf, "-G .");
|
||||
sprintf(buf, "-G ");
|
||||
Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) 0, (uint64_t) 15, "s", 0);
|
||||
Xorriso_record_cmd_linE
|
||||
sprintf(buf, "-B ...");
|
||||
Xorriso_record_cmd_linE
|
||||
} else {
|
||||
sprintf(buf, "-boot_image any system_area=.");
|
||||
sprintf(buf, "-boot_image any system_area=");
|
||||
Xorriso_add_intvl_adr(xorriso, buf, (uint64_t) 0, (uint64_t) 15, "s", 0);
|
||||
Xorriso_record_cmd_linE
|
||||
for(i= 2; i <= 8; i++) {
|
||||
sprintf(buf, "-append_partition %d 0x00 .", i);
|
||||
|
@ -1 +1 @@
|
||||
#define Xorriso_timestamP "2015.04.23.142407"
|
||||
#define Xorriso_timestamP "2015.05.07.075329"
|
||||
|
Loading…
Reference in New Issue
Block a user