New option -load session|track|sbsector|volid

This commit is contained in:
Thomas Schmitt 2008-05-12 08:27:18 +00:00
parent 96b808e0c5
commit fc8d4b8dbe
4 changed files with 170 additions and 51 deletions

View File

@ -417,7 +417,7 @@ An empty address string "" gives up the current device
without aquiring a new one.
.TP
\fB\-indev\fR address
Set input drive and load eventual ISO image. If the new input drive differs
Set input drive and load an eventual ISO image. If the new input drive differs
from -outdev then switch from growing to modifying. The same rules and
restrictions apply as with -dev.
.TP
@ -437,6 +437,33 @@ apply. See above paragraph "Libburn drives".
An empty address string "" gives up the current output drive
without aquiring a new one. No writing is possible without an output drive.
.TP
\fB\-load\fR entity id
Load a particular (possibly outdated) ISO image from a -dev or -indev which
hosts more than one session. Usually all available sessions are shown with
option -toc.
.br
entity depicts the kind of addressing. id depicts the particular
address. The following entities are defined:
.br
"auto" with any id addresses the last session in -toc. This is the default.
.br
"session" with id being a number as of a line "ISO session", column "Idx".
.br
"track" with id being a number as of a line "ISO track", column "Idx".
.br
"lba" or "sbsector" with a number as of a line "ISO ...", column "sbsector".
.br
"volid" with a text as of a line "ISO ...", column "Volume Id".
.br
Adressing a non-existing entity or one which does not represent an ISO
image will either abandon -indev or at least lead to a blank image.
.br
If an input drive is set at the moment when -load is executed, then the
addressed ISO image is loaded immediately. Else, the setting will be pending
until the next -dev or -indev. After the image has been loaded once, the
setting is valid for -rollback until next -dev or -indev, where it
will be reset to "auto".
.TP
\fB\-rom_toc_scan\fR "on"|"off"
Read-only drives do not tell the actual media type but show any media as
ROM (e.g. as DVD-ROM). The session history of MMC multi-session media might

View File

