Changing new option -scdbackup_tag

This commit is contained in:
Thomas Schmitt 2009-09-17 14:47:43 +00:00
parent c6429e4c36
commit 081b01ad1b
5 changed files with 68 additions and 18 deletions

View File

@ -1595,6 +1595,7 @@ completed:;
1= timestamp format YYYY.MM.DD.hhmmss
2= Wdy Mon Day hh:mm:ss Year
3= Mon Day hh:mm:ss Year
4= YYMMDD.hhmmss
*/
char *Ftimetxt(time_t t, char timetext[40], int flag)
{
@ -1623,7 +1624,15 @@ char *Ftimetxt(time_t t, char timetext[40], int flag)
sprintf(rpt+strlen(rpt), "%s %2.2d %2.2d:%2.2d:%2.2d %4.4d",
months[tms.tm_mon], tms.tm_mday,
tms.tm_hour, tms.tm_min, tms.tm_sec, 1900+tms.tm_year);
else if (flag&1)
else if (form == 4) {
if(tms.tm_year>99)
sprintf(rpt+strlen(rpt), "%c", 'A' + (tms.tm_year - 100) / 10);
else
sprintf(rpt+strlen(rpt), "%c", '0' + tms.tm_year / 10);
sprintf(rpt+strlen(rpt), "%1.1d%2.2d%2.2d.%2.2d%2.2d%2.2d",
tms.tm_year % 10, tms.tm_mon + 1, 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,
tms.tm_hour, tms.tm_min, tms.tm_sec);
@ -4692,6 +4701,8 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
m->do_md5= 0;
m->scdbackup_tag_name[0]= 0;
m->scdbackup_tag_time[0]= 0;
m->scdbackup_tag_written[0]= 0;
m->scdbackup_tag_listname[0]= 0;
m->relax_compliance= 0;
m->do_follow_pattern= 1;
m->do_follow_param= 0;
@ -7132,11 +7143,11 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
Xorriso_status_result(xorriso,filter,fp,flag&2);
is_default= (xorriso->scdbackup_tag_name[0] == 0 &&
xorriso->scdbackup_tag_time[0] == 0);
xorriso->scdbackup_tag_listname[0] == 0);
sprintf(line, "-scdbackup_tag ");
Text_shellsafe(xorriso->scdbackup_tag_name, line, 1);
Text_shellsafe(xorriso->scdbackup_tag_listname, line, 1);
strcat(line, " ");
Text_shellsafe(xorriso->scdbackup_tag_time, line, 1);
Text_shellsafe(xorriso->scdbackup_tag_name, line, 1);
strcat(line, "\n");
if(!(is_default && no_defaults))
Xorriso_status_result(xorriso,filter,fp,flag&2);
@ -10741,7 +10752,7 @@ int Xorriso_genisofs(struct XorrisO *xorriso, char *whom,
" --acl Record eventual ACLs of files",
" --xattr Record eventual user space xattr of files",
" --md5 Compute and record MD5 checksums of data files",
" --scdbackup_tag NAME TIME With --md5 record a scdbackup checksum tag",
" --scdbackup_tag PATH NAME With --md5 record a scdbackup checksum tag",
" --for_backup Use all options which improve backup fidelity",
" -V ID, -volid ID Set Volume ID",
" -b FILE, -eltorito-boot FILE",
@ -12639,6 +12650,36 @@ int Xorriso_report_md5_outcome(struct XorrisO *xorriso, char *severity,
}
int Xorriso_append_scdbackup_record(struct XorrisO *xorriso, int flag)
{
FILE *fp= NULL;
char dummy[81], name[81], timestamp[81], size[81], md5[81];
if(xorriso->scdbackup_tag_written[0] == 0)
return(1);
name[0]= timestamp[0]= size[0]= md5[0]= 0;
sscanf(xorriso->scdbackup_tag_written, "%s %s %s %s %s %s %s",
dummy, dummy, dummy, name, timestamp, size, md5);
sprintf(xorriso->info_text, "scdbackup tag written : %s %s %s %s\n",
name, timestamp, size, md5);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
if(xorriso->scdbackup_tag_listname[0]) {
fp= fopen(xorriso->scdbackup_tag_listname, "a");
if(fp==0) {
strcpy(xorriso->info_text, "-scdbackup_tag: Cannot open file ");
Text_shellsafe(xorriso->scdbackup_tag_listname, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
fprintf(fp, "%s %s %s %s\n", name, timestamp, size, md5);
fclose(fp);
}
return(1);
}
/* ---------------------------- Options API ------------------------ */
@ -15613,7 +15654,7 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" and their use in file comparison.",
" -md5 \"on\"|\"all\"|\"off\"",
" Enable resp. disable processing of MD5 checksums.",
" -scdbackup_tag name timestamp",
" -scdbackup_tag list_path record_name",
" Enable production of scdbackup tag with -md5 on",
" -ban_stdio_write",
" Allow for writing only the usage of optical drives.",
@ -17750,19 +17791,20 @@ unknown_mode:;
}
/* Option -scdbackup_tag name timestamp */
int Xorriso_option_scdbackup_tag(struct XorrisO *xorriso, char *name,
char *timestamp, int flag)
/* Option -scdbackup_tag list_path record_name */
int Xorriso_option_scdbackup_tag(struct XorrisO *xorriso, char *listname,
char *recname, int flag)
{
if(strlen(name) > 80 || strlen(timestamp) > 18 ||
name[0] == 0 || timestamp[0] == 0) {
if(strlen(recname) > 80) {
sprintf(xorriso->info_text,
"Unsuitable name or timestamp given with -scdbackup_tag");
"Unsuitable record name given with -scdbackup_tag");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
strcpy(xorriso->scdbackup_tag_name, name);
strcpy(xorriso->scdbackup_tag_time, timestamp);
strcpy(xorriso->scdbackup_tag_name, recname);
xorriso->scdbackup_tag_time[0]= 0;
if(Sfile_str(xorriso->scdbackup_tag_listname, listname, 0) <= 0)
return(-1);
return(1);
}

View File

@ -875,8 +875,8 @@ int Xorriso_option_rom_toc_scan(struct XorrisO *xorriso, char *mode,
int flag);
/* Option -scdbackup_tag */
int Xorriso_option_scdbackup_tag(struct XorrisO *xorriso, char *name,
char *timestamp, int flag);
int Xorriso_option_scdbackup_tag(struct XorrisO *xorriso, char *list_path,
char *record_name, int flag);
/* Option -session_log */
int Xorriso_option_session_log(struct XorrisO *xorriso, char *path, int flag);

View File

@ -130,8 +130,11 @@ struct XorrisO { /* the global context of xorriso */
bit3= make file content stability check by double reading
bit4= use recorded MD5 as proxy of ISO file
*/
char scdbackup_tag_name[81];
char scdbackup_tag_time[19];
char scdbackup_tag_written[512];
char scdbackup_tag_listname[SfileadrL];
int relax_compliance; /* opaque bitfield to be set by xorrisoburn */
int do_follow_pattern;
@ -686,6 +689,8 @@ int Xorriso_compare_2_files(struct XorrisO *xorriso, char *disk_adr,
int Xorriso_report_md5_outcome(struct XorrisO *xorriso, char *severity,
int flag);
int Xorriso_append_scdbackup_record(struct XorrisO *xorriso, int flag);
int Sfile_str(char target[SfileadrL], char *source, int flag);

View File

@ -1 +1 @@
#define Xorriso_timestamP "2009.09.17.144453"
#define Xorriso_timestamP "2009.09.17.144849"

View File

@ -1830,8 +1830,10 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag)
isoburn_igopt_set_over_ugid(sopts, 0, 0, (uid_t) 0, (gid_t) 0);
isoburn_igopt_set_out_charset(sopts, out_cs);
isoburn_igopt_set_fifo_size(sopts, xorriso->fs * 2048);
Ftimetxt(time(NULL), xorriso->scdbackup_tag_time, 8);
isoburn_igopt_set_scdbackup_tag(sopts, xorriso->scdbackup_tag_name,
xorriso->scdbackup_tag_time);
xorriso->scdbackup_tag_time,
xorriso->scdbackup_tag_written);
if(image!=NULL &&
strlen(Xorriso_program_versioN)+strlen(Xorriso_timestamP)<80) {
sprintf(xorriso_id, "XORRISO-%s %s",
@ -2011,6 +2013,7 @@ ex:;
iso_image_unref(image);
isoburn_igopt_destroy(&sopts, 0);
Xorriso_process_msg_queues(xorriso,0);
Xorriso_append_scdbackup_record(xorriso, 0);
return(ret);
}