Re: [PATCH] ecryptfs: set s_time_gran to get correct time granularity
Bert Wesarg <[email protected]>
| Newsgroups | org.kernel.vger.ecryptfs |
|---|---|
| Message-ID | <CAKPyHN1HbRq_hpMX29TjbZjH2fV5ppkUcXB+akz_erT_ULPQMw@mail.gmail.com> |
Dear all, On Fri, Dec 6, 2024 at 1:29 PM Bert Wesarg <[email protected]> wrote: > > Hi, > > On 17.05.24 12:09, Frank Hsiao 蕭法宣 wrote: > > 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 > > was there some discussion for this solution. I came to the same conclusion but cannot test it right now. now that there is renewed activity in eCryptfs (thanks, btw). Can we please consider this patch for a next cycle? Thanks. Best Bert > > Thanks > Bert > > > > > 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 蕭法宣 <[email protected]> > > > > 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) {