Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * include/linux/nfsd/xdr4.h | |
3 | * | |
4 | * Server-side types for NFSv4. | |
5 | * | |
6 | * Copyright (c) 2002 The Regents of the University of Michigan. | |
7 | * All rights reserved. | |
8 | * | |
9 | * Kendrick Smith <kmsmith@umich.edu> | |
10 | * Andy Adamson <andros@umich.edu> | |
11 | * | |
12 | * Redistribution and use in source and binary forms, with or without | |
13 | * modification, are permitted provided that the following conditions | |
14 | * are met: | |
15 | * | |
16 | * 1. Redistributions of source code must retain the above copyright | |
17 | * notice, this list of conditions and the following disclaimer. | |
18 | * 2. Redistributions in binary form must reproduce the above copyright | |
19 | * notice, this list of conditions and the following disclaimer in the | |
20 | * documentation and/or other materials provided with the distribution. | |
21 | * 3. Neither the name of the University nor the names of its | |
22 | * contributors may be used to endorse or promote products derived | |
23 | * from this software without specific prior written permission. | |
24 | * | |
25 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | |
26 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
27 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
28 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | |
32 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
33 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
34 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
35 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
36 | * | |
37 | */ | |
38 | ||
39 | #ifndef _LINUX_NFSD_XDR4_H | |
40 | #define _LINUX_NFSD_XDR4_H | |
41 | ||
42 | #include <linux/nfs4.h> | |
43 | ||
44 | #define NFSD4_MAX_TAGLEN 128 | |
45 | #define XDR_LEN(n) (((n) + 3) & ~3) | |
46 | ||
ca364317 BF |
47 | struct nfsd4_compound_state { |
48 | struct svc_fh current_fh; | |
49 | struct svc_fh save_fh; | |
50 | }; | |
51 | ||
1da177e4 LT |
52 | struct nfsd4_change_info { |
53 | u32 atomic; | |
54 | u32 before_ctime_sec; | |
55 | u32 before_ctime_nsec; | |
56 | u32 after_ctime_sec; | |
57 | u32 after_ctime_nsec; | |
58 | }; | |
59 | ||
60 | struct nfsd4_access { | |
61 | u32 ac_req_access; /* request */ | |
62 | u32 ac_supported; /* response */ | |
63 | u32 ac_resp_access; /* response */ | |
64 | }; | |
65 | ||
66 | struct nfsd4_close { | |
67 | u32 cl_seqid; /* request */ | |
68 | stateid_t cl_stateid; /* request+response */ | |
69 | struct nfs4_stateowner * cl_stateowner; /* response */ | |
70 | }; | |
71 | ||
72 | struct nfsd4_commit { | |
73 | u64 co_offset; /* request */ | |
74 | u32 co_count; /* request */ | |
75 | nfs4_verifier co_verf; /* response */ | |
76 | }; | |
77 | ||
78 | struct nfsd4_create { | |
79 | u32 cr_namelen; /* request */ | |
80 | char * cr_name; /* request */ | |
81 | u32 cr_type; /* request */ | |
82 | union { /* request */ | |
83 | struct { | |
84 | u32 namelen; | |
85 | char *name; | |
86 | } link; /* NF4LNK */ | |
87 | struct { | |
88 | u32 specdata1; | |
89 | u32 specdata2; | |
90 | } dev; /* NF4BLK, NF4CHR */ | |
91 | } u; | |
92 | u32 cr_bmval[2]; /* request */ | |
93 | struct iattr cr_iattr; /* request */ | |
94 | struct nfsd4_change_info cr_cinfo; /* response */ | |
95 | struct nfs4_acl *cr_acl; | |
96 | }; | |
97 | #define cr_linklen u.link.namelen | |
98 | #define cr_linkname u.link.name | |
99 | #define cr_specdata1 u.dev.specdata1 | |
100 | #define cr_specdata2 u.dev.specdata2 | |
101 | ||
102 | struct nfsd4_delegreturn { | |
103 | stateid_t dr_stateid; | |
104 | }; | |
105 | ||
106 | struct nfsd4_getattr { | |
107 | u32 ga_bmval[2]; /* request */ | |
108 | struct svc_fh *ga_fhp; /* response */ | |
109 | }; | |
110 | ||
111 | struct nfsd4_link { | |
112 | u32 li_namelen; /* request */ | |
113 | char * li_name; /* request */ | |
114 | struct nfsd4_change_info li_cinfo; /* response */ | |
115 | }; | |
116 | ||
117 | struct nfsd4_lock_denied { | |
118 | clientid_t ld_clientid; | |
119 | struct nfs4_stateowner *ld_sop; | |
120 | u64 ld_start; | |
121 | u64 ld_length; | |
122 | u32 ld_type; | |
123 | }; | |
124 | ||
125 | struct nfsd4_lock { | |
126 | /* request */ | |
127 | u32 lk_type; | |
128 | u32 lk_reclaim; /* boolean */ | |
129 | u64 lk_offset; | |
130 | u64 lk_length; | |
131 | u32 lk_is_new; | |
132 | union { | |
133 | struct { | |
134 | u32 open_seqid; | |
135 | stateid_t open_stateid; | |
136 | u32 lock_seqid; | |
137 | clientid_t clientid; | |
138 | struct xdr_netobj owner; | |
139 | } new; | |
140 | struct { | |
141 | stateid_t lock_stateid; | |
142 | u32 lock_seqid; | |
143 | } old; | |
144 | } v; | |
145 | ||
146 | /* response */ | |
147 | union { | |
148 | struct { | |
149 | stateid_t stateid; | |
150 | } ok; | |
151 | struct nfsd4_lock_denied denied; | |
152 | } u; | |
3a65588a BF |
153 | /* The lk_replay_owner is the open owner in the open_to_lock_owner |
154 | * case and the lock owner otherwise: */ | |
155 | struct nfs4_stateowner *lk_replay_owner; | |
1da177e4 LT |
156 | }; |
157 | #define lk_new_open_seqid v.new.open_seqid | |
158 | #define lk_new_open_stateid v.new.open_stateid | |
159 | #define lk_new_lock_seqid v.new.lock_seqid | |
160 | #define lk_new_clientid v.new.clientid | |
161 | #define lk_new_owner v.new.owner | |
162 | #define lk_old_lock_stateid v.old.lock_stateid | |
163 | #define lk_old_lock_seqid v.old.lock_seqid | |
164 | ||
165 | #define lk_rflags u.ok.rflags | |
166 | #define lk_resp_stateid u.ok.stateid | |
167 | #define lk_denied u.denied | |
168 | ||
169 | ||
170 | struct nfsd4_lockt { | |
171 | u32 lt_type; | |
172 | clientid_t lt_clientid; | |
173 | struct xdr_netobj lt_owner; | |
174 | u64 lt_offset; | |
175 | u64 lt_length; | |
176 | struct nfs4_stateowner * lt_stateowner; | |
177 | struct nfsd4_lock_denied lt_denied; | |
178 | }; | |
179 | ||
180 | ||
181 | struct nfsd4_locku { | |
182 | u32 lu_type; | |
183 | u32 lu_seqid; | |
184 | stateid_t lu_stateid; | |
185 | u64 lu_offset; | |
186 | u64 lu_length; | |
187 | struct nfs4_stateowner *lu_stateowner; | |
188 | }; | |
189 | ||
190 | ||
191 | struct nfsd4_lookup { | |
192 | u32 lo_len; /* request */ | |
193 | char * lo_name; /* request */ | |
194 | }; | |
195 | ||
196 | struct nfsd4_putfh { | |
197 | u32 pf_fhlen; /* request */ | |
198 | char *pf_fhval; /* request */ | |
199 | }; | |
200 | ||
201 | struct nfsd4_open { | |
202 | u32 op_claim_type; /* request */ | |
203 | struct xdr_netobj op_fname; /* request - everything but CLAIM_PREV */ | |
204 | u32 op_delegate_type; /* request - CLAIM_PREV only */ | |
205 | stateid_t op_delegate_stateid; /* request - response */ | |
206 | u32 op_create; /* request */ | |
207 | u32 op_createmode; /* request */ | |
208 | u32 op_bmval[2]; /* request */ | |
209 | union { /* request */ | |
210 | struct iattr iattr; /* UNCHECKED4,GUARDED4 */ | |
211 | nfs4_verifier verf; /* EXCLUSIVE4 */ | |
212 | } u; | |
213 | clientid_t op_clientid; /* request */ | |
214 | struct xdr_netobj op_owner; /* request */ | |
215 | u32 op_seqid; /* request */ | |
216 | u32 op_share_access; /* request */ | |
217 | u32 op_share_deny; /* request */ | |
218 | stateid_t op_stateid; /* response */ | |
7b190fec | 219 | u32 op_recall; /* recall */ |
1da177e4 LT |
220 | struct nfsd4_change_info op_cinfo; /* response */ |
221 | u32 op_rflags; /* response */ | |
222 | int op_truncate; /* used during processing */ | |
223 | struct nfs4_stateowner *op_stateowner; /* used during processing */ | |
224 | struct nfs4_acl *op_acl; | |
225 | }; | |
226 | #define op_iattr u.iattr | |
227 | #define op_verf u.verf | |
228 | ||
229 | struct nfsd4_open_confirm { | |
230 | stateid_t oc_req_stateid /* request */; | |
231 | u32 oc_seqid /* request */; | |
232 | stateid_t oc_resp_stateid /* response */; | |
233 | struct nfs4_stateowner * oc_stateowner; /* response */ | |
234 | }; | |
235 | ||
236 | struct nfsd4_open_downgrade { | |
237 | stateid_t od_stateid; | |
238 | u32 od_seqid; | |
239 | u32 od_share_access; | |
240 | u32 od_share_deny; | |
241 | struct nfs4_stateowner *od_stateowner; | |
242 | }; | |
243 | ||
244 | ||
245 | struct nfsd4_read { | |
246 | stateid_t rd_stateid; /* request */ | |
247 | u64 rd_offset; /* request */ | |
248 | u32 rd_length; /* request */ | |
1da177e4 LT |
249 | int rd_vlen; |
250 | struct file *rd_filp; | |
251 | ||
252 | struct svc_rqst *rd_rqstp; /* response */ | |
253 | struct svc_fh * rd_fhp; /* response */ | |
254 | }; | |
255 | ||
256 | struct nfsd4_readdir { | |
257 | u64 rd_cookie; /* request */ | |
258 | nfs4_verifier rd_verf; /* request */ | |
259 | u32 rd_dircount; /* request */ | |
260 | u32 rd_maxcount; /* request */ | |
261 | u32 rd_bmval[2]; /* request */ | |
262 | struct svc_rqst *rd_rqstp; /* response */ | |
263 | struct svc_fh * rd_fhp; /* response */ | |
264 | ||
265 | struct readdir_cd common; | |
2ebbc012 | 266 | __be32 * buffer; |
1da177e4 | 267 | int buflen; |
2ebbc012 | 268 | __be32 * offset; |
1da177e4 LT |
269 | }; |
270 | ||
271 | struct nfsd4_release_lockowner { | |
272 | clientid_t rl_clientid; | |
273 | struct xdr_netobj rl_owner; | |
274 | }; | |
275 | struct nfsd4_readlink { | |
276 | struct svc_rqst *rl_rqstp; /* request */ | |
277 | struct svc_fh * rl_fhp; /* request */ | |
278 | }; | |
279 | ||
280 | struct nfsd4_remove { | |
281 | u32 rm_namelen; /* request */ | |
282 | char * rm_name; /* request */ | |
283 | struct nfsd4_change_info rm_cinfo; /* response */ | |
284 | }; | |
285 | ||
286 | struct nfsd4_rename { | |
287 | u32 rn_snamelen; /* request */ | |
288 | char * rn_sname; /* request */ | |
289 | u32 rn_tnamelen; /* request */ | |
290 | char * rn_tname; /* request */ | |
291 | struct nfsd4_change_info rn_sinfo; /* response */ | |
292 | struct nfsd4_change_info rn_tinfo; /* response */ | |
293 | }; | |
294 | ||
295 | struct nfsd4_setattr { | |
296 | stateid_t sa_stateid; /* request */ | |
297 | u32 sa_bmval[2]; /* request */ | |
298 | struct iattr sa_iattr; /* request */ | |
299 | struct nfs4_acl *sa_acl; | |
300 | }; | |
301 | ||
302 | struct nfsd4_setclientid { | |
303 | nfs4_verifier se_verf; /* request */ | |
304 | u32 se_namelen; /* request */ | |
305 | char * se_name; /* request */ | |
306 | u32 se_callback_prog; /* request */ | |
307 | u32 se_callback_netid_len; /* request */ | |
308 | char * se_callback_netid_val; /* request */ | |
309 | u32 se_callback_addr_len; /* request */ | |
310 | char * se_callback_addr_val; /* request */ | |
311 | u32 se_callback_ident; /* request */ | |
312 | clientid_t se_clientid; /* response */ | |
313 | nfs4_verifier se_confirm; /* response */ | |
314 | }; | |
315 | ||
316 | struct nfsd4_setclientid_confirm { | |
317 | clientid_t sc_clientid; | |
318 | nfs4_verifier sc_confirm; | |
319 | }; | |
320 | ||
321 | /* also used for NVERIFY */ | |
322 | struct nfsd4_verify { | |
323 | u32 ve_bmval[2]; /* request */ | |
324 | u32 ve_attrlen; /* request */ | |
325 | char * ve_attrval; /* request */ | |
326 | }; | |
327 | ||
328 | struct nfsd4_write { | |
329 | stateid_t wr_stateid; /* request */ | |
330 | u64 wr_offset; /* request */ | |
331 | u32 wr_stable_how; /* request */ | |
332 | u32 wr_buflen; /* request */ | |
1da177e4 LT |
333 | int wr_vlen; |
334 | ||
335 | u32 wr_bytes_written; /* response */ | |
336 | u32 wr_how_written; /* response */ | |
337 | nfs4_verifier wr_verifier; /* response */ | |
338 | }; | |
339 | ||
340 | struct nfsd4_op { | |
341 | int opnum; | |
b37ad28b | 342 | __be32 status; |
1da177e4 LT |
343 | union { |
344 | struct nfsd4_access access; | |
345 | struct nfsd4_close close; | |
346 | struct nfsd4_commit commit; | |
347 | struct nfsd4_create create; | |
348 | struct nfsd4_delegreturn delegreturn; | |
349 | struct nfsd4_getattr getattr; | |
350 | struct svc_fh * getfh; | |
351 | struct nfsd4_link link; | |
352 | struct nfsd4_lock lock; | |
353 | struct nfsd4_lockt lockt; | |
354 | struct nfsd4_locku locku; | |
355 | struct nfsd4_lookup lookup; | |
356 | struct nfsd4_verify nverify; | |
357 | struct nfsd4_open open; | |
358 | struct nfsd4_open_confirm open_confirm; | |
359 | struct nfsd4_open_downgrade open_downgrade; | |
360 | struct nfsd4_putfh putfh; | |
361 | struct nfsd4_read read; | |
362 | struct nfsd4_readdir readdir; | |
363 | struct nfsd4_readlink readlink; | |
364 | struct nfsd4_remove remove; | |
365 | struct nfsd4_rename rename; | |
366 | clientid_t renew; | |
367 | struct nfsd4_setattr setattr; | |
368 | struct nfsd4_setclientid setclientid; | |
369 | struct nfsd4_setclientid_confirm setclientid_confirm; | |
370 | struct nfsd4_verify verify; | |
371 | struct nfsd4_write write; | |
372 | struct nfsd4_release_lockowner release_lockowner; | |
373 | } u; | |
374 | struct nfs4_replay * replay; | |
375 | }; | |
376 | ||
377 | struct nfsd4_compoundargs { | |
378 | /* scratch variables for XDR decode */ | |
2ebbc012 AV |
379 | __be32 * p; |
380 | __be32 * end; | |
1da177e4 LT |
381 | struct page ** pagelist; |
382 | int pagelen; | |
2ebbc012 AV |
383 | __be32 tmp[8]; |
384 | __be32 * tmpp; | |
1da177e4 LT |
385 | struct tmpbuf { |
386 | struct tmpbuf *next; | |
387 | void (*release)(const void *); | |
388 | void *buf; | |
389 | } *to_free; | |
390 | ||
391 | struct svc_rqst *rqstp; | |
392 | ||
393 | u32 taglen; | |
394 | char * tag; | |
395 | u32 minorversion; | |
396 | u32 opcnt; | |
397 | struct nfsd4_op *ops; | |
398 | struct nfsd4_op iops[8]; | |
399 | }; | |
400 | ||
401 | struct nfsd4_compoundres { | |
402 | /* scratch variables for XDR encode */ | |
2ebbc012 AV |
403 | __be32 * p; |
404 | __be32 * end; | |
1da177e4 LT |
405 | struct xdr_buf * xbuf; |
406 | struct svc_rqst * rqstp; | |
407 | ||
408 | u32 taglen; | |
409 | char * tag; | |
410 | u32 opcnt; | |
2ebbc012 | 411 | __be32 * tagp; /* where to encode tag and opcount */ |
1da177e4 LT |
412 | }; |
413 | ||
414 | #define NFS4_SVC_XDRSIZE sizeof(struct nfsd4_compoundargs) | |
415 | ||
416 | static inline void | |
417 | set_change_info(struct nfsd4_change_info *cinfo, struct svc_fh *fhp) | |
418 | { | |
419 | BUG_ON(!fhp->fh_pre_saved || !fhp->fh_post_saved); | |
420 | cinfo->atomic = 1; | |
421 | cinfo->before_ctime_sec = fhp->fh_pre_ctime.tv_sec; | |
422 | cinfo->before_ctime_nsec = fhp->fh_pre_ctime.tv_nsec; | |
423 | cinfo->after_ctime_sec = fhp->fh_post_ctime.tv_sec; | |
424 | cinfo->after_ctime_nsec = fhp->fh_post_ctime.tv_nsec; | |
425 | } | |
426 | ||
2ebbc012 AV |
427 | int nfs4svc_encode_voidres(struct svc_rqst *, __be32 *, void *); |
428 | int nfs4svc_decode_compoundargs(struct svc_rqst *, __be32 *, | |
1da177e4 | 429 | struct nfsd4_compoundargs *); |
2ebbc012 | 430 | int nfs4svc_encode_compoundres(struct svc_rqst *, __be32 *, |
1da177e4 LT |
431 | struct nfsd4_compoundres *); |
432 | void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *); | |
433 | void nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op); | |
b37ad28b AV |
434 | __be32 nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp, |
435 | struct dentry *dentry, __be32 *buffer, int *countp, | |
1da177e4 | 436 | u32 *bmval, struct svc_rqst *); |
b37ad28b | 437 | extern __be32 nfsd4_setclientid(struct svc_rqst *rqstp, |
1da177e4 | 438 | struct nfsd4_setclientid *setclid); |
b37ad28b | 439 | extern __be32 nfsd4_setclientid_confirm(struct svc_rqst *rqstp, |
1da177e4 | 440 | struct nfsd4_setclientid_confirm *setclientid_confirm); |
b37ad28b AV |
441 | extern __be32 nfsd4_process_open1(struct nfsd4_open *open); |
442 | extern __be32 nfsd4_process_open2(struct svc_rqst *rqstp, | |
1da177e4 | 443 | struct svc_fh *current_fh, struct nfsd4_open *open); |
b37ad28b | 444 | extern __be32 nfsd4_open_confirm(struct svc_rqst *rqstp, |
ca364317 | 445 | struct nfsd4_compound_state *, struct nfsd4_open_confirm *oc, |
f2327d9a | 446 | struct nfs4_stateowner **); |
ca364317 BF |
447 | extern __be32 nfsd4_close(struct svc_rqst *rqstp, |
448 | struct nfsd4_compound_state *, | |
f2327d9a NB |
449 | struct nfsd4_close *close, |
450 | struct nfs4_stateowner **replay_owner); | |
b37ad28b | 451 | extern __be32 nfsd4_open_downgrade(struct svc_rqst *rqstp, |
ca364317 | 452 | struct nfsd4_compound_state *, struct nfsd4_open_downgrade *od, |
f2327d9a | 453 | struct nfs4_stateowner **replay_owner); |
ca364317 | 454 | extern __be32 nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *, |
f2327d9a NB |
455 | struct nfsd4_lock *lock, |
456 | struct nfs4_stateowner **replay_owner); | |
ca364317 BF |
457 | extern __be32 nfsd4_lockt(struct svc_rqst *rqstp, |
458 | struct nfsd4_compound_state *, | |
1da177e4 | 459 | struct nfsd4_lockt *lockt); |
ca364317 BF |
460 | extern __be32 nfsd4_locku(struct svc_rqst *rqstp, |
461 | struct nfsd4_compound_state *, | |
f2327d9a NB |
462 | struct nfsd4_locku *locku, |
463 | struct nfs4_stateowner **replay_owner); | |
b37ad28b | 464 | extern __be32 |
1da177e4 LT |
465 | nfsd4_release_lockowner(struct svc_rqst *rqstp, |
466 | struct nfsd4_release_lockowner *rlockowner); | |
467 | extern void nfsd4_release_compoundargs(struct nfsd4_compoundargs *); | |
b37ad28b | 468 | extern __be32 nfsd4_delegreturn(struct svc_rqst *rqstp, |
ca364317 | 469 | struct nfsd4_compound_state *, struct nfsd4_delegreturn *dr); |
1da177e4 LT |
470 | #endif |
471 | ||
472 | /* | |
473 | * Local variables: | |
474 | * c-basic-offset: 8 | |
475 | * End: | |
476 | */ |