Re-aquiring outdev after formatting and blanking already in xorrisoburn

This commit is contained in:
Thomas Schmitt 2008-11-29 16:59:08 +00:00
parent 2ed45c9cb1
commit a860deb112
4 changed files with 107 additions and 14 deletions

View File

@ -10604,11 +10604,9 @@ unusable_index:;
if(ret==0)
return(ret);
strcpy(drive_name, xorriso->outdev);
if(ret!=2) {
if(ret<=0)
aq_flag= 0;
aq_ret= Xorriso_reaquire_outdev(xorriso, aq_flag);
if(ret<=0 && ret<aq_ret)
if(ret <= 0) { /* in case of success, above functions will have re-aquired */
aq_ret= Xorriso_reaquire_outdev(xorriso, 0); /* actually give up drive */
if(ret<aq_ret)
return(ret);
if(aq_ret<=0)
return(aq_ret);

View File

@ -527,6 +527,12 @@ int Xorriso_spotlist_to_sectormap(struct XorrisO *xorriso,
int Xorriso_toc_to_string(struct XorrisO *xorriso, char **toc_text, int flag);
/* @param flag bit0+1= what to aquire after giving up outdev
0=none, 1=indev, 2=outdev, 3=both
*/
int Xorriso_reaquire_outdev(struct XorrisO *xorriso, int flag);
struct Xorriso_lsT {
char *text;
struct Xorriso_lsT *prev,*next;

View File

@ -1 +1 @@
#define Xorriso_timestamP "2008.11.29.140837"
#define Xorriso_timestamP "2008.11.29.165843"

View File

@ -992,6 +992,40 @@ int Xorriso_set_isolinux_options(struct XorrisO *xorriso,
}
int Xorriso_auto_format(struct XorrisO *xorriso, int flag)
{
int ret, profile, status, num_formats;
char profile_name[80];
struct burn_drive_info *dinfo;
struct burn_drive *drive;
off_t size;
unsigned dummy;
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
"on attempt to autoformat", 2);
if(ret<=0)
return(0);
ret= burn_disc_get_profile(drive, &profile, profile_name);
if(ret>0 && (profile==0x12 || profile==0x43)) { /* DVD-RAM or BD-RE */
ret= burn_disc_get_formats(drive, &status, &size, &dummy, &num_formats);
if(ret>0 && status==BURN_FORMAT_IS_UNFORMATTED) {
sprintf(xorriso->info_text,
"Unformatted %s media detected. Trying -format fast.",
profile_name);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
ret= Xorriso_format_media(xorriso, 1 | 4);
if(ret<=0) {
sprintf(xorriso->info_text, "Automatic formatting of %s failed",
profile_name);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(ret);
}
}
}
return(1);
}
#define Xorriso_with_make_isohybrid_mbR 1
@ -999,16 +1033,15 @@ int Xorriso_set_isolinux_options(struct XorrisO *xorriso,
*/
int Xorriso_write_session(struct XorrisO *xorriso, int flag)
{
int ret, relax= 0, i, profile, status, num_formats;
int ret, relax= 0, i;
int major, minor, micro;
unsigned dummy;
char xorriso_id[256], *img_id, profile_name[80], sfe[5*SfileadrL], *cpt;
char xorriso_id[256], *img_id, sfe[5*SfileadrL], *cpt;
struct isoburn_imgen_opts *sopts= NULL;
struct burn_drive_info *dinfo, *source_dinfo;
struct burn_drive *drive, *source_drive;
struct burn_disc *disc= NULL;
struct burn_write_opts *burn_options;
off_t readcounter= 0,writecounter= 0, size;
off_t readcounter= 0,writecounter= 0;
int num_sessions= 0, num_tracks= 0;
struct burn_session **sessions;
struct burn_track **tracks;
@ -1018,6 +1051,13 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag)
ElToritoBootImage *bootimg;
enum eltorito_boot_media_type emul_type= ELTORITO_NO_EMUL;
#ifdef NIX
int profile, status, num_formats;
char profile_name[80];
off_t size;
unsigned dummy;
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
"on attempt to write", 2);
if(ret<=0)
@ -1042,9 +1082,24 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag)
"on attempt to write", 2);
if(ret<=0)
return(0);
ret= burn_disc_get_profile(drive, &profile, profile_name);
}
}
#else /* NIX */
if(!(flag & 1)) {
ret= Xorriso_auto_format(xorriso, 0);
if(ret <=0 )
return(0);
}
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
"on attempt to write", 2);
if(ret<=0)
return(0);
#endif /* ! NIX */
if(xorriso->out_drive_handle == xorriso->in_drive_handle) {
source_drive= drive;
} else {
@ -4317,7 +4372,9 @@ int Xorriso_tell_media_space(struct XorrisO *xorriso,
}
/* @param flag bit0=fast , bit1=deformat
/* @param flag bit0= fast
bit1= deformat
bit2= do not re-aquire drive
@return 0=failure, did not touch media , -1=failure, altered media
1=success, altered media , 2=success, did not touch media
*/
@ -4406,11 +4463,18 @@ int Xorriso_blank_media(struct XorrisO *xorriso, int flag)
Xorriso_process_msg_queues(xorriso,0);
sprintf(xorriso->info_text, "Blanking done\n");
Xorriso_info(xorriso,0);
if(!(flag & 4)) {
ret= Xorriso_reaquire_outdev(xorriso,
2 + (xorriso->in_drive_handle == xorriso->out_drive_handle));
if(ret <= 0)
return(-1);
}
return(1);
}
/* @param flag bit0= try to achieve faster formatting
bit2= do not re-aquire drive
bit7= by_index mode:
bit8 to bit15 contain the index of the format to use.
@return 0=failure, did not touch media , -1=failure, altered media
@ -4428,6 +4492,7 @@ int Xorriso_format_media(struct XorrisO *xorriso, int flag)
char current_profile_name[80];
off_t size= 0;
time_t start_time;
enum burn_disc_status disc_state;
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
"on attempt to -format", 2);
@ -4525,6 +4590,20 @@ int Xorriso_format_media(struct XorrisO *xorriso, int flag)
Xorriso_process_msg_queues(xorriso,0);
sprintf(xorriso->info_text, "Formatting done\n");
Xorriso_info(xorriso,0);
if(!(flag & 4)) {
ret= Xorriso_reaquire_outdev(xorriso,
2 + (xorriso->in_drive_handle == xorriso->out_drive_handle));
if(ret <= 0)
return(-1);
}
disc_state = isoburn_disc_get_status(drive);
if(disc_state==BURN_DISC_FULL && !(flag&1)) {
/* Blank because full format certification pattern might be non-zero */
ret= Xorriso_blank_media(xorriso, 1);
if(ret <= 0)
return(0);
}
return(1);
}
@ -4535,7 +4614,7 @@ int Xorriso_format_media(struct XorrisO *xorriso, int flag)
*/
int Xorriso_blank_as_needed(struct XorrisO *xorriso, int flag)
{
int ret, is_formatted= -1, status, num_formats;
int ret, is_formatted= -1, status, num_formats, did_work= 0;
struct burn_drive_info *dinfo;
struct burn_drive *drive;
enum burn_disc_status disc_state;
@ -4568,11 +4647,15 @@ int Xorriso_blank_as_needed(struct XorrisO *xorriso, int flag)
}
if(!is_formatted) {
ret= Xorriso_format_media(xorriso, (current_profile == 0x43));
if(ret <= 0)
return(ret);
did_work= (ret == 1);
}
} else if(current_profile == 0x14 && (flag&4)) { /* DVD-RW sequential */
ret= Xorriso_format_media(xorriso, 0);
if(ret <= 0)
return(ret);
did_work= (ret == 1);
}
disc_state = isoburn_disc_get_status(drive);
@ -4580,6 +4663,8 @@ int Xorriso_blank_as_needed(struct XorrisO *xorriso, int flag)
ret= Xorriso_blank_media(xorriso, 1);
return(ret);
}
if(did_work)
return(1);
sprintf(xorriso->info_text, "%s as_needed: no need for action detected",
(flag&4) ? "-format" : "-blank");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
@ -7031,6 +7116,10 @@ int Xorriso_burn_track(struct XorrisO *xorriso, off_t write_start_address,
char reasons[BURN_REASONS_LEN], sfe[5*SfileadrL], profile_name[80];
char head_buffer[64*1024];
ret= Xorriso_auto_format(xorriso, 0);
if(ret <=0 )
return(0);
do_isosize= !!(flag&2);
ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive,
"on attempt to burn track", 2);