Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 08ef7bd3 authored by Trond Myklebust's avatar Trond Myklebust
Browse files

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: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 0c2e53f1
Loading
Loading
Loading
Loading
+9 −1
Original line number Original line Diff line number Diff line
@@ -1593,8 +1593,14 @@ static int _nfs4_proc_open(struct nfs4_opendata *data)
	int status;
	int status;


	status = nfs4_run_open_task(data, 0);
	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;
		return status;
	}


	if (o_arg->open_flags & O_CREAT) {
	if (o_arg->open_flags & O_CREAT) {
		update_changeattr(dir, &o_res->cinfo);
		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);
		status = _nfs4_proc_lookup(clnt, dir, name, fhandle, fattr);
		switch (status) {
		switch (status) {
		case -NFS4ERR_BADNAME:
			return -ENOENT;
		case -NFS4ERR_MOVED:
		case -NFS4ERR_MOVED:
			err = nfs4_get_referral(dir, name, fattr, fhandle);
			err = nfs4_get_referral(dir, name, fattr, fhandle);
			break;
			break;