2 * include/linux/nfsd/xdr4.h
4 * Server-side types for NFSv4.
6 * Copyright (c) 2002 The Regents of the University of Michigan.
9 * Kendrick Smith <kmsmith@umich.edu>
10 * Andy Adamson <andros@umich.edu>
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
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.
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.
39 #ifndef _LINUX_NFSD_XDR4_H
40 #define _LINUX_NFSD_XDR4_H
42 #include <linux/nfs4.h>
44 #define NFSD4_MAX_TAGLEN 128
45 #define XDR_LEN(n) (((n) + 3) & ~3)
47 struct nfsd4_compound_state {
48 struct svc_fh current_fh;
49 struct svc_fh save_fh;
50 struct nfs4_stateowner *replay_owner;
51 /* For sessions DRC */
52 struct nfsd4_session *session;
53 struct nfsd4_slot *slot;
56 struct nfsd4_change_info {
59 u32 before_ctime_nsec;
65 u32 ac_req_access; /* request */
66 u32 ac_supported; /* response */
67 u32 ac_resp_access; /* response */
71 u32 cl_seqid; /* request */
72 stateid_t cl_stateid; /* request+response */
73 struct nfs4_stateowner * cl_stateowner; /* response */
77 u64 co_offset; /* request */
78 u32 co_count; /* request */
79 nfs4_verifier co_verf; /* response */
83 u32 cr_namelen; /* request */
84 char * cr_name; /* request */
85 u32 cr_type; /* request */
94 } dev; /* NF4BLK, NF4CHR */
96 u32 cr_bmval[2]; /* request */
97 struct iattr cr_iattr; /* request */
98 struct nfsd4_change_info cr_cinfo; /* response */
99 struct nfs4_acl *cr_acl;
101 #define cr_linklen u.link.namelen
102 #define cr_linkname u.link.name
103 #define cr_specdata1 u.dev.specdata1
104 #define cr_specdata2 u.dev.specdata2
106 struct nfsd4_delegreturn {
107 stateid_t dr_stateid;
110 struct nfsd4_getattr {
111 u32 ga_bmval[2]; /* request */
112 struct svc_fh *ga_fhp; /* response */
116 u32 li_namelen; /* request */
117 char * li_name; /* request */
118 struct nfsd4_change_info li_cinfo; /* response */
121 struct nfsd4_lock_denied {
122 clientid_t ld_clientid;
123 struct nfs4_stateowner *ld_sop;
132 u32 lk_reclaim; /* boolean */
139 stateid_t open_stateid;
142 struct xdr_netobj owner;
145 stateid_t lock_stateid;
155 struct nfsd4_lock_denied denied;
157 /* The lk_replay_owner is the open owner in the open_to_lock_owner
158 * case and the lock owner otherwise: */
159 struct nfs4_stateowner *lk_replay_owner;
161 #define lk_new_open_seqid v.new.open_seqid
162 #define lk_new_open_stateid v.new.open_stateid
163 #define lk_new_lock_seqid v.new.lock_seqid
164 #define lk_new_clientid v.new.clientid
165 #define lk_new_owner v.new.owner
166 #define lk_old_lock_stateid v.old.lock_stateid
167 #define lk_old_lock_seqid v.old.lock_seqid
169 #define lk_rflags u.ok.rflags
170 #define lk_resp_stateid u.ok.stateid
171 #define lk_denied u.denied
176 clientid_t lt_clientid;
177 struct xdr_netobj lt_owner;
180 struct nfs4_stateowner * lt_stateowner;
181 struct nfsd4_lock_denied lt_denied;
188 stateid_t lu_stateid;
191 struct nfs4_stateowner *lu_stateowner;
195 struct nfsd4_lookup {
196 u32 lo_len; /* request */
197 char * lo_name; /* request */
201 u32 pf_fhlen; /* request */
202 char *pf_fhval; /* request */
206 u32 op_claim_type; /* request */
207 struct xdr_netobj op_fname; /* request - everything but CLAIM_PREV */
208 u32 op_delegate_type; /* request - CLAIM_PREV only */
209 stateid_t op_delegate_stateid; /* request - response */
210 u32 op_create; /* request */
211 u32 op_createmode; /* request */
212 u32 op_bmval[2]; /* request */
213 union { /* request */
214 struct iattr iattr; /* UNCHECKED4,GUARDED4 */
215 nfs4_verifier verf; /* EXCLUSIVE4 */
217 clientid_t op_clientid; /* request */
218 struct xdr_netobj op_owner; /* request */
219 u32 op_seqid; /* request */
220 u32 op_share_access; /* request */
221 u32 op_share_deny; /* request */
222 stateid_t op_stateid; /* response */
223 u32 op_recall; /* recall */
224 struct nfsd4_change_info op_cinfo; /* response */
225 u32 op_rflags; /* response */
226 int op_truncate; /* used during processing */
227 struct nfs4_stateowner *op_stateowner; /* used during processing */
228 struct nfs4_acl *op_acl;
230 #define op_iattr u.iattr
231 #define op_verf u.verf
233 struct nfsd4_open_confirm {
234 stateid_t oc_req_stateid /* request */;
235 u32 oc_seqid /* request */;
236 stateid_t oc_resp_stateid /* response */;
237 struct nfs4_stateowner * oc_stateowner; /* response */
240 struct nfsd4_open_downgrade {
241 stateid_t od_stateid;
245 struct nfs4_stateowner *od_stateowner;
250 stateid_t rd_stateid; /* request */
251 u64 rd_offset; /* request */
252 u32 rd_length; /* request */
254 struct file *rd_filp;
256 struct svc_rqst *rd_rqstp; /* response */
257 struct svc_fh * rd_fhp; /* response */
260 struct nfsd4_readdir {
261 u64 rd_cookie; /* request */
262 nfs4_verifier rd_verf; /* request */
263 u32 rd_dircount; /* request */
264 u32 rd_maxcount; /* request */
265 u32 rd_bmval[2]; /* request */
266 struct svc_rqst *rd_rqstp; /* response */
267 struct svc_fh * rd_fhp; /* response */
269 struct readdir_cd common;
275 struct nfsd4_release_lockowner {
276 clientid_t rl_clientid;
277 struct xdr_netobj rl_owner;
279 struct nfsd4_readlink {
280 struct svc_rqst *rl_rqstp; /* request */
281 struct svc_fh * rl_fhp; /* request */
284 struct nfsd4_remove {
285 u32 rm_namelen; /* request */
286 char * rm_name; /* request */
287 struct nfsd4_change_info rm_cinfo; /* response */
290 struct nfsd4_rename {
291 u32 rn_snamelen; /* request */
292 char * rn_sname; /* request */
293 u32 rn_tnamelen; /* request */
294 char * rn_tname; /* request */
295 struct nfsd4_change_info rn_sinfo; /* response */
296 struct nfsd4_change_info rn_tinfo; /* response */
299 struct nfsd4_secinfo {
300 u32 si_namelen; /* request */
301 char *si_name; /* request */
302 struct svc_export *si_exp; /* response */
305 struct nfsd4_setattr {
306 stateid_t sa_stateid; /* request */
307 u32 sa_bmval[2]; /* request */
308 struct iattr sa_iattr; /* request */
309 struct nfs4_acl *sa_acl;
312 struct nfsd4_setclientid {
313 nfs4_verifier se_verf; /* request */
314 u32 se_namelen; /* request */
315 char * se_name; /* request */
316 u32 se_callback_prog; /* request */
317 u32 se_callback_netid_len; /* request */
318 char * se_callback_netid_val; /* request */
319 u32 se_callback_addr_len; /* request */
320 char * se_callback_addr_val; /* request */
321 u32 se_callback_ident; /* request */
322 clientid_t se_clientid; /* response */
323 nfs4_verifier se_confirm; /* response */
326 struct nfsd4_setclientid_confirm {
327 clientid_t sc_clientid;
328 nfs4_verifier sc_confirm;
331 /* also used for NVERIFY */
332 struct nfsd4_verify {
333 u32 ve_bmval[2]; /* request */
334 u32 ve_attrlen; /* request */
335 char * ve_attrval; /* request */
339 stateid_t wr_stateid; /* request */
340 u64 wr_offset; /* request */
341 u32 wr_stable_how; /* request */
342 u32 wr_buflen; /* request */
345 u32 wr_bytes_written; /* response */
346 u32 wr_how_written; /* response */
347 nfs4_verifier wr_verifier; /* response */
350 struct nfsd4_exchange_id {
351 nfs4_verifier verifier;
352 struct xdr_netobj clname;
359 struct nfsd4_create_session {
363 struct nfsd4_sequence {
364 struct nfs4_sessionid sessionid; /* request/response */
365 u32 seqid; /* request/response */
366 u32 slotid; /* request/response */
367 u32 maxslots; /* request/response */
368 u32 cachethis; /* request */
370 u32 target_maxslots; /* response */
371 u32 status_flags; /* response */
375 struct nfsd4_destroy_session {
383 struct nfsd4_access access;
384 struct nfsd4_close close;
385 struct nfsd4_commit commit;
386 struct nfsd4_create create;
387 struct nfsd4_delegreturn delegreturn;
388 struct nfsd4_getattr getattr;
389 struct svc_fh * getfh;
390 struct nfsd4_link link;
391 struct nfsd4_lock lock;
392 struct nfsd4_lockt lockt;
393 struct nfsd4_locku locku;
394 struct nfsd4_lookup lookup;
395 struct nfsd4_verify nverify;
396 struct nfsd4_open open;
397 struct nfsd4_open_confirm open_confirm;
398 struct nfsd4_open_downgrade open_downgrade;
399 struct nfsd4_putfh putfh;
400 struct nfsd4_read read;
401 struct nfsd4_readdir readdir;
402 struct nfsd4_readlink readlink;
403 struct nfsd4_remove remove;
404 struct nfsd4_rename rename;
406 struct nfsd4_secinfo secinfo;
407 struct nfsd4_setattr setattr;
408 struct nfsd4_setclientid setclientid;
409 struct nfsd4_setclientid_confirm setclientid_confirm;
410 struct nfsd4_verify verify;
411 struct nfsd4_write write;
412 struct nfsd4_release_lockowner release_lockowner;
415 struct nfsd4_exchange_id exchange_id;
416 struct nfsd4_create_session create_session;
417 struct nfsd4_destroy_session destroy_session;
418 struct nfsd4_sequence sequence;
420 struct nfs4_replay * replay;
423 struct nfsd4_compoundargs {
424 /* scratch variables for XDR decode */
427 struct page ** pagelist;
433 void (*release)(const void *);
437 struct svc_rqst *rqstp;
443 struct nfsd4_op *ops;
444 struct nfsd4_op iops[8];
447 struct nfsd4_compoundres {
448 /* scratch variables for XDR encode */
451 struct xdr_buf * xbuf;
452 struct svc_rqst * rqstp;
457 __be32 * tagp; /* tag, opcount encode location */
458 struct nfsd4_compound_state cstate;
461 #define NFS4_SVC_XDRSIZE sizeof(struct nfsd4_compoundargs)
464 set_change_info(struct nfsd4_change_info *cinfo, struct svc_fh *fhp)
466 BUG_ON(!fhp->fh_pre_saved || !fhp->fh_post_saved);
468 cinfo->before_ctime_sec = fhp->fh_pre_ctime.tv_sec;
469 cinfo->before_ctime_nsec = fhp->fh_pre_ctime.tv_nsec;
470 cinfo->after_ctime_sec = fhp->fh_post_attr.ctime.tv_sec;
471 cinfo->after_ctime_nsec = fhp->fh_post_attr.ctime.tv_nsec;
474 int nfs4svc_encode_voidres(struct svc_rqst *, __be32 *, void *);
475 int nfs4svc_decode_compoundargs(struct svc_rqst *, __be32 *,
476 struct nfsd4_compoundargs *);
477 int nfs4svc_encode_compoundres(struct svc_rqst *, __be32 *,
478 struct nfsd4_compoundres *);
479 void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *);
480 void nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op);
481 __be32 nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
482 struct dentry *dentry, __be32 *buffer, int *countp,
483 u32 *bmval, struct svc_rqst *, int ignore_crossmnt);
484 extern __be32 nfsd4_setclientid(struct svc_rqst *rqstp,
485 struct nfsd4_compound_state *,
486 struct nfsd4_setclientid *setclid);
487 extern __be32 nfsd4_setclientid_confirm(struct svc_rqst *rqstp,
488 struct nfsd4_compound_state *,
489 struct nfsd4_setclientid_confirm *setclientid_confirm);
490 extern __be32 nfsd4_exchange_id(struct svc_rqst *rqstp,
491 struct nfsd4_compound_state *,
492 struct nfsd4_exchange_id *);
493 extern __be32 nfsd4_create_session(struct svc_rqst *,
494 struct nfsd4_compound_state *,
495 struct nfsd4_create_session *);
496 extern __be32 nfsd4_sequence(struct svc_rqst *,
497 struct nfsd4_compound_state *,
498 struct nfsd4_sequence *);
499 extern __be32 nfsd4_destroy_session(struct svc_rqst *,
500 struct nfsd4_compound_state *,
501 struct nfsd4_destroy_session *);
502 extern __be32 nfsd4_process_open1(struct nfsd4_open *open);
503 extern __be32 nfsd4_process_open2(struct svc_rqst *rqstp,
504 struct svc_fh *current_fh, struct nfsd4_open *open);
505 extern __be32 nfsd4_open_confirm(struct svc_rqst *rqstp,
506 struct nfsd4_compound_state *, struct nfsd4_open_confirm *oc);
507 extern __be32 nfsd4_close(struct svc_rqst *rqstp,
508 struct nfsd4_compound_state *,
509 struct nfsd4_close *close);
510 extern __be32 nfsd4_open_downgrade(struct svc_rqst *rqstp,
511 struct nfsd4_compound_state *,
512 struct nfsd4_open_downgrade *od);
513 extern __be32 nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *,
514 struct nfsd4_lock *lock);
515 extern __be32 nfsd4_lockt(struct svc_rqst *rqstp,
516 struct nfsd4_compound_state *,
517 struct nfsd4_lockt *lockt);
518 extern __be32 nfsd4_locku(struct svc_rqst *rqstp,
519 struct nfsd4_compound_state *,
520 struct nfsd4_locku *locku);
522 nfsd4_release_lockowner(struct svc_rqst *rqstp,
523 struct nfsd4_compound_state *,
524 struct nfsd4_release_lockowner *rlockowner);
525 extern void nfsd4_release_compoundargs(struct nfsd4_compoundargs *);
526 extern __be32 nfsd4_delegreturn(struct svc_rqst *rqstp,
527 struct nfsd4_compound_state *, struct nfsd4_delegreturn *dr);
528 extern __be32 nfsd4_renew(struct svc_rqst *rqstp,
529 struct nfsd4_compound_state *, clientid_t *clid);