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 | int vlen; |
| 31 | }; |
| 32 | |
| 33 | struct nfsd_writeargs { |
| 34 | svc_fh fh; |
| 35 | __u32 offset; |
| 36 | int len; |
Chuck Lever | 8154ef2 | 2018-03-27 10:54:07 -0400 | [diff] [blame] | 37 | struct kvec first; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | }; |
| 39 | |
| 40 | struct nfsd_createargs { |
| 41 | struct svc_fh fh; |
| 42 | char * name; |
Chuck Lever | 29d5e55 | 2007-11-01 16:57:04 -0400 | [diff] [blame] | 43 | unsigned int len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | struct iattr attrs; |
| 45 | }; |
| 46 | |
| 47 | struct nfsd_renameargs { |
| 48 | struct svc_fh ffh; |
| 49 | char * fname; |
Chuck Lever | 29d5e55 | 2007-11-01 16:57:04 -0400 | [diff] [blame] | 50 | unsigned int flen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | struct svc_fh tfh; |
| 52 | char * tname; |
Chuck Lever | 29d5e55 | 2007-11-01 16:57:04 -0400 | [diff] [blame] | 53 | unsigned int tlen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | struct nfsd_readlinkargs { |
| 57 | struct svc_fh fh; |
| 58 | char * buffer; |
| 59 | }; |
| 60 | |
| 61 | struct nfsd_linkargs { |
| 62 | struct svc_fh ffh; |
| 63 | struct svc_fh tfh; |
| 64 | char * tname; |
Chuck Lever | 29d5e55 | 2007-11-01 16:57:04 -0400 | [diff] [blame] | 65 | unsigned int tlen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | struct nfsd_symlinkargs { |
| 69 | struct svc_fh ffh; |
| 70 | char * fname; |
Chuck Lever | 29d5e55 | 2007-11-01 16:57:04 -0400 | [diff] [blame] | 71 | unsigned int flen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | char * tname; |
Chuck Lever | 48b4ba3 | 2007-11-01 16:57:25 -0400 | [diff] [blame] | 73 | unsigned int tlen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | struct iattr attrs; |
Chuck Lever | 38a7031 | 2018-03-27 10:54:21 -0400 | [diff] [blame] | 75 | struct kvec first; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | struct nfsd_readdirargs { |
| 79 | struct svc_fh fh; |
| 80 | __u32 cookie; |
| 81 | __u32 count; |
Al Viro | 131a21c | 2006-10-19 23:28:56 -0700 | [diff] [blame] | 82 | __be32 * buffer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | }; |
| 84 | |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 85 | struct nfsd_stat { |
| 86 | __be32 status; |
| 87 | }; |
| 88 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | struct nfsd_attrstat { |
Chuck Lever | f0af221 | 2020-10-01 18:59:49 -0400 | [diff] [blame] | 90 | __be32 status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | struct svc_fh fh; |
David Shaw | a334de2 | 2006-01-06 00:19:58 -0800 | [diff] [blame] | 92 | struct kstat stat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | struct nfsd_diropres { |
Chuck Lever | f0af221 | 2020-10-01 18:59:49 -0400 | [diff] [blame] | 96 | __be32 status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | struct svc_fh fh; |
David Shaw | a334de2 | 2006-01-06 00:19:58 -0800 | [diff] [blame] | 98 | struct kstat stat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | }; |
| 100 | |
| 101 | struct nfsd_readlinkres { |
Chuck Lever | f0af221 | 2020-10-01 18:59:49 -0400 | [diff] [blame] | 102 | __be32 status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | int len; |
| 104 | }; |
| 105 | |
| 106 | struct nfsd_readres { |
Chuck Lever | f0af221 | 2020-10-01 18:59:49 -0400 | [diff] [blame] | 107 | __be32 status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | struct svc_fh fh; |
| 109 | unsigned long count; |
David Shaw | a334de2 | 2006-01-06 00:19:58 -0800 | [diff] [blame] | 110 | struct kstat stat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | }; |
| 112 | |
| 113 | struct nfsd_readdirres { |
Chuck Lever | f0af221 | 2020-10-01 18:59:49 -0400 | [diff] [blame] | 114 | __be32 status; |
| 115 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | int count; |
| 117 | |
| 118 | struct readdir_cd common; |
Al Viro | 131a21c | 2006-10-19 23:28:56 -0700 | [diff] [blame] | 119 | __be32 * buffer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | int buflen; |
Al Viro | 131a21c | 2006-10-19 23:28:56 -0700 | [diff] [blame] | 121 | __be32 * offset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | }; |
| 123 | |
| 124 | struct nfsd_statfsres { |
Chuck Lever | f0af221 | 2020-10-01 18:59:49 -0400 | [diff] [blame] | 125 | __be32 status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | struct kstatfs stats; |
| 127 | }; |
| 128 | |
| 129 | /* |
| 130 | * Storage requirements for XDR arguments and results. |
| 131 | */ |
| 132 | union nfsd_xdrstore { |
| 133 | struct nfsd_sattrargs sattr; |
| 134 | struct nfsd_diropargs dirop; |
| 135 | struct nfsd_readargs read; |
| 136 | struct nfsd_writeargs write; |
| 137 | struct nfsd_createargs create; |
| 138 | struct nfsd_renameargs rename; |
| 139 | struct nfsd_linkargs link; |
| 140 | struct nfsd_symlinkargs symlink; |
| 141 | struct nfsd_readdirargs readdir; |
| 142 | }; |
| 143 | |
| 144 | #define NFS2_SVC_XDRSIZE sizeof(union nfsd_xdrstore) |
| 145 | |
| 146 | |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 147 | int nfssvc_decode_void(struct svc_rqst *, __be32 *); |
| 148 | int nfssvc_decode_fhandle(struct svc_rqst *, __be32 *); |
| 149 | int nfssvc_decode_sattrargs(struct svc_rqst *, __be32 *); |
| 150 | int nfssvc_decode_diropargs(struct svc_rqst *, __be32 *); |
| 151 | int nfssvc_decode_readargs(struct svc_rqst *, __be32 *); |
| 152 | int nfssvc_decode_writeargs(struct svc_rqst *, __be32 *); |
| 153 | int nfssvc_decode_createargs(struct svc_rqst *, __be32 *); |
| 154 | int nfssvc_decode_renameargs(struct svc_rqst *, __be32 *); |
| 155 | int nfssvc_decode_readlinkargs(struct svc_rqst *, __be32 *); |
| 156 | int nfssvc_decode_linkargs(struct svc_rqst *, __be32 *); |
| 157 | int nfssvc_decode_symlinkargs(struct svc_rqst *, __be32 *); |
| 158 | int nfssvc_decode_readdirargs(struct svc_rqst *, __be32 *); |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 159 | int nfssvc_encode_void(struct svc_rqst *, __be32 *); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 160 | int nfssvc_encode_stat(struct svc_rqst *, __be32 *); |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 161 | int nfssvc_encode_attrstat(struct svc_rqst *, __be32 *); |
| 162 | int nfssvc_encode_diropres(struct svc_rqst *, __be32 *); |
| 163 | int nfssvc_encode_readlinkres(struct svc_rqst *, __be32 *); |
| 164 | int nfssvc_encode_readres(struct svc_rqst *, __be32 *); |
| 165 | int nfssvc_encode_statfsres(struct svc_rqst *, __be32 *); |
| 166 | int nfssvc_encode_readdirres(struct svc_rqst *, __be32 *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | |
NeilBrown | a0ad13e | 2007-01-26 00:57:10 -0800 | [diff] [blame] | 168 | int nfssvc_encode_entry(void *, const char *name, |
| 169 | int namlen, loff_t offset, u64 ino, unsigned int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | |
Chuck Lever | 1841b9b | 2020-10-01 18:59:44 -0400 | [diff] [blame] | 171 | void nfssvc_release_attrstat(struct svc_rqst *rqstp); |
| 172 | void nfssvc_release_diropres(struct svc_rqst *rqstp); |
| 173 | void nfssvc_release_readres(struct svc_rqst *rqstp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 175 | /* Helper functions for NFSv2 ACL code */ |
J. Bruce Fields | 4f4a4fa | 2013-02-01 15:13:04 -0500 | [diff] [blame] | 176 | __be32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp, struct kstat *stat); |
Al Viro | 131a21c | 2006-10-19 23:28:56 -0700 | [diff] [blame] | 177 | __be32 *nfs2svc_decode_fh(__be32 *p, struct svc_fh *fhp); |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 178 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | #endif /* LINUX_NFSD_H */ |