Introduced info option -boot_image "any" "show_status"

This commit is contained in:
Thomas Schmitt 2008-10-26 13:49:11 +00:00
parent 1ba33532e1
commit 50ae925204
6 changed files with 166 additions and 43 deletions

View File

@ -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 22, 2008"
.TH XORRISO 1 "Oct 25, 2008"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@ -1425,7 +1425,10 @@ when a follow-up session gets written. But one should not rely on the
capability to influence the bootability of the existing sessions, unless one
can assume overwriteable media.
.TP
\fB\-boot_image\fR "any"|"isolinux" "discard"|"keep"|"patch"|bootspec
\fB\-boot_image\fR "any"|"isolinux"
.br
"discard"|"keep"|"patch"|"show_status"|bootspec
.br
Define the handling of an eventual El Torito object which has
been read from an existing ISO image or defines how to make a prepared
ISOLINUX file set bootable.
@ -1435,6 +1438,9 @@ All types ("any") of El Torito boot images can be discarded or kept unaltered.
The latter makes only sense if the format of the boot image is
relocatable without content changes.
.br
With any type, "show_status" will print what is known about the loaded image
and its designated fate.
.br
An existing boot image of type "isolinux" can be discarded or it can be
patched to match its relocation. In the latter case the resulting ISO image
stays bootable if the boot image was really produced by ISOLINUX.
@ -1445,7 +1451,7 @@ xorriso cannot recognize the inner form of boot images.
So the user has already to know about the particular needs of the
boot image which is present on the input media.
.br
Most safe is the default: "any" "discard".
Most safe is the default: -boot_image "any" "discard".
.br
A bootspec is a word of the form name=value and is used describe the

View File

