[PATCH v4][ 1/2] erofs-utils: introduce fixed UNIX timestamp
Li Guifu
blucerlee at gmail.com
Sat Oct 12 04:09:52 AEDT 2019
Introduce option "-T" for UNIX timestamp.
Signed-off-by: Li Guifu <blucerlee at gmail.com>
---
include/erofs/config.h | 1 +
lib/config.c | 1 +
mkfs/main.c | 11 +++++++++--
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/include/erofs/config.h b/include/erofs/config.h
index fde936c..8df05a1 100644
--- a/include/erofs/config.h
+++ b/include/erofs/config.h
@@ -30,6 +30,7 @@ struct erofs_configure {
int c_force_inodeversion;
/* < 0, xattr disabled and INT_MAX, always use inline xattrs */
int c_inline_xattr_tolerance;
+ long long c_unix_timestamp;
};
extern struct erofs_configure cfg;
diff --git a/lib/config.c b/lib/config.c
index dc10754..cee835c 100644
--- a/lib/config.c
+++ b/lib/config.c
@@ -24,6 +24,7 @@ void erofs_init_configure(void)
sbi.feature_incompat = EROFS_FEATURE_INCOMPAT_LZ4_0PADDING;
cfg.c_force_inodeversion = 0;
cfg.c_inline_xattr_tolerance = 2;
+ cfg.c_unix_timestamp = -1;
}
void erofs_show_config(void)
diff --git a/mkfs/main.c b/mkfs/main.c
index 978c5b4..77a4b78 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -30,6 +30,7 @@ static void usage(void)
fprintf(stderr, " -zX[,Y] X=compressor (Y=compression level, optional)\n");
fprintf(stderr, " -d# set output message level to # (maximum 9)\n");
fprintf(stderr, " -EX[,...] X=extended options\n");
+ fprintf(stderr, " -T# set a fixed UNIX timestamp # to all files\n");
}
static int parse_extended_opts(const char *opts)
@@ -93,7 +94,7 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
{
int opt, i;
- while ((opt = getopt(argc, argv, "d:z:E:")) != -1) {
+ while ((opt = getopt(argc, argv, "d:z:E:T:")) != -1) {
switch (opt) {
case 'z':
if (!optarg) {
@@ -126,6 +127,9 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
if (opt)
return opt;
break;
+ case 'T':
+ cfg.c_unix_timestamp = atoll(optarg);
+ break;
default: /* '?' */
return -EINVAL;
@@ -224,7 +228,10 @@ int main(int argc, char **argv)
return 1;
}
- if (!gettimeofday(&t, NULL)) {
+ if (cfg.c_unix_timestamp != -1) {
+ sbi.build_time = cfg.c_unix_timestamp;
+ sbi.build_time_nsec = 0;
+ } else if (!gettimeofday(&t, NULL)) {
sbi.build_time = t.tv_sec;
sbi.build_time_nsec = t.tv_usec;
}
--
2.17.1
More information about the Linux-erofs
mailing list