[PATCH 2/2] erofs-utils: mkfs: use mtime instead of ctime
David Anderson
dvander at google.com
Fri Mar 11 15:17:24 AEDT 2022
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 at 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
More information about the Linux-erofs
mailing list