[PATCH v3] erofs-utils: mkfs: fix image reproducibility of `-E(all-)fragments`

Hongbo Li lihongbo22 at huawei.com
Tue Jun 3 13:08:14 AEST 2025


From: Gao Xiang <hsiangkao at linux.alibaba.com>

The timestamp of the packed inode should be fixed to the build time.

Fixes: 9fa9b017f773 ("erofs-utils: mkfs: support fragments")
Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
[hongbo: minor adjust]
Signed-off-by: Hongbo Li <lihongbo22 at huawei.com>
---
change since v2:
 - compare path with strcmp;

change since v1:
 - fix time assignment (assign `i_mtime_nsec` too) [Hongbo];
---
 lib/inode.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/inode.c b/lib/inode.c
index 108aa9e..46eb686 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -929,7 +929,8 @@ static bool erofs_should_use_inode_extended(struct erofs_inode *inode)
 		return true;
 	if (inode->i_nlink > USHRT_MAX)
 		return true;
-	if ((inode->i_mtime != inode->sbi->build_time ||
+	if (strcmp(inode->i_srcpath, EROFS_PACKED_INODE) &&
+	    (inode->i_mtime != inode->sbi->build_time ||
 	     inode->i_mtime_nsec != inode->sbi->build_time_nsec) &&
 	    !cfg.c_ignore_mtime)
 		return true;
@@ -1021,6 +1022,11 @@ int __erofs_fill_inode(struct erofs_inode *inode, struct stat *st,
 		erofs_err("gid overflow @ %s", path);
 	inode->i_gid += cfg.c_gid_offset;
 
+	if (path == EROFS_PACKED_INODE) {
+		inode->i_mtime = sbi->build_time;
+		inode->i_mtime_nsec = sbi->build_time_nsec;
+		return 0;
+	}
 	inode->i_mtime = st->st_mtime;
 	inode->i_mtime_nsec = ST_MTIM_NSEC(st);
 
@@ -1034,7 +1040,6 @@ int __erofs_fill_inode(struct erofs_inode *inode, struct stat *st,
 	default:
 		break;
 	}
-
 	return 0;
 }
 
-- 
2.22.0



More information about the Linux-erofs mailing list