Eventually reporting boot info with TOC of -indev, redirected drive aquiration TOC to info channel

This commit is contained in:
2008-10-25 12:34:36 +00:00
parent ceea749071
commit 7c1ddfd2a7
5 changed files with 226 additions and 22 deletions

View File

@ -84,6 +84,10 @@ 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,
char path[SfileadrL], int flag);
#define LIBISO_ISDIR(node) (iso_node_get_type(node) == LIBISO_DIR)
#define LIBISO_ISREG(node) (iso_node_get_type(node) == LIBISO_FILE)
#define LIBISO_ISLNK(node) (iso_node_get_type(node) == LIBISO_SYMLINK)
@ -553,7 +557,7 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag)
}
}
if(!(flag&32))
Xorriso_toc(xorriso, 1|2);
Xorriso_toc(xorriso, 1 | 2 | 8);
{ret= 1+not_writeable; goto ex;}
}
@ -657,8 +661,10 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag)
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
}
if(!(flag&32)) {
Xorriso_toc(xorriso, 1);
Xorriso_toc(xorriso, 1 | 8);
if(xorriso->loaded_volid[0]!=0) {
#ifdef NIX
sprintf(xorriso->result_line,"Volume id : '%s'\n",
xorriso->loaded_volid);
Xorriso_result(xorriso,0);
@ -667,6 +673,19 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag)
sprintf(xorriso->result_line, "New volume id: '%s'\n", xorriso->volid);
Xorriso_result(xorriso,0);
}
#else
sprintf(xorriso->info_text,"Volume id : '%s'\n",
xorriso->loaded_volid);
Xorriso_info(xorriso, 0);
if(strcmp(xorriso->loaded_volid, xorriso->volid) != 0 &&
!xorriso->volid_default) {
sprintf(xorriso->info_text, "New volume id: '%s'\n", xorriso->volid);
Xorriso_info(xorriso, 0);
}
#endif /* ! NIX */
}
}
ret= 1+not_writeable;
@ -746,7 +765,7 @@ int Xorriso_give_up_drive(struct XorrisO *xorriso, int flag)
sprintf(xorriso->info_text,
"Only the output drive remains. Created empty ISO image.\n");
Xorriso_info(xorriso, 0);
Xorriso_toc(xorriso, 1|2);
Xorriso_toc(xorriso, 1 | 2 | 8);
}
}
Xorriso_process_msg_queues(xorriso,0);
@ -857,15 +876,42 @@ ex:;
}
/* @return <0 yes , 0 no , <0 error */
int Xorriso_is_isohybrid(struct XorrisO *xorriso, IsoFile *bootimg_node,
int flag)
{
int ret;
unsigned char buf[68];
void *data_stream= NULL;
ret= Xorriso_iso_file_open(xorriso, "", (void *) bootimg_node,
&data_stream, 1);
if(ret <= 0)
return(-1);
ret= Xorriso_iso_file_read(xorriso, data_stream, (char *) buf, 68, 0);
Xorriso_iso_file_close(xorriso, &data_stream, 0);
if(ret <= 0)
return(0);
if(buf[64] == 0xfb && buf[65] == 0xc0 && buf[66] == 0x78 && buf[67] == 0x70)
return(1);
return(0);
}
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;
#ifdef NIX
unsigned char buf[68];
void *data_stream= NULL;
#endif /* NIX */
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()");
@ -880,6 +926,9 @@ int Xorriso_set_isolinux_options(struct XorrisO *xorriso,
if(xorriso->boot_image_isohybrid == 3) {
make_isohybrid_mbr= 1;
} else {
#ifdef NIX
ret= Xorriso_iso_file_open(xorriso, "", (void *) bootimg_node,
&data_stream, 1);
if(ret<=0)
@ -890,6 +939,17 @@ int Xorriso_set_isolinux_options(struct XorrisO *xorriso,
return(ret);
if(buf[64] == 0xfb && buf[65] == 0xc0 && buf[66] == 0x78 && buf[67] == 0x70)
make_isohybrid_mbr= 1;
#else
ret= Xorriso_is_isohybrid(xorriso, bootimg_node, 0);
if(ret < 0)
return(0);
if(ret > 0)
make_isohybrid_mbr= 1;
#endif
}
if(xorriso->boot_image_isohybrid == 2 && !make_isohybrid_mbr) {
@ -3713,9 +3773,25 @@ int Xorriso_process_msg_queues(struct XorrisO *xorriso, int flag)
}
/* @param flag
bit3=report to info channel (else to result channel)
*/
int Xorriso_toc_line(struct XorrisO *xorriso, int flag)
{
if(!(flag & 8)) {
Xorriso_result(xorriso,0);
return(1);
}
strcpy(xorriso->info_text, xorriso->result_line);
Xorriso_info(xorriso, 0);
return(1);
}
/* @param flag bit0=short report form
bit1=report about output drive
bit2=do not try to read ISO heads
bit3=report to info channel (else to result channel)
*/
int Xorriso_toc(struct XorrisO *xorriso, int flag)
{
@ -3729,7 +3805,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];
char mem_text[80], sfe[5*SfileadrL], path[SfileadrL];
off_t start_byte= 0, num_free= 0, size;
unsigned dummy;
struct isoburn_toc_disc *disc= NULL;
@ -3738,6 +3814,10 @@ 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);
@ -3755,11 +3835,11 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
sprintf(respt, "Drive current: %s '%s'\n",
(is_inout_drive ? "-dev" : (flag&2 ? "-outdev" : "-indev")),
devadr);
Xorriso_result(xorriso,0);
Xorriso_toc_line(xorriso, flag & 8);
sprintf(respt, "Drive type : vendor '%s' product '%s' revision '%s'\n",
dinfo[0].vendor, dinfo[0].product, dinfo[0].revision);
if(!(flag&1))
Xorriso_result(xorriso,0);
Xorriso_toc_line(xorriso, flag & 8);
sprintf(respt, "Media current: ");
ret= burn_disc_get_profile(drive, &profile_no, profile_name);
@ -3776,7 +3856,7 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
strcat(respt, "\n");
} else
sprintf(respt+strlen(respt), "is not recognizable\n");
Xorriso_result(xorriso,0);
Xorriso_toc_line(xorriso, flag & 8);
sprintf(respt, "Media status : ");
s= isoburn_disc_get_status(drive);
@ -3790,20 +3870,46 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
sprintf(respt+strlen(respt), "is not present\n");
else
sprintf(respt+strlen(respt), "is not recognizable\n");
Xorriso_result(xorriso,0);
Xorriso_toc_line(xorriso, flag & 8);
if(s == BURN_DISC_BLANK) {
sprintf(respt, "Media summary: 0 sessions, 0 data blocks, 0 data");
num_free= isoburn_disc_available_space(drive, NULL);
Sfile_scale((double) num_free, mem_text,5,1e4,1);
sprintf(respt+strlen(respt), ", %s free\n", mem_text);
Xorriso_result(xorriso,0);
Xorriso_toc_line(xorriso, flag & 8);
}
if(s != BURN_DISC_FULL && s != BURN_DISC_APPENDABLE)
return(1);
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)
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);
}
}
}
}
disc= isoburn_toc_drive_get_disc(drive);
if(flag & 4)
sprintf(respt, "TOC layout : %3s , %9s , %10s\n",
@ -3812,7 +3918,7 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
sprintf(respt, "TOC layout : %3s , %9s , %10s , %s\n",
"Idx", "sbsector", "Size", "Volume Id");
if(!(flag&1))
Xorriso_result(xorriso,0);
Xorriso_toc_line(xorriso, flag & 8);
if (disc==NULL) {
Xorriso_process_msg_queues(xorriso,0);
@ -3848,7 +3954,7 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
typetext, 1, 0, nwa);
}
if(!(flag&1))
Xorriso_result(xorriso,0);
Xorriso_toc_line(xorriso, flag & 8);
last_track_start= lba;
num_payload= num_data= last_track_size= nwa;
num_sessions= 1;
@ -3913,7 +4019,7 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
typetext, track_count, lba, track_size);
}
if(!(flag&1))
Xorriso_result(xorriso,0);
Xorriso_toc_line(xorriso, flag & 8);
if(track_no>0)
num_payload+= lba - last_track_start;
last_track_start= lba;
@ -3947,14 +4053,14 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
sprintf(respt+strlen(respt), ", %s free", mem_text);
sprintf(respt+strlen(respt), "\n");
Xorriso_result(xorriso,0);
Xorriso_toc_line(xorriso, flag & 8);
if (s==BURN_DISC_APPENDABLE && nwa!=0) {
ret= isoburn_disc_track_lba_nwa(drive, NULL, 0, &lba, &nwa);
if(ret>0) {
sprintf(respt, "Media nwa : %ds\n", nwa);
if(!(flag&1))
Xorriso_result(xorriso,0);
Xorriso_toc_line(xorriso, flag & 8);
}
}
@ -6059,6 +6165,8 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
ret= Xorriso_report_damage(xorriso, show_path, node, 0);
} else if(action == 22) {
ret= Xorriso_report_lba(xorriso, show_path, node, 0);
} else if(action == 23) {
ret= Findjob_set_found_path(job, show_path, 0);
} else { /* includes : 15 in_iso */
sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0));
Xorriso_result(xorriso, 0);
@ -6082,6 +6190,7 @@ int Xorriso_findi_test(struct XorrisO *xorriso, struct FindjoB *job,
int ret, start_lba, end_lba, damage_filter, commit_filter, lba;
off_t damage_start, damage_end, size;
int lba_count, *file_end_lbas= NULL, *file_start_lbas= NULL, i;
void *wanted_node;
ret= Findjob_test(job, name, boss_stbuf, stbuf, depth, 1);
if(ret<=0)
@ -6115,6 +6224,9 @@ int Xorriso_findi_test(struct XorrisO *xorriso, struct FindjoB *job,
if(ret > 0 && lba >= 0)
{ret= 0; goto ex;}
}
Findjob_get_wanted_node(job, &wanted_node, 0);
if(wanted_node != NULL && ((IsoNode *) wanted_node) != node)
{ret= 0; goto ex;}
ret= 1;
ex:;
if(file_start_lbas != NULL)
@ -6329,6 +6441,34 @@ ex:;
}
int Xorriso_path_from_node(struct XorrisO *xorriso, IsoNode *node,
char path[SfileadrL], int flag)
{
int ret;
struct FindjoB *job= NULL;
struct stat dir_stbuf;
char *found_path;
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);
Findjob_set_action_found_path(job, 0);
ret= Xorriso_findi(xorriso, job, NULL, (off_t) 0,
NULL, "/", &dir_stbuf, 0, 0);
if(ret > 0) {
ret= 1;
Findjob_get_found_path(job, &found_path, 0);
if(Sfile_str(path, found_path, 0) <= 0)
ret= -1;
}
Findjob_destroy(&job, 0);
return(ret);
}
/* @param flag bit0= do not mark image as changed */
int Xorriso_set_volid(struct XorrisO *xorriso, char *volid, int flag)
{