Commit 5cf35335 authored by Chuck Lever's avatar Chuck Lever

NFSD: Update the NFSv3 LOOKUP3res encoder to use struct xdr_stream

Also, clean up: Rename the encoder function to match the name of
the result structure in RFC 1813, consistent with other encoder
function names in nfs3xdr.c. "diropres" is an NFSv2 thingie.
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent 907c3822
...@@ -758,7 +758,7 @@ static const struct svc_procedure nfsd_procedures3[22] = { ...@@ -758,7 +758,7 @@ static const struct svc_procedure nfsd_procedures3[22] = {
[NFS3PROC_LOOKUP] = { [NFS3PROC_LOOKUP] = {
.pc_func = nfsd3_proc_lookup, .pc_func = nfsd3_proc_lookup,
.pc_decode = nfs3svc_decode_diropargs, .pc_decode = nfs3svc_decode_diropargs,
.pc_encode = nfs3svc_encode_diropres, .pc_encode = nfs3svc_encode_lookupres,
.pc_release = nfs3svc_release_fhandle2, .pc_release = nfs3svc_release_fhandle2,
.pc_argsize = sizeof(struct nfsd3_diropargs), .pc_argsize = sizeof(struct nfsd3_diropargs),
.pc_ressize = sizeof(struct nfsd3_diropres), .pc_ressize = sizeof(struct nfsd3_diropres),
......
...@@ -104,6 +104,23 @@ svcxdr_encode_nfsstat3(struct xdr_stream *xdr, __be32 status) ...@@ -104,6 +104,23 @@ svcxdr_encode_nfsstat3(struct xdr_stream *xdr, __be32 status)
return true; return true;
} }
static bool
svcxdr_encode_nfs_fh3(struct xdr_stream *xdr, const struct svc_fh *fhp)
{
u32 size = fhp->fh_handle.fh_size;
__be32 *p;
p = xdr_reserve_space(xdr, XDR_UNIT + size);
if (!p)
return false;
*p++ = cpu_to_be32(size);
if (size)
p[XDR_QUADLEN(size) - 1] = 0;
memcpy(p, &fhp->fh_handle.fh_base, size);
return true;
}
static __be32 * static __be32 *
encode_fh(__be32 *p, struct svc_fh *fhp) encode_fh(__be32 *p, struct svc_fh *fhp)
{ {
...@@ -846,18 +863,28 @@ nfs3svc_encode_wccstat(struct svc_rqst *rqstp, __be32 *p) ...@@ -846,18 +863,28 @@ nfs3svc_encode_wccstat(struct svc_rqst *rqstp, __be32 *p)
} }
/* LOOKUP */ /* LOOKUP */
int int nfs3svc_encode_lookupres(struct svc_rqst *rqstp, __be32 *p)
nfs3svc_encode_diropres(struct svc_rqst *rqstp, __be32 *p)
{ {
struct xdr_stream *xdr = &rqstp->rq_res_stream;
struct nfsd3_diropres *resp = rqstp->rq_resp; struct nfsd3_diropres *resp = rqstp->rq_resp;
*p++ = resp->status; if (!svcxdr_encode_nfsstat3(xdr, resp->status))
if (resp->status == 0) { return 0;
p = encode_fh(p, &resp->fh); switch (resp->status) {
p = encode_post_op_attr(rqstp, p, &resp->fh); case nfs_ok:
if (!svcxdr_encode_nfs_fh3(xdr, &resp->fh))
return 0;
if (!svcxdr_encode_post_op_attr(rqstp, xdr, &resp->fh))
return 0;
if (!svcxdr_encode_post_op_attr(rqstp, xdr, &resp->dirfh))
return 0;
break;
default:
if (!svcxdr_encode_post_op_attr(rqstp, xdr, &resp->dirfh))
return 0;
} }
p = encode_post_op_attr(rqstp, p, &resp->dirfh);
return xdr_ressize_check(rqstp, p); return 1;
} }
/* ACCESS */ /* ACCESS */
......
...@@ -282,7 +282,7 @@ int nfs3svc_decode_readdirplusargs(struct svc_rqst *, __be32 *); ...@@ -282,7 +282,7 @@ int nfs3svc_decode_readdirplusargs(struct svc_rqst *, __be32 *);
int nfs3svc_decode_commitargs(struct svc_rqst *, __be32 *); int nfs3svc_decode_commitargs(struct svc_rqst *, __be32 *);
int nfs3svc_encode_getattrres(struct svc_rqst *, __be32 *); int nfs3svc_encode_getattrres(struct svc_rqst *, __be32 *);
int nfs3svc_encode_wccstat(struct svc_rqst *, __be32 *); int nfs3svc_encode_wccstat(struct svc_rqst *, __be32 *);
int nfs3svc_encode_diropres(struct svc_rqst *, __be32 *); int nfs3svc_encode_lookupres(struct svc_rqst *, __be32 *);
int nfs3svc_encode_accessres(struct svc_rqst *, __be32 *); int nfs3svc_encode_accessres(struct svc_rqst *, __be32 *);
int nfs3svc_encode_readlinkres(struct svc_rqst *, __be32 *); int nfs3svc_encode_readlinkres(struct svc_rqst *, __be32 *);
int nfs3svc_encode_readres(struct svc_rqst *, __be32 *); int nfs3svc_encode_readres(struct svc_rqst *, __be32 *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment