From 9cdd4904a9cbed7ec4558789692ec9bcc0346a77 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Mon, 20 Oct 2008 18:08:28 +0000 Subject: [PATCH] Made use of new libisofs isohybrid capability --- libisoburn/trunk/xorriso/xorriso.1 | 39 +++++++--- libisoburn/trunk/xorriso/xorriso.c | 35 ++++++++- libisoburn/trunk/xorriso/xorriso_private.h | 1 + libisoburn/trunk/xorriso/xorriso_timestamp.h | 2 +- libisoburn/trunk/xorriso/xorrisoburn.c | 78 +++++++++++++++++++- 5 files changed, 138 insertions(+), 17 deletions(-) diff --git a/libisoburn/trunk/xorriso/xorriso.1 b/libisoburn/trunk/xorriso/xorriso.1 index 8915ee08..4d014ed8 100644 --- a/libisoburn/trunk/xorriso/xorriso.1 +++ b/libisoburn/trunk/xorriso/xorriso.1 @@ -2,7 +2,7 @@ .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) -.TH XORRISO 1 "Oct 17, 2008" +.TH XORRISO 1 "Oct 20, 2008" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: @@ -176,9 +176,10 @@ suitable for xorriso. .br Blank is the state of newly purchased optical media. With used CD-RW and DVD-RW it can be achieved by action -blank "as_needed". -Overwriteable media are considered blank unless they contain an ISO image -suitable for xorriso. Action -blank "as_needed" can be used to invalidate the -image on overwriteable media, or to apply eventual mandatory formatting. +Overwriteable media are considered blank if they are new or if they have +been marked as blank by xorriso. +Action -blank "as_needed" can be used to do this marking on overwriteable +media, or to apply eventual mandatory formatting of new media. .br \fBAppendable\fR media accept further sessions. Either they are MMC multi-session media in appendable state, or they are overwriteable media @@ -352,10 +353,16 @@ The content of the boot image files is not in the scope of El Torito. .br Most bootable Linux CDs are equipped with ISOLINUX boot images. xorriso is able to create or maintain an El Torito object which makes such an image -bootable. Emulation -as mkisofs supports the example options out of the -ISOLINUX wiki. +bootable. For details see option -boot_image. +Emulation -as mkisofs supports the example options out of the ISOLINUX wiki. .br The support for other boot image types is sparse. +.br +An MBR is generated together with the El Torito boot record if the boot image +bears the isohybrid signature of ISOLINUX 3.72 or later. It will occupy the +first 512 bytes of the emerging ISO image and enable booting from media which +appear as hard disk rather than as CDROM. An MBR does not hamper CDROM booting. +The MBR of a follow-up session can get in effect only on overwriteable media. .SS .B Command processing: .br @@ -394,7 +401,7 @@ differs from the usual shell parsers. In xorriso, a quotation mark does not make a pattern symbol literal. .PP .B Quoted input -combines words from text pieces which are separated by whitespace. +converts whitespace separated text pieces into words. The double quotation mark " and the single quotation mark ' can be used to enclose whitespace and make it part of words (e.g. of file names). Each mark type can enclose the marks of the other type. A trailing backslash \\ outside @@ -421,7 +428,7 @@ event which triggers the threshold of command -abort_on. .SS .B Dialog, Readline, Result pager: .br -Dialog mode prompts for an input line, parses it into words, and performs +Dialog mode prompts for a quoted input line, parses it into words, and performs them as commands with their parameters. It provides assisting services to make dialog more comfortable. .PP @@ -1441,10 +1448,13 @@ boot image which is present on the input media. Most safe is the default: "any" "discard". .br -On all media types it is possible to activate a set of ISOLINUX files -for booting within the first session. In further sessions an existing boot -image can get replaced by a new one, but depending on the media type -this may have few effect at boot time. See above. +A bootspec is a word of the form name=value and is used describe the +activation of a ISOLINUX boot image by an El Torito record and eventually +a MBR. The names "dir" and "bin_path" lead to boot image activation. +.br +On all media types this is possible within the first session. In further +sessions an existing boot image can get replaced by a new one, but depending +on the media type this may have few effect at boot time. See above. .br The ISOLINUX files have to be added to the ISO image by normal means (image loading, -map, -add, ...) and should reside either in ISO image @@ -1470,6 +1480,11 @@ cat_path at -commit time. It is subject to normal -overwrite and -reassure processing if there is already a file with the same name. .br +Bootspec "isohybrid=off" disables MBR generation, "isohybrid=on" prevents the +write session if not the isohybrid signature is found in the bin_path file. +Default is "isohybrid=auto" which silently omits the MBR if the signature is +missing. +.br The setting of -boot_image will change to "isolinux" "patch" after successful writing of a session with -boot_image "isolinux" bootspec. .TP diff --git a/libisoburn/trunk/xorriso/xorriso.c b/libisoburn/trunk/xorriso/xorriso.c index a20a6bfd..fa317b48 100644 --- a/libisoburn/trunk/xorriso/xorriso.c +++ b/libisoburn/trunk/xorriso/xorriso.c @@ -3635,6 +3635,7 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag) m->boot_image_emul= 0; m->boot_image_cat_path[0]= 0; m->boot_image_load_size= 4 * 512; /* hearsay out of libisofs/demo/iso.c */ + m->boot_image_isohybrid= 1; m->allow_graft_points= 0; m->allow_restore= 0; m->do_concat_split= 1; @@ -5504,6 +5505,14 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag) if(!(is_default && no_defaults)) Xorriso_status_result(xorriso,filter,fp,flag&2); } + if(strcmp(form, "isolinux") == 0) { + static char modes[4][6]= {"off", "auto", "on", "force"}; + is_default= (xorriso->boot_image_isohybrid == 1); + sprintf(line,"-boot_image isolinux isohybrid=%s\n", + modes[xorriso->boot_image_isohybrid & 3]); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + } sprintf(line,"-cd %s\n", (xorriso->wdi[0] ? Text_shellsafe(xorriso->wdi,sfe,0) : "'/'")); @@ -10509,7 +10518,7 @@ int Xorriso_option_boot_image(struct XorrisO *xorriso, char *form, xorriso->boot_image_cat_path, 2); if(ret <= 0) return(ret); - } else if(strncmp(treatpt, "load_size=", 10) == 0) { + } else if(strncmp(treatpt, "load_size=", 10) == 0) { num= Scanf_io_size(treatpt + 10, 0); if(num < 512) { sprintf(xorriso->info_text, @@ -10519,6 +10528,26 @@ int Xorriso_option_boot_image(struct XorrisO *xorriso, char *form, return(0); } xorriso->boot_image_load_size= num; + } else if(strncmp(treatpt, "isohybrid=", 10) == 0) { + if(strcmp(treatpt + 10, "off") == 0) + xorriso->boot_image_isohybrid= 0; + else if(strcmp(treatpt + 10, "auto") == 0) + xorriso->boot_image_isohybrid= 1; + else if(strcmp(treatpt + 10, "off") == 0) + xorriso->boot_image_isohybrid= 2; + else if(strcmp(treatpt + 10, "force") == 0) + xorriso->boot_image_isohybrid= 3; + else { + sprintf(xorriso->info_text, + "Unrecognized keyword with -boot_image %s %s", + form, treatment); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + sprintf(xorriso->info_text, + "Allowed with isohybrid= are: off , auto , on , force"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "HINT", 0); + return(0); + + } } else was_ok= 0; } else @@ -13847,9 +13876,11 @@ int Xorriso_option_publisher(struct XorrisO *xorriso, char *name, int flag) /* Option -pwd alias -pwdi */ int Xorriso_option_pwdi(struct XorrisO *xorriso, int flag) { + char sfe[5 * SfileadrL]; + sprintf(xorriso->info_text,"current working directory in ISO image:\n"); Xorriso_info(xorriso,0); - sprintf(xorriso->result_line,"%s/\n",xorriso->wdi); + sprintf(xorriso->result_line,"%s/\n", Text_shellsafe(xorriso->wdi, sfe, 0)); Xorriso_result(xorriso,0); return(1); } diff --git a/libisoburn/trunk/xorriso/xorriso_private.h b/libisoburn/trunk/xorriso/xorriso_private.h index 6cd9721d..0a57c204 100644 --- a/libisoburn/trunk/xorriso/xorriso_private.h +++ b/libisoburn/trunk/xorriso/xorriso_private.h @@ -194,6 +194,7 @@ struct XorrisO { /* the global context of xorriso */ */ char boot_image_cat_path[SfileadrL]; off_t boot_image_load_size; + int boot_image_isohybrid; /* 0=off , 1=auto , 2=on , 3=force */ /* XORRISO options */ diff --git a/libisoburn/trunk/xorriso/xorriso_timestamp.h b/libisoburn/trunk/xorriso/xorriso_timestamp.h index 4a04a353..2d60d55a 100644 --- a/libisoburn/trunk/xorriso/xorriso_timestamp.h +++ b/libisoburn/trunk/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2008.10.19.182512" +#define Xorriso_timestamP "2008.10.20.180747" diff --git a/libisoburn/trunk/xorriso/xorrisoburn.c b/libisoburn/trunk/xorriso/xorrisoburn.c index 1c7c92d6..33f1278a 100644 --- a/libisoburn/trunk/xorriso/xorrisoburn.c +++ b/libisoburn/trunk/xorriso/xorrisoburn.c @@ -846,6 +846,60 @@ ex:; } +int Xorriso_set_isolinux_options(struct XorrisO *xorriso, + IsoImage *image, int flag) +{ + int make_isohybrid_mbr= 0, ret; + unsigned char buf[68]; + ElToritoBootImage *bootimg; + IsoFile *bootimg_node; + void *data_stream= NULL; + + ret= iso_image_get_boot_image(image, &bootimg, &bootimg_node, NULL); + if(ret != 1) { + sprintf(xorriso->info_text, "Programming error: No boot image available in Xorriso_set_isolinux_options()"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); + return(-1); + } + + if(xorriso->boot_image_isohybrid == 0) { + ret= el_torito_set_isolinux_options(bootimg, 1, 0); + return(ret == 1); + } + if(xorriso->boot_image_isohybrid == 3) { + make_isohybrid_mbr= 1; + } else { + ret= Xorriso_iso_file_open(xorriso, "", (void *) bootimg_node, + &data_stream, 1); + if(ret<=0) + return(ret); + ret= Xorriso_iso_file_read(xorriso, data_stream, (char *) buf, 68, 0); + Xorriso_iso_file_close(xorriso, &data_stream, 0); + if(ret<=0) + return(ret); + if(buf[64] == 0xfb && buf[65] == 0xc0 && buf[66] == 0x78 && buf[67] == 0x70) + make_isohybrid_mbr= 1; + } + + if(xorriso->boot_image_isohybrid == 2 && !make_isohybrid_mbr) { + sprintf(xorriso->info_text, + "Isohybrid signature is demanded but not found in boot image file."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); + return(0); + } + if(make_isohybrid_mbr) { + sprintf(xorriso->info_text, "Will write isohybrid MBR."); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + } + + ret= el_torito_set_isolinux_options(bootimg, 1 | (make_isohybrid_mbr << 1),0); + return(ret == 1); +} + + +#define Xorriso_with_make_isohybrid_mbR 1 + + /* @param flag bit0= do not write but only prepare and return size in sectors */ int Xorriso_write_session(struct XorrisO *xorriso, int flag) @@ -928,7 +982,7 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag) } relax= isoburn_igopt_allow_deep_paths; - /* Adjust or discard boot image */ + /* Activate, adjust or discard boot image */ image= isoburn_get_attached_image(source_drive); /* >>> ??? move down to libisoburn ? */ if(image!=NULL && !(flag&1)) { @@ -951,7 +1005,6 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag) cpt++; strcpy(cpt, "boot.cat"); } - sprintf(xorriso->info_text, "Activating alleged isolinux boot image %s", Text_shellsafe(xorriso->boot_image_bin_path, sfe, 0)); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); @@ -1003,13 +1056,34 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag) {ret= 0; goto ex;} } el_torito_set_load_size(bootimg, xorriso->boot_image_load_size / 512); + +#ifdef Xorriso_with_make_isohybrid_mbR + + ret= Xorriso_set_isolinux_options(xorriso, image, 0); + if(ret <= 0) + goto ex; + +#else el_torito_patch_isolinux_image(bootimg); +#endif + } else if(xorriso->patch_isolinux_image) { if(ret==1) { relax|= isoburn_igopt_allow_full_ascii; sprintf(xorriso->info_text, "Patching alleged isolinux boot image"); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); + + +#ifdef Xorriso_with_make_isohybrid_mbR + + ret= Xorriso_set_isolinux_options(xorriso, image, 0); + if(ret <= 0) + goto ex; + +#else el_torito_patch_isolinux_image(bootimg); +#endif + } else { sprintf(xorriso->info_text, "Could not find any boot image for -boot_image isolinux patch");