Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
J. Bruce Fields | 7663dac | 2009-12-04 19:49:00 -0500 | [diff] [blame] | 2 | /* XDR types for nfsd. This is mainly a typing exercise. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | |
| 4 | #ifndef LINUX_NFSD_H |
| 5 | #define LINUX_NFSD_H |
| 6 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | #include <linux/vfs.h> |
Boaz Harrosh | 9a74af2 | 2009-12-03 20:30:56 +0200 | [diff] [blame] | 8 | #include "nfsd.h" |
J. Bruce Fields | 1557aca | 2009-12-04 19:36:06 -0500 | [diff] [blame] | 9 | #include "nfsfh.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | |
| 11 | struct nfsd_fhandle { |
| 12 | struct svc_fh fh; |
| 13 | }; |
| 14 | |
| 15 | struct nfsd_sattrargs { |
| 16 | struct svc_fh fh; |
| 17 | struct iattr attrs; |
| 18 | }; |
| 19 | |
| 20 | struct nfsd_diropargs { |
| 21 | struct svc_fh fh; |
| 22 | char * name; |
Chuck Lever | 29d5e55 | 2007-11-01 16:57:04 -0400 | [diff] [blame] | 23 | unsigned int len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | }; |
| 25 | |
| 26 | struct nfsd_readargs { |
| 27 | struct svc_fh fh; |
| 28 | __u32 offset; |
| 29 | __u32 count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | }; |
| 31 | |
| 32 | struct nfsd_writeargs { |
| 33 | svc_fh fh; |
| 34 | __u32 offset; |
| 35 | int len; |
Chuck Lever | dae9a6c | 2021-09-30 17:06:21 -0400 | [diff] [blame] | 36 | struct xdr_buf payload; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | }; |
| 38 | |
| 39 | struct nfsd_createargs { |
| 40 | struct svc_fh fh; |
| 41 | char * name; |
Chuck Lever | 29d5e55 | 2007-11-01 16:57:04 -0400 | [diff] [blame] | 42 | unsigned int len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | struct iattr attrs; |
| 44 | }; |
| 45 | |
| 46 | struct nfsd_renameargs { |
| 47 | struct svc_fh ffh; |
| 48 | char * fname; |
Chuck Lever | 29d5e55 | 2007-11-01 16:57:04 -0400 | [diff] [blame] | 49 | unsigned int flen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | struct svc_fh tfh; |
| 51 | char * tname; |
Chuck Lever | 29d5e55 | 2007-11-01 16:57:04 -0400 | [diff] [blame] | 52 | unsigned int tlen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | }; |
| 54 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | struct nfsd_linkargs { |
| 56 | struct svc_fh ffh; |
| 57 | struct svc_fh tfh; |
| 58 | char * tname; |
Chuck Lever | 29d5e55 | 2007-11-01 16:57:04 -0400 | [diff] [blame] | 59 | unsigned int tlen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | }; |
| 61 | |
| 62 | struct nfsd_symlinkargs { |
| 63 | struct svc_fh ffh; |
| 64 | char * fname; |
Chuck Lever | 29d5e55 | 2007-11-01 16:57:04 -0400 | [diff] [blame] | 65 | unsigned int flen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | char * tname; |
Chuck Lever | 48b4ba3 | 2007-11-01 16:57:25 -0400 | [diff] [blame] | 67 | unsigned int tlen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | struct iattr attrs; |
Chuck Lever | 38a7031 | 2018-03-27 10:54:21 -0400 | [diff] [blame] | 69 | struct kvec first; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | struct nfsd_readdirargs { |
| 73 | struct svc_fh fh; |
| 74 | __u32 cookie; |
| 75 | __u32 count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | }; |
| 77 | |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 78 | struct nfsd_stat { |
| 79 | __be32 status; |
| 80 | }; |
| 81 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | struct nfsd_attrstat { |
Chuck Lever | f0af221 | 2020-10-01 18:59:49 -0400 | [diff] [blame] | 83 | __be32 status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | struct svc_fh fh; |
David Shaw | a334de2 | 2006-01-06 00:19:58 -0800 | [diff] [blame] | 85 | struct kstat stat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | struct nfsd_diropres { |
Chuck Lever | f0af221 | 2020-10-01 18:59:49 -0400 | [diff] [blame] | 89 | __be32 status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | struct svc_fh fh; |
David Shaw | a334de2 | 2006-01-06 00:19:58 -0800 | [diff] [blame] | 91 | struct kstat stat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | struct nfsd_readlinkres { |
Chuck Lever | f0af221 | 2020-10-01 18:59:49 -0400 | [diff] [blame] | 95 | __be32 status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | int len; |
Chuck Lever | d9014b0 | 2020-10-23 15:41:09 -0400 | [diff] [blame] | 97 | struct page *page; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | }; |
| 99 | |
| 100 | struct nfsd_readres { |
Chuck Lever | f0af221 | 2020-10-01 18:59:49 -0400 | [diff] [blame] | 101 | __be32 status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | struct svc_fh fh; |
| 103 | unsigned long count; |
David Shaw | a334de2 | 2006-01-06 00:19:58 -0800 | [diff] [blame] | 104 | struct kstat stat; |
Chuck Lever | a6f8d9d | 2020-10-23 16:40:11 -0400 | [diff] [blame] | 105 | struct page **pages; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | }; |
| 107 | |
| 108 | struct nfsd_readdirres { |
Chuck Lever | f5dcccd | 2020-11-14 13:45:35 -0500 | [diff] [blame] | 109 | /* Components of the reply */ |
Chuck Lever | f0af221 | 2020-10-01 18:59:49 -0400 | [diff] [blame] | 110 | __be32 status; |
| 111 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | int count; |
| 113 | |
Chuck Lever | f5dcccd | 2020-11-14 13:45:35 -0500 | [diff] [blame] | 114 | /* Used to encode the reply's entry list */ |
| 115 | struct xdr_stream xdr; |
| 116 | struct xdr_buf dirlist; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | struct readdir_cd common; |
Chuck Lever | f5dcccd | 2020-11-14 13:45:35 -0500 | [diff] [blame] | 118 | unsigned int cookie_offset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | }; |
| 120 | |
| 121 | struct nfsd_statfsres { |
Chuck Lever | f0af221 | 2020-10-01 18:59:49 -0400 | [diff] [blame] | 122 | __be32 status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | struct kstatfs stats; |
| 124 | }; |
| 125 | |
| 126 | /* |
| 127 | * Storage requirements for XDR arguments and results. |
| 128 | */ |
| 129 | union nfsd_xdrstore { |
| 130 | struct nfsd_sattrargs sattr; |
| 131 | struct nfsd_diropargs dirop; |
| 132 | struct nfsd_readargs read; |
| 133 | struct nfsd_writeargs write; |
| 134 | struct nfsd_createargs create; |
| 135 | struct nfsd_renameargs rename; |
| 136 | struct nfsd_linkargs link; |
| 137 | struct nfsd_symlinkargs symlink; |
| 138 | struct nfsd_readdirargs readdir; |
| 139 | }; |
| 140 | |
| 141 | #define NFS2_SVC_XDRSIZE sizeof(union nfsd_xdrstore) |
| 142 | |
| 143 | |
Chuck Lever | c44b31c | 2021-10-12 11:57:28 -0400 | [diff] [blame] | 144 | bool nfssvc_decode_fhandleargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); |
| 145 | bool nfssvc_decode_sattrargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); |
| 146 | bool nfssvc_decode_diropargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); |
| 147 | bool nfssvc_decode_readargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); |
| 148 | bool nfssvc_decode_writeargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); |
| 149 | bool nfssvc_decode_createargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); |
| 150 | bool nfssvc_decode_renameargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); |
| 151 | bool nfssvc_decode_linkargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); |
| 152 | bool nfssvc_decode_symlinkargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); |
| 153 | bool nfssvc_decode_readdirargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); |
Chuck Lever | 16c6636 | 2021-10-12 11:57:22 -0400 | [diff] [blame] | 154 | |
Chuck Lever | 130e205 | 2021-10-13 10:41:13 -0400 | [diff] [blame] | 155 | bool nfssvc_encode_statres(struct svc_rqst *rqstp, struct xdr_stream *xdr); |
| 156 | bool nfssvc_encode_attrstatres(struct svc_rqst *rqstp, struct xdr_stream *xdr); |
| 157 | bool nfssvc_encode_diropres(struct svc_rqst *rqstp, struct xdr_stream *xdr); |
| 158 | bool nfssvc_encode_readlinkres(struct svc_rqst *rqstp, struct xdr_stream *xdr); |
| 159 | bool nfssvc_encode_readres(struct svc_rqst *rqstp, struct xdr_stream *xdr); |
| 160 | bool nfssvc_encode_statfsres(struct svc_rqst *rqstp, struct xdr_stream *xdr); |
| 161 | bool nfssvc_encode_readdirres(struct svc_rqst *rqstp, struct xdr_stream *xdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | |
Chuck Lever | d5253200 | 2020-11-13 16:53:17 -0500 | [diff] [blame] | 163 | void nfssvc_encode_nfscookie(struct nfsd_readdirres *resp, u32 offset); |
Chuck Lever | 8a2cf9f | 2020-11-15 14:30:13 -0500 | [diff] [blame] | 164 | int nfssvc_encode_entry(void *data, const char *name, int namlen, |
| 165 | loff_t offset, u64 ino, unsigned int d_type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | |
Chuck Lever | 1841b9b | 2020-10-01 18:59:44 -0400 | [diff] [blame] | 167 | void nfssvc_release_attrstat(struct svc_rqst *rqstp); |
| 168 | void nfssvc_release_diropres(struct svc_rqst *rqstp); |
| 169 | void nfssvc_release_readres(struct svc_rqst *rqstp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 171 | /* Helper functions for NFSv2 ACL code */ |
Chuck Lever | 635a45d | 2020-11-17 11:32:04 -0500 | [diff] [blame] | 172 | bool svcxdr_decode_fhandle(struct xdr_stream *xdr, struct svc_fh *fhp); |
Chuck Lever | f8cba47 | 2020-11-18 14:38:47 -0500 | [diff] [blame] | 173 | bool svcxdr_encode_stat(struct xdr_stream *xdr, __be32 status); |
| 174 | bool svcxdr_encode_fattr(struct svc_rqst *rqstp, struct xdr_stream *xdr, |
| 175 | const struct svc_fh *fhp, const struct kstat *stat); |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 176 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | #endif /* LINUX_NFSD_H */ |