diff options
author | Gao Xiang <hsiangkao@redhat.com> | 2020-10-30 20:30:18 +0800 |
---|---|---|
committer | Gao Xiang <hsiangkao@redhat.com> | 2020-11-01 23:44:29 +0800 |
commit | 4d109df7f04264eb17892ad0fd2928a1d2bc4542 (patch) | |
tree | 55a6f954a4ba56d4f636c6842f98616bfee39427 /lib/inode.c | |
parent | 10d529afab6e708a7aeaceb1fc0bfba6668fa9d6 (diff) |
erofs-utils: support $SOURCE_DATE_EPOCH
Currently, we use -T to set a given UNIX timestamp for all
files, yet reproducible builds [1] requires what is called
"timestamp clamping", IOW, a timestamp must be used no later
than the value of this variable.
Let's support $SOURCE_DATE_EPOCH as well.
[1] https://reproducible-builds.org/specs/source-date-epoch/
Link: https://lore.kernel.org/r/20201030123020.133084-2-hsiangkao@redhat.com
Suggested-by: nl6720 <nl6720@gmail.com>
Reviewed-by: Li Guifu <bluce.lee@aliyun.com>
Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
Diffstat (limited to 'lib/inode.c')
-rw-r--r-- | lib/inode.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/inode.c b/lib/inode.c index 5695bbc..fee5c96 100644 --- a/lib/inode.c +++ b/lib/inode.c @@ -729,8 +729,19 @@ int erofs_fill_inode(struct erofs_inode *inode, inode->i_mode = st->st_mode; inode->i_uid = st->st_uid; inode->i_gid = st->st_gid; - inode->i_ctime = sbi.build_time; - inode->i_ctime_nsec = sbi.build_time_nsec; + inode->i_ctime = st->st_ctime; + inode->i_ctime_nsec = st->st_ctim.tv_nsec; + + switch (cfg.c_timeinherit) { + case TIMESTAMP_CLAMPING: + if (st->st_ctime < sbi.build_time) + break; + case TIMESTAMP_FIXED: + inode->i_ctime = sbi.build_time; + inode->i_ctime_nsec = sbi.build_time_nsec; + default: + break; + } inode->i_nlink = 1; /* fix up later if needed */ switch (inode->i_mode & S_IFMT) { |