Skip to content

Commit

Permalink
NFSv4: Translate NFS4ERR_BADNAME into ENOENT when applied to a lookup
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Trond Myklebust authored and Trond Myklebust committed Oct 18, 2011
1 parent 0c2e53f commit 08ef7bd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion fs/nfs/nfs4proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 08ef7bd

Please sign in to comment.