Discarding, keeping or patching boot images from existing ISO images

This commit is contained in:
2008-02-11 09:48:29 +00:00
parent 9134a8d5b8
commit 5f67e789ed
6 changed files with 174 additions and 25 deletions

View File

@ -407,13 +407,14 @@ int Xorriso_create_empty_iso(struct XorrisO *xorriso, int flag)
*/
int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag)
{
int ret, hret, not_writeable= 0;
int ret, hret, not_writeable= 0, has_what;
uint32_t size;
struct burn_drive_info *dinfo= NULL, *out_dinfo, *in_dinfo;
struct burn_drive *drive, *out_drive, *in_drive;
enum burn_disc_status state;
IsoImage *volset = NULL;
struct isoburn_read_opts *ropts= NULL;
char adr_data[SfileadrL], *libburn_adr;
char adr_data[SfileadrL], *libburn_adr, *boot_fate;
if((flag&3)==0) {
sprintf(xorriso->info_text,
@ -568,6 +569,20 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag)
isoburn_attach_image(out_drive, xorriso->in_volset_handle);
}
Xorriso_process_msg_queues(xorriso,0);
isoburn_ropt_get_size_what(ropts, &size, &has_what);
if(has_what & isoburn_ropt_has_el_torito) {
if(xorriso->patch_isolinux_image)
boot_fate= "patched as isolinux image";
else if(xorriso->keep_boot_image)
boot_fate= "kept unchanged";
else
boot_fate= "discarded";
sprintf(xorriso->info_text,
"Detected El-Torito boot information which currently is set to be %s",
boot_fate);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
}
Xorriso_toc(xorriso, 1);
if(xorriso->loaded_volid[0]!=0) {
sprintf(xorriso->result_line,"Volume id : '%s'\n",xorriso->loaded_volid);
@ -688,7 +703,7 @@ int Xorriso_make_write_options(
*/
int Xorriso_write_session(struct XorrisO *xorriso, int flag)
{
int ret, media_space, img_sectors, padding= 0, profile= 0;
int ret, media_space, img_sectors, padding= 0, profile= 0, relax= 0;
char profile_name[80];
struct isoburn_imgen_opts *sopts= NULL;
struct burn_drive_info *dinfo, *source_dinfo;
@ -700,15 +715,67 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag)
struct burn_session **sessions;
struct burn_track **tracks;
enum burn_disc_status s;
IsoImage *image = NULL;
ElToritoBootImage *bootimg;
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
"on attempt to write", 2);
if(ret<=0)
return(0);
if(xorriso->out_drive_handle == xorriso->in_drive_handle ||
xorriso->in_drive_handle == NULL) {
source_drive= drive;
} else {
ret= Xorriso_get_drive_handles(xorriso, &source_dinfo, &source_drive,
"on attempt to get source for write", 0);
if(ret<=0)
goto ex;
s= isoburn_disc_get_status(drive);
if(s!=BURN_DISC_BLANK) {
s= burn_disc_get_status(drive);
if(s!=BURN_DISC_BLANK)
sprintf(xorriso->info_text,
"-indev differs from -outdev and -outdev media is not blank");
else
sprintf(xorriso->info_text,
"-indev differs from -outdev and -outdev media holds valid ISO image");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
{ret= 0; goto ex;}
}
}
ret= isoburn_igopt_new(&sopts, 0);
if(ret<=0)
return(ret);
relax= isoburn_igopt_allow_deep_paths;
/* Adjust or discard boot image */
image= isoburn_get_attached_image(source_drive);
/* >>> ??? move down to libisoburn ? */
if(image!=NULL && !(flag&1)) {
ret= iso_image_get_boot_image(image, &bootimg, NULL, NULL);
if(xorriso->patch_isolinux_image) {
if(ret==1) {
relax|= isoburn_igopt_allow_full_ascii;
el_torito_patch_isolinux_image(bootimg);
sprintf(xorriso->info_text, "Patched alleged isolinux boot image");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
} else {
sprintf(xorriso->info_text,
"Could not find any boot image for -patch_isolinux_image");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
}
} else if(xorriso->keep_boot_image) {
sprintf(xorriso->info_text, "Keeping boot image unchanged");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
} else if(ret==1) {
iso_image_remove_boot_image(image);
sprintf(xorriso->info_text, "Discarded boot image from old session");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
}
}
isoburn_igopt_set_level(sopts, 2);
isoburn_igopt_set_extensions(sopts, 1|((!!xorriso->do_joliet)<<1));
isoburn_igopt_set_relaxed(sopts, isoburn_igopt_allow_deep_paths);
@ -747,25 +814,8 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag)
if(xorriso->out_drive_handle == xorriso->in_drive_handle ||
xorriso->in_drive_handle == NULL) {
source_drive= drive;
ret= isoburn_prepare_disc(source_drive, &disc, sopts);
} else {
s= isoburn_disc_get_status(drive);
if(s!=BURN_DISC_BLANK) {
s= burn_disc_get_status(drive);
if(s!=BURN_DISC_BLANK)
sprintf(xorriso->info_text,
"-indev differs from -outdev and -outdev media is not blank");
else
sprintf(xorriso->info_text,
"-indev differs from -outdev and -outdev media holds valid ISO image");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
{ret= 0; goto ex;}
}
ret= Xorriso_get_drive_handles(xorriso, &source_dinfo, &source_drive,
"on attempt to get source for write", 0);
if(ret<=0)
goto ex;
ret= isoburn_prepare_new_image(source_drive, &disc, sopts, drive);
}
if (ret <= 0) {
@ -870,6 +920,11 @@ no_track:;
Xorriso_info(xorriso, 0);
ret= 1;
ex:;
if(ret<=0) {
/* >>> ??? revive discarded boot image */;
}
if(disc!=NULL)
burn_disc_free(disc);
isoburn_igopt_destroy(&sopts, 0);