Made -boot_image isolinux|grub patch and partition_table=on patch System Area

master
Thomas Schmitt 13 years ago
parent 932a7e84e1
commit 3076ce56fb
  1. 88
      xorriso/xorriso.c
  2. 8
      xorriso/xorriso_private.h
  3. 2
      xorriso/xorriso_timestamp.h
  4. 98
      xorriso/xorrisoburn.c

@ -4892,6 +4892,7 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
m->system_area_disk_path[0]= 0;
m->system_area_options= 0;
m->patch_system_area= 0;
m->vol_creation_time= 0;
m->vol_modification_time= 0;
m->vol_expiration_time= 0;
@ -6735,6 +6736,7 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
{
int is_default, no_defaults, i, ret, adr_mode, bin_path_in_use= 0, do_single;
int show_indev= 1, show_outdev= 1, show_dev= 0, patch_is_implicit= 0;
int part_table_implicit= 0;
char *line, sfe[5 * SfileadrL + 80], mode[80], *form, *treatment;
char *in_pt, *out_pt, *nl_charset, *local_charset, *mode_pt;
char *dev_filter= NULL;
@ -6956,24 +6958,24 @@ bin_path:;
treatment= sfe;
bin_path_in_use= 1;
}
} else if(xorriso->patch_isolinux_image) {
treatment= "patch";
if(xorriso->patch_system_area & 1)
form= "grub";
else if(xorriso->patch_system_area & 2)
form= "isolinux";
if(xorriso->patch_system_area)
part_table_implicit= 1;
} else if(xorriso->keep_boot_image) {
treatment= "keep";
}
sprintf(line,"-boot_image %s %s\n", form, treatment);
if(!(is_default && no_defaults))
Xorriso_status_result(xorriso,filter,fp,flag&2);
if(!patch_is_implicit) {
form= "any";
if(xorriso->patch_isolinux_image) {
if(xorriso->boot_image_bin_path[0]) {
form= xorriso->boot_image_bin_form;
treatment= "boot_info_table=on";
} else
treatment= "patch";
} else if(xorriso->boot_image_bin_path[0] == 0 && xorriso->keep_boot_image){
treatment= "keep";
} else
treatment= "";
sprintf(line,"-boot_image %s %s\n", form, treatment);
if(treatment[0] && !(is_default && no_defaults))
if(xorriso->patch_isolinux_image && xorriso->boot_image_bin_path[0] &&
!patch_is_implicit) {
sprintf(line,"-boot_image any boot_info_table=on\n");
if(!(is_default && no_defaults))
Xorriso_status_result(xorriso,filter,fp,flag&2);
}
if(xorriso->boot_image_cat_path[0] && bin_path_in_use) {
@ -6993,16 +6995,20 @@ bin_path:;
Xorriso_status_result(xorriso,filter,fp,flag&2);
}
is_default= (xorriso->system_area_disk_path[0] == 0);
sprintf(line,"-boot_image any system_area=%s\n",
Text_shellsafe(xorriso->system_area_disk_path, sfe, 0));
if(!(is_default && no_defaults))
Xorriso_status_result(xorriso,filter,fp,flag&2);
is_default= ((xorriso->system_area_options & 3) == 0);
sprintf(line,"-boot_image %s partition_table=%s\n",
xorriso->system_area_options & 2 ? "isolinux" : "grub",
xorriso->system_area_options & 3 ? "on" : "off");
sprintf(line,"-boot_image %s system_area=%s\n",
xorriso->system_area_disk_path[0] && (xorriso->system_area_options & 2)
? "isolinux" : "any",
Text_shellsafe(xorriso->system_area_disk_path, sfe, 0));
if(!(is_default && no_defaults))
Xorriso_status_result(xorriso,filter,fp,flag&2);
if(xorriso->system_area_disk_path[0] || !part_table_implicit) {
is_default= ((xorriso->system_area_options & 3) == 0);
sprintf(line,"-boot_image %s partition_table=%s\n",
xorriso->system_area_options & 2 ? "isolinux" : "grub",
xorriso->system_area_options & 3 ? "on" : "off");
if(!(is_default && no_defaults))
Xorriso_status_result(xorriso,filter,fp,flag&2);
}
#ifdef Xorriso_with_isohybriD
if(strcmp(form, "isolinux") == 0) {
@ -8181,7 +8187,7 @@ int Xorriso_compare_2_files(struct XorrisO *xorriso, char *disk_adr,
!((*result) & (8 | 128 | 256 | 512 | 1024))) {
sprintf(respt,
"%s content : node timestamp younger than image timestamp\n", a);
if(!(flag&(1<<31)))
if((xorriso->do_aaip & 32) && !(flag&(1<<31)))
Xorriso_result(xorriso,0);
stamp= s2.st_mtime;
if((flag & 1) && s2.st_atime >= stamp)
@ -8192,19 +8198,19 @@ int Xorriso_compare_2_files(struct XorrisO *xorriso, char *disk_adr,
a, Ftimetxt(stamp, ttx1, 3 << 1),
Ftimetxt(xorriso->isofs_st_in, ttx2, 3 << 1),
((double) stamp) - (double) xorriso->isofs_st_in);
if(!(flag&(1<<31)))
if((xorriso->do_aaip & 32) && !(flag&(1<<31)))
Xorriso_result(xorriso,0);
}
sprintf(respt,
"%s content : assuming inequality due to size or timestamps\n", a);
if(!(flag&(1<<31)))
if((xorriso->do_aaip & 32) && !(flag&(1<<31)))
Xorriso_result(xorriso,0);
}
}
} else if(ret == 1) { /* mismatch */
(*result)|= (1 << 21);
sprintf(respt, "%s dev_ino : differing\n", a);
if(!(flag&(1<<31)))
if((xorriso->do_aaip & 32) && !(flag&(1<<31)))
Xorriso_result(xorriso,0);
if((xorriso->do_aaip & 64) && S_ISREG(s1.st_mode) && S_ISREG(s2.st_mode)){
@ -8213,12 +8219,12 @@ int Xorriso_compare_2_files(struct XorrisO *xorriso, char *disk_adr,
(*result)|= (1 << 15); /* content bytes differ */
sprintf(respt,
"%s content : assuming inequality after dev_ino mismatch\n", a);
if(!(flag&(1<<31)))
if((xorriso->do_aaip & 32) && !(flag&(1<<31)))
Xorriso_result(xorriso,0);
}
} else {
sprintf(respt, "%s dev_ino : no dev_ino stored with image node\n", a);
if(!(flag&(1<<31)))
if((xorriso->do_aaip & 32) && !(flag&(1<<31)))
Xorriso_result(xorriso,0);
(*result)|= (1 << 22);
}
@ -11189,7 +11195,7 @@ int Xorriso_genisofs_help(struct XorrisO *xorriso, int flag)
" -G FILE, -generic-boot FILE Set generic boot image name",
" --protective-msdos-label Patch System Area by partition table",
" --modification-date=YYYYMMDDhhmmsscc",
" Override modification date",
" Override date of creation and modification",
" -isohybrid-mbr FILE Set SYSLINUX mbr/isohdp[fp]x*.bin for isohybrid",
#ifdef Xorriso_with_isohybriD
" isolinux_mbr=on|auto|off Control eventual isohybrid MBR generation",
@ -11300,7 +11306,7 @@ int Xorriso_genisofs(struct XorrisO *xorriso, char *whom,
} else if(strcmp(argv[i], "-no-emul-boot")==0) {
no_emul_boot= 1;
} else if(strcmp(argv[i], "-boot-info-table")==0) {
;
xorriso->patch_isolinux_image= 1;
} else if(strcmp(argv[i], "-b") == 0 ||
strcmp(argv[i], "-eltorito-boot") == 0) {
if(i+1>=argc)
@ -11315,7 +11321,6 @@ int Xorriso_genisofs(struct XorrisO *xorriso, char *whom,
goto ex;
option_b= 1;
xorriso->keep_boot_image= 0;
xorriso->patch_isolinux_image= 1;
} else if(strcmp(argv[i], "-c") == 0 ||
strcmp(argv[i], "-eltorito-catalog") == 0) {
if(i+1>=argc)
@ -12355,6 +12360,7 @@ int Xorriso_afile_fopen(struct XorrisO *xorriso,
char *filename, char *mode, FILE **ret_fp, int flag)
/*
bit0= do not print error message on failure
bit1= do not open stdin
*/
{
FILE *fp= NULL;
@ -12365,7 +12371,11 @@ int Xorriso_afile_fopen(struct XorrisO *xorriso,
(mode[0]=='r' && mode[1]=='+') ||
(mode[0]=='r' && mode[1]=='b' && mode[2]=='+'))
fp= stdout;
else {
else if(flag & 2) {
Xorriso_msgs_submit(xorriso, 0, "Not allowed as input path: '-'", 0,
"FAILURE", 0);
return(0);
} else {
Xorriso_msgs_submit(xorriso, 0, "Ready for data at standard input", 0,
"NOTE", 0);
fp= stdin;
@ -13750,16 +13760,24 @@ int Xorriso_option_boot_image(struct XorrisO *xorriso, char *form,
xorriso->keep_boot_image= 1;
xorriso->patch_isolinux_image= !!isolinux_grub;
xorriso->boot_image_bin_path[0]= 0;
xorriso->patch_system_area= 0;
} else if(strcmp(treatpt, "patch")==0) {
xorriso->keep_boot_image= 0;
xorriso->patch_isolinux_image= 1;
xorriso->boot_image_bin_path[0]= 0;
if(strcmp(formpt, "grub")==0)
xorriso->patch_system_area= 1;
else if(strcmp(formpt, "isolinux")==0)
xorriso->patch_system_area= 2;
else
xorriso->patch_system_area= 0;
} else if(strcmp(treatpt, "discard")==0) {
xorriso->keep_boot_image= 0;
xorriso->patch_isolinux_image= 0;
xorriso->boot_image_bin_path[0]= 0;
xorriso->patch_system_area= 0;
} else if(strcmp(treatpt, "show_status")==0) {
sprintf(xorriso->result_line, "------------------------------------\n");
@ -13869,14 +13887,16 @@ int Xorriso_option_boot_image(struct XorrisO *xorriso, char *form,
xorriso->system_area_options= (xorriso->system_area_options & ~3) | 2;
} else if(strncmp(treatpt, "partition_table=", 16)==0) {
if(strcmp(treatpt + 16, "off") == 0)
if(strcmp(treatpt + 16, "off") == 0) {
xorriso->system_area_options&= ~3;
else if(strcmp(treatpt + 16, "on") == 0) {
xorriso->patch_system_area= xorriso->system_area_options;
} else if(strcmp(treatpt + 16, "on") == 0) {
xorriso->system_area_options&= ~3;
if(strcmp(formpt, "isolinux")==0)
xorriso->system_area_options|= 2;
else
xorriso->system_area_options|= 1;
xorriso->patch_system_area= xorriso->system_area_options;
} else
was_ok= 0;

@ -272,8 +272,14 @@ struct XorrisO { /* the global context of xorriso */
char system_area_disk_path[SfileadrL];
int system_area_options; /* bit0= "GRUB protective msdos label"
(a simple partition table)
bit1= isohybrid boot image pointer
and partition table
*/
int patch_system_area; /* Bits as of system_area_options.
to be applied to the loaded system
area of the image, if no
system_area_disk_path is set.
*/
/* User settable PVD time stamps */
time_t vol_creation_time;
time_t vol_modification_time;

@ -1 +1 @@
#define Xorriso_timestamP "2010.04.16.195349"
#define Xorriso_timestamP "2010.04.16.195835"

@ -1620,7 +1620,7 @@ int Xorriso_set_isolinux_options(struct XorrisO *xorriso,
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
return(-1);
}
patch_table = (xorriso->patch_isolinux_image == 1);
patch_table = !!xorriso->patch_isolinux_image;
if(xorriso->boot_image_isohybrid == 0) {
ret= el_torito_set_isolinux_options(bootimg, patch_table, 0);
return(ret == 1);
@ -1691,21 +1691,87 @@ int Xorriso_auto_format(struct XorrisO *xorriso, int flag)
}
int Xorriso_set_system_area(struct XorrisO *xorriso,
struct isoburn_imgen_opts *sopts, int flag)
int Xorriso_set_system_area(struct XorrisO *xorriso, struct burn_drive *drive,
IsoImage *img, struct isoburn_imgen_opts *sopts,
int flag)
{
int ret;
int ret, options, system_area_options, iso_lba= 0;
FILE *fp= NULL;
char buf[32768], *bufpt= NULL;
off_t hd_lba;
unsigned char *ub;
ElToritoBootImage *bootimg;
IsoFile *bootimg_node;
struct isoburn_toc_disc *isoburn_disc= NULL;
system_area_options= xorriso->system_area_options;
memset(buf, 0, 32768);
if(xorriso->system_area_disk_path[0] == 0) {
if(xorriso->patch_system_area) {
ret= iso_image_get_system_area(img, buf, &options, 0);
if(ret == 0)
goto do_set;
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",
0, "FAILURE", 1);
{ret= 0; goto ex;}
} else {
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));
isoburn_disc= isoburn_toc_drive_get_disc(drive);
if(isoburn_disc == NULL)
iso_lba= -1;
else {
if(xorriso->system_area_disk_path[0] == 0)
{ret= 0; goto do_set;}
/* >>> wrong: with CD-R this is the track end, not the ISO size */
iso_lba= isoburn_toc_disc_get_sectors(isoburn_disc);
}
if(((off_t) iso_lba) * (off_t) 4 > hd_lba) {
system_area_options= 0;
} else if((xorriso->patch_system_area & 1) &&
((off_t) iso_lba) * (off_t) 4 != hd_lba) {
system_area_options= 0;
} else if((xorriso->patch_system_area & 2) &&
((off_t) iso_lba) * (off_t) 4 + (off_t) (63 * 256) < hd_lba) {
system_area_options= 0;
} else if(xorriso->patch_system_area & 2) { /* isohybrid patching */
/* Check whether bytes 432-345 point to ElTorito LBA */
hd_lba= ub[432] | (ub[433] << 8) | (ub[434] << 16) | (ub[435] << 24);
ret= iso_image_get_boot_image(img, &bootimg, &bootimg_node, NULL);
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;
}
}
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;
ret= 1;
} else
ret= 0;
goto do_set;
}
if(strcmp(xorriso->system_area_disk_path, "/dev/zero") == 0)
{ret= 1; goto do_set;}
ret= Xorriso_afile_fopen(xorriso, xorriso->system_area_disk_path,
"rb", &fp, 0);
"rb", &fp, 2);
if(ret <= 0)
{ret= 0; goto ex;}
memset(buf, 0, 32768);
ret= fread(buf, 1, 32768, fp);
if(ret < 32768) {
if(ferror(fp)) {
@ -1719,14 +1785,13 @@ int Xorriso_set_system_area(struct XorrisO *xorriso,
bufpt= buf;
do_set:;
if(ret > 0) {
if(ret > 0 && xorriso->system_area_disk_path[0]) {
sprintf(xorriso->info_text, "Copying to System Area: %d bytes from file ",
ret);
Text_shellsafe(xorriso->system_area_disk_path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
}
ret= isoburn_igopt_set_system_area(sopts, bufpt,
xorriso->system_area_options);
ret= isoburn_igopt_set_system_area(sopts, bufpt, system_area_options);
if(ret != ISO_SUCCESS) {
Xorriso_process_msg_queues(xorriso,0);
Xorriso_report_iso_error(xorriso, "", ret,
@ -1736,8 +1801,10 @@ do_set:;
}
ret= 1;
ex:;
if(fp != NULL && fp != stdin)
if(fp != NULL && fp != stdin)
fclose(fp);
if(isoburn_disc != NULL)
isoburn_toc_disc_free(isoburn_disc);
return(ret);
}
@ -1841,6 +1908,10 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag)
goto ex;
}
ret= Xorriso_set_system_area(xorriso, source_drive, image, sopts, 0);
if(ret <= 0)
goto ex;
/* Activate, adjust or discard boot image */
/* >>> ??? move down to libisoburn ? */
if(image!=NULL && !(flag&1)) {
@ -1958,9 +2029,6 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag)
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
}
}
ret= Xorriso_set_system_area(xorriso, sopts, 0);
if(ret <= 0)
goto ex;
if((xorriso->do_aaip & 16) || !(xorriso->ino_behavior & 2)) {
/* Overwrite isofs.st of root node by xorriso->isofs_st_out */

Loading…
Cancel
Save