From: Li Guifu <blucerlee@gmail.com>
To: linux-erofs@lists.ozlabs.org
Subject: [PATCH v1] erofs-utils: introduce fixed timestamp
Date: Fri, 11 Oct 2019 01:04:55 +0800 [thread overview]
Message-ID: <20191010170455.2169-1-blucerlee@gmail.com> (raw)
Introduce option "-T" for timestamp.
Signed-off-by: Li Guifu <blucerlee@gmail.com>
---
include/erofs/config.h | 3 +++
lib/config.c | 1 +
mkfs/main.c | 14 ++++++++++++--
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/include/erofs/config.h b/include/erofs/config.h
index fde936c..61f5c71 100644
--- a/include/erofs/config.h
+++ b/include/erofs/config.h
@@ -11,6 +11,8 @@
#include "defs.h"
+#define EROFS_FIXED_TIMESTAMP 1569859200 // 2019/10/1 00:00:00
+
enum {
FORCE_INODE_COMPACT = 1,
FORCE_INODE_EXTENDED,
@@ -30,6 +32,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_timestamp;
};
extern struct erofs_configure cfg;
diff --git a/lib/config.c b/lib/config.c
index dc10754..6141497 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_timestamp = -1;
}
void erofs_show_config(void)
diff --git a/mkfs/main.c b/mkfs/main.c
index 978c5b4..85b8f34 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 timestamp to files and dirs\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,12 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
if (opt)
return opt;
break;
+ case 'T':
+ if (optarg)
+ cfg.c_timestamp = strtoll(optarg, NULL, 10);
+ else
+ cfg.c_timestamp = EROFS_FIXED_TIMESTAMP;
+ break;
default: /* '?' */
return -EINVAL;
@@ -224,7 +231,10 @@ int main(int argc, char **argv)
return 1;
}
- if (!gettimeofday(&t, NULL)) {
+ if (cfg.c_timestamp != -1) {
+ sbi.build_time = cfg.c_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
next reply other threads:[~2019-10-10 17:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-10 17:04 Li Guifu [this message]
2019-10-11 0:29 ` [PATCH v1] erofs-utils: introduce fixed timestamp Gao Xiang via Linux-erofs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191010170455.2169-1-blucerlee@gmail.com \
--to=blucerlee@gmail.com \
--cc=linux-erofs@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.