EcryptFS development
 help / color / mirror / Atom feed
* [PATCH] ecryptfs: set s_time_gran to get correct time granularity
@ 2024-05-17 10:09 Frank Hsiao 蕭法宣
  2024-12-06 12:29 ` Bert Wesarg
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Frank Hsiao 蕭法宣 @ 2024-05-17 10:09 UTC (permalink / raw)
  To: code@tyhicks.com; +Cc: ecryptfs@vger.kernel.org

related to: https://bugs.launchpad.net/ecryptfs/+bug/1890486

This bug happens in the two following situations:
cp -p: copy a file and preserve its atime and mtime
touch -r: touch a file and use a ref file's time instead of current time

In fs/attr.c notify_change(), atime and mtime is truncated by timestamp_truncate(),
ecryptfs gets wrong s_time_gran (10^9 instead of original fs time granularity) and
truncates a/mtime to whole second. Setting s_time_gran when mounting ecryptfs
 solves the issue. 

Signed-off-by: Frank Hsiao 蕭法宣 <frankhsiao@qnap.com>

diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index b2f6a1937d239..19dbe9d1187e1 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -567,6 +567,7 @@ static struct dentry *ecryptfs_mount(struct file_system_type
 *fs_type, int flags
 	s->s_blocksize = path.dentry->d_sb->s_blocksize;
 	s->s_magic = ECRYPTFS_SUPER_MAGIC;
 	s->s_stack_depth = path.dentry->d_sb->s_stack_depth + 1;
+	s->s_time_gran = path.dentry->d_sb->s_time_gran;
 
 	rc = -EINVAL;
 	if (s->s_stack_depth > FILESYSTEM_MAX_STACK_DEPTH) {

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-03-26  5:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-17 10:09 [PATCH] ecryptfs: set s_time_gran to get correct time granularity Frank Hsiao 蕭法宣
2024-12-06 12:29 ` Bert Wesarg
2026-02-23 19:11   ` Bert Wesarg
2025-01-08  6:56 ` 回覆: " Frank Hsiao 蕭法宣
2026-03-26  5:10 ` Tyler Hicks

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox