New option -volume_date, for grub-mkrescue: -as mkisofs --modification-date=

This commit is contained in:
2010-04-07 20:27:05 +00:00
parent a65aa4f804
commit cc0ddbeb10
8 changed files with 338 additions and 84 deletions

View File

@ -1456,6 +1456,45 @@ ex:
}
int Decode_ecma119_format(struct tm *erg, char *text, int flag)
/* YYYYMMDDhhmmsscc */
/* 2010040711405800 */
{
int i, l, num;
memset(erg, 0, sizeof(*erg));
erg->tm_isdst= -1;
l= strlen(text);
if(l != 16)
return(0);
for(i= 0; i < l; i++)
if(text[i] < '0' || text[i] > '9')
return(0);
num= 0;
for(i= 0; i < 4; i++)
num= num * 10 + text[i] - '0';
if(num < 1970 || num > 3000)
return(0);
erg->tm_year = num - 1900;
erg->tm_mon= 10*(text[4]-'0')+text[5]-'0'-1;
if(erg->tm_mon > 12)
return(0);
erg->tm_mday= 10*(text[6]-'0')+text[7]-'0';
if(erg->tm_mday > 31)
return(0);
erg->tm_hour= 10*(text[8]-'0')+text[9]-'0';
if(erg->tm_hour > 23)
return(0);
erg->tm_min= 10*(text[10]-'0')+text[11]-'0';
if(erg->tm_min > 59)
return(0);
erg->tm_sec= 10*(text[12]-'0')+text[13]-'0';
if(erg->tm_sec > 59)
return(0);
return(1);
}
int Decode_xorriso_timestamp(struct tm *erg, char *code, int flag)
/* 2007.11.07.225624 */
{
@ -1589,6 +1628,12 @@ time_t Decode_timestring(char *code, time_t *date, int flag)
seconds= mktime(&result_tm);
seconds_valid= 1;
goto completed;
} else if(Decode_ecma119_format(&result_tm, code, 0)>0) {
/* YYYYMMDDhhmmsscc */
/* 2010040711405800 */
seconds= mktime(&result_tm);
seconds_valid= 1;
goto completed;
}
return(0);
completed:;
@ -4847,6 +4892,11 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
m->system_area_disk_path[0]= 0;
m->system_area_options= 0;
m->vol_creation_time= 0;
m->vol_modification_time= 0;
m->vol_expiration_time= 0;
m->vol_effective_time= 0;
m->vol_uuid[0]= 0;
m->loaded_boot_bin_lba= 0;
m->loaded_boot_cat_path[0]= 0;
m->allow_graft_points= 0;
@ -7069,6 +7119,41 @@ bin_path:;
if(!(is_default && no_defaults))
Xorriso_status_result(xorriso,filter,fp,flag&2);
is_default= (xorriso->vol_creation_time == 0);
sprintf(line,"-volume_date c %s\n",
is_default ? "default" :
Ftimetxt(xorriso->vol_creation_time, sfe, 2));
if(!(is_default && no_defaults))
Xorriso_status_result(xorriso,filter,fp,flag&2);
is_default= (xorriso->vol_modification_time == 0);
sprintf(line,"-volume_date m %s\n",
xorriso->vol_uuid[0] ? "overridden" :
is_default ? "default" :
Ftimetxt(xorriso->vol_modification_time, sfe, 2));
if(!(is_default && no_defaults))
Xorriso_status_result(xorriso,filter,fp,flag&2);
is_default= (xorriso->vol_expiration_time == 0);
sprintf(line,"-volume_date x %s\n",
is_default ? "default" :
Ftimetxt(xorriso->vol_expiration_time, sfe, 2));
if(!(is_default && no_defaults))
Xorriso_status_result(xorriso,filter,fp,flag&2);
is_default= (xorriso->vol_effective_time == 0);
sprintf(line,"-volume_date f %s\n",
is_default ? "default" :
Ftimetxt(xorriso->vol_effective_time, sfe, 2));
if(!(is_default && no_defaults))
Xorriso_status_result(xorriso,filter,fp,flag&2);
is_default= (xorriso->vol_uuid[0] == 0);
sprintf(line,"-volume_date uuid %s\n",
Text_shellsafe(xorriso->vol_uuid,sfe,0));
if(!(is_default && no_defaults))
Xorriso_status_result(xorriso,filter,fp,flag&2);
is_default= (xorriso->do_joliet==0);
sprintf(line,"-joliet %s\n", (xorriso->do_joliet == 1 ? "on" : "off"));
if(!(is_default && no_defaults))
@ -9195,6 +9280,7 @@ unrecognizable:;
}
/* @param flag bit0= do not complain in case of error, but set info_text */
int Xorriso_convert_datestring(struct XorrisO *xorriso, char *cmd,
char *time_type, char *timestring,
int *t_type, time_t *t, int flag)
@ -9209,14 +9295,16 @@ int Xorriso_convert_datestring(struct XorrisO *xorriso, char *cmd,
(*t_type)|= 5;
else {
sprintf(xorriso->info_text, "%s: Unrecognized type '%s'", cmd, time_type);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
if(!(flag & 1))
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
return(0);
}
ret= Decode_timestring(timestring, t, 0);
if(ret<=0) {
sprintf(xorriso->info_text, "%s: Cannot decode timestring '%s'", cmd,
timestring);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
if(!(flag & 1))
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
return(0);
}
sprintf(xorriso->info_text, "Understanding timestring '%s' as: %s",
@ -11096,6 +11184,8 @@ int Xorriso_genisofs_help(struct XorrisO *xorriso, int flag)
" -boot-info-table Patch boot image with info table",
" -G FILE, -generic-boot FILE Set generic boot image name",
" --protective-msdos-label Patch System Area by partition table",
" --modification-date=YYYYMMDDhhmmsscc",
" Override modification date",
#ifdef Xorriso_with_isohybriD
" isolinux_mbr=on|auto|off Control eventual isohybrid MBR generation",
#endif
@ -11253,6 +11343,10 @@ int Xorriso_genisofs(struct XorrisO *xorriso, char *whom,
goto ex;
} else if(strcmp(argv[i], "--protective-msdos-label")==0) {
xorriso->system_area_options|= 1;
} else if(strncmp(argv[i], "--modification-date=", 20)==0) {
ret= Xorriso_option_volume_date(xorriso, "uuid", argv[i] + 20, 0);
if(ret <= 0)
goto problem_handler_1;
} else if(strcmp(argv[i], "-input-charset")==0) {
if(i+1>=argc)
goto not_enough_args;
@ -11523,6 +11617,8 @@ not_enough_args:;
/* was already handled in first argument scan */;
} else if(strcmp(argv[i], "--protective-msdos-label")==0) {
/* was already handled in first argument scan */;
} else if(strncmp(argv[i], "--modification-date=", 20)==0) {
/* was already handled in first argument scan */;
} else if(strcmp(argv[i], "-boot-load-size") == 0) {
i++;
/* was already handled in first argument scan */;
@ -16357,6 +16453,8 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
" Specifies the application id. (128 chars)",
" -system_id name",
" Specifies the system id for the System Area. (32 chars)",
" -volume_date type timestring",
" Specifies volume timestamps. [\"c\",\"m\",\"x\",\"f\",\"uuid\"]",
" -joliet \"on\"|\"off\"",
" Generate Joliet info additional to Rock Ridge info.",
" -compliance rule[:rule...]",
@ -19595,6 +19693,62 @@ int Xorriso_option_volset_id(struct XorrisO *xorriso, char *name, int flag)
}
/* Option -volume_date */
int Xorriso_option_volume_date(struct XorrisO *xorriso,
char *time_type, char *timestring, int flag)
{
int ret, t_type= 0;
time_t t;
struct tm erg;
if(timestring[0] == 0 || strcmp(timestring, "default") == 0 ||
strcmp(timestring, "overridden") == 0 ){
t= 0;
} else if(strcmp(time_type, "uuid") != 0) {
ret= Xorriso_convert_datestring(xorriso, "-volume_date",
"m", timestring, &t_type, &t, 0);
if(ret<=0)
goto ex;
}
if(strcmp(time_type, "uuid") == 0) {
if(t == 0) {
xorriso->vol_uuid[0]= 0;
ret= 1; goto ex;
}
ret= Decode_ecma119_format(&erg, timestring, 0);
if(ret <= 0) {
sprintf(xorriso->info_text, "-volume_date uuid : Not an ECMA-119 time string. (16 decimal digits, range 1970... to 2999...)");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
ret= 0; goto ex;
}
strcpy(xorriso->vol_uuid, timestring);
if(erg.tm_year < 138) {
sprintf(xorriso->info_text,
"Understanding ECMA-119 timestring '%s' as: %s",
timestring, asctime(&erg));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
}
} else if(strcmp(time_type, "c") == 0) {
xorriso->vol_creation_time= t;
} else if(strcmp(time_type, "m") == 0) {
xorriso->vol_modification_time= t;
} else if(strcmp(time_type, "x") == 0) {
xorriso->vol_expiration_time= t;
} else if(strcmp(time_type, "f") == 0) {
xorriso->vol_effective_time= t;
} else {
/* >>> unknown time type */;
ret= 0; goto ex;
}
ret= 1;
ex:;
return(ret);
}
/* Option -xattr "on"|"off" */
int Xorriso_option_xattr(struct XorrisO *xorriso, char *mode, int flag)
{
@ -19771,7 +19925,7 @@ int Xorriso_count_args(struct XorrisO *xorriso, int argc, char **argv,
"errfile_log","error_behavior","extract","extract_single",
"load","logfile",
"map","map_single","page","return_with",
"scdbackup_tag","update","update_r",
"scdbackup_tag","update","update_r","volume_date",
""
};
static char arg4_commands[][40]= {
@ -20598,6 +20752,10 @@ next_command:;
(*idx)++;
ret= Xorriso_option_volid(xorriso,arg1,0);
} else if(strcmp(cmd,"volume_date")==0) {
(*idx)+= 2;
ret= Xorriso_option_volume_date(xorriso, arg1, arg2, 0);
} else if(strcmp(cmd,"xattr")==0) {
(*idx)++;
ret= Xorriso_option_xattr(xorriso, arg1, 0);