Improved processing of system area in multi-session situations

This commit is contained in:
Thomas Schmitt 2014-10-28 14:04:37 +00:00
parent 726696747a
commit 8e4a7482f3
2 changed files with 56 additions and 57 deletions

View File

@ -339,6 +339,7 @@ int Xorriso_set_system_area(struct XorrisO *xorriso, struct burn_drive *drive,
int flag) int flag)
{ {
int ret, options, system_area_options, iso_lba= -1, start_lba, image_blocks; int ret, options, system_area_options, iso_lba= -1, start_lba, image_blocks;
int sa_loaded;
char volid[33]; char volid[33];
FILE *fp= NULL; FILE *fp= NULL;
char *buf= NULL, *bufpt= NULL; char *buf= NULL, *bufpt= NULL;
@ -378,69 +379,68 @@ int Xorriso_set_system_area(struct XorrisO *xorriso, struct burn_drive *drive,
} }
Xorriso_alloc_meM(buf, char, 32768); Xorriso_alloc_meM(buf, char, 32768);
system_area_options= xorriso->system_area_options;
memset(buf, 0, 32768); memset(buf, 0, 32768);
if(xorriso->system_area_disk_path[0] == 0) { system_area_options= xorriso->system_area_options;
if(xorriso->patch_system_area) { sa_loaded= iso_image_get_system_area(img, buf, &options, 0);
ret= iso_image_get_system_area(img, buf, &options, 0); if(sa_loaded < 0) {
if(ret == 0) { Xorriso_process_msg_queues(xorriso,0);
goto do_set; Xorriso_report_iso_error(xorriso, "", ret,
} else if(ret < 0) {
Xorriso_process_msg_queues(xorriso,0);
Xorriso_report_iso_error(xorriso, "", ret,
"Error when inquiring System Area data of ISO 9660 image", "Error when inquiring System Area data of ISO 9660 image",
0, "FAILURE", 1); 0, "FAILURE", 1);
{ret= 0; goto ex;} {ret= 0; goto ex;}
} else { } if(sa_loaded > 0)
system_area_options= xorriso->patch_system_area; bufpt= buf;
/* Check whether partition 1 ends at image end */; if(xorriso->system_area_disk_path[0] == 0) {
ub= (unsigned char *) buf; if(xorriso->patch_system_area && xorriso->system_area_options == 0 &&
hd_lba= (ub[454] | (ub[455] << 8) | (ub[456] << 16) | (ub[457] << 24)) + sa_loaded > 0) {
(ub[458] | (ub[459] << 8) | (ub[460] << 16) | (ub[461] << 24)); system_area_options= xorriso->patch_system_area;
/* Check whether partition 1 ends at image end */;
ub= (unsigned char *) buf;
hd_lba= (ub[454] | (ub[455] << 8) | (ub[456] << 16) | (ub[457] << 24)) +
(ub[458] | (ub[459] << 8) | (ub[460] << 16) | (ub[461] << 24));
iso_lba= -1; iso_lba= -1;
ret= isoburn_disc_get_msc1(drive, &start_lba); ret= isoburn_disc_get_msc1(drive, &start_lba);
if(ret > 0) { if(ret > 0) {
ret= isoburn_read_iso_head(drive, start_lba, &image_blocks, ret= isoburn_read_iso_head(drive, start_lba, &image_blocks,
volid, 1); volid, 1);
if(ret > 0) if(ret > 0)
iso_lba= start_lba + image_blocks; iso_lba= start_lba + image_blocks;
} }
if(((off_t) iso_lba) * (off_t) 4 > hd_lba) { if(((off_t) iso_lba) * (off_t) 4 > hd_lba) {
system_area_options= 0; system_area_options= 0;
} else if((xorriso->patch_system_area & 1) && } else if((xorriso->patch_system_area & 1) &&
((off_t) iso_lba) * (off_t) 4 != hd_lba) { ((off_t) iso_lba) * (off_t) 4 != hd_lba) {
system_area_options= 0; system_area_options= 0;
} else if((xorriso->patch_system_area & 2) && } else if((xorriso->patch_system_area & 2) &&
((off_t) iso_lba) * (off_t) 4 + (off_t) (63 * 256) < hd_lba) { ((off_t) iso_lba) * (off_t) 4 + (off_t) (63 * 256) < hd_lba) {
system_area_options= 0; system_area_options= 0;
} else if(xorriso->patch_system_area & 2) { /* isohybrid patching */ } else if(xorriso->patch_system_area & 2) { /* isohybrid patching */
/* Check whether bytes 432-345 point to ElTorito LBA */ /* Check whether bytes 432-345 point to ElTorito LBA */
hd_lba= ub[432] | (ub[433] << 8) | (ub[434] << 16) | (ub[435] << 24); hd_lba= ub[432] | (ub[433] << 8) | (ub[434] << 16) | (ub[435] << 24);
ret= iso_image_get_boot_image(img, &bootimg, &bootimg_node, NULL); ret= iso_image_get_boot_image(img, &bootimg, &bootimg_node, NULL);
if(ret != 1) if(ret != 1) {
system_area_options= 0;
} else if(bootimg_node != NULL) {
Xorriso__file_start_lba((IsoNode *) bootimg_node, &(iso_lba), 0);
if(((off_t) iso_lba) * (off_t) 4 != hd_lba)
system_area_options= 0; system_area_options= 0;
else if(bootimg_node != NULL) {
Xorriso__file_start_lba((IsoNode *) bootimg_node, &(iso_lba), 0);
if(((off_t) iso_lba) * (off_t) 4 != hd_lba)
system_area_options= 0;
}
}
if(system_area_options == 0) {
Xorriso_msgs_submit(xorriso, 0,
"Loaded System Area data are not suitable for MBR patching.",
0, "DEBUG", 0);
} }
} }
bufpt= buf; if(system_area_options == 0) {
ret= 1; Xorriso_msgs_submit(xorriso, 0,
} else "Loaded System Area data are not suitable for MBR patching.",
ret= 0; 0, "DEBUG", 0);
goto do_set; }
} }
if(strcmp(xorriso->system_area_disk_path, "/dev/zero") == 0)
{ret= 1; goto do_set;} {ret= 1; goto do_set;}
}
bufpt= buf;
if(strcmp(xorriso->system_area_disk_path, "/dev/zero") == 0) {
memset(buf, 0, 32768);
{ret= 1; goto do_set;}
}
ret= Xorriso_afile_fopen(xorriso, xorriso->system_area_disk_path, ret= Xorriso_afile_fopen(xorriso, xorriso->system_area_disk_path,
"rb", &fp, 2); "rb", &fp, 2);
if(ret <= 0) if(ret <= 0)
@ -455,7 +455,6 @@ int Xorriso_set_system_area(struct XorrisO *xorriso, struct burn_drive *drive,
{ret= 0; goto ex;} {ret= 0; goto ex;}
} }
} }
bufpt= buf;
do_set:; do_set:;
if(ret > 0 && xorriso->system_area_disk_path[0]) { if(ret > 0 && xorriso->system_area_disk_path[0]) {
@ -1063,7 +1062,7 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag)
} }
} }
if(image!=NULL && !(flag&1)) { if(image!=NULL && !(flag&1)) {
if(xorriso->boot_count > 0) { if(xorriso->boot_count > 0 || freshly_bootable) {
/* Eventually rename boot catalog node to changed boot_image_cat_path */ /* Eventually rename boot catalog node to changed boot_image_cat_path */
if(is_bootable > 0) { if(is_bootable > 0) {
ret= Xorriso_path_from_node(xorriso, (IsoNode *) bootcat_node, sfe, 0); ret= Xorriso_path_from_node(xorriso, (IsoNode *) bootcat_node, sfe, 0);

View File

@ -1 +1 @@
#define Xorriso_timestamP "2014.10.28.140220" #define Xorriso_timestamP "2014.10.28.140313"