Re-aquiring drives by their burn_drive_convert_fs_adr() names

This commit is contained in:
Thomas Schmitt 2011-09-22 14:22:02 +00:00
parent 014b5f3e51
commit b2f5991651
7 changed files with 52 additions and 17 deletions

View File

@ -196,6 +196,7 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
m->in_charset= NULL;
m->isofs_st_out= time(0) - 1;
m->indev_is_exclusive= 1;
m->indev_off_adr[0]= 0;
m->isofs_st_in= 0;
m->volset_change_pending= 0;
m->no_volset_present= 0;
@ -207,6 +208,7 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
m->out_charset= NULL;
m->dev_fd_1= -1;
m->outdev_is_exclusive= 1;
m->outdev_off_adr[0]= 0;
m->grow_blindly_msc2= -1;
m->ban_stdio_write= 0;
m->do_dummy= 0;

View File

@ -157,7 +157,8 @@ ex:;
2=success, but not writeable with bit1
3=success, but not blank and not ISO with bit0
*/
int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag)
int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, char *show_adr,
int flag)
{
int ret, hret, not_writeable= 0, has_what, aquire_flag, load_lba, ext;
int lba, track, session, params_flag, adr_mode, read_ret;
@ -168,15 +169,23 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag)
IsoImage *volset = NULL;
IsoNode *root_node;
struct isoburn_read_opts *ropts= NULL;
char *libburn_adr= NULL, *boot_fate, *sev;
char *libburn_adr= NULL, *off_adr= NULL, *boot_fate, *sev;
size_t value_length;
char *value= NULL;
double num;
char volid[33], *adr_data= NULL, *adr_pt;
Xorriso_alloc_meM(libburn_adr, char, SfileadrL);
Xorriso_alloc_meM(off_adr, char, SfileadrL);
Xorriso_alloc_meM(adr_data, char, 163);
if(show_adr == NULL) {
show_adr= adr;
ret= burn_drive_convert_fs_adr(adr, off_adr);
if(ret > 0)
adr= off_adr;
}
if((flag&3)==0) {
sprintf(xorriso->info_text,
"XORRISOBURN program error : Xorriso_aquire_drive bit0+bit1 not set");
@ -310,8 +319,11 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag)
if(flag&2) {
xorriso->out_drive_handle= dinfo;
if(Sfile_str(xorriso->outdev, adr, 0)<=0)
if(Sfile_str(xorriso->outdev, show_adr, 0)<=0)
{ret= -1; goto ex;}
ret= burn_drive_convert_fs_adr(adr, xorriso->outdev_off_adr);
if(ret <= 0)
xorriso->outdev_off_adr[0]= 0;
if(state != BURN_DISC_BLANK && state != BURN_DISC_APPENDABLE) {
sprintf(xorriso->info_text, "Disc status unsuitable for writing");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
@ -320,8 +332,11 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag)
}
if(flag&1) {
xorriso->in_drive_handle= dinfo;
if(Sfile_str(xorriso->indev, adr, 0)<=0)
if(Sfile_str(xorriso->indev, show_adr, 0)<=0)
{ret= -1; goto ex;}
ret= burn_drive_convert_fs_adr(adr, xorriso->indev_off_adr);
if(ret <= 0)
xorriso->indev_off_adr[0]= 0;
} else if(flag&2) {
if(xorriso->in_volset_handle==NULL) {
/* No volume loaded: create empty one */
@ -538,6 +553,7 @@ ex:
}
if(ropts!=NULL)
isoburn_ropt_destroy(&ropts, 0);
Xorriso_free_meM(off_adr);
Xorriso_free_meM(libburn_adr);
Xorriso_free_meM(adr_data);
return(ret);
@ -619,6 +635,7 @@ int Xorriso_give_up_drive(struct XorrisO *xorriso, int flag)
}
xorriso->out_drive_handle= NULL;
xorriso->outdev[0]= 0;
xorriso->outdev_off_adr[0]= 0;
} else if((flag&1) && xorriso->out_drive_handle!=NULL) {
ret= Xorriso_create_empty_iso(xorriso, 0);
if(ret<=0)
@ -685,17 +702,22 @@ ex:;
}
/* @param flag bit0+1= what to aquire after giving up outdev
/* @param flag bit0+1= what to give up and re-aquire by the address of outdev
0=none, 1=indev, 2=outdev, 3=both
*/
int Xorriso_reaquire_outdev(struct XorrisO *xorriso, int flag)
{
int ret, aq_flag;
char *drive_name= NULL;
char *drive_name= NULL, *off_name= NULL;
Xorriso_alloc_meM(drive_name, char, SfileadrL);
Xorriso_alloc_meM(off_name, char, SfileadrL);
aq_flag= flag&3;
strcpy(drive_name, xorriso->outdev);
if(xorriso->outdev_off_adr[0])
strcpy(off_name, xorriso->outdev_off_adr);
else
strcpy(off_name, drive_name);
Xorriso_give_up_drive(xorriso, aq_flag);
if(aq_flag==0) {
sprintf(xorriso->info_text,"Gave up -outdev ");
@ -705,17 +727,26 @@ int Xorriso_reaquire_outdev(struct XorrisO *xorriso, int flag)
}
sprintf(xorriso->info_text,"Re-aquiring -outdev ");
Text_shellsafe(drive_name, xorriso->info_text, 1);
if(strcmp(drive_name, off_name) != 0) {
strcat(xorriso->info_text, " (");
Text_shellsafe(off_name, xorriso->info_text, 1);
strcat(xorriso->info_text, ")");
}
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
ret= Xorriso_aquire_drive(xorriso, drive_name, aq_flag);
ret= Xorriso_aquire_drive(xorriso, off_name, drive_name, aq_flag);
if(ret<=0) {
sprintf(xorriso->info_text,"Could not re-aquire -outdev ");
Text_shellsafe(xorriso->outdev, xorriso->info_text, 1);
Text_shellsafe(drive_name, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
goto ex;
}
strcpy(xorriso->outdev, drive_name);
if(strcmp(xorriso->outdev, xorriso->indev) == 0)
strcpy(xorriso->indev, drive_name);
ret= 1;
ex:;
Xorriso_free_meM(drive_name);
Xorriso_free_meM(off_name);
return(ret);
}

View File

@ -1795,9 +1795,6 @@ int Xorriso_option_close_filter_list(struct XorrisO *xorriso, int flag)
int Xorriso_option_commit(struct XorrisO *xorriso, int flag)
{
int ret;
char *newdev= NULL;
Xorriso_alloc_meM(newdev, char, SfileadrL);
if(!xorriso->volset_change_pending) {
sprintf(xorriso->info_text, "-commit: No image modifications pending");
@ -1822,16 +1819,16 @@ int Xorriso_option_commit(struct XorrisO *xorriso, int flag)
{ret= 1; goto ex;}
if(Sregex_string(&(xorriso->in_charset), xorriso->out_charset, 0) <= 0)
{ret= -1; goto ex;}
strcpy(newdev, xorriso->outdev);
if(xorriso->grow_blindly_msc2>=0)
ret= Xorriso_option_dev(xorriso, "", 3|4);
else {
xorriso->displacement= 0;
xorriso->displacement_sign= 0;
ret= Xorriso_option_dev(xorriso, newdev, 3|4);
ret= Xorriso_reaquire_outdev(xorriso, 3);
if(xorriso->in_drive_handle == NULL)
xorriso->image_start_mode= 0; /* session setting is invalid by now */
}
ex:;
Xorriso_free_meM(newdev);
return(ret);
}

View File

@ -91,7 +91,7 @@ int Xorriso_option_dev(struct XorrisO *xorriso, char *in_adr, int flag)
}
ret= Xorriso_give_up_drive(xorriso, (flag&3)|((flag&32)>>2));
} else
ret= Xorriso_aquire_drive(xorriso, adr,
ret= Xorriso_aquire_drive(xorriso, adr, NULL,
(flag & (3 | 32 | 64)) | (((flag & (8 | 16)) >> 1)));
if(ret<=0)
return(ret);

View File

@ -270,6 +270,8 @@ struct XorrisO { /* the global context of xorriso */
void *in_volset_handle; /* interpreted only by libburnia oriented modules */
char *in_charset; /* The charset to interpret the filename bytes */
int indev_is_exclusive;
char indev_off_adr[SfileadrL]; /* Result of burn_drive_convert_fs_adr(indev)
when indev gets aquired. */
time_t isofs_st_out; /* A time point at least 1 second before image
composition began. To be stored with image as
@ -296,6 +298,8 @@ struct XorrisO { /* the global context of xorriso */
connected to externaly perveived stdout.
*/
int outdev_is_exclusive;
char outdev_off_adr[SfileadrL]; /* Result of burn_drive_convert_fs_adr(outdev)
when outdev gets aquired. */
int grow_blindly_msc2; /* if >= 0 this causes growing from drive to drive.
The value is used as block address offset for

View File

@ -1 +1 @@
#define Xorriso_timestamP "2011.09.20.133438"
#define Xorriso_timestamP "2011.09.22.142118"

View File

@ -37,7 +37,8 @@ int Xorriso_create_empty_iso(struct XorrisO *xorriso, int flag);
bit1=aquire as libburn output drive (as isoburn drive if bit0)
@return <=0 failure , 1=success , 2=neither readable or writeable
*/
int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag);
int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, char *show_adr,
int flag);
int Xorriso_give_up_drive(struct XorrisO *xorriso, int flag);