string: factorize skip_spaces and export it to be generally available
[safe/jmp/linux-2.6] / include / linux / nfs_xdr.h
1 #ifndef _LINUX_NFS_XDR_H
2 #define _LINUX_NFS_XDR_H
3
4 #include <linux/nfsacl.h>
5
6 /*
7  * To change the maximum rsize and wsize supported by the NFS client, adjust
8  * NFS_MAX_FILE_IO_SIZE.  64KB is a typical maximum, but some servers can
9  * support a megabyte or more.  The default is left at 4096 bytes, which is
10  * reasonable for NFS over UDP.
11  */
12 #define NFS_MAX_FILE_IO_SIZE    (1048576U)
13 #define NFS_DEF_FILE_IO_SIZE    (4096U)
14 #define NFS_MIN_FILE_IO_SIZE    (1024U)
15
16 struct nfs_fsid {
17         uint64_t                major;
18         uint64_t                minor;
19 };
20
21 /*
22  * Helper for checking equality between 2 fsids.
23  */
24 static inline int nfs_fsid_equal(const struct nfs_fsid *a, const struct nfs_fsid *b)
25 {
26         return a->major == b->major && a->minor == b->minor;
27 }
28
29 struct nfs_fattr {
30         unsigned int            valid;          /* which fields are valid */
31         umode_t                 mode;
32         __u32                   nlink;
33         __u32                   uid;
34         __u32                   gid;
35         dev_t                   rdev;
36         __u64                   size;
37         union {
38                 struct {
39                         __u32   blocksize;
40                         __u32   blocks;
41                 } nfs2;
42                 struct {
43                         __u64   used;
44                 } nfs3;
45         } du;
46         struct nfs_fsid         fsid;
47         __u64                   fileid;
48         struct timespec         atime;
49         struct timespec         mtime;
50         struct timespec         ctime;
51         __u64                   change_attr;    /* NFSv4 change attribute */
52         __u64                   pre_change_attr;/* pre-op NFSv4 change attribute */
53         __u64                   pre_size;       /* pre_op_attr.size       */
54         struct timespec         pre_mtime;      /* pre_op_attr.mtime      */
55         struct timespec         pre_ctime;      /* pre_op_attr.ctime      */
56         unsigned long           time_start;
57         unsigned long           gencount;
58 };
59
60 #define NFS_ATTR_FATTR_TYPE             (1U << 0)
61 #define NFS_ATTR_FATTR_MODE             (1U << 1)
62 #define NFS_ATTR_FATTR_NLINK            (1U << 2)
63 #define NFS_ATTR_FATTR_OWNER            (1U << 3)
64 #define NFS_ATTR_FATTR_GROUP            (1U << 4)
65 #define NFS_ATTR_FATTR_RDEV             (1U << 5)
66 #define NFS_ATTR_FATTR_SIZE             (1U << 6)
67 #define NFS_ATTR_FATTR_PRESIZE          (1U << 7)
68 #define NFS_ATTR_FATTR_BLOCKS_USED      (1U << 8)
69 #define NFS_ATTR_FATTR_SPACE_USED       (1U << 9)
70 #define NFS_ATTR_FATTR_FSID             (1U << 10)
71 #define NFS_ATTR_FATTR_FILEID           (1U << 11)
72 #define NFS_ATTR_FATTR_ATIME            (1U << 12)
73 #define NFS_ATTR_FATTR_MTIME            (1U << 13)
74 #define NFS_ATTR_FATTR_CTIME            (1U << 14)
75 #define NFS_ATTR_FATTR_PREMTIME         (1U << 15)
76 #define NFS_ATTR_FATTR_PRECTIME         (1U << 16)
77 #define NFS_ATTR_FATTR_CHANGE           (1U << 17)
78 #define NFS_ATTR_FATTR_PRECHANGE        (1U << 18)
79 #define NFS_ATTR_FATTR_V4_REFERRAL      (1U << 19)      /* NFSv4 referral */
80
81 #define NFS_ATTR_FATTR (NFS_ATTR_FATTR_TYPE \
82                 | NFS_ATTR_FATTR_MODE \
83                 | NFS_ATTR_FATTR_NLINK \
84                 | NFS_ATTR_FATTR_OWNER \
85                 | NFS_ATTR_FATTR_GROUP \
86                 | NFS_ATTR_FATTR_RDEV \
87                 | NFS_ATTR_FATTR_SIZE \
88                 | NFS_ATTR_FATTR_FSID \
89                 | NFS_ATTR_FATTR_FILEID \
90                 | NFS_ATTR_FATTR_ATIME \
91                 | NFS_ATTR_FATTR_MTIME \
92                 | NFS_ATTR_FATTR_CTIME)
93 #define NFS_ATTR_FATTR_V2 (NFS_ATTR_FATTR \
94                 | NFS_ATTR_FATTR_BLOCKS_USED)
95 #define NFS_ATTR_FATTR_V3 (NFS_ATTR_FATTR \
96                 | NFS_ATTR_FATTR_SPACE_USED)
97 #define NFS_ATTR_FATTR_V4 (NFS_ATTR_FATTR \
98                 | NFS_ATTR_FATTR_SPACE_USED \
99                 | NFS_ATTR_FATTR_CHANGE)
100
101 /*
102  * Info on the file system
103  */
104 struct nfs_fsinfo {
105         struct nfs_fattr        *fattr; /* Post-op attributes */
106         __u32                   rtmax;  /* max.  read transfer size */
107         __u32                   rtpref; /* pref. read transfer size */
108         __u32                   rtmult; /* reads should be multiple of this */
109         __u32                   wtmax;  /* max.  write transfer size */
110         __u32                   wtpref; /* pref. write transfer size */
111         __u32                   wtmult; /* writes should be multiple of this */
112         __u32                   dtpref; /* pref. readdir transfer size */
113         __u64                   maxfilesize;
114         __u32                   lease_time; /* in seconds */
115 };
116
117 struct nfs_fsstat {
118         struct nfs_fattr        *fattr; /* Post-op attributes */
119         __u64                   tbytes; /* total size in bytes */
120         __u64                   fbytes; /* # of free bytes */
121         __u64                   abytes; /* # of bytes available to user */
122         __u64                   tfiles; /* # of files */
123         __u64                   ffiles; /* # of free files */
124         __u64                   afiles; /* # of files available to user */
125 };
126
127 struct nfs2_fsstat {
128         __u32                   tsize;  /* Server transfer size */
129         __u32                   bsize;  /* Filesystem block size */
130         __u32                   blocks; /* No. of "bsize" blocks on filesystem */
131         __u32                   bfree;  /* No. of free "bsize" blocks */
132         __u32                   bavail; /* No. of available "bsize" blocks */
133 };
134
135 struct nfs_pathconf {
136         struct nfs_fattr        *fattr; /* Post-op attributes */
137         __u32                   max_link; /* max # of hard links */
138         __u32                   max_namelen; /* max name length */
139 };
140
141 struct nfs4_change_info {
142         u32                     atomic;
143         u64                     before;
144         u64                     after;
145 };
146
147 struct nfs_seqid;
148
149 /* nfs41 sessions channel attributes */
150 struct nfs4_channel_attrs {
151         u32                     headerpadsz;
152         u32                     max_rqst_sz;
153         u32                     max_resp_sz;
154         u32                     max_resp_sz_cached;
155         u32                     max_ops;
156         u32                     max_reqs;
157 };
158
159 /* nfs41 sessions slot seqid */
160 struct nfs4_slot {
161         u32                     seq_nr;
162 };
163
164 struct nfs4_sequence_args {
165         struct nfs4_session     *sa_session;
166         u8                      sa_slotid;
167         u8                      sa_cache_this;
168 };
169
170 struct nfs4_sequence_res {
171         struct nfs4_session     *sr_session;
172         u8                      sr_slotid;      /* slot used to send request */
173         int                     sr_status;      /* sequence operation status */
174         unsigned long           sr_renewal_time;
175         u32                     sr_status_flags;
176 };
177
178 struct nfs4_get_lease_time_args {
179         struct nfs4_sequence_args       la_seq_args;
180 };
181
182 struct nfs4_get_lease_time_res {
183         struct nfs_fsinfo              *lr_fsinfo;
184         struct nfs4_sequence_res        lr_seq_res;
185 };
186
187 /*
188  * Arguments to the open call.
189  */
190 struct nfs_openargs {
191         const struct nfs_fh *   fh;
192         struct nfs_seqid *      seqid;
193         int                     open_flags;
194         fmode_t                 fmode;
195         __u64                   clientid;
196         __u64                   id;
197         union {
198                 struct iattr *  attrs;    /* UNCHECKED, GUARDED */
199                 nfs4_verifier   verifier; /* EXCLUSIVE */
200                 nfs4_stateid    delegation;             /* CLAIM_DELEGATE_CUR */
201                 fmode_t         delegation_type;        /* CLAIM_PREVIOUS */
202         } u;
203         const struct qstr *     name;
204         const struct nfs_server *server;         /* Needed for ID mapping */
205         const u32 *             bitmask;
206         __u32                   claim;
207         struct nfs4_sequence_args       seq_args;
208 };
209
210 struct nfs_openres {
211         nfs4_stateid            stateid;
212         struct nfs_fh           fh;
213         struct nfs4_change_info cinfo;
214         __u32                   rflags;
215         struct nfs_fattr *      f_attr;
216         struct nfs_fattr *      dir_attr;
217         struct nfs_seqid *      seqid;
218         const struct nfs_server *server;
219         fmode_t                 delegation_type;
220         nfs4_stateid            delegation;
221         __u32                   do_recall;
222         __u64                   maxsize;
223         __u32                   attrset[NFS4_BITMAP_SIZE];
224         struct nfs4_sequence_res        seq_res;
225 };
226
227 /*
228  * Arguments to the open_confirm call.
229  */
230 struct nfs_open_confirmargs {
231         const struct nfs_fh *   fh;
232         nfs4_stateid *          stateid;
233         struct nfs_seqid *      seqid;
234 };
235
236 struct nfs_open_confirmres {
237         nfs4_stateid            stateid;
238         struct nfs_seqid *      seqid;
239 };
240
241 /*
242  * Arguments to the close call.
243  */
244 struct nfs_closeargs {
245         struct nfs_fh *         fh;
246         nfs4_stateid *          stateid;
247         struct nfs_seqid *      seqid;
248         fmode_t                 fmode;
249         const u32 *             bitmask;
250         struct nfs4_sequence_args       seq_args;
251 };
252
253 struct nfs_closeres {
254         nfs4_stateid            stateid;
255         struct nfs_fattr *      fattr;
256         struct nfs_seqid *      seqid;
257         const struct nfs_server *server;
258         struct nfs4_sequence_res        seq_res;
259 };
260 /*
261  *  * Arguments to the lock,lockt, and locku call.
262  *   */
263 struct nfs_lowner {
264         __u64                   clientid;
265         __u64                   id;
266 };
267
268 struct nfs_lock_args {
269         struct nfs_fh *         fh;
270         struct file_lock *      fl;
271         struct nfs_seqid *      lock_seqid;
272         nfs4_stateid *          lock_stateid;
273         struct nfs_seqid *      open_seqid;
274         nfs4_stateid *          open_stateid;
275         struct nfs_lowner       lock_owner;
276         unsigned char           block : 1;
277         unsigned char           reclaim : 1;
278         unsigned char           new_lock_owner : 1;
279         struct nfs4_sequence_args       seq_args;
280 };
281
282 struct nfs_lock_res {
283         nfs4_stateid            stateid;
284         struct nfs_seqid *      lock_seqid;
285         struct nfs_seqid *      open_seqid;
286         struct nfs4_sequence_res        seq_res;
287 };
288
289 struct nfs_locku_args {
290         struct nfs_fh *         fh;
291         struct file_lock *      fl;
292         struct nfs_seqid *      seqid;
293         nfs4_stateid *          stateid;
294         struct nfs4_sequence_args       seq_args;
295 };
296
297 struct nfs_locku_res {
298         nfs4_stateid            stateid;
299         struct nfs_seqid *      seqid;
300         struct nfs4_sequence_res        seq_res;
301 };
302
303 struct nfs_lockt_args {
304         struct nfs_fh *         fh;
305         struct file_lock *      fl;
306         struct nfs_lowner       lock_owner;
307         struct nfs4_sequence_args       seq_args;
308 };
309
310 struct nfs_lockt_res {
311         struct file_lock *      denied; /* LOCK, LOCKT failed */
312         struct nfs4_sequence_res        seq_res;
313 };
314
315 struct nfs4_delegreturnargs {
316         const struct nfs_fh *fhandle;
317         const nfs4_stateid *stateid;
318         const u32 * bitmask;
319         struct nfs4_sequence_args       seq_args;
320 };
321
322 struct nfs4_delegreturnres {
323         struct nfs_fattr * fattr;
324         const struct nfs_server *server;
325         struct nfs4_sequence_res        seq_res;
326 };
327
328 /*
329  * Arguments to the read call.
330  */
331 struct nfs_readargs {
332         struct nfs_fh *         fh;
333         struct nfs_open_context *context;
334         __u64                   offset;
335         __u32                   count;
336         unsigned int            pgbase;
337         struct page **          pages;
338         struct nfs4_sequence_args       seq_args;
339 };
340
341 struct nfs_readres {
342         struct nfs_fattr *      fattr;
343         __u32                   count;
344         int                     eof;
345         struct nfs4_sequence_res        seq_res;
346 };
347
348 /*
349  * Arguments to the write call.
350  */
351 struct nfs_writeargs {
352         struct nfs_fh *         fh;
353         struct nfs_open_context *context;
354         __u64                   offset;
355         __u32                   count;
356         enum nfs3_stable_how    stable;
357         unsigned int            pgbase;
358         struct page **          pages;
359         const u32 *             bitmask;
360         struct nfs4_sequence_args       seq_args;
361 };
362
363 struct nfs_writeverf {
364         enum nfs3_stable_how    committed;
365         __be32                  verifier[2];
366 };
367
368 struct nfs_writeres {
369         struct nfs_fattr *      fattr;
370         struct nfs_writeverf *  verf;
371         __u32                   count;
372         const struct nfs_server *server;
373         struct nfs4_sequence_res        seq_res;
374 };
375
376 /*
377  * Common arguments to the unlink call
378  */
379 struct nfs_removeargs {
380         const struct nfs_fh     *fh;
381         struct qstr             name;
382         const u32 *             bitmask;
383         struct nfs4_sequence_args       seq_args;
384 };
385
386 struct nfs_removeres {
387         const struct nfs_server *server;
388         struct nfs4_change_info cinfo;
389         struct nfs_fattr        dir_attr;
390         struct nfs4_sequence_res        seq_res;
391 };
392
393 /*
394  * Argument struct for decode_entry function
395  */
396 struct nfs_entry {
397         __u64                   ino;
398         __u64                   cookie,
399                                 prev_cookie;
400         const char *            name;
401         unsigned int            len;
402         int                     eof;
403         struct nfs_fh *         fh;
404         struct nfs_fattr *      fattr;
405 };
406
407 /*
408  * The following types are for NFSv2 only.
409  */
410 struct nfs_sattrargs {
411         struct nfs_fh *         fh;
412         struct iattr *          sattr;
413 };
414
415 struct nfs_diropargs {
416         struct nfs_fh *         fh;
417         const char *            name;
418         unsigned int            len;
419 };
420
421 struct nfs_createargs {
422         struct nfs_fh *         fh;
423         const char *            name;
424         unsigned int            len;
425         struct iattr *          sattr;
426 };
427
428 struct nfs_renameargs {
429         struct nfs_fh *         fromfh;
430         const char *            fromname;
431         unsigned int            fromlen;
432         struct nfs_fh *         tofh;
433         const char *            toname;
434         unsigned int            tolen;
435 };
436
437 struct nfs_setattrargs {
438         struct nfs_fh *                 fh;
439         nfs4_stateid                    stateid;
440         struct iattr *                  iap;
441         const struct nfs_server *       server; /* Needed for name mapping */
442         const u32 *                     bitmask;
443         struct nfs4_sequence_args       seq_args;
444 };
445
446 struct nfs_setaclargs {
447         struct nfs_fh *                 fh;
448         size_t                          acl_len;
449         unsigned int                    acl_pgbase;
450         struct page **                  acl_pages;
451         struct nfs4_sequence_args       seq_args;
452 };
453
454 struct nfs_setaclres {
455         struct nfs4_sequence_res        seq_res;
456 };
457
458 struct nfs_getaclargs {
459         struct nfs_fh *                 fh;
460         size_t                          acl_len;
461         unsigned int                    acl_pgbase;
462         struct page **                  acl_pages;
463         struct nfs4_sequence_args       seq_args;
464 };
465
466 struct nfs_getaclres {
467         size_t                          acl_len;
468         struct nfs4_sequence_res        seq_res;
469 };
470
471 struct nfs_setattrres {
472         struct nfs_fattr *              fattr;
473         const struct nfs_server *       server;
474         struct nfs4_sequence_res        seq_res;
475 };
476
477 struct nfs_linkargs {
478         struct nfs_fh *         fromfh;
479         struct nfs_fh *         tofh;
480         const char *            toname;
481         unsigned int            tolen;
482 };
483
484 struct nfs_symlinkargs {
485         struct nfs_fh *         fromfh;
486         const char *            fromname;
487         unsigned int            fromlen;
488         struct page **          pages;
489         unsigned int            pathlen;
490         struct iattr *          sattr;
491 };
492
493 struct nfs_readdirargs {
494         struct nfs_fh *         fh;
495         __u32                   cookie;
496         unsigned int            count;
497         struct page **          pages;
498 };
499
500 struct nfs3_getaclargs {
501         struct nfs_fh *         fh;
502         int                     mask;
503         struct page **          pages;
504 };
505
506 struct nfs3_setaclargs {
507         struct inode *          inode;
508         int                     mask;
509         struct posix_acl *      acl_access;
510         struct posix_acl *      acl_default;
511         size_t                  len;
512         unsigned int            npages;
513         struct page **          pages;
514 };
515
516 struct nfs_diropok {
517         struct nfs_fh *         fh;
518         struct nfs_fattr *      fattr;
519 };
520
521 struct nfs_readlinkargs {
522         struct nfs_fh *         fh;
523         unsigned int            pgbase;
524         unsigned int            pglen;
525         struct page **          pages;
526 };
527
528 struct nfs3_sattrargs {
529         struct nfs_fh *         fh;
530         struct iattr *          sattr;
531         unsigned int            guard;
532         struct timespec         guardtime;
533 };
534
535 struct nfs3_diropargs {
536         struct nfs_fh *         fh;
537         const char *            name;
538         unsigned int            len;
539 };
540
541 struct nfs3_accessargs {
542         struct nfs_fh *         fh;
543         __u32                   access;
544 };
545
546 struct nfs3_createargs {
547         struct nfs_fh *         fh;
548         const char *            name;
549         unsigned int            len;
550         struct iattr *          sattr;
551         enum nfs3_createmode    createmode;
552         __be32                  verifier[2];
553 };
554
555 struct nfs3_mkdirargs {
556         struct nfs_fh *         fh;
557         const char *            name;
558         unsigned int            len;
559         struct iattr *          sattr;
560 };
561
562 struct nfs3_symlinkargs {
563         struct nfs_fh *         fromfh;
564         const char *            fromname;
565         unsigned int            fromlen;
566         struct page **          pages;
567         unsigned int            pathlen;
568         struct iattr *          sattr;
569 };
570
571 struct nfs3_mknodargs {
572         struct nfs_fh *         fh;
573         const char *            name;
574         unsigned int            len;
575         enum nfs3_ftype         type;
576         struct iattr *          sattr;
577         dev_t                   rdev;
578 };
579
580 struct nfs3_renameargs {
581         struct nfs_fh *         fromfh;
582         const char *            fromname;
583         unsigned int            fromlen;
584         struct nfs_fh *         tofh;
585         const char *            toname;
586         unsigned int            tolen;
587 };
588
589 struct nfs3_linkargs {
590         struct nfs_fh *         fromfh;
591         struct nfs_fh *         tofh;
592         const char *            toname;
593         unsigned int            tolen;
594 };
595
596 struct nfs3_readdirargs {
597         struct nfs_fh *         fh;
598         __u64                   cookie;
599         __be32                  verf[2];
600         int                     plus;
601         unsigned int            count;
602         struct page **          pages;
603 };
604
605 struct nfs3_diropres {
606         struct nfs_fattr *      dir_attr;
607         struct nfs_fh *         fh;
608         struct nfs_fattr *      fattr;
609 };
610
611 struct nfs3_accessres {
612         struct nfs_fattr *      fattr;
613         __u32                   access;
614 };
615
616 struct nfs3_readlinkargs {
617         struct nfs_fh *         fh;
618         unsigned int            pgbase;
619         unsigned int            pglen;
620         struct page **          pages;
621 };
622
623 struct nfs3_renameres {
624         struct nfs_fattr *      fromattr;
625         struct nfs_fattr *      toattr;
626 };
627
628 struct nfs3_linkres {
629         struct nfs_fattr *      dir_attr;
630         struct nfs_fattr *      fattr;
631 };
632
633 struct nfs3_readdirres {
634         struct nfs_fattr *      dir_attr;
635         __be32 *                verf;
636         int                     plus;
637 };
638
639 struct nfs3_getaclres {
640         struct nfs_fattr *      fattr;
641         int                     mask;
642         unsigned int            acl_access_count;
643         unsigned int            acl_default_count;
644         struct posix_acl *      acl_access;
645         struct posix_acl *      acl_default;
646 };
647
648 #ifdef CONFIG_NFS_V4
649
650 typedef u64 clientid4;
651
652 struct nfs4_accessargs {
653         const struct nfs_fh *           fh;
654         const u32 *                     bitmask;
655         u32                             access;
656         struct nfs4_sequence_args       seq_args;
657 };
658
659 struct nfs4_accessres {
660         const struct nfs_server *       server;
661         struct nfs_fattr *              fattr;
662         u32                             supported;
663         u32                             access;
664         struct nfs4_sequence_res        seq_res;
665 };
666
667 struct nfs4_create_arg {
668         u32                             ftype;
669         union {
670                 struct {
671                         struct page **  pages;
672                         unsigned int    len;
673                 } symlink;   /* NF4LNK */
674                 struct {
675                         u32             specdata1;
676                         u32             specdata2;
677                 } device;    /* NF4BLK, NF4CHR */
678         } u;
679         const struct qstr *             name;
680         const struct nfs_server *       server;
681         const struct iattr *            attrs;
682         const struct nfs_fh *           dir_fh;
683         const u32 *                     bitmask;
684         struct nfs4_sequence_args       seq_args;
685 };
686
687 struct nfs4_create_res {
688         const struct nfs_server *       server;
689         struct nfs_fh *                 fh;
690         struct nfs_fattr *              fattr;
691         struct nfs4_change_info         dir_cinfo;
692         struct nfs_fattr *              dir_fattr;
693         struct nfs4_sequence_res        seq_res;
694 };
695
696 struct nfs4_fsinfo_arg {
697         const struct nfs_fh *           fh;
698         const u32 *                     bitmask;
699         struct nfs4_sequence_args       seq_args;
700 };
701
702 struct nfs4_fsinfo_res {
703         struct nfs_fsinfo              *fsinfo;
704         struct nfs4_sequence_res        seq_res;
705 };
706
707 struct nfs4_getattr_arg {
708         const struct nfs_fh *           fh;
709         const u32 *                     bitmask;
710         struct nfs4_sequence_args       seq_args;
711 };
712
713 struct nfs4_getattr_res {
714         const struct nfs_server *       server;
715         struct nfs_fattr *              fattr;
716         struct nfs4_sequence_res        seq_res;
717 };
718
719 struct nfs4_link_arg {
720         const struct nfs_fh *           fh;
721         const struct nfs_fh *           dir_fh;
722         const struct qstr *             name;
723         const u32 *                     bitmask;
724         struct nfs4_sequence_args       seq_args;
725 };
726
727 struct nfs4_link_res {
728         const struct nfs_server *       server;
729         struct nfs_fattr *              fattr;
730         struct nfs4_change_info         cinfo;
731         struct nfs_fattr *              dir_attr;
732         struct nfs4_sequence_res        seq_res;
733 };
734
735
736 struct nfs4_lookup_arg {
737         const struct nfs_fh *           dir_fh;
738         const struct qstr *             name;
739         const u32 *                     bitmask;
740         struct nfs4_sequence_args       seq_args;
741 };
742
743 struct nfs4_lookup_res {
744         const struct nfs_server *       server;
745         struct nfs_fattr *              fattr;
746         struct nfs_fh *                 fh;
747         struct nfs4_sequence_res        seq_res;
748 };
749
750 struct nfs4_lookup_root_arg {
751         const u32 *                     bitmask;
752         struct nfs4_sequence_args       seq_args;
753 };
754
755 struct nfs4_pathconf_arg {
756         const struct nfs_fh *           fh;
757         const u32 *                     bitmask;
758         struct nfs4_sequence_args       seq_args;
759 };
760
761 struct nfs4_pathconf_res {
762         struct nfs_pathconf            *pathconf;
763         struct nfs4_sequence_res        seq_res;
764 };
765
766 struct nfs4_readdir_arg {
767         const struct nfs_fh *           fh;
768         u64                             cookie;
769         nfs4_verifier                   verifier;
770         u32                             count;
771         struct page **                  pages;  /* zero-copy data */
772         unsigned int                    pgbase; /* zero-copy data */
773         const u32 *                     bitmask;
774         struct nfs4_sequence_args       seq_args;
775 };
776
777 struct nfs4_readdir_res {
778         nfs4_verifier                   verifier;
779         unsigned int                    pgbase;
780         struct nfs4_sequence_res        seq_res;
781 };
782
783 struct nfs4_readlink {
784         const struct nfs_fh *           fh;
785         unsigned int                    pgbase;
786         unsigned int                    pglen;   /* zero-copy data */
787         struct page **                  pages;   /* zero-copy data */
788         struct nfs4_sequence_args       seq_args;
789 };
790
791 struct nfs4_readlink_res {
792         struct nfs4_sequence_res        seq_res;
793 };
794
795 struct nfs4_rename_arg {
796         const struct nfs_fh *           old_dir;
797         const struct nfs_fh *           new_dir;
798         const struct qstr *             old_name;
799         const struct qstr *             new_name;
800         const u32 *                     bitmask;
801         struct nfs4_sequence_args       seq_args;
802 };
803
804 struct nfs4_rename_res {
805         const struct nfs_server *       server;
806         struct nfs4_change_info         old_cinfo;
807         struct nfs_fattr *              old_fattr;
808         struct nfs4_change_info         new_cinfo;
809         struct nfs_fattr *              new_fattr;
810         struct nfs4_sequence_res        seq_res;
811 };
812
813 #define NFS4_SETCLIENTID_NAMELEN        (127)
814 struct nfs4_setclientid {
815         const nfs4_verifier *           sc_verifier;
816         unsigned int                    sc_name_len;
817         char                            sc_name[NFS4_SETCLIENTID_NAMELEN + 1];
818         u32                             sc_prog;
819         unsigned int                    sc_netid_len;
820         char                            sc_netid[RPCBIND_MAXNETIDLEN + 1];
821         unsigned int                    sc_uaddr_len;
822         char                            sc_uaddr[RPCBIND_MAXUADDRLEN + 1];
823         u32                             sc_cb_ident;
824 };
825
826 struct nfs4_statfs_arg {
827         const struct nfs_fh *           fh;
828         const u32 *                     bitmask;
829         struct nfs4_sequence_args       seq_args;
830 };
831
832 struct nfs4_statfs_res {
833         struct nfs_fsstat              *fsstat;
834         struct nfs4_sequence_res        seq_res;
835 };
836
837 struct nfs4_server_caps_arg {
838         struct nfs_fh                  *fhandle;
839         struct nfs4_sequence_args       seq_args;
840 };
841
842 struct nfs4_server_caps_res {
843         u32                             attr_bitmask[2];
844         u32                             acl_bitmask;
845         u32                             has_links;
846         u32                             has_symlinks;
847         struct nfs4_sequence_res        seq_res;
848 };
849
850 struct nfs4_string {
851         unsigned int len;
852         char *data;
853 };
854
855 #define NFS4_PATHNAME_MAXCOMPONENTS 512
856 struct nfs4_pathname {
857         unsigned int ncomponents;
858         struct nfs4_string components[NFS4_PATHNAME_MAXCOMPONENTS];
859 };
860
861 #define NFS4_FS_LOCATION_MAXSERVERS 10
862 struct nfs4_fs_location {
863         unsigned int nservers;
864         struct nfs4_string servers[NFS4_FS_LOCATION_MAXSERVERS];
865         struct nfs4_pathname rootpath;
866 };
867
868 #define NFS4_FS_LOCATIONS_MAXENTRIES 10
869 struct nfs4_fs_locations {
870         struct nfs_fattr fattr;
871         const struct nfs_server *server;
872         struct nfs4_pathname fs_path;
873         int nlocations;
874         struct nfs4_fs_location locations[NFS4_FS_LOCATIONS_MAXENTRIES];
875 };
876
877 struct nfs4_fs_locations_arg {
878         const struct nfs_fh *dir_fh;
879         const struct qstr *name;
880         struct page *page;
881         const u32 *bitmask;
882         struct nfs4_sequence_args       seq_args;
883 };
884
885 struct nfs4_fs_locations_res {
886         struct nfs4_fs_locations       *fs_locations;
887         struct nfs4_sequence_res        seq_res;
888 };
889
890 #endif /* CONFIG_NFS_V4 */
891
892 struct nfstime4 {
893         u64     seconds;
894         u32     nseconds;
895 };
896
897 #ifdef CONFIG_NFS_V4_1
898 struct nfs_impl_id4 {
899         u32             domain_len;
900         char            *domain;
901         u32             name_len;
902         char            *name;
903         struct nfstime4 date;
904 };
905
906 #define NFS4_EXCHANGE_ID_LEN    (48)
907 struct nfs41_exchange_id_args {
908         struct nfs_client               *client;
909         nfs4_verifier                   *verifier;
910         unsigned int                    id_len;
911         char                            id[NFS4_EXCHANGE_ID_LEN];
912         u32                             flags;
913 };
914
915 struct server_owner {
916         uint64_t                        minor_id;
917         uint32_t                        major_id_sz;
918         char                            major_id[NFS4_OPAQUE_LIMIT];
919 };
920
921 struct server_scope {
922         uint32_t                        server_scope_sz;
923         char                            server_scope[NFS4_OPAQUE_LIMIT];
924 };
925
926 struct nfs41_exchange_id_res {
927         struct nfs_client               *client;
928         u32                             flags;
929 };
930
931 struct nfs41_create_session_args {
932         struct nfs_client              *client;
933         uint32_t                        flags;
934         uint32_t                        cb_program;
935         struct nfs4_channel_attrs       fc_attrs;       /* Fore Channel */
936         struct nfs4_channel_attrs       bc_attrs;       /* Back Channel */
937 };
938
939 struct nfs41_create_session_res {
940         struct nfs_client              *client;
941 };
942
943 struct nfs41_reclaim_complete_args {
944         /* In the future extend to include curr_fh for use with migration */
945         unsigned char                   one_fs:1;
946         struct nfs4_sequence_args       seq_args;
947 };
948
949 struct nfs41_reclaim_complete_res {
950         struct nfs4_sequence_res        seq_res;
951 };
952 #endif /* CONFIG_NFS_V4_1 */
953
954 struct nfs_page;
955
956 #define NFS_PAGEVEC_SIZE        (8U)
957
958 struct nfs_read_data {
959         int                     flags;
960         struct rpc_task         task;
961         struct inode            *inode;
962         struct rpc_cred         *cred;
963         struct nfs_fattr        fattr;  /* fattr storage */
964         struct list_head        pages;  /* Coalesced read requests */
965         struct nfs_page         *req;   /* multi ops per nfs_page */
966         struct page             **pagevec;
967         unsigned int            npages; /* Max length of pagevec */
968         struct nfs_readargs args;
969         struct nfs_readres  res;
970 #ifdef CONFIG_NFS_V4
971         unsigned long           timestamp;      /* For lease renewal */
972 #endif
973         struct page             *page_array[NFS_PAGEVEC_SIZE];
974 };
975
976 struct nfs_write_data {
977         int                     flags;
978         struct rpc_task         task;
979         struct inode            *inode;
980         struct rpc_cred         *cred;
981         struct nfs_fattr        fattr;
982         struct nfs_writeverf    verf;
983         struct list_head        pages;          /* Coalesced requests we wish to flush */
984         struct nfs_page         *req;           /* multi ops per nfs_page */
985         struct page             **pagevec;
986         unsigned int            npages;         /* Max length of pagevec */
987         struct nfs_writeargs    args;           /* argument struct */
988         struct nfs_writeres     res;            /* result struct */
989 #ifdef CONFIG_NFS_V4
990         unsigned long           timestamp;      /* For lease renewal */
991 #endif
992         struct page             *page_array[NFS_PAGEVEC_SIZE];
993 };
994
995 struct nfs_access_entry;
996
997 /*
998  * RPC procedure vector for NFSv2/NFSv3 demuxing
999  */
1000 struct nfs_rpc_ops {
1001         u32     version;                /* Protocol version */
1002         const struct dentry_operations *dentry_ops;
1003         const struct inode_operations *dir_inode_ops;
1004         const struct inode_operations *file_inode_ops;
1005
1006         int     (*getroot) (struct nfs_server *, struct nfs_fh *,
1007                             struct nfs_fsinfo *);
1008         int     (*lookupfh)(struct nfs_server *, struct nfs_fh *,
1009                             struct qstr *, struct nfs_fh *,
1010                             struct nfs_fattr *);
1011         int     (*getattr) (struct nfs_server *, struct nfs_fh *,
1012                             struct nfs_fattr *);
1013         int     (*setattr) (struct dentry *, struct nfs_fattr *,
1014                             struct iattr *);
1015         int     (*lookup)  (struct inode *, struct qstr *,
1016                             struct nfs_fh *, struct nfs_fattr *);
1017         int     (*access)  (struct inode *, struct nfs_access_entry *);
1018         int     (*readlink)(struct inode *, struct page *, unsigned int,
1019                             unsigned int);
1020         int     (*create)  (struct inode *, struct dentry *,
1021                             struct iattr *, int, struct nameidata *);
1022         int     (*remove)  (struct inode *, struct qstr *);
1023         void    (*unlink_setup)  (struct rpc_message *, struct inode *dir);
1024         int     (*unlink_done) (struct rpc_task *, struct inode *);
1025         int     (*rename)  (struct inode *, struct qstr *,
1026                             struct inode *, struct qstr *);
1027         int     (*link)    (struct inode *, struct inode *, struct qstr *);
1028         int     (*symlink) (struct inode *, struct dentry *, struct page *,
1029                             unsigned int, struct iattr *);
1030         int     (*mkdir)   (struct inode *, struct dentry *, struct iattr *);
1031         int     (*rmdir)   (struct inode *, struct qstr *);
1032         int     (*readdir) (struct dentry *, struct rpc_cred *,
1033                             u64, struct page *, unsigned int, int);
1034         int     (*mknod)   (struct inode *, struct dentry *, struct iattr *,
1035                             dev_t);
1036         int     (*statfs)  (struct nfs_server *, struct nfs_fh *,
1037                             struct nfs_fsstat *);
1038         int     (*fsinfo)  (struct nfs_server *, struct nfs_fh *,
1039                             struct nfs_fsinfo *);
1040         int     (*pathconf) (struct nfs_server *, struct nfs_fh *,
1041                              struct nfs_pathconf *);
1042         int     (*set_capabilities)(struct nfs_server *, struct nfs_fh *);
1043         __be32 *(*decode_dirent)(__be32 *, struct nfs_entry *, int plus);
1044         void    (*read_setup)   (struct nfs_read_data *, struct rpc_message *);
1045         int     (*read_done)  (struct rpc_task *, struct nfs_read_data *);
1046         void    (*write_setup)  (struct nfs_write_data *, struct rpc_message *);
1047         int     (*write_done)  (struct rpc_task *, struct nfs_write_data *);
1048         void    (*commit_setup) (struct nfs_write_data *, struct rpc_message *);
1049         int     (*commit_done) (struct rpc_task *, struct nfs_write_data *);
1050         int     (*lock)(struct file *, int, struct file_lock *);
1051         int     (*lock_check_bounds)(const struct file_lock *);
1052         void    (*clear_acl_cache)(struct inode *);
1053         void    (*close_context)(struct nfs_open_context *ctx, int);
1054 };
1055
1056 /*
1057  *      NFS_CALL(getattr, inode, (fattr));
1058  * into
1059  *      NFS_PROTO(inode)->getattr(fattr);
1060  */
1061 #define NFS_CALL(op, inode, args)       NFS_PROTO(inode)->op args
1062
1063 /*
1064  * Function vectors etc. for the NFS client
1065  */
1066 extern const struct nfs_rpc_ops nfs_v2_clientops;
1067 extern const struct nfs_rpc_ops nfs_v3_clientops;
1068 extern const struct nfs_rpc_ops nfs_v4_clientops;
1069 extern struct rpc_version       nfs_version2;
1070 extern struct rpc_version       nfs_version3;
1071 extern struct rpc_version       nfs_version4;
1072
1073 extern struct rpc_version       nfsacl_version3;
1074 extern struct rpc_program       nfsacl_program;
1075
1076 #endif