[PATCH] Fix some problems with truncate and mtime semantics.
[linux-block.git] / fs / open.c
index f53a5b9ffb7dce308f6e0e05d4982d343261564c..94968cb3afca0268c8e2667420975f22815dab17 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -194,7 +194,8 @@ out:
        return error;
 }
 
-int do_truncate(struct dentry *dentry, loff_t length, struct file *filp)
+int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
+       struct file *filp)
 {
        int err;
        struct iattr newattrs;
@@ -204,7 +205,7 @@ int do_truncate(struct dentry *dentry, loff_t length, struct file *filp)
                return -EINVAL;
 
        newattrs.ia_size = length;
-       newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
+       newattrs.ia_valid = ATTR_SIZE | time_attrs;
        if (filp) {
                newattrs.ia_file = filp;
                newattrs.ia_valid |= ATTR_FILE;
@@ -266,7 +267,7 @@ static inline long do_sys_truncate(const char __user * path, loff_t length)
        error = locks_verify_truncate(inode, NULL, length);
        if (!error) {
                DQUOT_INIT(inode);
-               error = do_truncate(nd.dentry, length, NULL);
+               error = do_truncate(nd.dentry, length, 0, NULL);
        }
        put_write_access(inode);
 
@@ -318,7 +319,7 @@ static inline long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
 
        error = locks_verify_truncate(inode, file, length);
        if (!error)
-               error = do_truncate(dentry, length, file);
+               error = do_truncate(dentry, length, 0, file);
 out_putf:
        fput(file);
 out: