From bda4b37e97f4df884a1240af9ac54d9856fe3aca Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Tue, 16 Aug 2016 13:13:05 +0000 Subject: [PATCH] New -volume_date mode "all_file_dates" --- xorriso/base_obj.c | 1 + xorriso/emulators.c | 28 ++++++---------------------- xorriso/opts_p_z.c | 9 +++++++++ xorriso/text_io.c | 6 ++++++ xorriso/write_run.c | 27 +++++++++++++++++++++++++++ xorriso/xorriso_private.h | 2 ++ xorriso/xorriso_timestamp.h | 2 +- 7 files changed, 52 insertions(+), 23 deletions(-) diff --git a/xorriso/base_obj.c b/xorriso/base_obj.c index b5aac365..9bc7d0c9 100644 --- a/xorriso/base_obj.c +++ b/xorriso/base_obj.c @@ -304,6 +304,7 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag) m->vol_expiration_time= 0; m->vol_effective_time= 0; m->vol_uuid[0]= 0; + m->all_file_dates[0]= 0; #ifdef Xorriso_with_libjtE m->libjte_handle= NULL; diff --git a/xorriso/emulators.c b/xorriso/emulators.c index f06632a9..e434e125 100644 --- a/xorriso/emulators.c +++ b/xorriso/emulators.c @@ -1282,7 +1282,6 @@ int Xorriso_genisofs(struct XorrisO *xorriso, char *whom, int *delay_opt_list= NULL, delay_opt_count= 0; char *sfe= NULL, *adr= NULL, ra_text[80], *pathspec= NULL, *sort_file= NULL; char *ept, *add_pt, *eff_path= NULL, *indev= NULL, msc[80], *cpt; - char *all_file_dates= NULL; char *old_root= NULL, *argpt, *hargv[1]; char *boot_path, partno_text[8], *iso_rr_pt, *disk_pt, *rpt, *wpt; char *rm_merge_args[3], *rr_reloc_dir_pt= NULL; @@ -1925,11 +1924,12 @@ not_enough_args:; if(i+1>=argc) goto not_enough_args; i++; - if(all_file_dates != NULL) - Xorriso_free_meM(all_file_dates); - all_file_dates= NULL; - Xorriso_alloc_meM(all_file_dates, char, strlen(argv[i]) + 1); - strcpy(all_file_dates, argv[i]); + if(strlen(argv[i]) >= sizeof(xorriso->all_file_dates)) { + sprintf(xorriso->info_text, "--set_all_file_dates: time text too long"); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + ret= 0; goto problem_handler_2; + } + strcpy(xorriso->all_file_dates, argv[i]); } else if(strcmp(argpt, "-input-charset")==0) { i++; @@ -2631,21 +2631,6 @@ problem_handler_boot:; if(xorriso->no_emul_toc & 1) xorriso->do_padding_by_libisofs= 1; - if(all_file_dates != NULL) if(all_file_dates[0] != 0) { - hargv[0]= "/"; - idx= 0; - ret= Xorriso_option_alter_date(xorriso, "b", all_file_dates, 1, hargv, - &idx, 1); - if(ret <= 0) - was_failure= 1; - idx= 0; - ret= Xorriso_option_alter_date(xorriso, "c", all_file_dates, 1, hargv, - &idx, 1); - if(ret <= 0) - was_failure= 1; - Xorriso_relax_compliance(xorriso, "always_gmt", 0); - } - if(do_print_size) { ret= Xorriso_option_print_size(xorriso, 1); goto ex; @@ -2662,7 +2647,6 @@ ex:; free(weight_list); if(delay_opt_list != NULL) free(delay_opt_list); - Xorriso_free_meM(all_file_dates); Xorriso_free_meM(sort_file); Xorriso_free_meM(sfe); Xorriso_free_meM(adr); diff --git a/xorriso/opts_p_z.c b/xorriso/opts_p_z.c index 065880a0..1ee6bd33 100644 --- a/xorriso/opts_p_z.c +++ b/xorriso/opts_p_z.c @@ -2133,6 +2133,15 @@ int Xorriso_option_volume_date(struct XorrisO *xorriso, Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); } + } else if(strcmp(time_type, "all_file_dates") == 0) { + if(t == 0) { + xorriso->all_file_dates[0]= 0; + ret= 1; goto ex; + } + strncpy(xorriso->all_file_dates, timestring, + sizeof(xorriso->all_file_dates) - 1); + xorriso->all_file_dates[sizeof(xorriso->all_file_dates) - 1]= 0; + } else if(strcmp(time_type, "c") == 0) { xorriso->vol_creation_time= t; } else if(strcmp(time_type, "m") == 0) { diff --git a/xorriso/text_io.c b/xorriso/text_io.c index 4c5a4666..f7809608 100644 --- a/xorriso/text_io.c +++ b/xorriso/text_io.c @@ -3286,6 +3286,12 @@ 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); + is_default= (xorriso->all_file_dates[0] == 0); + sprintf(line,"-volume_date all_file_dates %s\n", + Text_shellsafe(xorriso->all_file_dates,sfe,0)); + if(!(is_default && no_defaults)) + Xorriso_status_result(xorriso,filter,fp,flag&2); + is_default= (xorriso->copyright_file[0] == 0); sprintf(line,"-copyright_file %s\n", Text_shellsafe(xorriso->copyright_file,sfe,0)); diff --git a/xorriso/write_run.c b/xorriso/write_run.c index be9ec970..9ed86a87 100644 --- a/xorriso/write_run.c +++ b/xorriso/write_run.c @@ -1028,6 +1028,29 @@ ex:; } +int Xorriso_set_all_file_dates(struct XorrisO *xorriso, int flag) +{ + int idx, ret, was_failure= 0; + char *hargv[1]; + + if(xorriso->all_file_dates[0] == 0) + return(2); + hargv[0]= "/"; + idx= 0; + ret= Xorriso_option_alter_date(xorriso, "b", xorriso->all_file_dates, + 1, hargv, &idx, 1); + if(ret <= 0) + was_failure= 1; + idx= 0; + ret= Xorriso_option_alter_date(xorriso, "c", xorriso->all_file_dates, + 1, hargv, &idx, 1); + if(ret <= 0) + was_failure= 1; + Xorriso_relax_compliance(xorriso, "always_gmt", 0); + return(!was_failure); +} + + /* @param flag bit0= do not write but only prepare and return size in sectors @return <=0 error , 1= success 2= failure with DVD-RW, please call Xorriso_retry_write_session() @@ -1061,6 +1084,10 @@ int Xorriso_write_session(struct XorrisO *xorriso, int flag) if(ret <= 0) goto ex; + ret= Xorriso_set_all_file_dates(xorriso, 1); + if(ret <= 0) + goto ex; + out_cs= xorriso->out_charset; if(out_cs == NULL) Xorriso_get_local_charset(xorriso, &out_cs, 0); diff --git a/xorriso/xorriso_private.h b/xorriso/xorriso_private.h index 74d7d7fd..7d875ebb 100644 --- a/xorriso/xorriso_private.h +++ b/xorriso/xorriso_private.h @@ -528,6 +528,8 @@ struct XorrisO { /* the global context of xorriso */ /* To eventually override vol_modification_time by unconverted string and timezone 0 */ char vol_uuid[17]; + /* To flatly set all file timestamps to the same value */ + char all_file_dates[80]; #ifdef Xorriso_with_libjtE /* Parameters and state of Jigdo Template Export environment */ diff --git a/xorriso/xorriso_timestamp.h b/xorriso/xorriso_timestamp.h index 4c34044b..5bcb9003 100644 --- a/xorriso/xorriso_timestamp.h +++ b/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2016.08.15.175002" +#define Xorriso_timestamP "2016.08.16.131434"