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 typedef u32 delegation_zero_t;
48 typedef u32 delegation_boot_t;
49 typedef u64 delegation_id_t;
52 delegation_zero_t ds_zero;
53 delegation_boot_t ds_boot;
54 delegation_id_t ds_id;
55 } delegation_stateid_t;
57 struct nfsd4_change_info {
60 u32 before_ctime_nsec;
66 u32 ac_req_access; /* request */
67 u32 ac_supported; /* response */
68 u32 ac_resp_access; /* response */
72 u32 cl_seqid; /* request */
73 stateid_t cl_stateid; /* request+response */
74 struct nfs4_stateowner * cl_stateowner; /* response */
78 u64 co_offset; /* request */
79 u32 co_count; /* request */
80 nfs4_verifier co_verf; /* response */
84 u32 cr_namelen; /* request */
85 char * cr_name; /* request */
86 u32 cr_type; /* request */
95 } dev; /* NF4BLK, NF4CHR */
97 u32 cr_bmval[2]; /* request */
98 struct iattr cr_iattr; /* request */
99 struct nfsd4_change_info cr_cinfo; /* response */
100 struct nfs4_acl *cr_acl;
102 #define cr_linklen u.link.namelen
103 #define cr_linkname u.link.name
104 #define cr_specdata1 u.dev.specdata1
105 #define cr_specdata2 u.dev.specdata2
107 struct nfsd4_getattr {
108 u32 ga_bmval[2]; /* request */
109 struct svc_fh *ga_fhp; /* response */
113 u32 li_namelen; /* request */
114 char * li_name; /* request */
115 struct nfsd4_change_info li_cinfo; /* response */
118 struct nfsd4_lock_denied {
119 clientid_t ld_clientid;
120 struct nfs4_stateowner *ld_sop;
129 u32 lk_reclaim; /* boolean */
136 stateid_t open_stateid;
139 struct xdr_netobj owner;
142 stateid_t lock_stateid;
152 struct nfsd4_lock_denied denied;
155 struct nfs4_stateowner *lk_stateowner;
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
165 #define lk_rflags u.ok.rflags
166 #define lk_resp_stateid u.ok.stateid
167 #define lk_denied u.denied
172 clientid_t lt_clientid;
173 struct xdr_netobj lt_owner;
176 struct nfs4_stateowner * lt_stateowner;
177 struct nfsd4_lock_denied lt_denied;
184 stateid_t lu_stateid;
187 struct nfs4_stateowner *lu_stateowner;
191 struct nfsd4_lookup {
192 u32 lo_len; /* request */
193 char * lo_name; /* request */
197 u32 pf_fhlen; /* request */
198 char *pf_fhval; /* request */
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 delegation_stateid_t op_delegate_stateid; /* request - CLAIM_DELEGATE_CUR only */
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 */
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 */
219 struct nfsd4_change_info op_cinfo; /* response */
220 u32 op_rflags; /* response */
221 int op_truncate; /* used during processing */
222 struct nfs4_stateowner *op_stateowner; /* used during processing */
223 struct nfs4_acl *op_acl;
225 #define op_iattr u.iattr
226 #define op_verf u.verf
228 struct nfsd4_open_confirm {
229 stateid_t oc_req_stateid /* request */;
230 u32 oc_seqid /* request */;
231 stateid_t oc_resp_stateid /* response */;
232 struct nfs4_stateowner * oc_stateowner; /* response */
235 struct nfsd4_open_downgrade {
236 stateid_t od_stateid;
240 struct nfs4_stateowner *od_stateowner;
245 stateid_t rd_stateid; /* request */
246 u64 rd_offset; /* request */
247 u32 rd_length; /* request */
248 struct kvec rd_iov[RPCSVC_MAXPAGES];
251 struct svc_rqst *rd_rqstp; /* response */
252 struct svc_fh * rd_fhp; /* response */
255 struct nfsd4_readdir {
256 u64 rd_cookie; /* request */
257 nfs4_verifier rd_verf; /* request */
258 u32 rd_dircount; /* request */
259 u32 rd_maxcount; /* request */
260 u32 rd_bmval[2]; /* request */
261 struct svc_rqst *rd_rqstp; /* response */
262 struct svc_fh * rd_fhp; /* response */
264 struct readdir_cd common;
270 struct nfsd4_release_lockowner {
271 clientid_t rl_clientid;
272 struct xdr_netobj rl_owner;
274 struct nfsd4_readlink {
275 struct svc_rqst *rl_rqstp; /* request */
276 struct svc_fh * rl_fhp; /* request */
279 struct nfsd4_remove {
280 u32 rm_namelen; /* request */
281 char * rm_name; /* request */
282 struct nfsd4_change_info rm_cinfo; /* response */
285 struct nfsd4_rename {
286 u32 rn_snamelen; /* request */
287 char * rn_sname; /* request */
288 u32 rn_tnamelen; /* request */
289 char * rn_tname; /* request */
290 struct nfsd4_change_info rn_sinfo; /* response */
291 struct nfsd4_change_info rn_tinfo; /* response */
294 struct nfsd4_setattr {
295 stateid_t sa_stateid; /* request */
296 u32 sa_bmval[2]; /* request */
297 struct iattr sa_iattr; /* request */
298 struct nfs4_acl *sa_acl;
301 struct nfsd4_setclientid {
302 nfs4_verifier se_verf; /* request */
303 u32 se_namelen; /* request */
304 char * se_name; /* request */
305 u32 se_callback_prog; /* request */
306 u32 se_callback_netid_len; /* request */
307 char * se_callback_netid_val; /* request */
308 u32 se_callback_addr_len; /* request */
309 char * se_callback_addr_val; /* request */
310 u32 se_callback_ident; /* request */
311 clientid_t se_clientid; /* response */
312 nfs4_verifier se_confirm; /* response */
315 struct nfsd4_setclientid_confirm {
316 clientid_t sc_clientid;
317 nfs4_verifier sc_confirm;
320 /* also used for NVERIFY */
321 struct nfsd4_verify {
322 u32 ve_bmval[2]; /* request */
323 u32 ve_attrlen; /* request */
324 char * ve_attrval; /* request */
328 stateid_t wr_stateid; /* request */
329 u64 wr_offset; /* request */
330 u32 wr_stable_how; /* request */
331 u32 wr_buflen; /* request */
332 struct kvec wr_vec[RPCSVC_MAXPAGES]; /* request */
335 u32 wr_bytes_written; /* response */
336 u32 wr_how_written; /* response */
337 nfs4_verifier wr_verifier; /* response */
344 struct nfsd4_access access;
345 struct nfsd4_close close;
346 struct nfsd4_commit commit;
347 struct nfsd4_create create;
348 struct nfsd4_getattr getattr;
349 struct svc_fh * getfh;
350 struct nfsd4_link link;
351 struct nfsd4_lock lock;
352 struct nfsd4_lockt lockt;
353 struct nfsd4_locku locku;
354 struct nfsd4_lookup lookup;
355 struct nfsd4_verify nverify;
356 struct nfsd4_open open;
357 struct nfsd4_open_confirm open_confirm;
358 struct nfsd4_open_downgrade open_downgrade;
359 struct nfsd4_putfh putfh;
360 struct nfsd4_read read;
361 struct nfsd4_readdir readdir;
362 struct nfsd4_readlink readlink;
363 struct nfsd4_remove remove;
364 struct nfsd4_rename rename;
366 struct nfsd4_setattr setattr;
367 struct nfsd4_setclientid setclientid;
368 struct nfsd4_setclientid_confirm setclientid_confirm;
369 struct nfsd4_verify verify;
370 struct nfsd4_write write;
371 struct nfsd4_release_lockowner release_lockowner;
373 struct nfs4_replay * replay;
376 struct nfsd4_compoundargs {
377 /* scratch variables for XDR decode */
380 struct page ** pagelist;
386 void (*release)(const void *);
390 struct svc_rqst *rqstp;
396 struct nfsd4_op *ops;
397 struct nfsd4_op iops[8];
400 struct nfsd4_compoundres {
401 /* scratch variables for XDR encode */
404 struct xdr_buf * xbuf;
405 struct svc_rqst * rqstp;
410 u32 * tagp; /* where to encode tag and opcount */
413 #define NFS4_SVC_XDRSIZE sizeof(struct nfsd4_compoundargs)
416 set_change_info(struct nfsd4_change_info *cinfo, struct svc_fh *fhp)
418 BUG_ON(!fhp->fh_pre_saved || !fhp->fh_post_saved);
420 cinfo->before_ctime_sec = fhp->fh_pre_ctime.tv_sec;
421 cinfo->before_ctime_nsec = fhp->fh_pre_ctime.tv_nsec;
422 cinfo->after_ctime_sec = fhp->fh_post_ctime.tv_sec;
423 cinfo->after_ctime_nsec = fhp->fh_post_ctime.tv_nsec;
426 int nfs4svc_encode_voidres(struct svc_rqst *, u32 *, void *);
427 int nfs4svc_decode_compoundargs(struct svc_rqst *, u32 *,
428 struct nfsd4_compoundargs *);
429 int nfs4svc_encode_compoundres(struct svc_rqst *, u32 *,
430 struct nfsd4_compoundres *);
431 void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *);
432 void nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op);
433 int nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
434 struct dentry *dentry, u32 *buffer, int *countp,
435 u32 *bmval, struct svc_rqst *);
436 extern int nfsd4_setclientid(struct svc_rqst *rqstp,
437 struct nfsd4_setclientid *setclid);
438 extern int nfsd4_setclientid_confirm(struct svc_rqst *rqstp,
439 struct nfsd4_setclientid_confirm *setclientid_confirm);
440 extern int nfsd4_process_open1(struct nfsd4_open *open);
441 extern int nfsd4_process_open2(struct svc_rqst *rqstp,
442 struct svc_fh *current_fh, struct nfsd4_open *open);
443 extern int nfsd4_open_confirm(struct svc_rqst *rqstp,
444 struct svc_fh *current_fh, struct nfsd4_open_confirm *oc);
445 extern int nfsd4_close(struct svc_rqst *rqstp, struct svc_fh *current_fh,
446 struct nfsd4_close *close);
447 extern int nfsd4_open_downgrade(struct svc_rqst *rqstp,
448 struct svc_fh *current_fh, struct nfsd4_open_downgrade *od);
449 extern int nfsd4_lock(struct svc_rqst *rqstp, struct svc_fh *current_fh,
450 struct nfsd4_lock *lock);
451 extern int nfsd4_lockt(struct svc_rqst *rqstp, struct svc_fh *current_fh,
452 struct nfsd4_lockt *lockt);
453 extern int nfsd4_locku(struct svc_rqst *rqstp, struct svc_fh *current_fh,
454 struct nfsd4_locku *locku);
456 nfsd4_release_lockowner(struct svc_rqst *rqstp,
457 struct nfsd4_release_lockowner *rlockowner);
458 extern void nfsd4_release_compoundargs(struct nfsd4_compoundargs *);