@ -3682,6 +3682,8 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
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->loaded_boot_bin_lba= 0;
m->loaded_boot_cat_path[0]= 0;
m->allow_graft_points= 0;
m->allow_restore= 0;
m->do_concat_split= 1;
@ -10537,6 +10539,24 @@ int Xorriso_option_boot_image(struct XorrisO *xorriso, char *form,
xorriso->keep_boot_image= 0;
xorriso->patch_isolinux_image= 0;
xorriso->boot_image_bin_path[0]= 0;
} else if(strcmp(treatpt, "show_status")==0) {
show_status:;
sprintf(xorriso->result_line, "------------------------------------\n");
Xorriso_result(xorriso, 0);
sprintf(xorriso->result_line, "Status of loaded boot image :\n");
Xorriso_result(xorriso, 0);
sprintf(xorriso->result_line, "------------------------------------\n");
Xorriso_result(xorriso, 0);
Xorriso_show_boot_info(xorriso, 0);
sprintf(xorriso->result_line, "------------------------------------\n");
Xorriso_result(xorriso, 0);
sprintf(xorriso->result_line, "Boot image settings for next commit:\n");
Xorriso_result(xorriso, 0);
sprintf(xorriso->result_line, "------------------------------------\n");
Xorriso_result(xorriso, 0);
Xorriso_status(xorriso, "-boot_image", NULL, 0);
sprintf(xorriso->result_line, "------------------------------------\n");
Xorriso_result(xorriso, 0);
} else
was_ok= 0;
} else if(strcmp(formpt, "isolinux")==0) {
@ -10549,6 +10569,8 @@ int Xorriso_option_boot_image(struct XorrisO *xorriso, char *form,
xorriso->keep_boot_image= 0;
xorriso->patch_isolinux_image= 0;
xorriso->boot_image_bin_path[0]= 0;
} else if(strcmp(treatpt, "show_status")==0) {
goto show_status;
} else if(strncmp(treatpt, "dir=", 4) == 0) {
/* The three locations mentioned in http://syslinux.zytor.com/iso.php */
if(strcmp(treatpt + 4, "/") == 0)

View File

@ -201,6 +201,10 @@ struct XorrisO { /* the global context of xorriso */
off_t boot_image_load_size;
int boot_image_isohybrid; /* 0=off , 1=auto , 2=on , 3=force */
/* LBA of boot image after image loading */
int loaded_boot_bin_lba;
/* Path of the catalog node after image loading */
char loaded_boot_cat_path[SfileadrL];
/* XORRISO options */
int allow_graft_points;
@ -691,6 +695,9 @@ int Findjob_set_action_found_path(struct FindjoB *o, int flag);
int Findjob_get_start_path(struct FindjoB *o, char **start_path, int flag);
int Findjob_set_lba_range(struct FindjoB *o, int start_lba, int count,
int flag);
int Findjob_get_lba_damage_filter(struct FindjoB *o, int *start_lba,
int *end_lba, int *damage_filter, int flag);

View File

@ -1 +1 @@
#define Xorriso_timestamP "2008.10.25.170010"
#define Xorriso_timestamP "2008.10.26.134421"

View File

@ -84,7 +84,7 @@ int Xorriso_read_file_data(struct XorrisO *xorriso, IsoNode *node,
int Xorriso_node_from_path(struct XorrisO *xorriso, IsoImage *volume,
char *path, IsoNode **node, int flag);
int Xorriso_path_from_node(struct XorrisO *xorriso, IsoNode *node,
int Xorriso_path_from_node(struct XorrisO *xorriso, IsoNode *node, int lba,
char path[SfileadrL], int flag);
@ -422,6 +422,39 @@ int Xorriso_create_empty_iso(struct XorrisO *xorriso, int flag)
}
int Xorriso_record_boot_info(struct XorrisO *xorriso, int flag)
{
int ret;
struct burn_drive_info *dinfo;
struct burn_drive *drive;
IsoImage *image;
ElToritoBootImage *bootimg;
IsoFile *bootimg_node;
IsoBoot *bootcat_node;
xorriso->loaded_boot_bin_lba= -1;
xorriso->loaded_boot_cat_path[0]= 0;
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
"on attempt to record boot LBAs", 0);
if(ret<=0)
return(0);
image= isoburn_get_attached_image(drive);
if(image == NULL)
return(0);
ret= iso_image_get_boot_image(image, &bootimg,
&bootimg_node, &bootcat_node);
if(ret != 1)
return(0);
if(bootimg_node != NULL)
Xorriso__file_start_lba((IsoNode *) bootimg_node,
&(xorriso->loaded_boot_bin_lba), 0);
if(bootcat_node != NULL)
Xorriso_path_from_node(xorriso, (IsoNode *) bootcat_node, 0,
xorriso->loaded_boot_cat_path, 0);
return(1);
}
/* @param flag bit0= aquire as isoburn input drive
bit1= aquire as libburn output drive (as isoburn drive if bit0)
bit2= regard overwriteable media as blank
@ -659,6 +692,7 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag)
"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_record_boot_info(xorriso, 0);
}
if(!(flag&32)) {
Xorriso_toc(xorriso, 1 | 8);
@ -744,6 +778,8 @@ int Xorriso_give_up_drive(struct XorrisO *xorriso, int flag)
xorriso->loaded_volid[0]= 0;
xorriso->volset_change_pending= 0;
xorriso->no_volset_present= 0;
xorriso->loaded_boot_bin_lba= 0;
xorriso->loaded_boot_cat_path[0]= 0;
in_is_out_too= 0;
}
if((flag&2) && xorriso->out_drive_handle!=NULL) {
@ -3788,6 +3824,77 @@ int Xorriso_toc_line(struct XorrisO *xorriso, int flag)
}
/* @param flag bit0= no output if no boot record was found
bit3= report to info channel (else to result channel)
*/
int Xorriso_show_boot_info(struct XorrisO *xorriso, int flag)
{
int ret, bin_path_valid= 0;
char *respt, sfe[5*SfileadrL], path[SfileadrL];
struct burn_drive_info *dinfo;
struct burn_drive *drive;
IsoImage *image= NULL;
ElToritoBootImage *bootimg;
IsoFile *bootimg_node;
IsoBoot *bootcat_node;
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
"on attempt to print boot info", 0);
if(ret<=0)
return(0);
respt= xorriso->result_line;
image= isoburn_get_attached_image(drive);
if(image == NULL) {
ret= 0;
no_boot:;
if(!(flag & 1)) {
sprintf(respt, "Boot record : none\n");
Xorriso_toc_line(xorriso, flag & 8);
}
return(ret);
}
/* Using the nodes with extreme care . They might be deleted meanwhile. */
ret= iso_image_get_boot_image(image, &bootimg, &bootimg_node, &bootcat_node);
if(ret != 1)
goto no_boot;
ret= Xorriso_path_from_node(xorriso, NULL, xorriso->loaded_boot_bin_lba,
path, 1);
if(ret > 0)
bin_path_valid= 1;
sprintf(respt, "Boot record : El Torito");
if(bin_path_valid)
ret= Xorriso_is_isohybrid(xorriso, bootimg_node, 0);
else
ret= 0;
if(ret > 0) {
/* >>> Conditions for MBR recognition : first 512 bytes of LBA 0*/
/* >>> byte 432 to 435 holds the lba of bootimg_node */
/* >>> byte 510 is 0x55 , byte 511 is 0xaa */
strcat(respt, " , ISOLINUX boot image capable of isohybrid");
}
strcat(respt, "\n");
Xorriso_toc_line(xorriso, flag & 8);
if(bin_path_valid)
sprintf(respt, "Boot bin_path: %s\n", Text_shellsafe(path, sfe, 0));
else if(xorriso->loaded_boot_bin_lba <= 0)
sprintf(respt, "Boot bin_path: -not-found-at-load-time-\n");
else
sprintf(respt, "Boot bin_path: -not-found-any-more-by-lba=%d\n",
xorriso->loaded_boot_bin_lba);
Xorriso_toc_line(xorriso, flag & 8);
if(xorriso->loaded_boot_cat_path[0])
sprintf(respt, "Boot cat_path: %s\n",
Text_shellsafe(xorriso->loaded_boot_cat_path, sfe, 0));
else
sprintf(respt, "Boot cat_path: -not-found-at-load-time-\n");
Xorriso_toc_line(xorriso, flag & 8);
return(1);
}
/* @param flag bit0=short report form
bit1=report about output drive
bit2=do not try to read ISO heads
@ -3805,7 +3912,7 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
struct burn_drive_info *dinfo;
struct burn_drive *drive;
enum burn_disc_status s;
char mem_text[80], sfe[5*SfileadrL], path[SfileadrL];
char mem_text[80];
off_t start_byte= 0, num_free= 0, size;
unsigned dummy;
struct isoburn_toc_disc *disc= NULL;
@ -3814,10 +3921,6 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
int image_blocks;
char volume_id[33];
struct burn_toc_entry next_toc_entry;
IsoImage *image= NULL;
ElToritoBootImage *bootimg;
IsoFile *bootimg_node;
IsoBoot *bootcat_node;
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
"on attempt to print Table Of Content", flag&2);
@ -3884,37 +3987,8 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
if(xorriso->request_to_abort)
return(1);
if(!(flag & 2)) {
image= isoburn_get_attached_image(drive);
if(image != NULL) {
ret= iso_image_get_boot_image(image, &bootimg,
&bootimg_node, &bootcat_node);
if(ret == 1) {
sprintf(respt, "Boot record : El Torito");
ret= Xorriso_is_isohybrid(xorriso, bootimg_node, 0);
if(ret > 0) {
/* >>> Conditions for MBR recognition : first 512 bytes of LBA 0*/
/* >>> byte 432 to 435 holds the lba of bootimg_node */
/* >>> byte 510 is 0x55 , byte 511 is 0xaa */
strcat(respt, " , ISOLINUX boot image capable of isohybrid");
}
strcat(respt, "\n");
Xorriso_toc_line(xorriso, flag & 8);
ret= Xorriso_path_from_node(xorriso, (IsoNode *) bootimg_node, path, 0);
if(ret > 0) {
sprintf(respt, "Boot bin_path: %s\n", Text_shellsafe(path, sfe, 0));
Xorriso_toc_line(xorriso, flag & 8);
}
ret= Xorriso_path_from_node(xorriso, (IsoNode *) bootcat_node, path, 0);
if(ret > 0) {
sprintf(respt, "Boot cat_path: %s\n", Text_shellsafe(path, sfe, 0));
Xorriso_toc_line(xorriso, flag & 8);
}
}
}
}
if(!(flag & 2))
Xorriso_show_boot_info(xorriso, 1 | (flag & 8));
disc= isoburn_toc_drive_get_disc(drive);
if(flag & 4)
@ -6447,7 +6521,9 @@ ex:;
}
int Xorriso_path_from_node(struct XorrisO *xorriso, IsoNode *node,
/* @param flag bit0= use lba rather than node pointer
*/
int Xorriso_path_from_node(struct XorrisO *xorriso, IsoNode *node, int lba,
char path[SfileadrL], int flag)
{
int ret;
@ -6455,12 +6531,19 @@ int Xorriso_path_from_node(struct XorrisO *xorriso, IsoNode *node,
struct stat dir_stbuf;
char *found_path;
path[0]= 0;
if((flag & 1) && lba <= 0)
return(0);
ret= Findjob_new(&job, "/", 0);
if(ret <= 0) {
Xorriso_no_findjob(xorriso, "path_from_node", 0);
return(ret);
}
Findjob_set_wanted_node(job, (void *) node, 0);
if(flag & 1)
Findjob_set_lba_range(job, lba, 1, 0);
else
Findjob_set_wanted_node(job, (void *) node, 0);
Findjob_set_action_found_path(job, 0);
ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0,
NULL, "/", &dir_stbuf, 0, 0);

View File

@ -57,6 +57,11 @@ int Xorriso__text_to_sev(char *severity_name, int *severity_number,int flag);
*/
int Xorriso_toc(struct XorrisO *xorriso, int flag);
/* @param flag bit0= no output if no boot record was found
bit3= report to info channel (else to result channel)
*/
int Xorriso_show_boot_info(struct XorrisO *xorriso, int flag);
int Xorriso_show_devices(struct XorrisO *xorriso, int flag);
int Xorriso_tell_media_space(struct XorrisO *xorriso,