Linux-EROFS Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: David Anderson via Linux-erofs <linux-erofs@lists.ozlabs.org>
To: linux-erofs@lists.ozlabs.org
Subject: [PATCH 2/2] erofs-utils: mkfs: use mtime instead of ctime
Date: Fri, 11 Mar 2022 04:17:24 +0000	[thread overview]
Message-ID: <20220311041724.3107622-2-dvander@google.com> (raw)
In-Reply-To: <20220311041724.3107622-1-dvander@google.com>

Change the default timestamp behavior to use modification time rather
than creation time. This will allow more control over the output
timestamps when not using TIMESTAMP_FIXED.

EROFS_FEATURE_COMPAT_MTIME has been added so tooling can detect the
change in timestamp behavior.

Signed-off-by: David Anderson <dvander@google.com>
---
 dump/main.c        | 1 +
 include/erofs_fs.h | 1 +
 lib/inode.c        | 4 ++--
 mkfs/main.c        | 8 +++++---
 4 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/dump/main.c b/dump/main.c
index 6565d35..72761bd 100644
--- a/dump/main.c
+++ b/dump/main.c
@@ -84,6 +84,7 @@ struct erofsdump_feature {
 
 static struct erofsdump_feature feature_lists[] = {
 	{ true, EROFS_FEATURE_COMPAT_SB_CHKSUM, "sb_csum" },
+	{ true, EROFS_FEATURE_COMPAT_MTIME, "mtime" },
 	{ false, EROFS_FEATURE_INCOMPAT_LZ4_0PADDING, "0padding" },
 	{ false, EROFS_FEATURE_INCOMPAT_BIG_PCLUSTER, "big_pcluster" },
 	{ false, EROFS_FEATURE_INCOMPAT_CHUNKED_FILE, "chunked_file" },
diff --git a/include/erofs_fs.h b/include/erofs_fs.h
index e01f5c7..7956a62 100644
--- a/include/erofs_fs.h
+++ b/include/erofs_fs.h
@@ -13,6 +13,7 @@
 #define EROFS_SUPER_OFFSET      1024
 
 #define EROFS_FEATURE_COMPAT_SB_CHKSUM		0x00000001
+#define EROFS_FEATURE_COMPAT_MTIME		0x00000002
 
 /*
  * Any bits that aren't in EROFS_ALL_FEATURE_INCOMPAT should
diff --git a/lib/inode.c b/lib/inode.c
index 24f2567..c9fdda1 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -806,8 +806,8 @@ static int erofs_fill_inode(struct erofs_inode *inode,
 	inode->i_mode = st->st_mode;
 	inode->i_uid = cfg.c_uid == -1 ? st->st_uid : cfg.c_uid;
 	inode->i_gid = cfg.c_gid == -1 ? st->st_gid : cfg.c_gid;
-	inode->i_mtime = st->st_ctime;
-	inode->i_mtime_nsec = ST_CTIM_NSEC(st);
+	inode->i_mtime = st->st_mtime;
+	inode->i_mtime_nsec = ST_MTIM_NSEC(st);
 
 	switch (cfg.c_timeinherit) {
 	case TIMESTAMP_CLAMPING:
diff --git a/mkfs/main.c b/mkfs/main.c
index 3f34450..b1ed187 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -421,6 +421,8 @@ int erofs_mkfs_update_super_block(struct erofs_buffer_head *bh,
 				  erofs_nid_t root_nid,
 				  erofs_blk_t *blocks)
 {
+	int compat = EROFS_FEATURE_COMPAT_SB_CHKSUM |
+		EROFS_FEATURE_COMPAT_MTIME;
 	struct erofs_super_block sb = {
 		.magic     = cpu_to_le32(EROFS_SUPER_MAGIC_V1),
 		.blkszbits = LOG_BLOCK_SIZE,
@@ -431,8 +433,7 @@ int erofs_mkfs_update_super_block(struct erofs_buffer_head *bh,
 		.meta_blkaddr  = sbi.meta_blkaddr,
 		.xattr_blkaddr = sbi.xattr_blkaddr,
 		.feature_incompat = cpu_to_le32(sbi.feature_incompat),
-		.feature_compat = cpu_to_le32(sbi.feature_compat &
-					      ~EROFS_FEATURE_COMPAT_SB_CHKSUM),
+		.feature_compat = cpu_to_le32(sbi.feature_compat & ~compat),
 		.extra_devices = cpu_to_le16(sbi.extra_devices),
 		.devt_slotoff = cpu_to_le16(sbi.devt_slotoff),
 	};
@@ -511,7 +512,8 @@ static void erofs_mkfs_default_options(void)
 {
 	cfg.c_legacy_compress = false;
 	sbi.feature_incompat = EROFS_FEATURE_INCOMPAT_LZ4_0PADDING;
-	sbi.feature_compat = EROFS_FEATURE_COMPAT_SB_CHKSUM;
+	sbi.feature_compat = EROFS_FEATURE_COMPAT_SB_CHKSUM |
+			     EROFS_FEATURE_COMPAT_MTIME;
 
 	/* generate a default uuid first */
 #ifdef HAVE_LIBUUID
-- 
2.35.1.723.g4982287a31-goog


      reply	other threads:[~2022-03-11  4:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-11  4:17 [PATCH 1/2] erofs-utils: mkfs: rename ctime to mtime David Anderson via Linux-erofs
2022-03-11  4:17 ` David Anderson 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=20220311041724.3107622-2-dvander@google.com \
    --to=linux-erofs@lists.ozlabs.org \
    --cc=dvander@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox