[<prev] [next>] [day] [month] [year] [list]
Message-ID: <1539589321-103638-1-git-send-email-zhuangshengen@huawei.com>
Date: Mon, 15 Oct 2018 15:42:01 +0800
From: ZhuangShengen <zhuangshengen@...wei.com>
To: <dwmw2@...radead.org>, <linux-mtd@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>
CC: <arnd@...db.de>, <boris.brezillon@...tlin.com>,
<viro@...iv.linux.org.uk>, <houtao1@...wei.com>,
<zhuangshengen@...wei.com>
Subject: [PATCH] jffs2: modify the mtime and ctime when truncate file
The syscall truncate don't modify the mtime or ctime of the file.
The reason is that it only check the ATTR_MTIME or ATTR_CTIME flag
in function jffs2_do_setattr,and the syscall truncate has not set these
two flags in VFS layer.
Fix the problem by checking the ATTR_SIZE flag when modify the
mtime or ctime of the file in jffs2_do_setattr.
This fix solve the same problem with commit 3972f2603d85 ("btrfs:
update timestamps on truncate()")
Signed-off-by: ZhuangShengen <zhuangshengen@...wei.com>
---
fs/jffs2/fs.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index eab04ec..98261f6 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -113,8 +113,10 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
ri->isize = cpu_to_je32((ivalid & ATTR_SIZE)?iattr->ia_size:inode->i_size);
ri->atime = cpu_to_je32(I_SEC((ivalid & ATTR_ATIME)?iattr->ia_atime:inode->i_atime));
- ri->mtime = cpu_to_je32(I_SEC((ivalid & ATTR_MTIME)?iattr->ia_mtime:inode->i_mtime));
- ri->ctime = cpu_to_je32(I_SEC((ivalid & ATTR_CTIME)?iattr->ia_ctime:inode->i_ctime));
+ ri->mtime = cpu_to_je32(I_SEC((ivalid & (ATTR_SIZE | ATTR_MTIME)) ?
+ iattr->ia_mtime:inode->i_mtime));
+ ri->ctime = cpu_to_je32(I_SEC((ivalid & (ATTR_SIZE | ATTR_CTIME)) ?
+ iattr->ia_ctime:inode->i_ctime));
ri->offset = cpu_to_je32(0);
ri->csize = ri->dsize = cpu_to_je32(mdatalen);
--
2.7.4
Powered by blists - more mailing lists