New command -drive_access, new -as cdrecord option --drive_not_exclusive

This commit is contained in:
2019-09-08 12:30:52 +02:00
parent 8828d6f465
commit 901939986a
15 changed files with 509 additions and 288 deletions

View File

@ -1,7 +1,7 @@
/* xorriso - creates, loads, manipulates and burns ISO 9660 filesystem images.
Copyright 2007-2017 Thomas Schmitt, <scdbackup@gmx.net>
Copyright 2007-2019 Thomas Schmitt, <scdbackup@gmx.net>
Provided under GPL version 2 or later.
@ -279,12 +279,16 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, char *show_adr,
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)
if(flag & 2) {
xorriso->outdev_is_exclusive= xorriso->indev_is_exclusive;
xorriso->outdev_access= xorriso->indev_access;
}
} else if(out_dinfo != NULL && in_dinfo == NULL) {
dinfo= out_dinfo;
if(flag & 1)
if(flag & 1) {
xorriso->indev_is_exclusive= xorriso->outdev_is_exclusive;
xorriso->indev_access= xorriso->outdev_access;
}
} else if(out_dinfo != NULL || in_dinfo != NULL) {
sprintf(xorriso->info_text,
"Two different drives shall be re-assed in one call");
@ -304,6 +308,7 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, char *show_adr,
if(ret==1) {
dinfo= out_dinfo;
xorriso->indev_is_exclusive= xorriso->outdev_is_exclusive;
xorriso->indev_access= xorriso->outdev_access;
}
} else if((flag&3)==2 && xorriso->in_drive_handle!=NULL) {
ret= Xorriso_get_drive_handles(xorriso, &in_dinfo, &in_drive,
@ -314,6 +319,7 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, char *show_adr,
if(ret==1) {
dinfo= in_dinfo;
xorriso->outdev_is_exclusive= xorriso->indev_is_exclusive;
xorriso->outdev_access= xorriso->indev_access;
}
}
@ -362,10 +368,14 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, char *show_adr,
if(flag&1)
if(xorriso->image_start_mode&(1u<<31)) /* used up setting */
xorriso->image_start_mode= 0; /* no need to perform auto setting */
if(flag & 1)
if(flag & 1) {
xorriso->indev_is_exclusive= xorriso->drives_exclusive;
if(flag & 2)
xorriso->indev_access= xorriso->drives_access;
}
if(flag & 2) {
xorriso->outdev_is_exclusive= xorriso->drives_exclusive;
xorriso->outdev_access= xorriso->drives_access;
}
}
drive= dinfo[0].drive;
volset= isoburn_get_attached_image(drive);
@ -727,9 +737,9 @@ int Xorriso_give_up_drive(struct XorrisO *xorriso, int flag)
if(!in_is_out_too) {
do_eject= !!(flag&4);
if((flag & 4) && !xorriso->indev_is_exclusive) {
if((flag & 4) && xorriso->indev_access == 0) {
sprintf(xorriso->info_text,
"Will not eject medium in non-exclusively acquired input drive.");
"Will not eject medium in readonly acquired input drive.");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
do_eject= 0;
}
@ -759,9 +769,9 @@ int Xorriso_give_up_drive(struct XorrisO *xorriso, int flag)
}
if((flag&2) && xorriso->out_drive_handle!=NULL) {
do_eject= !!(flag&4);
if((flag & 4) && !xorriso->outdev_is_exclusive) {
if((flag & 4) && xorriso->outdev_access == 0) {
sprintf(xorriso->info_text,
"Will not eject medium in non-exclusively acquired drive.");
"Will not eject medium in readonly acquired drive.");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
do_eject= 0;
}
@ -795,16 +805,17 @@ int Xorriso_give_up_drive(struct XorrisO *xorriso, int flag)
int Xorriso_may_burn(struct XorrisO *xorriso, int flag)
{
if(xorriso->outdev_is_exclusive)
if(xorriso->outdev_access == 1)
return(1);
sprintf(xorriso->info_text, "The output drive was not acquired exclusively.");
sprintf(xorriso->info_text, "The output drive was acquired readonly.");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
sprintf(xorriso->info_text, "A possible remedy is: -osirrox 'o_excl_on'");
if(xorriso->outdev[0]) {
strcat(xorriso->info_text," -outdev ");
Text_shellsafe(xorriso->outdev, xorriso->info_text, 1);
}
sprintf(xorriso->info_text, "Possible remedy: -drive_access \"exclusive:unrestricted\".");
strcat(xorriso->info_text," Then give up and re-acquire the drive.");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "HINT", 0);
if(!xorriso->outdev_is_exclusive) {
sprintf(xorriso->info_text, "If you insist in -drive_access \"shared:unrestricted\", first read man xorriso about the risks.");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "HINT", 0);
}
return(0);
}
@ -1026,6 +1037,25 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
Xorriso_toc_line(xorriso, flag & 8);
if(flag & 128)
{ret= 1; goto ex;}
/* Report -drive_access if non-default or if long form */
respt[0]= 0;
if(flag & 2) {
if(xorriso->outdev_is_exclusive == 0 || xorriso->outdev_access == 0 ||
!(flag & 33)) {
sprintf(respt, "Drive access : %s:%s\n",
xorriso->outdev_is_exclusive ? "exclusive" : "shared",
xorriso->outdev_access == 0 ? "readonly" : "unrestricted");
}
} else {
if(xorriso->indev_is_exclusive == 0 || xorriso->indev_access == 0 ||
!(flag & 33)) {
sprintf(respt, "Drive access : %s:%s\n",
xorriso->indev_is_exclusive ? "exclusive" : "shared",
xorriso->indev_access == 0 ? "readonly" : "unrestricted");
}
}
if(respt[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 & 32) || !(flag & 1))
@ -1417,11 +1447,11 @@ int Xorriso_toc(struct XorrisO *xorriso, int flag)
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
}
if (disc!=NULL)
isoburn_toc_disc_free(disc);
Xorriso_process_msg_queues(xorriso,0);
ret= 1;
ex:;
Xorriso_process_msg_queues(xorriso,0);
if (disc!=NULL)
isoburn_toc_disc_free(disc);
return(ret);
}