Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* XDR types for nfsd. This is mainly a typing exercise. */
0003 
0004 #ifndef LINUX_NFSD_H
0005 #define LINUX_NFSD_H
0006 
0007 #include <linux/vfs.h>
0008 #include "nfsd.h"
0009 #include "nfsfh.h"
0010 
0011 struct nfsd_fhandle {
0012     struct svc_fh       fh;
0013 };
0014 
0015 struct nfsd_sattrargs {
0016     struct svc_fh       fh;
0017     struct iattr        attrs;
0018 };
0019 
0020 struct nfsd_diropargs {
0021     struct svc_fh       fh;
0022     char *          name;
0023     unsigned int        len;
0024 };
0025 
0026 struct nfsd_readargs {
0027     struct svc_fh       fh;
0028     __u32           offset;
0029     __u32           count;
0030 };
0031 
0032 struct nfsd_writeargs {
0033     svc_fh          fh;
0034     __u32           offset;
0035     __u32           len;
0036     struct xdr_buf      payload;
0037 };
0038 
0039 struct nfsd_createargs {
0040     struct svc_fh       fh;
0041     char *          name;
0042     unsigned int        len;
0043     struct iattr        attrs;
0044 };
0045 
0046 struct nfsd_renameargs {
0047     struct svc_fh       ffh;
0048     char *          fname;
0049     unsigned int        flen;
0050     struct svc_fh       tfh;
0051     char *          tname;
0052     unsigned int        tlen;
0053 };
0054 
0055 struct nfsd_linkargs {
0056     struct svc_fh       ffh;
0057     struct svc_fh       tfh;
0058     char *          tname;
0059     unsigned int        tlen;
0060 };
0061 
0062 struct nfsd_symlinkargs {
0063     struct svc_fh       ffh;
0064     char *          fname;
0065     unsigned int        flen;
0066     char *          tname;
0067     unsigned int        tlen;
0068     struct iattr        attrs;
0069     struct kvec     first;
0070 };
0071 
0072 struct nfsd_readdirargs {
0073     struct svc_fh       fh;
0074     __u32           cookie;
0075     __u32           count;
0076 };
0077 
0078 struct nfsd_stat {
0079     __be32          status;
0080 };
0081 
0082 struct nfsd_attrstat {
0083     __be32          status;
0084     struct svc_fh       fh;
0085     struct kstat        stat;
0086 };
0087 
0088 struct nfsd_diropres  {
0089     __be32          status;
0090     struct svc_fh       fh;
0091     struct kstat        stat;
0092 };
0093 
0094 struct nfsd_readlinkres {
0095     __be32          status;
0096     int         len;
0097     struct page     *page;
0098 };
0099 
0100 struct nfsd_readres {
0101     __be32          status;
0102     struct svc_fh       fh;
0103     unsigned long       count;
0104     struct kstat        stat;
0105     struct page     **pages;
0106 };
0107 
0108 struct nfsd_readdirres {
0109     /* Components of the reply */
0110     __be32          status;
0111 
0112     int         count;
0113 
0114     /* Used to encode the reply's entry list */
0115     struct xdr_stream   xdr;
0116     struct xdr_buf      dirlist;
0117     struct readdir_cd   common;
0118     unsigned int        cookie_offset;
0119 };
0120 
0121 struct nfsd_statfsres {
0122     __be32          status;
0123     struct kstatfs      stats;
0124 };
0125 
0126 /*
0127  * Storage requirements for XDR arguments and results.
0128  */
0129 union nfsd_xdrstore {
0130     struct nfsd_sattrargs   sattr;
0131     struct nfsd_diropargs   dirop;
0132     struct nfsd_readargs    read;
0133     struct nfsd_writeargs   write;
0134     struct nfsd_createargs  create;
0135     struct nfsd_renameargs  rename;
0136     struct nfsd_linkargs    link;
0137     struct nfsd_symlinkargs symlink;
0138     struct nfsd_readdirargs readdir;
0139 };
0140 
0141 #define NFS2_SVC_XDRSIZE    sizeof(union nfsd_xdrstore)
0142 
0143 
0144 bool nfssvc_decode_fhandleargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0145 bool nfssvc_decode_sattrargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0146 bool nfssvc_decode_diropargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0147 bool nfssvc_decode_readargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0148 bool nfssvc_decode_writeargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0149 bool nfssvc_decode_createargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0150 bool nfssvc_decode_renameargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0151 bool nfssvc_decode_linkargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0152 bool nfssvc_decode_symlinkargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0153 bool nfssvc_decode_readdirargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0154 
0155 bool nfssvc_encode_statres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0156 bool nfssvc_encode_attrstatres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0157 bool nfssvc_encode_diropres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0158 bool nfssvc_encode_readlinkres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0159 bool nfssvc_encode_readres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0160 bool nfssvc_encode_statfsres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0161 bool nfssvc_encode_readdirres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
0162 
0163 void nfssvc_encode_nfscookie(struct nfsd_readdirres *resp, u32 offset);
0164 int nfssvc_encode_entry(void *data, const char *name, int namlen,
0165             loff_t offset, u64 ino, unsigned int d_type);
0166 
0167 void nfssvc_release_attrstat(struct svc_rqst *rqstp);
0168 void nfssvc_release_diropres(struct svc_rqst *rqstp);
0169 void nfssvc_release_readres(struct svc_rqst *rqstp);
0170 
0171 /* Helper functions for NFSv2 ACL code */
0172 bool svcxdr_decode_fhandle(struct xdr_stream *xdr, struct svc_fh *fhp);
0173 bool svcxdr_encode_stat(struct xdr_stream *xdr, __be32 status);
0174 bool svcxdr_encode_fattr(struct svc_rqst *rqstp, struct xdr_stream *xdr,
0175              const struct svc_fh *fhp, const struct kstat *stat);
0176 
0177 #endif /* LINUX_NFSD_H */