ecryptfs.vger.kernel.org archive mirror
 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
  2025-01-08  6:56 ` 回覆: " Frank Hsiao 蕭法宣
  0 siblings, 2 replies; 3+ 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] 3+ messages in thread

* Re: [PATCH] ecryptfs: set s_time_gran to get correct time granularity
  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
  2025-01-08  6:56 ` 回覆: " Frank Hsiao 蕭法宣
  1 sibling, 0 replies; 3+ messages in thread
From: Bert Wesarg @ 2024-12-06 12:29 UTC (permalink / raw)
  To: Frank Hsiao 蕭法宣, code@tyhicks.com
  Cc: ecryptfs@vger.kernel.org

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.

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 蕭法宣 <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	[flat|nested] 3+ messages in thread

* 回覆: [PATCH] ecryptfs: set s_time_gran to get correct time granularity
  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
@ 2025-01-08  6:56 ` Frank Hsiao 蕭法宣
  1 sibling, 0 replies; 3+ messages in thread
From: Frank Hsiao 蕭法宣 @ 2025-01-08  6:56 UTC (permalink / raw)
  To: code@tyhicks.com; +Cc: ecryptfs@vger.kernel.org

Friendly ping, thanks.

________________________________________
寄件者: Frank Hsiao 蕭法宣 <frankhsiao@qnap.com>
寄件日期: 2024年5月17日 下午 06:09
收件者: code@tyhicks.com
副本: ecryptfs@vger.kernel.org
主旨: [PATCH] ecryptfs: set s_time_gran to get correct time granularity

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] 3+ messages in thread

end of thread, other threads:[~2025-01-08  6:56 UTC | newest]

Thread overview: 3+ 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
2025-01-08  6:56 ` 回覆: " Frank Hsiao 蕭法宣

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).