summaryrefslogtreecommitdiff
path: root/fs/nfs
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2011-10-19 03:11:49 +0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2011-10-19 03:13:51 +0400
commit08ef7bd3bc04261d14d570ac7eaac3eac947b1ba (patch)
treecc64173b71d4df4a8da4fd2230ae121828fd5443 /fs/nfs
parent0c2e53f11a6dae9e3af5f50f5ad0382e7c3e0cfa (diff)
downloadlinux-08ef7bd3bc04261d14d570ac7eaac3eac947b1ba.tar.xz
NFSv4: Translate NFS4ERR_BADNAME into ENOENT when applied to a lookup
Both LOOKUP and OPEN operations may return NFS4ERR_BADNAME if we send a an invalid name as a filename argument. As far as the application is concerned, it just has to know that the file doesn't exist, and so ENOENT would be the appropriate reply. We should only return EINVAL if the filename is being used to _create_ a new object on the remote filesystem. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/nfs4proc.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index b0c01b23422d..ba0da50865fe 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -1593,8 +1593,14 @@ static int _nfs4_proc_open(struct nfs4_opendata *data)
int status;
status = nfs4_run_open_task(data, 0);
- if (status != 0 || !data->rpc_done)
+ if (!data->rpc_done)
+ return status;
+ if (status != 0) {
+ if (status == -NFS4ERR_BADNAME &&
+ !(o_arg->open_flags & O_CREAT))
+ return -ENOENT;
return status;
+ }
if (o_arg->open_flags & O_CREAT) {
update_changeattr(dir, &o_res->cinfo);
@@ -2455,6 +2461,8 @@ static int nfs4_proc_lookup(struct rpc_clnt *clnt, struct inode *dir, struct qst
status = _nfs4_proc_lookup(clnt, dir, name, fhandle, fattr);
switch (status) {
+ case -NFS4ERR_BADNAME:
+ return -ENOENT;
case -NFS4ERR_MOVED:
err = nfs4_get_referral(dir, name, fattr, fhandle);
break;