[PATCH] erofs-utils: mkfs: Use mtime to seed ctimes

David Anderson dvander at google.com
Tue Mar 1 15:11:39 AEDT 2022


Currently mkfs.erofs picks up whatever the system time happened to be
when the input file structure was created. Since there's no (easy) way for
userspace to control ctime, there's no way to control the per-file ctime
that mkfs.erofs uses.

Switching to mtime allows this tuning, which is important when the
timestamp of files is used to detect staleness.

Change-Id: I9cab662398bedc43d6d68ae798912f33360814e3
Signed-off-by: David Anderson <dvander at google.com>
---
 lib/inode.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/inode.c b/lib/inode.c
index 461c797..f0a71a8 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -806,12 +806,12 @@ 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_ctime = st->st_ctime;
-	inode->i_ctime_nsec = ST_CTIM_NSEC(st);
+	inode->i_ctime = st->st_mtime;
+	inode->i_ctime_nsec = ST_MTIM_NSEC(st);
 
 	switch (cfg.c_timeinherit) {
 	case TIMESTAMP_CLAMPING:
-		if (st->st_ctime < sbi.build_time)
+		if (st->st_mtime < sbi.build_time)
 			break;
 	case TIMESTAMP_FIXED:
 		inode->i_ctime = sbi.build_time;
-- 
2.35.1.574.g5d30c73bfb-goog



More information about the Linux-erofs mailing list