nfsd41: proc stubs
[safe/jmp/linux-2.6] / include / linux / nfsd / xdr4.h
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
47 struct nfsd4_compound_state {
48         struct svc_fh           current_fh;
49         struct svc_fh           save_fh;
50         struct nfs4_stateowner  *replay_owner;
51 };
52
53 struct nfsd4_change_info {
54         u32             atomic;
55         u32             before_ctime_sec;
56         u32             before_ctime_nsec;
57         u32             after_ctime_sec;
58         u32             after_ctime_nsec;
59 };
60
61 struct nfsd4_access {
62         u32             ac_req_access;      /* request */
63         u32             ac_supported;       /* response */
64         u32             ac_resp_access;     /* response */
65 };
66
67 struct nfsd4_close {
68         u32             cl_seqid;           /* request */
69         stateid_t       cl_stateid;         /* request+response */
70         struct nfs4_stateowner * cl_stateowner; /* response */
71 };
72
73 struct nfsd4_commit {
74         u64             co_offset;          /* request */
75         u32             co_count;           /* request */
76         nfs4_verifier   co_verf;            /* response */
77 };
78
79 struct nfsd4_create {
80         u32             cr_namelen;         /* request */
81         char *          cr_name;            /* request */
82         u32             cr_type;            /* request */
83         union {                             /* request */
84                 struct {
85                         u32 namelen;
86                         char *name;
87                 } link;   /* NF4LNK */
88                 struct {
89                         u32 specdata1;
90                         u32 specdata2;
91                 } dev;    /* NF4BLK, NF4CHR */
92         } u;
93         u32             cr_bmval[2];        /* request */
94         struct iattr    cr_iattr;           /* request */
95         struct nfsd4_change_info  cr_cinfo; /* response */
96         struct nfs4_acl *cr_acl;
97 };
98 #define cr_linklen      u.link.namelen
99 #define cr_linkname     u.link.name
100 #define cr_specdata1    u.dev.specdata1
101 #define cr_specdata2    u.dev.specdata2
102
103 struct nfsd4_delegreturn {
104         stateid_t       dr_stateid;
105 };
106
107 struct nfsd4_getattr {
108         u32             ga_bmval[2];        /* request */
109         struct svc_fh   *ga_fhp;            /* response */
110 };
111
112 struct nfsd4_link {
113         u32             li_namelen;         /* request */
114         char *          li_name;            /* request */
115         struct nfsd4_change_info  li_cinfo; /* response */
116 };
117
118 struct nfsd4_lock_denied {
119         clientid_t      ld_clientid;
120         struct nfs4_stateowner   *ld_sop;
121         u64             ld_start;
122         u64             ld_length;
123         u32             ld_type;
124 };
125
126 struct nfsd4_lock {
127         /* request */
128         u32             lk_type;
129         u32             lk_reclaim;         /* boolean */
130         u64             lk_offset;
131         u64             lk_length;
132         u32             lk_is_new;
133         union {
134                 struct {
135                         u32             open_seqid;
136                         stateid_t       open_stateid;
137                         u32             lock_seqid;
138                         clientid_t      clientid;
139                         struct xdr_netobj owner;
140                 } new;
141                 struct {
142                         stateid_t       lock_stateid;
143                         u32             lock_seqid;
144                 } old;
145         } v;
146
147         /* response */
148         union {
149                 struct {
150                         stateid_t               stateid;
151                 } ok;
152                 struct nfsd4_lock_denied        denied;
153         } u;
154         /* The lk_replay_owner is the open owner in the open_to_lock_owner
155          * case and the lock owner otherwise: */
156         struct nfs4_stateowner *lk_replay_owner;
157 };
158 #define lk_new_open_seqid       v.new.open_seqid
159 #define lk_new_open_stateid     v.new.open_stateid
160 #define lk_new_lock_seqid       v.new.lock_seqid
161 #define lk_new_clientid         v.new.clientid
162 #define lk_new_owner            v.new.owner
163 #define lk_old_lock_stateid     v.old.lock_stateid
164 #define lk_old_lock_seqid       v.old.lock_seqid
165
166 #define lk_rflags       u.ok.rflags
167 #define lk_resp_stateid u.ok.stateid
168 #define lk_denied       u.denied
169
170
171 struct nfsd4_lockt {
172         u32                             lt_type;
173         clientid_t                      lt_clientid;
174         struct xdr_netobj               lt_owner;
175         u64                             lt_offset;
176         u64                             lt_length;
177         struct nfs4_stateowner *        lt_stateowner;
178         struct nfsd4_lock_denied        lt_denied;
179 };
180
181  
182 struct nfsd4_locku {
183         u32             lu_type;
184         u32             lu_seqid;
185         stateid_t       lu_stateid;
186         u64             lu_offset;
187         u64             lu_length;
188         struct nfs4_stateowner  *lu_stateowner;
189 };
190
191
192 struct nfsd4_lookup {
193         u32             lo_len;             /* request */
194         char *          lo_name;            /* request */
195 };
196
197 struct nfsd4_putfh {
198         u32             pf_fhlen;           /* request */
199         char            *pf_fhval;          /* request */
200 };
201
202 struct nfsd4_open {
203         u32             op_claim_type;      /* request */
204         struct xdr_netobj op_fname;         /* request - everything but CLAIM_PREV */
205         u32             op_delegate_type;   /* request - CLAIM_PREV only */
206         stateid_t       op_delegate_stateid; /* request - response */
207         u32             op_create;          /* request */
208         u32             op_createmode;      /* request */
209         u32             op_bmval[2];        /* request */
210         union {                             /* request */
211                 struct iattr    iattr;                      /* UNCHECKED4,GUARDED4 */
212                 nfs4_verifier   verf;                                /* EXCLUSIVE4 */
213         } u;
214         clientid_t      op_clientid;        /* request */
215         struct xdr_netobj op_owner;           /* request */
216         u32             op_seqid;           /* request */
217         u32             op_share_access;    /* request */
218         u32             op_share_deny;      /* request */
219         stateid_t       op_stateid;         /* response */
220         u32             op_recall;          /* recall */
221         struct nfsd4_change_info  op_cinfo; /* response */
222         u32             op_rflags;          /* response */
223         int             op_truncate;        /* used during processing */
224         struct nfs4_stateowner *op_stateowner; /* used during processing */
225         struct nfs4_acl *op_acl;
226 };
227 #define op_iattr        u.iattr
228 #define op_verf         u.verf
229
230 struct nfsd4_open_confirm {
231         stateid_t       oc_req_stateid          /* request */;
232         u32             oc_seqid                /* request */;
233         stateid_t       oc_resp_stateid         /* response */;
234         struct nfs4_stateowner * oc_stateowner; /* response */
235 };
236
237 struct nfsd4_open_downgrade {
238         stateid_t       od_stateid;
239         u32             od_seqid;
240         u32             od_share_access;
241         u32             od_share_deny;
242         struct nfs4_stateowner *od_stateowner;
243 };
244
245
246 struct nfsd4_read {
247         stateid_t       rd_stateid;         /* request */
248         u64             rd_offset;          /* request */
249         u32             rd_length;          /* request */
250         int             rd_vlen;
251         struct file     *rd_filp;
252         
253         struct svc_rqst *rd_rqstp;          /* response */
254         struct svc_fh * rd_fhp;             /* response */
255 };
256
257 struct nfsd4_readdir {
258         u64             rd_cookie;          /* request */
259         nfs4_verifier   rd_verf;            /* request */
260         u32             rd_dircount;        /* request */
261         u32             rd_maxcount;        /* request */
262         u32             rd_bmval[2];        /* request */
263         struct svc_rqst *rd_rqstp;          /* response */
264         struct svc_fh * rd_fhp;             /* response */
265
266         struct readdir_cd       common;
267         __be32 *                buffer;
268         int                     buflen;
269         __be32 *                offset;
270 };
271
272 struct nfsd4_release_lockowner {
273         clientid_t        rl_clientid;
274         struct xdr_netobj rl_owner;
275 };
276 struct nfsd4_readlink {
277         struct svc_rqst *rl_rqstp;          /* request */
278         struct svc_fh * rl_fhp;             /* request */
279 };
280
281 struct nfsd4_remove {
282         u32             rm_namelen;         /* request */
283         char *          rm_name;            /* request */
284         struct nfsd4_change_info  rm_cinfo; /* response */
285 };
286
287 struct nfsd4_rename {
288         u32             rn_snamelen;        /* request */
289         char *          rn_sname;           /* request */
290         u32             rn_tnamelen;        /* request */
291         char *          rn_tname;           /* request */
292         struct nfsd4_change_info  rn_sinfo; /* response */
293         struct nfsd4_change_info  rn_tinfo; /* response */
294 };
295
296 struct nfsd4_secinfo {
297         u32 si_namelen;                                 /* request */
298         char *si_name;                                  /* request */
299         struct svc_export *si_exp;                      /* response */
300 };
301
302 struct nfsd4_setattr {
303         stateid_t       sa_stateid;         /* request */
304         u32             sa_bmval[2];        /* request */
305         struct iattr    sa_iattr;           /* request */
306         struct nfs4_acl *sa_acl;
307 };
308
309 struct nfsd4_setclientid {
310         nfs4_verifier   se_verf;            /* request */
311         u32             se_namelen;         /* request */
312         char *          se_name;            /* request */
313         u32             se_callback_prog;   /* request */
314         u32             se_callback_netid_len;  /* request */
315         char *          se_callback_netid_val;  /* request */
316         u32             se_callback_addr_len;   /* request */
317         char *          se_callback_addr_val;   /* request */
318         u32             se_callback_ident;  /* request */
319         clientid_t      se_clientid;        /* response */
320         nfs4_verifier   se_confirm;         /* response */
321 };
322
323 struct nfsd4_setclientid_confirm {
324         clientid_t      sc_clientid;
325         nfs4_verifier   sc_confirm;
326 };
327
328 /* also used for NVERIFY */
329 struct nfsd4_verify {
330         u32             ve_bmval[2];        /* request */
331         u32             ve_attrlen;         /* request */
332         char *          ve_attrval;         /* request */
333 };
334
335 struct nfsd4_write {
336         stateid_t       wr_stateid;         /* request */
337         u64             wr_offset;          /* request */
338         u32             wr_stable_how;      /* request */
339         u32             wr_buflen;          /* request */
340         int             wr_vlen;
341
342         u32             wr_bytes_written;   /* response */
343         u32             wr_how_written;     /* response */
344         nfs4_verifier   wr_verifier;        /* response */
345 };
346
347 struct nfsd4_exchange_id {
348         int     foo;    /* stub */
349 };
350
351 struct nfsd4_create_session {
352         int     foo;    /* stub */
353 };
354
355 struct nfsd4_sequence {
356         int     foo;    /* stub */
357 };
358
359 struct nfsd4_destroy_session {
360         int     foo;    /* stub */
361 };
362
363 struct nfsd4_op {
364         int                                     opnum;
365         __be32                                  status;
366         union {
367                 struct nfsd4_access             access;
368                 struct nfsd4_close              close;
369                 struct nfsd4_commit             commit;
370                 struct nfsd4_create             create;
371                 struct nfsd4_delegreturn        delegreturn;
372                 struct nfsd4_getattr            getattr;
373                 struct svc_fh *                 getfh;
374                 struct nfsd4_link               link;
375                 struct nfsd4_lock               lock;
376                 struct nfsd4_lockt              lockt;
377                 struct nfsd4_locku              locku;
378                 struct nfsd4_lookup             lookup;
379                 struct nfsd4_verify             nverify;
380                 struct nfsd4_open               open;
381                 struct nfsd4_open_confirm       open_confirm;
382                 struct nfsd4_open_downgrade     open_downgrade;
383                 struct nfsd4_putfh              putfh;
384                 struct nfsd4_read               read;
385                 struct nfsd4_readdir            readdir;
386                 struct nfsd4_readlink           readlink;
387                 struct nfsd4_remove             remove;
388                 struct nfsd4_rename             rename;
389                 clientid_t                      renew;
390                 struct nfsd4_secinfo            secinfo;
391                 struct nfsd4_setattr            setattr;
392                 struct nfsd4_setclientid        setclientid;
393                 struct nfsd4_setclientid_confirm setclientid_confirm;
394                 struct nfsd4_verify             verify;
395                 struct nfsd4_write              write;
396                 struct nfsd4_release_lockowner  release_lockowner;
397
398                 /* NFSv4.1 */
399                 struct nfsd4_exchange_id        exchange_id;
400                 struct nfsd4_create_session     create_session;
401                 struct nfsd4_destroy_session    destroy_session;
402                 struct nfsd4_sequence           sequence;
403         } u;
404         struct nfs4_replay *                    replay;
405 };
406
407 struct nfsd4_compoundargs {
408         /* scratch variables for XDR decode */
409         __be32 *                        p;
410         __be32 *                        end;
411         struct page **                  pagelist;
412         int                             pagelen;
413         __be32                          tmp[8];
414         __be32 *                        tmpp;
415         struct tmpbuf {
416                 struct tmpbuf *next;
417                 void (*release)(const void *);
418                 void *buf;
419         }                               *to_free;
420
421         struct svc_rqst                 *rqstp;
422
423         u32                             taglen;
424         char *                          tag;
425         u32                             minorversion;
426         u32                             opcnt;
427         struct nfsd4_op                 *ops;
428         struct nfsd4_op                 iops[8];
429 };
430
431 struct nfsd4_compoundres {
432         /* scratch variables for XDR encode */
433         __be32 *                        p;
434         __be32 *                        end;
435         struct xdr_buf *                xbuf;
436         struct svc_rqst *               rqstp;
437
438         u32                             taglen;
439         char *                          tag;
440         u32                             opcnt;
441         __be32 *                        tagp; /* tag, opcount encode location */
442         struct nfsd4_compound_state     cstate;
443 };
444
445 #define NFS4_SVC_XDRSIZE                sizeof(struct nfsd4_compoundargs)
446
447 static inline void
448 set_change_info(struct nfsd4_change_info *cinfo, struct svc_fh *fhp)
449 {
450         BUG_ON(!fhp->fh_pre_saved || !fhp->fh_post_saved);
451         cinfo->atomic = 1;
452         cinfo->before_ctime_sec = fhp->fh_pre_ctime.tv_sec;
453         cinfo->before_ctime_nsec = fhp->fh_pre_ctime.tv_nsec;
454         cinfo->after_ctime_sec = fhp->fh_post_attr.ctime.tv_sec;
455         cinfo->after_ctime_nsec = fhp->fh_post_attr.ctime.tv_nsec;
456 }
457
458 int nfs4svc_encode_voidres(struct svc_rqst *, __be32 *, void *);
459 int nfs4svc_decode_compoundargs(struct svc_rqst *, __be32 *,
460                 struct nfsd4_compoundargs *);
461 int nfs4svc_encode_compoundres(struct svc_rqst *, __be32 *,
462                 struct nfsd4_compoundres *);
463 void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *);
464 void nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op);
465 __be32 nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
466                        struct dentry *dentry, __be32 *buffer, int *countp,
467                        u32 *bmval, struct svc_rqst *, int ignore_crossmnt);
468 extern __be32 nfsd4_setclientid(struct svc_rqst *rqstp,
469                 struct nfsd4_compound_state *,
470                 struct nfsd4_setclientid *setclid);
471 extern __be32 nfsd4_setclientid_confirm(struct svc_rqst *rqstp,
472                 struct nfsd4_compound_state *,
473                 struct nfsd4_setclientid_confirm *setclientid_confirm);
474 extern __be32 nfsd4_exchange_id(struct svc_rqst *rqstp,
475                 struct nfsd4_compound_state *,
476 struct nfsd4_exchange_id *);
477                 extern __be32 nfsd4_create_session(struct svc_rqst *,
478                 struct nfsd4_compound_state *,
479                 struct nfsd4_create_session *);
480 extern __be32 nfsd4_sequence(struct svc_rqst *,
481                 struct nfsd4_compound_state *,
482                 struct nfsd4_sequence *);
483 extern __be32 nfsd4_destroy_session(struct svc_rqst *,
484                 struct nfsd4_compound_state *,
485                 struct nfsd4_destroy_session *);
486 extern __be32 nfsd4_process_open1(struct nfsd4_open *open);
487 extern __be32 nfsd4_process_open2(struct svc_rqst *rqstp,
488                 struct svc_fh *current_fh, struct nfsd4_open *open);
489 extern __be32 nfsd4_open_confirm(struct svc_rqst *rqstp,
490                 struct nfsd4_compound_state *, struct nfsd4_open_confirm *oc);
491 extern __be32 nfsd4_close(struct svc_rqst *rqstp,
492                 struct nfsd4_compound_state *,
493                 struct nfsd4_close *close);
494 extern __be32 nfsd4_open_downgrade(struct svc_rqst *rqstp,
495                 struct nfsd4_compound_state *,
496                 struct nfsd4_open_downgrade *od);
497 extern __be32 nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *,
498                 struct nfsd4_lock *lock);
499 extern __be32 nfsd4_lockt(struct svc_rqst *rqstp,
500                 struct nfsd4_compound_state *,
501                 struct nfsd4_lockt *lockt);
502 extern __be32 nfsd4_locku(struct svc_rqst *rqstp,
503                 struct nfsd4_compound_state *,
504                 struct nfsd4_locku *locku);
505 extern __be32
506 nfsd4_release_lockowner(struct svc_rqst *rqstp,
507                 struct nfsd4_compound_state *,
508                 struct nfsd4_release_lockowner *rlockowner);
509 extern void nfsd4_release_compoundargs(struct nfsd4_compoundargs *);
510 extern __be32 nfsd4_delegreturn(struct svc_rqst *rqstp,
511                 struct nfsd4_compound_state *, struct nfsd4_delegreturn *dr);
512 extern __be32 nfsd4_renew(struct svc_rqst *rqstp,
513                           struct nfsd4_compound_state *, clientid_t *clid);
514 #endif
515
516 /*
517  * Local variables:
518  *  c-basic-offset: 8
519  * End:
520  */