summaryrefslogtreecommitdiff
path: root/fs/nfsd/nfs4xdr.c
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2023-09-18 17:00:18 +0300
committerChuck Lever <chuck.lever@oracle.com>2023-10-16 19:44:21 +0300
commita460cda28e9b3709794932a0158d7ded57a32136 (patch)
tree52f1395c238987bc29877eb5af5fa204eac986c0 /fs/nfsd/nfs4xdr.c
parent62f31e56d51a10e5c8867d64c83a3679bc71184b (diff)
downloadlinux-a460cda28e9b3709794932a0158d7ded57a32136.tar.xz
NFSD: Add nfsd4_encode_fattr4_rawdev()
Refactor the encoder for FATTR4_RAWDEV into a helper. In a subsequent patch, this helper will be called from a bitmask loop. Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Diffstat (limited to 'fs/nfsd/nfs4xdr.c')
-rw-r--r--fs/nfsd/nfs4xdr.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index e7cbb70959d8..94cddd768af8 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -2550,6 +2550,17 @@ static __be32 nfsd4_encode_nfstime4(struct xdr_stream *xdr,
return nfs_ok;
}
+static __be32 nfsd4_encode_specdata4(struct xdr_stream *xdr,
+ unsigned int major, unsigned int minor)
+{
+ __be32 status;
+
+ status = nfsd4_encode_uint32_t(xdr, major);
+ if (status != nfs_ok)
+ return status;
+ return nfsd4_encode_uint32_t(xdr, minor);
+}
+
/*
* ctime (in NFSv4, time_metadata) is not writeable, and the client
* doesn't really care what resolution could theoretically be stored by
@@ -3207,6 +3218,13 @@ static __be32 nfsd4_encode_fattr4_owner_group(struct xdr_stream *xdr,
return nfsd4_encode_group(xdr, args->rqstp, args->stat.gid);
}
+static __be32 nfsd4_encode_fattr4_rawdev(struct xdr_stream *xdr,
+ const struct nfsd4_fattr_args *args)
+{
+ return nfsd4_encode_specdata4(xdr, MAJOR(args->stat.rdev),
+ MINOR(args->stat.rdev));
+}
+
/*
* Note: @fhp can be NULL; in this case, we might have to compose the filehandle
* ourselves.
@@ -3511,11 +3529,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
goto out;
}
if (bmval1 & FATTR4_WORD1_RAWDEV) {
- p = xdr_reserve_space(xdr, 8);
- if (!p)
- goto out_resource;
- *p++ = cpu_to_be32((u32) MAJOR(args.stat.rdev));
- *p++ = cpu_to_be32((u32) MINOR(args.stat.rdev));
+ status = nfsd4_encode_fattr4_rawdev(xdr, &args);
+ if (status != nfs_ok)
+ goto out;
}
if (bmval1 & FATTR4_WORD1_SPACE_AVAIL) {
p = xdr_reserve_space(xdr, 8);