Avoiding open-close cycles on MMC drives after blanking or burning

This commit is contained in:
Thomas Schmitt 2011-10-05 17:22:30 +00:00
parent aa2b37aa84
commit 53238362ac
2 changed files with 62 additions and 21 deletions

View File

@ -160,6 +160,9 @@ ex:;
the write start address
bit5= do not print toc
bit6= do not calm down drive after aquiring it
bit7= re-assess rather than aquire:
Do not give up drives,
use isoburn_drive_aquire() with re-assessment bit
@return <=0 failure , 1= ok
2=success, but not writeable with bit1
3=success, but not blank and not ISO with bit0
@ -170,8 +173,8 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, char *show_adr,
int ret, hret, not_writeable= 0, has_what, aquire_flag, load_lba, ext;
int lba, track, session, params_flag, adr_mode, read_ret;
uint32_t size, offst;
struct burn_drive_info *dinfo= NULL, *out_dinfo, *in_dinfo;
struct burn_drive *drive= NULL, *out_drive, *in_drive;
struct burn_drive_info *dinfo= NULL, *out_dinfo= NULL, *in_dinfo= NULL;
struct burn_drive *drive= NULL, *out_drive= NULL, *in_drive= NULL;
enum burn_disc_status state;
IsoImage *volset = NULL;
IsoNode *root_node;
@ -199,9 +202,11 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, char *show_adr,
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
{ret= -1; goto ex;}
}
if(!(flag & 128)) {
ret= Xorriso_give_up_drive(xorriso, (flag&3)|8);
if(ret<=0)
goto ex;
}
if(flag & 1)
xorriso->isofs_st_out= time(0) - 1;
@ -219,7 +224,30 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, char *show_adr,
}
}
if((flag&3)==1 && xorriso->out_drive_handle!=NULL) {
if(flag & 128) {
if(flag & 1)
Xorriso_get_drive_handles(xorriso, &in_dinfo, &in_drive, "", 16);
if(flag & 2)
Xorriso_get_drive_handles(xorriso, &out_dinfo, &out_drive, "", 2 | 16);
if(in_dinfo != NULL && (out_dinfo == NULL || out_dinfo == in_dinfo)) {
dinfo= in_dinfo;
if(flag & 2)
xorriso->outdev_is_exclusive= xorriso->indev_is_exclusive;
} else if(out_dinfo != NULL && in_dinfo == NULL) {
dinfo= out_dinfo;
if(flag & 1)
xorriso->indev_is_exclusive= xorriso->outdev_is_exclusive;
} else if(out_dinfo != NULL || in_dinfo != NULL) {
sprintf(xorriso->info_text,
"Two different drives shall be re-assed in one call");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
{ret= 0; goto ex;}
} else {
sprintf(xorriso->info_text, "No drive aquired on re-assessment");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
{ret= 0; goto ex;}
}
} else if((flag&3)==1 && xorriso->out_drive_handle!=NULL) {
ret= Xorriso_get_drive_handles(xorriso, &out_dinfo, &out_drive,
"on attempt to compare new indev with outdev", 2);
if(ret<=0)
@ -241,7 +269,7 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, char *show_adr,
}
}
if(dinfo==NULL) {
if(dinfo == NULL || (flag & 128)) {
aquire_flag= 1 | ((flag&(8|4))>>1) | ((xorriso->toc_emulation_flag & 3)<<3);
if(xorriso->toc_emulation_flag & 4)
aquire_flag|= 128;
@ -249,17 +277,21 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, char *show_adr,
aquire_flag|= 32;
if((xorriso->ino_behavior & (1 | 2)) && !(xorriso->do_aaip & (4 | 32)))
aquire_flag|= 64;
if(flag & 128)
aquire_flag|= 256;
burn_preset_device_open(xorriso->drives_exclusive, 0, 0);
burn_allow_drive_role_4(1 | (xorriso->early_stdio_test & 14));
ret= isoburn_drive_aquire(&dinfo, libburn_adr, aquire_flag);
burn_preset_device_open(1, 0, 0);
Xorriso_process_msg_queues(xorriso,0);
if(ret<=0) {
if(flag & 128)
sprintf(xorriso->info_text,"Cannot re-assess drive '%s'", adr);
else
sprintf(xorriso->info_text,"Cannot aquire drive '%s'", adr);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
ret= 0; goto ex;
}
state= isoburn_disc_get_status(dinfo[0].drive);
ret= isoburn_get_img_partition_offset(dinfo[0].drive, &offst);
if((state == BURN_DISC_APPENDABLE || state == BURN_DISC_FULL) && ret == 1) {
@ -709,8 +741,11 @@ ex:;
}
/* @param flag bit0+1= what to give up and re-aquire by the address of outdev
0=none, 1=indev, 2=outdev, 3=both
/* @param flag bit0+1= what to give up and/or re-assess in what role
0=give up outdev
1=give up indev if not outdev, re-assess outdev as indev
2=re-assess outdev as outdev
3=give up indev if not outdev, re-assess outdev as dev
*/
int Xorriso_reaquire_outdev(struct XorrisO *xorriso, int flag)
{
@ -725,14 +760,20 @@ int Xorriso_reaquire_outdev(struct XorrisO *xorriso, int flag)
strcpy(off_name, xorriso->outdev_off_adr);
else
strcpy(off_name, drive_name);
Xorriso_give_up_drive(xorriso, aq_flag);
if(aq_flag==0) {
if(aq_flag == 0) {
Xorriso_give_up_drive(xorriso, 2);
sprintf(xorriso->info_text,"Gave up -outdev ");
Text_shellsafe(xorriso->outdev, xorriso->info_text, 1);
Text_shellsafe(xorriso->indev, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
{ret= 1; goto ex;}
}
sprintf(xorriso->info_text,"Re-aquiring -outdev ");
/* Only give up indev, and only if it is not outdev */;
if(xorriso->in_drive_handle != xorriso->out_drive_handle &&
xorriso->in_drive_handle != NULL && (aq_flag & 1))
Xorriso_give_up_drive(xorriso, 1 | 8);
sprintf(xorriso->info_text,"Re-assessing -outdev ");
Text_shellsafe(drive_name, xorriso->info_text, 1);
if(strcmp(drive_name, off_name) != 0) {
strcat(xorriso->info_text, " (");
@ -740,16 +781,16 @@ int Xorriso_reaquire_outdev(struct XorrisO *xorriso, int flag)
strcat(xorriso->info_text, ")");
}
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
ret= Xorriso_aquire_drive(xorriso, off_name, drive_name, aq_flag);
/* Re-assess outdev */
ret= Xorriso_aquire_drive(xorriso, off_name, drive_name, aq_flag | 128);
if(ret<=0) {
sprintf(xorriso->info_text,"Could not re-aquire -outdev ");
sprintf(xorriso->info_text,"Could not re-assess -outdev ");
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);

View File

@ -1 +1 @@
#define Xorriso_timestamP "2011.10.05.085704"
#define Xorriso_timestamP "2011.10.05.172142"