summaryrefslogtreecommitdiff
path: root/fs/nfsd/nfs3xdr.c
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2020-10-20 21:30:02 +0300
committerChuck Lever <chuck.lever@oracle.com>2021-01-25 17:36:23 +0300
commit9575363a9e4c8d7e2f9ba5e79884d623fff0be6f (patch)
tree2c6ea1b751e2252e9bad992e5c6fd83ddd51ebf1 /fs/nfsd/nfs3xdr.c
parent81d217474326b25d7f14274b02fe3da1e85ad934 (diff)
downloadlinux-9575363a9e4c8d7e2f9ba5e79884d623fff0be6f.tar.xz
NFSD: Update GETATTR3args decoder to use struct xdr_stream
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Diffstat (limited to 'fs/nfsd/nfs3xdr.c')
-rw-r--r--fs/nfsd/nfs3xdr.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c
index 34b880211e5e..3a2b4abea1a4 100644
--- a/fs/nfsd/nfs3xdr.c
+++ b/fs/nfsd/nfs3xdr.c
@@ -29,8 +29,9 @@ static u32 nfs3_ftypes[] = {
/*
- * XDR functions for basic NFS types
+ * Basic NFSv3 data types (RFC 1813 Sections 2.5 and 2.6)
*/
+
static __be32 *
encode_time3(__be32 *p, struct timespec64 *time)
{
@@ -46,6 +47,26 @@ decode_time3(__be32 *p, struct timespec64 *time)
return p;
}
+static bool
+svcxdr_decode_nfs_fh3(struct xdr_stream *xdr, struct svc_fh *fhp)
+{
+ __be32 *p;
+ u32 size;
+
+ if (xdr_stream_decode_u32(xdr, &size) < 0)
+ return false;
+ if (size == 0 || size > NFS3_FHSIZE)
+ return false;
+ p = xdr_inline_decode(xdr, size);
+ if (!p)
+ return false;
+ fh_init(fhp, NFS3_FHSIZE);
+ fhp->fh_handle.fh_size = size;
+ memcpy(&fhp->fh_handle.fh_base, p, size);
+
+ return true;
+}
+
static __be32 *
decode_fh(__be32 *p, struct svc_fh *fhp)
{
@@ -312,14 +333,12 @@ void fill_post_wcc(struct svc_fh *fhp)
*/
int
-nfs3svc_decode_fhandle(struct svc_rqst *rqstp, __be32 *p)
+nfs3svc_decode_fhandleargs(struct svc_rqst *rqstp, __be32 *p)
{
+ struct xdr_stream *xdr = &rqstp->rq_arg_stream;
struct nfsd_fhandle *args = rqstp->rq_argp;
- p = decode_fh(p, &args->fh);
- if (!p)
- return 0;
- return xdr_argsize_check(rqstp, p);
+ return svcxdr_decode_nfs_fh3(xdr, &args->fh);
}
int