[PATCH] ecryptfs: set s_time_gran to get correct time granularity

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx>

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) {




[Index of Archives]     [Linux Crypto]     [Device Mapper Crypto]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux