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

This commit is contained in:
Thomas Schmitt 2008-10-25 12:34:36 +00:00
bovenliggende e76340d4f3
commit 3b14ee2117
5 gewijzigde bestanden met toevoegingen van 226 en 22 verwijderingen

Bestand weergeven

@ -2120,6 +2120,8 @@ struct FindjoB {
int damage_filter; /* -1=only undamaged , 0=all , 1=only damaged */
int commit_filter; /* bit0= test -pending_data : uncommitted regular files */
void *wanted_node; /* if not NULL, then only this node address matches */
/* 0= echo
1= rm (also rmdir)
2= rm_r
@ -2143,6 +2145,7 @@ struct FindjoB {
20= is_full_in_iso iso_rr_equiv
21= report_damage
22= report_lba
23= internal:memorize path of last matching node in found_path
*/
int action;
char *target;
@ -2151,11 +2154,10 @@ struct FindjoB {
mode_t mode_and, mode_or;
int type; /* see Xorriso_set_time flag */
time_t date;
char *found_path;
struct FindjoB *subjob;
};
int Findjob_destroy(struct FindjoB **job, int flag);
int Findjob_new(struct FindjoB **o, char *start_path, int flag)
{
@ -2171,16 +2173,18 @@ int Findjob_new(struct FindjoB **o, char *start_path, int flag)
m->end_lba= -1;
m->damage_filter= 0;
m->commit_filter= 0;
m->wanted_node= NULL;
m->action= 0; /* print */
m->target= NULL; /* a mere pointer, not managed memory */
m->user= 0;
m->group= 0;
m->type= 0;
m->date= 0;
m->subjob= NULL;
m->start_path= strdup(start_path);
if(m->start_path==NULL)
goto failed;
m->found_path= NULL;
m->subjob= NULL;
return(1);
failed:;
Findjob_destroy(o, 0);
@ -2311,6 +2315,41 @@ int Findjob_get_commit_filter(struct FindjoB *o, int *commit_filter, int flag)
}
int Findjob_set_wanted_node(struct FindjoB *o, void *wanted_node, int flag)
{
o->wanted_node= wanted_node;
return(1);
}
int Findjob_get_wanted_node(struct FindjoB *o, void **wanted_node, int flag)
{
*wanted_node= o->wanted_node;
return(1);
}
int Findjob_set_found_path(struct FindjoB *o, char *path, int flag)
{
if(o->found_path != NULL)
free(o->found_path);
if(path != NULL) {
o->found_path= strdup(path);
if(o->found_path == NULL)
return(-1);
} else
o->found_path= NULL;
return(1);
}
int Findjob_get_found_path(struct FindjoB *o, char **path, int flag)
{
*path= o->found_path;
return(1);
}
/* @flag bit0=recognize type "e" = El-Torito
@return 0=no match , 1=match , <0 = error
*/
@ -2504,6 +2543,14 @@ int Findjob_set_action_subjob(struct FindjoB *o, int action,
}
int Findjob_set_action_found_path(struct FindjoB *o, int flag)
{
o->action= 23;
Findjob_set_found_path(o, NULL, 0);
return(1);
}
/* ---------------------------- SplitparT ------------------------- */
@ -3158,8 +3205,6 @@ struct SectorbitmaP {
int map_size;
};
int Sectorbitmap_destroy(struct SectorbitmaP **o, int flag);
int Sectorbitmap_new(struct SectorbitmaP **o, int sectors, int sector_size,
int flag)
@ -7351,7 +7396,7 @@ int Xorriso_much_too_long(struct XorrisO *xorriso, int len, int flag)
int Xorriso_no_findjob(struct XorrisO *xorriso, char *cmd, int flag)
{
sprintf(xorriso->info_text, "%s: cannot set create find job object", cmd);
sprintf(xorriso->info_text, "%s: cannot create find job object", cmd);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
return(1);
}

Bestand weergeven

@ -576,6 +576,7 @@ int Xorriso_lst_destroy(struct Xorriso_lsT **lstring, int flag);
int Xorriso_open_job_data_to(struct XorrisO *xorriso,
struct CheckmediajoB *job, int flag);
int Xorriso_no_findjob(struct XorrisO *xorriso, char *cmd, int flag);
int Sfile_str(char target[SfileadrL], char *source, int flag);
@ -642,6 +643,12 @@ int Linkitem_reset_stack(struct LinkiteM **o, struct LinkiteM *to, int flag);
struct FindjoB;
int Findjob_new(struct FindjoB **o, char *start_path, int flag);
int Findjob_destroy(struct FindjoB **job, int flag);
/* @return 0=no match , 1=match , <0 = error
*/
int Findjob_test(struct FindjoB *job, char *name,
@ -680,6 +687,8 @@ int Findjob_set_action_ad(struct FindjoB *o, int type, time_t date, int flag);
int Findjob_set_start_path(struct FindjoB *o, char *start_path, int flag);
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_get_lba_damage_filter(struct FindjoB *o, int *start_lba,
@ -687,6 +696,14 @@ int Findjob_get_lba_damage_filter(struct FindjoB *o, int *start_lba,
int Findjob_get_commit_filter(struct FindjoB *o, int *commit_filter, int flag);
int Findjob_set_wanted_node(struct FindjoB *o, void *wanted_node, int flag);
int Findjob_get_wanted_node(struct FindjoB *o, void **wanted_node, int flag);
int Findjob_set_found_path(struct FindjoB *o, char *path, int flag);
int Findjob_get_found_path(struct FindjoB *o, char **path, int flag);
struct SplitparT;

Bestand weergeven

@ -1 +1 @@
#define Xorriso_timestamP "2008.10.24.130124"
#define Xorriso_timestamP "2008.10.25.123133"

Bestand weergeven

@ -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)
{

Bestand weergeven

@ -52,6 +52,8 @@ int Xorriso__text_to_sev(char *severity_name, int *severity_number,int flag);
/* @param flag bit0=report about output drive
bit1=short report form
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);