xref: /linux/fs/nfsd/xdr3.h (revision 8bc7c5e525584903ea83332e18a2118ed3b1985e)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * XDR types for NFSv3 in nfsd.
4  *
5  * Copyright (C) 1996-1998, Olaf Kirch <okir@monad.swb.de>
6  */
7 
8 #ifndef _LINUX_NFSD_XDR3_H
9 #define _LINUX_NFSD_XDR3_H
10 
11 #include "xdr.h"
12 
13 struct nfsd3_sattrargs {
14 	struct svc_fh		fh;
15 	struct iattr		attrs;
16 	int			check_guard;
17 	struct timespec64	guardtime;
18 };
19 
20 struct nfsd3_diropargs {
21 	struct svc_fh		fh;
22 	char *			name;
23 	unsigned int		len;
24 };
25 
26 struct nfsd3_accessargs {
27 	struct svc_fh		fh;
28 	__u32			access;
29 };
30 
31 struct nfsd3_readargs {
32 	struct svc_fh		fh;
33 	__u64			offset;
34 	__u32			count;
35 };
36 
37 struct nfsd3_writeargs {
38 	svc_fh			fh;
39 	__u64			offset;
40 	__u32			count;
41 	int			stable;
42 	__u32			len;
43 	struct xdr_buf		payload;
44 };
45 
46 struct nfsd3_createargs {
47 	struct svc_fh		fh;
48 	char *			name;
49 	unsigned int		len;
50 	int			createmode;
51 	struct iattr		attrs;
52 	__be32 *		verf;
53 };
54 
55 struct nfsd3_mknodargs {
56 	struct svc_fh		fh;
57 	char *			name;
58 	unsigned int		len;
59 	__u32			ftype;
60 	__u32			major, minor;
61 	struct iattr		attrs;
62 };
63 
64 struct nfsd3_renameargs {
65 	struct svc_fh		ffh;
66 	char *			fname;
67 	unsigned int		flen;
68 	struct svc_fh		tfh;
69 	char *			tname;
70 	unsigned int		tlen;
71 };
72 
73 struct nfsd3_linkargs {
74 	struct svc_fh		ffh;
75 	struct svc_fh		tfh;
76 	char *			tname;
77 	unsigned int		tlen;
78 };
79 
80 struct nfsd3_symlinkargs {
81 	struct svc_fh		ffh;
82 	char *			fname;
83 	unsigned int		flen;
84 	char *			tname;
85 	unsigned int		tlen;
86 	struct iattr		attrs;
87 	struct kvec		first;
88 };
89 
90 struct nfsd3_readdirargs {
91 	struct svc_fh		fh;
92 	__u64			cookie;
93 	__u32			count;
94 	__be32 *		verf;
95 };
96 
97 struct nfsd3_commitargs {
98 	struct svc_fh		fh;
99 	__u64			offset;
100 	__u32			count;
101 };
102 
103 struct nfsd3_getaclargs {
104 	struct svc_fh		fh;
105 	__u32			mask;
106 };
107 
108 struct posix_acl;
109 struct nfsd3_setaclargs {
110 	struct svc_fh		fh;
111 	__u32			mask;
112 	struct posix_acl	*acl_access;
113 	struct posix_acl	*acl_default;
114 };
115 
116 struct nfsd3_attrstat {
117 	__be32			status;
118 	struct svc_fh		fh;
119 	struct kstat            stat;
120 };
121 
122 /* LOOKUP, CREATE, MKDIR, SYMLINK, MKNOD */
123 struct nfsd3_diropres  {
124 	__be32			status;
125 	struct svc_fh		dirfh;
126 	struct svc_fh		fh;
127 };
128 
129 struct nfsd3_accessres {
130 	__be32			status;
131 	struct svc_fh		fh;
132 	__u32			access;
133 	struct kstat		stat;
134 };
135 
136 struct nfsd3_readlinkres {
137 	__be32			status;
138 	struct svc_fh		fh;
139 	__u32			len;
140 	struct page		**pages;
141 };
142 
143 struct nfsd3_readres {
144 	__be32			status;
145 	struct svc_fh		fh;
146 	unsigned long		count;
147 	__u32			eof;
148 	struct page		**pages;
149 };
150 
151 struct nfsd3_writeres {
152 	__be32			status;
153 	struct svc_fh		fh;
154 	unsigned long		count;
155 	int			committed;
156 	__be32			verf[2];
157 };
158 
159 struct nfsd3_renameres {
160 	__be32			status;
161 	struct svc_fh		ffh;
162 	struct svc_fh		tfh;
163 };
164 
165 struct nfsd3_linkres {
166 	__be32			status;
167 	struct svc_fh		tfh;
168 	struct svc_fh		fh;
169 };
170 
171 struct nfsd3_readdirres {
172 	/* Components of the reply */
173 	__be32			status;
174 	struct svc_fh		fh;
175 	__be32			verf[2];
176 
177 	/* Used to encode the reply's entry list */
178 	struct xdr_stream	xdr;
179 	struct xdr_buf		dirlist;
180 	struct svc_fh		scratch;
181 	struct readdir_cd	common;
182 	unsigned int		cookie_offset;
183 	struct svc_rqst *	rqstp;
184 
185 };
186 
187 struct nfsd3_fsstatres {
188 	__be32			status;
189 	struct kstatfs		stats;
190 	__u32			invarsec;
191 };
192 
193 struct nfsd3_fsinfores {
194 	__be32			status;
195 	__u32			f_rtmax;
196 	__u32			f_rtpref;
197 	__u32			f_rtmult;
198 	__u32			f_wtmax;
199 	__u32			f_wtpref;
200 	__u32			f_wtmult;
201 	__u32			f_dtpref;
202 	__u64			f_maxfilesize;
203 	__u32			f_properties;
204 };
205 
206 struct nfsd3_pathconfres {
207 	__be32			status;
208 	__u32			p_link_max;
209 	__u32			p_name_max;
210 	__u32			p_no_trunc;
211 	__u32			p_chown_restricted;
212 	__u32			p_case_insensitive;
213 	__u32			p_case_preserving;
214 };
215 
216 struct nfsd3_commitres {
217 	__be32			status;
218 	struct svc_fh		fh;
219 	__be32			verf[2];
220 };
221 
222 struct nfsd3_getaclres {
223 	__be32			status;
224 	struct svc_fh		fh;
225 	int			mask;
226 	struct posix_acl	*acl_access;
227 	struct posix_acl	*acl_default;
228 	struct kstat		stat;
229 };
230 
231 /* dummy type for release */
232 struct nfsd3_fhandle_pair {
233 	__u32			dummy;
234 	struct svc_fh		fh1;
235 	struct svc_fh		fh2;
236 };
237 
238 /*
239  * Storage requirements for XDR arguments and results.
240  */
241 union nfsd3_xdrstore {
242 	struct nfsd3_sattrargs		sattrargs;
243 	struct nfsd3_diropargs		diropargs;
244 	struct nfsd3_readargs		readargs;
245 	struct nfsd3_writeargs		writeargs;
246 	struct nfsd3_createargs		createargs;
247 	struct nfsd3_renameargs		renameargs;
248 	struct nfsd3_linkargs		linkargs;
249 	struct nfsd3_symlinkargs	symlinkargs;
250 	struct nfsd3_readdirargs	readdirargs;
251 	struct nfsd3_diropres 		diropres;
252 	struct nfsd3_accessres		accessres;
253 	struct nfsd3_readlinkres	readlinkres;
254 	struct nfsd3_readres		readres;
255 	struct nfsd3_writeres		writeres;
256 	struct nfsd3_renameres		renameres;
257 	struct nfsd3_linkres		linkres;
258 	struct nfsd3_readdirres		readdirres;
259 	struct nfsd3_fsstatres		fsstatres;
260 	struct nfsd3_fsinfores		fsinfores;
261 	struct nfsd3_pathconfres	pathconfres;
262 	struct nfsd3_commitres		commitres;
263 	struct nfsd3_getaclres		getaclres;
264 };
265 
266 #define NFS3_SVC_XDRSIZE		sizeof(union nfsd3_xdrstore)
267 
268 bool nfs3svc_decode_fhandleargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
269 bool nfs3svc_decode_sattrargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
270 bool nfs3svc_decode_diropargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
271 bool nfs3svc_decode_accessargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
272 bool nfs3svc_decode_readargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
273 bool nfs3svc_decode_writeargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
274 bool nfs3svc_decode_createargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
275 bool nfs3svc_decode_mkdirargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
276 bool nfs3svc_decode_mknodargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
277 bool nfs3svc_decode_renameargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
278 bool nfs3svc_decode_linkargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
279 bool nfs3svc_decode_symlinkargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
280 bool nfs3svc_decode_readdirargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
281 bool nfs3svc_decode_readdirplusargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
282 bool nfs3svc_decode_commitargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
283 
284 bool nfs3svc_encode_getattrres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
285 bool nfs3svc_encode_wccstat(struct svc_rqst *rqstp, struct xdr_stream *xdr);
286 bool nfs3svc_encode_lookupres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
287 bool nfs3svc_encode_accessres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
288 bool nfs3svc_encode_readlinkres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
289 bool nfs3svc_encode_readres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
290 bool nfs3svc_encode_writeres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
291 bool nfs3svc_encode_createres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
292 bool nfs3svc_encode_renameres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
293 bool nfs3svc_encode_linkres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
294 bool nfs3svc_encode_readdirres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
295 bool nfs3svc_encode_fsstatres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
296 bool nfs3svc_encode_fsinfores(struct svc_rqst *rqstp, struct xdr_stream *xdr);
297 bool nfs3svc_encode_pathconfres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
298 bool nfs3svc_encode_commitres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
299 
300 void nfs3svc_release_fhandle(struct svc_rqst *);
301 void nfs3svc_release_fhandle2(struct svc_rqst *);
302 
303 void nfs3svc_encode_cookie3(struct nfsd3_readdirres *resp, u64 offset);
304 int nfs3svc_encode_entry3(void *data, const char *name, int namlen,
305 			  loff_t offset, u64 ino, unsigned int d_type);
306 int nfs3svc_encode_entryplus3(void *data, const char *name, int namlen,
307 			      loff_t offset, u64 ino, unsigned int d_type);
308 /* Helper functions for NFSv3 ACL code */
309 bool svcxdr_decode_nfs_fh3(struct xdr_stream *xdr, struct svc_fh *fhp);
310 bool svcxdr_encode_nfsstat3(struct xdr_stream *xdr, __be32 status);
311 bool svcxdr_encode_post_op_attr(struct svc_rqst *rqstp, struct xdr_stream *xdr,
312 				const struct svc_fh *fhp);
313 
314 #endif /* _LINUX_NFSD_XDR3_H */
315