Introduced info option -boot_image "any" "show_status"

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

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);