Rev 423 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
423 | giacomo | 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 | #define NFSD4_MAX_TAGLEN 128 |
||
43 | #define XDR_LEN(n) (((n) + 3) & ~3) |
||
44 | |||
45 | typedef u32 delegation_zero_t; |
||
46 | typedef u32 delegation_boot_t; |
||
47 | typedef u64 delegation_id_t; |
||
48 | |||
49 | typedef struct { |
||
50 | delegation_zero_t ds_zero; |
||
51 | delegation_boot_t ds_boot; |
||
52 | delegation_id_t ds_id; |
||
53 | } delegation_stateid_t; |
||
54 | |||
55 | struct nfsd4_change_info { |
||
56 | u32 atomic; |
||
57 | u32 before_size; |
||
58 | u32 before_ctime; |
||
59 | u32 after_size; |
||
60 | u32 after_ctime; |
||
61 | }; |
||
62 | |||
63 | struct nfsd4_access { |
||
64 | u32 ac_req_access; /* request */ |
||
65 | u32 ac_supported; /* response */ |
||
66 | u32 ac_resp_access; /* response */ |
||
67 | }; |
||
68 | |||
69 | struct nfsd4_close { |
||
70 | u32 cl_seqid; /* request */ |
||
71 | stateid_t cl_stateid; /* request+response */ |
||
72 | struct nfs4_stateowner * cl_stateowner; /* response */ |
||
73 | }; |
||
74 | |||
75 | struct nfsd4_commit { |
||
76 | u64 co_offset; /* request */ |
||
77 | u32 co_count; /* request */ |
||
78 | nfs4_verifier co_verf; /* response */ |
||
79 | }; |
||
80 | |||
81 | struct nfsd4_create { |
||
82 | u32 cr_namelen; /* request */ |
||
83 | char * cr_name; /* request */ |
||
84 | u32 cr_type; /* request */ |
||
85 | union { /* request */ |
||
86 | struct { |
||
87 | u32 namelen; |
||
88 | char *name; |
||
89 | } link; /* NF4LNK */ |
||
90 | struct { |
||
91 | u32 specdata1; |
||
92 | u32 specdata2; |
||
93 | } dev; /* NF4BLK, NF4CHR */ |
||
94 | } u; |
||
95 | u32 cr_bmval[2]; /* request */ |
||
96 | struct iattr cr_iattr; /* request */ |
||
97 | struct nfsd4_change_info cr_cinfo; /* response */ |
||
98 | }; |
||
99 | #define cr_linklen u.link.namelen |
||
100 | #define cr_linkname u.link.name |
||
101 | #define cr_specdata1 u.dev.specdata1 |
||
102 | #define cr_specdata2 u.dev.specdata2 |
||
103 | |||
104 | struct nfsd4_getattr { |
||
105 | u32 ga_bmval[2]; /* request */ |
||
106 | struct svc_fh *ga_fhp; /* response */ |
||
107 | }; |
||
108 | |||
109 | struct nfsd4_link { |
||
110 | u32 li_namelen; /* request */ |
||
111 | char * li_name; /* request */ |
||
112 | struct nfsd4_change_info li_cinfo; /* response */ |
||
113 | }; |
||
114 | |||
115 | struct nfsd4_lock_denied { |
||
116 | struct nfs4_stateowner *ld_sop; |
||
117 | u64 ld_start; |
||
118 | u64 ld_length; |
||
119 | u32 ld_type; |
||
120 | }; |
||
121 | |||
122 | struct nfsd4_lock { |
||
123 | /* request */ |
||
124 | u32 lk_type; |
||
125 | u32 lk_reclaim; /* boolean */ |
||
126 | u64 lk_offset; |
||
127 | u64 lk_length; |
||
128 | u32 lk_is_new; |
||
129 | union { |
||
130 | struct { |
||
131 | u32 open_seqid; |
||
132 | stateid_t open_stateid; |
||
133 | u32 lock_seqid; |
||
134 | clientid_t clientid; |
||
135 | struct xdr_netobj owner; |
||
136 | } new; |
||
137 | struct { |
||
138 | stateid_t lock_stateid; |
||
139 | u32 lock_seqid; |
||
140 | } old; |
||
141 | } v; |
||
142 | |||
143 | /* response */ |
||
144 | union { |
||
145 | struct { |
||
146 | stateid_t stateid; |
||
147 | } ok; |
||
148 | struct nfsd4_lock_denied denied; |
||
149 | } u; |
||
150 | |||
151 | struct nfs4_stateowner *lk_stateowner; |
||
152 | }; |
||
153 | #define lk_new_open_seqid v.new.open_seqid |
||
154 | #define lk_new_open_stateid v.new.open_stateid |
||
155 | #define lk_new_lock_seqid v.new.lock_seqid |
||
156 | #define lk_new_clientid v.new.clientid |
||
157 | #define lk_new_owner v.new.owner |
||
158 | #define lk_old_lock_stateid v.old.lock_stateid |
||
159 | #define lk_old_lock_seqid v.old.lock_seqid |
||
160 | |||
161 | #define lk_rflags u.ok.rflags |
||
162 | #define lk_resp_stateid u.ok.stateid |
||
163 | #define lk_denied u.denied |
||
164 | |||
165 | |||
166 | struct nfsd4_lockt { |
||
167 | u32 lt_type; |
||
168 | clientid_t lt_clientid; |
||
169 | struct xdr_netobj lt_owner; |
||
170 | u64 lt_offset; |
||
171 | u64 lt_length; |
||
172 | struct nfs4_stateowner * lt_stateowner; |
||
173 | struct nfsd4_lock_denied lt_denied; |
||
174 | }; |
||
175 | |||
176 | |||
177 | struct nfsd4_locku { |
||
178 | u32 lu_type; |
||
179 | u32 lu_seqid; |
||
180 | stateid_t lu_stateid; |
||
181 | u64 lu_offset; |
||
182 | u64 lu_length; |
||
183 | struct nfs4_stateowner *lu_stateowner; |
||
184 | }; |
||
185 | |||
186 | |||
187 | struct nfsd4_lookup { |
||
188 | u32 lo_len; /* request */ |
||
189 | char * lo_name; /* request */ |
||
190 | }; |
||
191 | |||
192 | struct nfsd4_putfh { |
||
193 | u32 pf_fhlen; /* request */ |
||
194 | char *pf_fhval; /* request */ |
||
195 | }; |
||
196 | |||
197 | struct nfsd4_open { |
||
198 | u32 op_claim_type; /* request */ |
||
199 | struct xdr_netobj op_fname; /* request - everything but CLAIM_PREV */ |
||
200 | u32 op_delegate_type; /* request - CLAIM_PREV only */ |
||
201 | delegation_stateid_t op_delegate_stateid; /* request - CLAIM_DELEGATE_CUR only */ |
||
202 | u32 op_create; /* request */ |
||
203 | u32 op_createmode; /* request */ |
||
204 | u32 op_bmval[2]; /* request */ |
||
205 | union { /* request */ |
||
206 | struct iattr iattr; /* UNCHECKED4,GUARDED4 */ |
||
207 | nfs4_verifier verf; /* EXCLUSIVE4 */ |
||
208 | } u; |
||
209 | clientid_t op_clientid; /* request */ |
||
210 | struct xdr_netobj op_owner; /* request */ |
||
211 | u32 op_seqid; /* request */ |
||
212 | u32 op_share_access; /* request */ |
||
213 | u32 op_share_deny; /* request */ |
||
214 | stateid_t op_stateid; /* response */ |
||
215 | struct nfsd4_change_info op_cinfo; /* response */ |
||
216 | u32 op_rflags; /* response */ |
||
217 | int op_truncate; /* used during processing */ |
||
218 | struct nfs4_stateowner *op_stateowner; /* used during processing */ |
||
219 | |||
220 | }; |
||
221 | #define op_iattr u.iattr |
||
222 | #define op_verf u.verf |
||
223 | |||
224 | struct nfsd4_open_confirm { |
||
225 | stateid_t oc_req_stateid /* request */; |
||
226 | u32 oc_seqid /* request */; |
||
227 | stateid_t oc_resp_stateid /* response */; |
||
228 | struct nfs4_stateowner * oc_stateowner; /* response */ |
||
229 | }; |
||
230 | |||
231 | struct nfsd4_open_downgrade { |
||
232 | stateid_t od_stateid; |
||
233 | u32 od_seqid; |
||
234 | u32 od_share_access; |
||
235 | u32 od_share_deny; |
||
236 | struct nfs4_stateowner *od_stateowner; |
||
237 | }; |
||
238 | |||
239 | |||
240 | struct nfsd4_read { |
||
241 | stateid_t rd_stateid; /* request */ |
||
242 | u64 rd_offset; /* request */ |
||
243 | u32 rd_length; /* request */ |
||
244 | struct iovec rd_iov[RPCSVC_MAXPAGES]; |
||
245 | int rd_vlen; |
||
246 | |||
247 | struct svc_rqst *rd_rqstp; /* response */ |
||
248 | struct svc_fh * rd_fhp; /* response */ |
||
249 | }; |
||
250 | |||
251 | struct nfsd4_readdir { |
||
252 | u64 rd_cookie; /* request */ |
||
253 | nfs4_verifier rd_verf; /* request */ |
||
254 | u32 rd_dircount; /* request */ |
||
255 | u32 rd_maxcount; /* request */ |
||
256 | u32 rd_bmval[2]; /* request */ |
||
257 | struct svc_rqst *rd_rqstp; /* response */ |
||
258 | struct svc_fh * rd_fhp; /* response */ |
||
259 | |||
260 | struct readdir_cd common; |
||
261 | u32 * buffer; |
||
262 | int buflen; |
||
263 | u32 * offset; |
||
264 | }; |
||
265 | |||
266 | struct nfsd4_readlink { |
||
267 | struct svc_rqst *rl_rqstp; /* request */ |
||
268 | struct svc_fh * rl_fhp; /* request */ |
||
269 | }; |
||
270 | |||
271 | struct nfsd4_remove { |
||
272 | u32 rm_namelen; /* request */ |
||
273 | char * rm_name; /* request */ |
||
274 | struct nfsd4_change_info rm_cinfo; /* response */ |
||
275 | }; |
||
276 | |||
277 | struct nfsd4_rename { |
||
278 | u32 rn_snamelen; /* request */ |
||
279 | char * rn_sname; /* request */ |
||
280 | u32 rn_tnamelen; /* request */ |
||
281 | char * rn_tname; /* request */ |
||
282 | struct nfsd4_change_info rn_sinfo; /* response */ |
||
283 | struct nfsd4_change_info rn_tinfo; /* response */ |
||
284 | }; |
||
285 | |||
286 | struct nfsd4_setattr { |
||
287 | stateid_t sa_stateid; /* request */ |
||
288 | u32 sa_bmval[2]; /* request */ |
||
289 | struct iattr sa_iattr; /* request */ |
||
290 | }; |
||
291 | |||
292 | struct nfsd4_setclientid { |
||
293 | nfs4_verifier se_verf; /* request */ |
||
294 | u32 se_namelen; /* request */ |
||
295 | char * se_name; /* request */ |
||
296 | u32 se_callback_prog; /* request */ |
||
297 | u32 se_callback_netid_len; /* request */ |
||
298 | char * se_callback_netid_val; /* request */ |
||
299 | u32 se_callback_addr_len; /* request */ |
||
300 | char * se_callback_addr_val; /* request */ |
||
301 | u32 se_callback_ident; /* request */ |
||
302 | clientid_t se_clientid; /* response */ |
||
303 | nfs4_verifier se_confirm; /* response */ |
||
304 | }; |
||
305 | |||
306 | struct nfsd4_setclientid_confirm { |
||
307 | clientid_t sc_clientid; |
||
308 | nfs4_verifier sc_confirm; |
||
309 | }; |
||
310 | |||
311 | /* also used for NVERIFY */ |
||
312 | struct nfsd4_verify { |
||
313 | u32 ve_bmval[2]; /* request */ |
||
314 | u32 ve_attrlen; /* request */ |
||
315 | char * ve_attrval; /* request */ |
||
316 | }; |
||
317 | |||
318 | struct nfsd4_write { |
||
319 | stateid_t wr_stateid; /* request */ |
||
320 | u64 wr_offset; /* request */ |
||
321 | u32 wr_stable_how; /* request */ |
||
322 | u32 wr_buflen; /* request */ |
||
323 | struct iovec wr_vec[RPCSVC_MAXPAGES]; /* request */ |
||
324 | int wr_vlen; |
||
325 | |||
326 | u32 wr_bytes_written; /* response */ |
||
327 | u32 wr_how_written; /* response */ |
||
328 | nfs4_verifier wr_verifier; /* response */ |
||
329 | }; |
||
330 | |||
331 | struct nfsd4_op { |
||
332 | int opnum; |
||
333 | int status; |
||
334 | union { |
||
335 | struct nfsd4_access access; |
||
336 | struct nfsd4_close close; |
||
337 | struct nfsd4_commit commit; |
||
338 | struct nfsd4_create create; |
||
339 | struct nfsd4_getattr getattr; |
||
340 | struct svc_fh * getfh; |
||
341 | struct nfsd4_link link; |
||
342 | struct nfsd4_lock lock; |
||
343 | struct nfsd4_lockt lockt; |
||
344 | struct nfsd4_locku locku; |
||
345 | struct nfsd4_lookup lookup; |
||
346 | struct nfsd4_verify nverify; |
||
347 | struct nfsd4_open open; |
||
348 | struct nfsd4_open_confirm open_confirm; |
||
349 | struct nfsd4_open_downgrade open_downgrade; |
||
350 | struct nfsd4_putfh putfh; |
||
351 | struct nfsd4_read read; |
||
352 | struct nfsd4_readdir readdir; |
||
353 | struct nfsd4_readlink readlink; |
||
354 | struct nfsd4_remove remove; |
||
355 | struct nfsd4_rename rename; |
||
356 | clientid_t renew; |
||
357 | struct nfsd4_setattr setattr; |
||
358 | struct nfsd4_setclientid setclientid; |
||
359 | struct nfsd4_setclientid_confirm setclientid_confirm; |
||
360 | struct nfsd4_verify verify; |
||
361 | struct nfsd4_write write; |
||
362 | } u; |
||
363 | struct nfs4_replay * replay; |
||
364 | }; |
||
365 | |||
366 | struct nfsd4_compoundargs { |
||
367 | /* scratch variables for XDR decode */ |
||
368 | u32 * p; |
||
369 | u32 * end; |
||
370 | struct page ** pagelist; |
||
371 | int pagelen; |
||
372 | u32 tmp[8]; |
||
373 | u32 * tmpp; |
||
374 | struct tmpbuf { |
||
375 | struct tmpbuf *next; |
||
376 | void *buf; |
||
377 | } *to_free; |
||
378 | |||
379 | u32 taglen; |
||
380 | char * tag; |
||
381 | u32 minorversion; |
||
382 | u32 opcnt; |
||
383 | struct nfsd4_op *ops; |
||
384 | struct nfsd4_op iops[8]; |
||
385 | }; |
||
386 | |||
387 | struct nfsd4_compoundres { |
||
388 | /* scratch variables for XDR encode */ |
||
389 | u32 * p; |
||
390 | u32 * end; |
||
391 | struct xdr_buf * xbuf; |
||
392 | struct svc_rqst * rqstp; |
||
393 | |||
394 | u32 taglen; |
||
395 | char * tag; |
||
396 | u32 opcnt; |
||
397 | u32 * tagp; /* where to encode tag and opcount */ |
||
398 | }; |
||
399 | |||
400 | #define NFS4_SVC_XDRSIZE sizeof(struct nfsd4_compoundargs) |
||
401 | |||
402 | static inline void |
||
403 | set_change_info(struct nfsd4_change_info *cinfo, struct svc_fh *fhp) |
||
404 | { |
||
405 | BUG_ON(!fhp->fh_pre_saved || !fhp->fh_post_saved); |
||
406 | cinfo->atomic = 1; |
||
407 | cinfo->before_size = fhp->fh_pre_size; |
||
408 | cinfo->before_ctime = fhp->fh_pre_ctime.tv_sec; |
||
409 | cinfo->after_size = fhp->fh_post_size; |
||
410 | cinfo->after_ctime = fhp->fh_post_ctime.tv_sec; |
||
411 | } |
||
412 | |||
413 | int nfs4svc_encode_voidres(struct svc_rqst *, u32 *, void *); |
||
414 | int nfs4svc_decode_compoundargs(struct svc_rqst *, u32 *, |
||
415 | struct nfsd4_compoundargs *); |
||
416 | int nfs4svc_encode_compoundres(struct svc_rqst *, u32 *, |
||
417 | struct nfsd4_compoundres *); |
||
418 | void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *); |
||
419 | void nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op); |
||
420 | int nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp, |
||
421 | struct dentry *dentry, u32 *buffer, int *countp, |
||
422 | u32 *bmval); |
||
423 | extern int nfsd4_setclientid(struct svc_rqst *rqstp, |
||
424 | struct nfsd4_setclientid *setclid); |
||
425 | extern int nfsd4_setclientid_confirm(struct svc_rqst *rqstp, |
||
426 | struct nfsd4_setclientid_confirm *setclientid_confirm); |
||
427 | extern int nfsd4_process_open1(struct nfsd4_open *open); |
||
428 | extern int nfsd4_process_open2(struct svc_rqst *rqstp, |
||
429 | struct svc_fh *current_fh, struct nfsd4_open *open); |
||
430 | extern int nfsd4_open_confirm(struct svc_rqst *rqstp, |
||
431 | struct svc_fh *current_fh, struct nfsd4_open_confirm *oc); |
||
432 | extern int nfsd4_close(struct svc_rqst *rqstp, struct svc_fh *current_fh, |
||
433 | struct nfsd4_close *close); |
||
434 | extern int nfsd4_open_downgrade(struct svc_rqst *rqstp, |
||
435 | struct svc_fh *current_fh, struct nfsd4_open_downgrade *od); |
||
436 | extern int nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh, |
||
437 | struct nfsd4_lock *lock); |
||
438 | extern int nfsd4_lockt(struct svc_rqst *rqstp, struct svc_fh *current_fh, |
||
439 | struct nfsd4_lockt *lockt); |
||
440 | extern int nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh, |
||
441 | struct nfsd4_locku *locku); |
||
442 | #endif |
||
443 | |||
444 | /* |
||
445 | * Local variables: |
||
446 | * c-basic-offset: 8 |
||
447 | * End: |
||
448 | */ |