[PATCH 2.6] Do not set ATTR_CTIME in do_truncate(). - was: Re: truncate(2) sometimes updates ctime and sometimes ctime and mtime!

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

 



Hi Linus,

Here is a (tested) patch to remove the setting of ATTR_CTIME in
do_truncate() as you suggested.

Signed-off-by: Anton Altaparmakov <[email protected]>

---

On Fri, 2005-09-30 at 08:36 -0700, Linus Torvalds wrote:
> On Fri, 30 Sep 2005, Anton Altaparmakov wrote:
> > There is an inconsistency in the way truncate works which was introduced
> > (relatively) recently.
> > 
> > fs/open.c::sys_truncate
> >   -> do_sys_truncate
> >     -> do_truncate does:
> > 
> >         newattrs.ia_size = length;
> >         newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
> > 
> > Hmm.. That looks wrong, partly because I don't think it should even set 
> > ATTR_CTIME _either_. However, I don't see any recent changes to that code, 
> > so it must have been logn for a long time. That line in do_truncate() has 
> > been like that since at _least_ 2002.

Having gone through looking at ext2/3 and having made ntfs_truncate()
behave the same way as ext2/3_truncate() wrt m/ctime, I now agree with
you.  do_truncate() should only set ATTR_SIZE, not ATTR_CTIME.  The file
system will set ATTR_CTIME and ATTR_MTIME anyway so it's a waste for the
attribute to also set ATTR_CTIME.  That way it happens twice.

Below is a patch to remove it...

Best regards,

        Anton
-- 
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Unix Support, Computing Service, University of Cambridge, CB2 3QH, UK
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/ & http://www-stu.christs.cam.ac.uk/~aia21/

diff --git a/fs/open.c b/fs/open.c
--- a/fs/open.c
+++ b/fs/open.c
@@ -204,7 +204,7 @@ int do_truncate(struct dentry *dentry, l
 		return -EINVAL;
 
 	newattrs.ia_size = length;
-	newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
+	newattrs.ia_valid = ATTR_SIZE;
 
 	down(&dentry->d_inode->i_sem);
 	err = notify_change(dentry, &newattrs);


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux