New option -session_log

This commit is contained in:
2008-04-03 20:41:00 +00:00
parent 992996f902
commit 9992f64247
8 changed files with 121 additions and 12 deletions

View File

@ -2,7 +2,7 @@
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH XORRISO 1 "March, 29, 2008"
.TH XORRISO 1 "April, 3, 2008"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@ -1559,6 +1559,17 @@ some input file arguments might not have been processed at all.
The errfile paths are transported as messages of very low priority "ERRFILE".
This transport becomes visible with -report_about "ALL".
.TP
\fB\-session_log\fR path
If path is not empty it gives the address of a plain text file where
a log record gets appended after each session. This log can be used to
determine the start_lba of a session for mount option sbsector= from
date or volume id. With non-multi-session media this is currently the only
way to obtain this parameter.
.br
Record format is: timestamp start_lba size volume-id
.br
The first three items are single words, the rest of the line is the volume id.
.TP
\fB\-end\fR
.br
End program immediately
@ -1849,11 +1860,12 @@ DVD-R, DVD+R if the full backup leaves substantial remaining capacity
on media and if the expected changes are much smaller than the full backup.
An update run will probably save no time but last longer than a full backup.
.br
With overwriteable media like DVD+RW or disk files, the older backup versions
cannot be retrieved. But with multi-session media and mount option "sbsector="
it is possible to access the session trees which represent the older backup
versions. sbsector of a session is its "data lba:" number from xorriso
option -toc.
With \fBmount\fR option \fB"sbsector="\fR it is possible to access the session
trees which represent the older backup versions. Multi-session media can tell
the sbsector by xorriso option -toc, as "data lba:". For other media one
may set before writing a suitable path for xorriso option -session_log where
the sbsector number gets recorded as the second word in each line.
.br
With CD media, Linux mount accepts session numbers directly by its option
"session=".
.br

View File

