All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gao Xiang via Linux-erofs <linux-erofs@lists.ozlabs.org>
To: Li Guifu <blucerlee@gmail.com>
Cc: linux-erofs@lists.ozlabs.org
Subject: Re: [PATCH v4][ 1/2] erofs-utils: introduce fixed UNIX timestamp
Date: Sat, 12 Oct 2019 08:18:50 +0800	[thread overview]
Message-ID: <20191012001847.GA5701@hsiangkao-HP-ZHAN-66-Pro-G1> (raw)
In-Reply-To: <20191011170953.6267-1-blucerlee@gmail.com>

Hi Guifu,

On Sat, Oct 12, 2019 at 01:09:52AM +0800, Li Guifu wrote:
> Introduce option "-T" for UNIX timestamp.
> 
> Signed-off-by: Li Guifu <blucerlee@gmail.com>
> ---

Applied with the following minor changes.
Let me know if you have some other thoughts...

From 0da0c97cc5ca7e02192ee99dde0a82cb531823a6 Mon Sep 17 00:00:00 2001
From: Li Guifu <blucerlee@gmail.com>
Date: Sat, 12 Oct 2019 01:09:52 +0800
Subject: [PATCH] erofs-utils: introduce fixed UNIX timestamp

Introduce option "-T" for UNIX timestamp.

Signed-off-by: Li Guifu <blucerlee@gmail.com>
[ Gao Xiang: use u64 for timestamp rather than long long. ]
Signed-off-by: Gao Xiang <hsiangkao@aol.com>
---
 include/erofs/config.h |  1 +
 lib/config.c           |  1 +
 mkfs/main.c            | 16 ++++++++++++++--
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/include/erofs/config.h b/include/erofs/config.h
index 8b09430..9711638 100644
--- a/include/erofs/config.h
+++ b/include/erofs/config.h
@@ -28,6 +28,7 @@ struct erofs_configure {
 	char *c_compr_alg_master;
 	int c_compr_level_master;
 	int c_force_inodeversion;
+	u64 c_unix_timestamp;
 };
 
 extern struct erofs_configure cfg;
diff --git a/lib/config.c b/lib/config.c
index 110c8b6..4cddc25 100644
--- a/lib/config.c
+++ b/lib/config.c
@@ -23,6 +23,7 @@ void erofs_init_configure(void)
 	cfg.c_compr_level_master = -1;
 	sbi.feature_incompat = EROFS_FEATURE_INCOMPAT_LZ4_0PADDING;
 	cfg.c_force_inodeversion = 0;
+	cfg.c_unix_timestamp = -1;
 }
 
 void erofs_show_config(void)
diff --git a/mkfs/main.c b/mkfs/main.c
index 4b279c0..6ecc905 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -29,6 +29,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)
@@ -90,9 +91,10 @@ static int parse_extended_opts(const char *opts)
 
 static int mkfs_parse_options_cfg(int argc, char *argv[])
 {
+	char *endptr;
 	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) {
@@ -125,6 +127,13 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
 			if (opt)
 				return opt;
 			break;
+		case 'T':
+			cfg.c_unix_timestamp = strtoull(optarg, &endptr, 0);
+			if (cfg.c_unix_timestamp == -1 || *endptr != '\0') {
+				erofs_err("invalid UNIX timestamp %s", optarg);
+				return -EINVAL;
+			}
+			break;
 
 		default: /* '?' */
 			return -EINVAL;
@@ -223,7 +232,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


      parent reply	other threads:[~2019-10-12  0:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-11 17:09 [PATCH v4][ 1/2] erofs-utils: introduce fixed UNIX timestamp Li Guifu
2019-10-11 17:09 ` [PATCH v4][ 2/2] erofs-utils: fix error handler notes when parameter miss Li Guifu
2019-10-12  0:19   ` Gao Xiang via Linux-erofs
2019-10-12  0:18 ` Gao Xiang via Linux-erofs [this message]

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=20191012001847.GA5701@hsiangkao-HP-ZHAN-66-Pro-G1 \
    --to=linux-erofs@lists.ozlabs.org \
    --cc=blucerlee@gmail.com \
    --cc=hsiangkao@aol.com \
    /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.