Skip to content

Commit

Permalink
Mksquashfs: extend -root-time option to take date string
Browse files Browse the repository at this point in the history
TIME can now be an unsigned 32-bit integer since the epoch of 1970-01-01
or a string value which is passed to the "date" command to parse.

Any string value which the date command recognises can be used such as
"now", "last week", Wed Feb 08 06:02:39" or "Wed Feb 15 21:02:39 GMT 2023".

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
  • Loading branch information
plougher committed Feb 18, 2023
1 parent b57bac8 commit 274a58f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions squashfs-tools/mksquashfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -6178,10 +6178,13 @@ static void print_options(FILE *stream, char *name, int total_mem)
fprintf(stream, "be used such as \"now\", \"last\n\t\t\tweek\", or ");
fprintf(stream, "\"Wed Feb 15 21:02:39 GMT 2023\"\n");
fprintf(stream, "-root-time <time>\tset root directory time to ");
fprintf(stream, "<time>, which is an unsigned\n\t\t\t32-bit int ");
fprintf(stream, "indicating seconds since the epoch\n\t\t\t(1970-01-01)\n");
fprintf(stream, "-root-mode <mode>\tset root directory permissions to octal ");
fprintf(stream, "<mode>\n");
fprintf(stream, "<time>. <time> can be an\n\t\t\tunsigned 32-bit ");
fprintf(stream, "int indicating seconds since the epoch\n\t\t\t");
fprintf(stream, "(1970-01-01) or a string value which is passed to ");
fprintf(stream, "the\n\t\t\t\"date\" command to parse. Any string ");
fprintf(stream, "value which the date\n\t\t\tcommand recognises can ");
fprintf(stream, "be used such as \"now\", \"last\n\t\t\tweek\", or ");
fprintf(stream, "\"Wed Feb 15 21:02:39 GMT 2023\"\n");
fprintf(stream, "-root-uid <value>\tset root directory owner to ");
fprintf(stream, "specified <value>,\n\t\t\t<value> can be either an ");
fprintf(stream, "integer uid or user name\n");
Expand Down Expand Up @@ -7795,7 +7798,9 @@ int main(int argc, char *argv[])
}
root_gid_opt = TRUE;
} else if(strcmp(argv[i], "-root-time") == 0) {
if((++i == argc) || !parse_num_unsigned(argv[i], &root_time)) {
if((++i == argc) ||
(!parse_num_unsigned(argv[i], &root_time) &&
!exec_date(argv[i], &root_time))) {
ERROR("%s: -root-time missing or invalid time\n",
argv[0]);
exit(1);
Expand Down

0 comments on commit 274a58f

Please sign in to comment.