1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* XDR types for nfsd. This is mainly a typing exercise. */ 3 4 #ifndef _LINUX_NFSD_XDR_H 5 #define _LINUX_NFSD_XDR_H 6 7 #include <linux/vfs.h> 8 9 #include "vfs.h" 10 11 struct nfsd_attrstat { 12 __be32 status; 13 struct svc_fh fh; 14 struct kstat stat; 15 }; 16 17 /* 18 * Declared here rather than in nfsproc.c with the other proc wrappers 19 * because READDIR's encode hooks in nfsxdr.c reference it. The xdrgen 20 * field must be first so the struct can be cast to its XDR type for the 21 * RPC dispatch layer. 22 * 23 * The file handle lives here rather than in an argument wrapper: the 24 * RPC layer zeroes the result before decode, so ->pc_release can run on 25 * a request that failed to decode. 26 */ 27 struct readdirres_wrapper { 28 struct readdirres xdrgen; 29 struct svc_fh fh; 30 31 /* Streaming state for encoding the reply's entry list */ 32 struct nfsd_readdir_iter iter; /* directory reader */ 33 u32 count; /* client's reply size hint */ 34 u32 space_left; /* remaining entry budget */ 35 unsigned int cookie_offset; /* prev entry's cookie slot */ 36 }; 37 38 static_assert(offsetof(struct readdirres_wrapper, xdrgen) == 0); 39 40 bool nfssvc_decode_fhandleargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); 41 42 bool nfssvc_encode_attrstatres(struct svc_rqst *rqstp, struct xdr_stream *xdr); 43 44 void nfssvc_encode_nfscookie(struct xdr_stream *xdr, unsigned int pos, 45 u32 cookie); 46 47 void nfssvc_release_readdirres(struct svc_rqst *rqstp); 48 49 void nfssvc_release_attrstat(struct svc_rqst *rqstp); 50 51 /* Helper functions for NFSv2 ACL code */ 52 bool svcxdr_decode_fhandle(struct xdr_stream *xdr, struct svc_fh *fhp); 53 bool svcxdr_encode_stat(struct xdr_stream *xdr, __be32 status); 54 bool svcxdr_encode_fattr(struct svc_rqst *rqstp, struct xdr_stream *xdr, 55 const struct svc_fh *fhp, const struct kstat *stat); 56 57 #endif /* _LINUX_NFSD_XDR_H */ 58