summaryrefslogtreecommitdiffstats
path: root/fs/nfs/dir.c
diff options
context:
space:
mode:
authorTrond Myklebust2012-04-18 22:29:11 +0200
committerTrond Myklebust2012-04-19 19:23:09 +0200
commit451146be933e26e21277852b5e40c6a52266ef96 (patch)
tree207795769b9e1b18952f67fda9db5c7259fb9d63 /fs/nfs/dir.c
parentNFSv4: Ensure that we check lock exclusive/shared type against open modes (diff)
downloadkernel-qcow2-linux-451146be933e26e21277852b5e40c6a52266ef96.tar.gz
kernel-qcow2-linux-451146be933e26e21277852b5e40c6a52266ef96.tar.xz
kernel-qcow2-linux-451146be933e26e21277852b5e40c6a52266ef96.zip
NFSv4: Fix open(O_TRUNC) and ftruncate() error handling
If the file wasn't opened for writing, then truncate and ftruncate need to report the appropriate errors. Reported-by: Miklos Szeredi <miklos@szeredi.hu> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> Cc: stable@vger.kernel.org
Diffstat (limited to 'fs/nfs/dir.c')
-rw-r--r--fs/nfs/dir.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 4aaf0316d76a..8789210c6905 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1429,7 +1429,7 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry
}
open_flags = nd->intent.open.flags;
- attr.ia_valid = 0;
+ attr.ia_valid = ATTR_OPEN;
ctx = create_nfs_open_context(dentry, open_flags);
res = ERR_CAST(ctx);
@@ -1536,7 +1536,7 @@ static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd)
if (IS_ERR(ctx))
goto out;
- attr.ia_valid = 0;
+ attr.ia_valid = ATTR_OPEN;
if (openflags & O_TRUNC) {
attr.ia_valid |= ATTR_SIZE;
attr.ia_size = 0;