@ -2696,6 +2696,8 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
m->do_overwrite= 2;
m->do_reassure= 0;
m->toc_emulation_flag= 0;
m->image_start_mode= 0;
m->image_start_value[0]= 0;
m->indev[0]= 0;
m->in_drive_handle= NULL;
m->in_volset_handle= NULL;
@ -3726,9 +3728,11 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
-options_from_file:${resume_state_file}_pos
*/
{
int is_default, no_defaults, i, ret;
int is_default, no_defaults, i, ret, adr_mode;
char *line, sfe[5*SfileadrL], mode[80], *form, *treatment;
static char channel_prefixes[4][4]= {".","R","I","M"};
static char load_names[][20]= {"auto", "session", "track", "lba", "volid"};
static int max_load_mode= 4;
struct LstrinG *paths, *leafs;
no_defaults= flag&1;
@ -4041,6 +4045,21 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
if(!(is_default && no_defaults))
Xorriso_status_result(xorriso,filter,fp,flag&2);
adr_mode= xorriso->image_start_mode & 0xffff;
if(adr_mode>=0 && adr_mode<=max_load_mode) {
is_default= (adr_mode==0);
sprintf(line,"-load %s ", load_names[adr_mode]);
if(adr_mode==0)
sprintf(line+strlen(line),"''\n");
else if(adr_mode>=1 && adr_mode<=3)
sprintf(line+strlen(line),"%s\n", xorriso->image_start_value);
else
sprintf(line+strlen(line),"%s\n",
Text_shellsafe(xorriso->image_start_value, sfe, 0));
if(!(is_default && no_defaults))
Xorriso_status_result(xorriso,filter,fp,flag&2);
}
if(strcmp(xorriso->indev,xorriso->outdev)==0) {
sprintf(line,"-dev %s\n", Text_shellsafe(xorriso->indev,sfe,0));
Xorriso_status_result(xorriso,filter,fp,flag&2);
@ -8401,6 +8420,8 @@ int Xorriso_option_dev(struct XorrisO *xorriso, char *in_adr, int flag)
ret= Xorriso_aquire_drive(xorriso, adr, (flag&3)|((flag&(8|16))>>1));
if(ret<=0)
return(ret);
if(xorriso->in_drive_handle == NULL)
xorriso->image_start_mode= 0; /* session setting is invalid by now */
return(1);
}
@ -8984,6 +9005,9 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" growing to modifying.",
" -outdev address",
" Set output drive and switch from growing to modifying.",
" -load \"session\"|\"track\"|\"lba\"|\"sbsector\"|\"volid\"|\"auto\" id",
" Load a particular (outdated) ISO image from a -dev or",
" -indev which hosts more than one session.",
" -rom_toc_scan \"on\"|\"off\"",
" Enable scanning for ISO sessions on read-only drives/media.",
" -ban_stdio_write",
@ -9351,6 +9375,105 @@ int Xorriso_option_joliet(struct XorrisO *xorriso, char *mode, int flag)
}
/* Option -load session|track|sbsector value */
/* @return <=0 error , 1 success, 2 revoked by -reassure
*/
int Xorriso_option_load(struct XorrisO *xorriso, char *adr_mode,
char *adr_value, int flag)
{
double num;
int ret, l;
if(xorriso->volset_change_pending) {
sprintf(xorriso->info_text,
"-load: Image changes pending. -commit or -rollback first");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
ret= Xorriso_reassure(xorriso, "-load", "loads an alternative image", 0);
if(ret<=0)
return(2);
if(strcmp(adr_mode, "auto")==0)
xorriso->image_start_mode= 0;
else if(strcmp(adr_mode, "session")==0)
xorriso->image_start_mode= 1;
else if(strcmp(adr_mode, "track")==0)
xorriso->image_start_mode= 2;
else if(strcmp(adr_mode, "lba")==0 || strcmp(adr_mode, "sbsector")==0)
xorriso->image_start_mode= 3;
else if(strcmp(adr_mode, "volid")==0)
xorriso->image_start_mode= 4;
else {
sprintf(xorriso->info_text, "-load: unknown address mode '%s'", adr_mode);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
l= strlen(adr_value);
if(l==0)
xorriso->image_start_mode= 0;
if(xorriso->image_start_mode>=1 && xorriso->image_start_mode<= 3) {
num= Scanf_io_size(adr_value, 0);
if(xorriso->image_start_mode==3 &&
(adr_value[l-1]<'0' || adr_value[l-1]>'9'))
num/= 2048.0;
sprintf(xorriso->image_start_value, "%.f", num);
} else {
if(strlen(adr_value)>80) {
sprintf(xorriso->info_text, "-load: address value too long (80 < %d)",
(int) strlen(adr_value));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
strcpy(xorriso->image_start_value, adr_value);
}
xorriso->image_start_mode|= (1<<30); /* enable non-default msc1 processing */
if(strlen(xorriso->indev)>0) {
ret= Xorriso_option_rollback(xorriso, 1); /* Load image, no -reassure */
if(ret<=0)
return(ret);
}
return(1);
}
/* Option -logfile */
int Xorriso_option_logfile(struct XorrisO *xorriso, char *channel,
char *fileadr, int flag)
{
int hflag,channel_no= 0, ret;
if(channel[0]==0) {
logfile_wrong_form:;
sprintf(xorriso->info_text,"Wrong form. Correct would be: -logfile \".\"|\"R\"|\"I\"|\"M\" file_address");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
return(0);
}
hflag= 2;
if(channel[0]=='R')
channel_no= 1;
else if(channel[0]=='I')
channel_no= 2;
else if(channel[0]=='M')
channel_no= 3;
else if(channel[0]=='.')
hflag= 4;
else
goto logfile_wrong_form;
if(strcmp(fileadr,"-")==0 || fileadr[0]==0)
hflag|= (1<<15);
xorriso->logfile[channel_no][0]= 0;
ret= Write_to_channel(fileadr,channel_no,hflag);
if(ret<=0) {
sprintf(xorriso->info_text, "Cannot open logfile: %s", fileadr);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
} else if(!(hflag&(1<<15)))
if(Sfile_str(xorriso->logfile[channel_no], fileadr, 0)<=0)
return(-1);
return(ret>0);
}
/* Options -ls alias -lsi and -lsl alias -lsli
and -lsd alias -lsdi and -lsdl alias -lsdli
and -du alias -dui and -dus alias -dusi
@ -9516,43 +9639,6 @@ ex:;
}
/* Option -logfile */
int Xorriso_option_logfile(struct XorrisO *xorriso, char *channel,
char *fileadr, int flag)
{
int hflag,channel_no= 0, ret;
if(channel[0]==0) {
logfile_wrong_form:;
sprintf(xorriso->info_text,"Wrong form. Correct would be: -logfile \".\"|\"R\"|\"I\"|\"M\" file_address");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
return(0);
}
hflag= 2;
if(channel[0]=='R')
channel_no= 1;
else if(channel[0]=='I')
channel_no= 2;
else if(channel[0]=='M')
channel_no= 3;
else if(channel[0]=='.')
hflag= 4;
else
goto logfile_wrong_form;
if(strcmp(fileadr,"-")==0 || fileadr[0]==0)
hflag|= (1<<15);
xorriso->logfile[channel_no][0]= 0;
ret= Write_to_channel(fileadr,channel_no,hflag);
if(ret<=0) {
sprintf(xorriso->info_text, "Cannot open logfile: %s", fileadr);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
} else if(!(hflag&(1<<15)))
if(Sfile_str(xorriso->logfile[channel_no], fileadr, 0)<=0)
return(-1);
return(ret>0);
}
/* Option -mark */
int Xorriso_option_mark(struct XorrisO *xorriso, char *mark, int flag)
{
@ -10346,7 +10432,8 @@ ex:;
/* Option -rollback */
/* @return <=0 error , 1 success, 2 revoked by -reassure
/* @param flag bit0= do not -reassure
@return <=0 error , 1 success, 2 revoked by -reassure
*/
int Xorriso_option_rollback(struct XorrisO *xorriso, int flag)
{
@ -10357,19 +10444,19 @@ int Xorriso_option_rollback(struct XorrisO *xorriso, int flag)
which_will= "revoke the pending image changes";
else
which_will= "reload the image";
ret= Xorriso_reassure(xorriso, "-rollback", which_will, 0);
if(ret<=0)
return(2);
if(!(flag&1)) {
ret= Xorriso_reassure(xorriso, "-rollback", which_will, 0);
if(ret<=0)
return(2);
}
if(Sfile_str(indev, xorriso->indev, 0)<=0)
return(-1);
ret= Xorriso_give_up_drive(xorriso, 1|8);
if(ret<=0)
return(ret);
xorriso->image_start_mode&= ~(1<<31); /* reactivate eventual -load address */
ret= Xorriso_option_dev(xorriso, indev, 1|4);
/*
1|((xorriso->out_drive_handle==NULL)<<1));
*/
return(ret);
}
@ -11029,6 +11116,14 @@ next_command:;
(*idx)++;
ret= Xorriso_option_joliet(xorriso, arg1, 0);
} else if(strcmp(cmd,"load")==0) {
(*idx)+= 2;
ret= Xorriso_option_load(xorriso, arg1, arg2, 0);
} else if(strcmp(cmd,"logfile")==0) {
(*idx)+= 2;
ret= Xorriso_option_logfile(xorriso, arg1, arg2, 0);
} else if(strcmp(cmd,"ls")==0 || strcmp(cmd,"lsi")==0 ||
strcmp(cmd,"lsl")==0 || strcmp(cmd,"lsli")==0) {
ret= Xorriso_option_lsi(xorriso, argc, argv, idx, (cmd[2]=='l'));
@ -11043,10 +11138,6 @@ next_command:;
} else if(strcmp(cmd,"lsx")==0 || strcmp(cmd,"lslx")==0) {
ret= Xorriso_option_lsx(xorriso, argc, argv, idx, (cmd[2]=='l'));
} else if(strcmp(cmd,"logfile")==0) {
(*idx)+= 2;
ret= Xorriso_option_logfile(xorriso, arg1, arg2, 0);
} else if(strcmp(cmd,"mark")==0) {
(*idx)++;
ret= Xorriso_option_mark(xorriso, arg1, 0);

View File

@ -360,6 +360,7 @@ Bug fixes towards xorriso-0.1.2.pl00:
<LI>Emulated -toc on overwriteable media</LI>
<LI>New TOC layout with volume id</LI>
<LI>New option -rom_toc_scan for read-only drive problems</LI>
<LI>New option -load makes alternative sessions accessible</LI>
<!-- <LI>- none yet -</LI> -->
</UL>
</DD>

View File

@ -1 +1 @@
#define Xorriso_timestamP "2008.05.12.081331"
#define Xorriso_timestamP "2008.05.12.082733"