mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 04:33:26 +02:00
NFSD: Update the NFSv2 diropres encoder to use struct xdr_stream
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
This commit is contained in:
@@ -63,11 +63,17 @@ svcxdr_decode_fhandle(struct xdr_stream *xdr, struct svc_fh *fhp)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __be32 *
|
static bool
|
||||||
encode_fh(__be32 *p, struct svc_fh *fhp)
|
svcxdr_encode_fhandle(struct xdr_stream *xdr, const struct svc_fh *fhp)
|
||||||
{
|
{
|
||||||
|
__be32 *p;
|
||||||
|
|
||||||
|
p = xdr_reserve_space(xdr, NFS_FHSIZE);
|
||||||
|
if (!p)
|
||||||
|
return false;
|
||||||
memcpy(p, &fhp->fh_handle.fh_base, NFS_FHSIZE);
|
memcpy(p, &fhp->fh_handle.fh_base, NFS_FHSIZE);
|
||||||
return p + (NFS_FHSIZE>> 2);
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static __be32 *
|
static __be32 *
|
||||||
@@ -244,7 +250,7 @@ encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp,
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static bool
|
||||||
svcxdr_encode_fattr(struct svc_rqst *rqstp, struct xdr_stream *xdr,
|
svcxdr_encode_fattr(struct svc_rqst *rqstp, struct xdr_stream *xdr,
|
||||||
const struct svc_fh *fhp, const struct kstat *stat)
|
const struct svc_fh *fhp, const struct kstat *stat)
|
||||||
{
|
{
|
||||||
@@ -257,7 +263,7 @@ svcxdr_encode_fattr(struct svc_rqst *rqstp, struct xdr_stream *xdr,
|
|||||||
|
|
||||||
p = xdr_reserve_space(xdr, XDR_UNIT * 17);
|
p = xdr_reserve_space(xdr, XDR_UNIT * 17);
|
||||||
if (!p)
|
if (!p)
|
||||||
return 0;
|
return false;
|
||||||
|
|
||||||
*p++ = cpu_to_be32(nfs_ftypes[type >> 12]);
|
*p++ = cpu_to_be32(nfs_ftypes[type >> 12]);
|
||||||
*p++ = cpu_to_be32((u32)stat->mode);
|
*p++ = cpu_to_be32((u32)stat->mode);
|
||||||
@@ -299,7 +305,7 @@ svcxdr_encode_fattr(struct svc_rqst *rqstp, struct xdr_stream *xdr,
|
|||||||
p = encode_timeval(p, &time);
|
p = encode_timeval(p, &time);
|
||||||
encode_timeval(p, &stat->ctime);
|
encode_timeval(p, &stat->ctime);
|
||||||
|
|
||||||
return 1;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Helper function for NFSv2 ACL code */
|
/* Helper function for NFSv2 ACL code */
|
||||||
@@ -501,15 +507,21 @@ nfssvc_encode_attrstatres(struct svc_rqst *rqstp, __be32 *p)
|
|||||||
int
|
int
|
||||||
nfssvc_encode_diropres(struct svc_rqst *rqstp, __be32 *p)
|
nfssvc_encode_diropres(struct svc_rqst *rqstp, __be32 *p)
|
||||||
{
|
{
|
||||||
|
struct xdr_stream *xdr = &rqstp->rq_res_stream;
|
||||||
struct nfsd_diropres *resp = rqstp->rq_resp;
|
struct nfsd_diropres *resp = rqstp->rq_resp;
|
||||||
|
|
||||||
*p++ = resp->status;
|
if (!svcxdr_encode_stat(xdr, resp->status))
|
||||||
if (resp->status != nfs_ok)
|
return 0;
|
||||||
goto out;
|
switch (resp->status) {
|
||||||
p = encode_fh(p, &resp->fh);
|
case nfs_ok:
|
||||||
p = encode_fattr(rqstp, p, &resp->fh, &resp->stat);
|
if (!svcxdr_encode_fhandle(xdr, &resp->fh))
|
||||||
out:
|
return 0;
|
||||||
return xdr_ressize_check(rqstp, p);
|
if (!svcxdr_encode_fattr(rqstp, xdr, &resp->fh, &resp->stat))
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
Reference in New Issue
Block a user