@ -1491,6 +1491,7 @@ completed:;
/* @param flag bit0=with year and seconds
bit1=timestamp format YYYY.MM.DD.hhmmss
*/
char *Ftimetxt(time_t t, char timetext[40], int flag)
{
@ -1504,6 +1505,10 @@ char *Ftimetxt(time_t t, char timetext[40], int flag)
rpt[0]= 0;
if(tmpt==0)
sprintf(rpt+strlen(rpt), "%12.f", (double) t);
else if (flag&2)
sprintf(rpt+strlen(rpt), "%4.4d.%2.2d.%2.2d.%2.2d%2.2d%2.2d",
1900+tms.tm_year, tms.tm_mon, tms.tm_mday,
tms.tm_hour, tms.tm_min, tms.tm_sec);
else if (flag&1)
sprintf(rpt+strlen(rpt), "%2d %3s %4.4d %2.2d:%2.2d:%2.2d",
tms.tm_mday, months[tms.tm_mon], 1900+tms.tm_year,
@ -2971,8 +2976,11 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
m->global_uid= 0;
strcpy(m->volid, "ISOIMAGE");
m->loaded_volid[0]= 0;
m->publisher[0]= 0;
m->volid_default= 1;
m->publisher[0]= 0;
m->session_logfile[0]= 0;
m->session_lba= -1;
m->session_blocks= 0;
m->do_global_gid= 0;
m->global_gid= 0;
m->do_global_mode= 0;
@ -4287,6 +4295,12 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
sprintf(line,"-report_about %s\n",xorriso->report_about_text);
if(!(is_default && no_defaults))
Xorriso_status_result(xorriso,filter,fp,flag&2);
is_default= (xorriso->session_logfile[0]==0);
sprintf(line,"-session_log %s\n",
Text_shellsafe(xorriso->session_logfile,sfe,0));
if(!(is_default && no_defaults))
Xorriso_status_result(xorriso,filter,fp,flag&2);
is_default= (strcmp(xorriso->return_with_text,"SORRY")==0 &&
xorriso->return_with_value==32);
@ -7760,6 +7774,37 @@ ex:;
return(1);
}
int Xorriso_write_session_log(struct XorrisO *xorriso, int flag)
{
FILE *fp= NULL;
char sfe[5*SfileadrL], timetext[40], *rpt, *wpt;
if(xorriso->session_logfile[0]==0)
return(2);
fp= fopen(xorriso->session_logfile, "a");
if(fp==0) {
sprintf(xorriso->info_text, "-session_log: Cannot open file %s",
Text_shellsafe(xorriso->session_logfile, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
wpt= sfe;
for(rpt= xorriso->volid; *rpt!=0; rpt++) {
if(*rpt=='\n') {
*(wpt++)= '\\';
*(wpt++)= 'n';
} else
*(wpt++)= *rpt;
}
*wpt= 0;
fprintf(fp, "%s %d %d %s\n",
Ftimetxt(time(0), timetext, 2), xorriso->session_lba,
xorriso->session_blocks, sfe);
fclose(fp);
return(1);
}
/* ---------------------------- Options API ------------------------ */
@ -8468,6 +8513,7 @@ int Xorriso_option_commit(struct XorrisO *xorriso, int flag)
Xorriso_process_errfile(xorriso, 0, "burn session end", 0, 1);
if(ret<=0)
return(ret);
Xorriso_write_session_log(xorriso, 0);
xorriso->volset_change_pending= 0;
xorriso->no_volset_present= 0;
if(flag&1)
@ -9520,7 +9566,7 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" exit_value may be 0 or 32 to 63.",
" -report_about severity Set the threshhold for events to be reported.",
" Use -abort_on severities or: HINT, NOTE, UPDATE, DEBUG, ALL",
" -dialog after all arguments are processed, enter dialog mode.",
" -dialog After all arguments are processed, enter dialog mode.",
" In this mode you may enter searchtexts or any of the options",
" described here. One per line.",
" -dialog_reset Revoke -dialog (works only if given as argument)",
@ -9572,6 +9618,9 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" Wait for Enter key resp. for a line of input at stdin.",
" -errfile_log mode path|channel",
" Log disk paths of files involved in problem events.",
" -session_log path",
" Set path of a file where a log record gets appended after",
" each session. Form: timestamp start_lba size volume-id",
" # any text Is ignored. In dialog mode the input line will be stored in",
" the eventual readline history, nevertheless.",
" -version Tell program and version number",
@ -10508,6 +10557,15 @@ int Xorriso_option_rollback(struct XorrisO *xorriso, int flag)
}
/* Option -session_log */
int Xorriso_option_session_log(struct XorrisO *xorriso, char *path, int flag)
{
if(Sfile_str(xorriso->session_logfile, path, 0)<=0)
return(-1);
return(1);
}
/* Option -speed */
int Xorriso_option_speed(struct XorrisO *xorriso, char *speed, int flag)
{
@ -11244,6 +11302,10 @@ next_command:;
if(end_ret!=2)
{ret= 3; goto ex;}
} else if(strcmp(cmd,"session_log")==0) {
(*idx)++;
ret= Xorriso_option_session_log(xorriso, arg1, 0);
} else if(strcmp(cmd,"speed")==0) {
(*idx)++;
ret= Xorriso_option_speed(xorriso, arg1, 0);

View File

@ -104,6 +104,10 @@ struct XorrisO { /* the global context of xorriso */
char publisher[129];
char session_logfile[SfileadrL];
int session_lba;
int session_blocks;
/* >>> put libburn/isoburn aspects here */
char indev[SfileadrL];

View File

@ -1 +1 @@
#define Xorriso_timestamP "2008.04.01.213121"
#define Xorriso_timestamP "2008.04.03.204051"

View File

@ -959,6 +959,7 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag)
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
{ret= 0; goto ex;}
}
isoburn_igopt_get_effective_lba(sopts, &(xorriso->session_lba));
ret= Xorriso_make_write_options(xorriso, drive, &burn_options, 0);
if(ret<=0)
@ -995,10 +996,11 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag)
tracks= burn_session_get_tracks(sessions[0], &num_tracks);
if(tracks!=NULL && num_tracks>0) {
burn_track_get_counters(tracks[0],&readcounter,&writecounter);
xorriso->session_blocks= (int) (writecounter/ (off_t) 2048);
sprintf(xorriso->info_text,
"ISO image produced: %d sectors. Written to media: %d sectors\n",
(int) (readcounter/ (off_t) 2048),
(int) (writecounter/ (off_t) 2048));
"ISO image produced: %d sectors. Written to media: %d sectors at LBA %d\n",
(int) (readcounter/ (off_t) 2048),
xorriso->session_blocks, xorriso->session_lba);
Xorriso_info(xorriso, 0);
}
}