[PATCH] jffs2: modify the mtime and ctime when truncate file

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

 



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


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux