ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / linux / nfs_xdr.h
1 #ifndef _LINUX_NFS_XDR_H
2 #define _LINUX_NFS_XDR_H
3
4 #include <linux/sunrpc/xprt.h>
5
6 struct nfs4_fsid {
7         __u64 major;
8         __u64 minor;
9 };
10
11 struct nfs_fattr {
12         unsigned short          valid;          /* which fields are valid */
13         __u64                   pre_size;       /* pre_op_attr.size       */
14         struct timespec         pre_mtime;      /* pre_op_attr.mtime      */
15         struct timespec         pre_ctime;      /* pre_op_attr.ctime      */
16         enum nfs_ftype          type;           /* always use NFSv2 types */
17         __u32                   mode;
18         __u32                   nlink;
19         __u32                   uid;
20         __u32                   gid;
21         __u64                   size;
22         union {
23                 struct {
24                         __u32   blocksize;
25                         __u32   blocks;
26                 } nfs2;
27                 struct {
28                         __u64   used;
29                 } nfs3;
30         } du;
31         dev_t                   rdev;
32         union {
33                 __u64           nfs3;           /* also nfs2 */
34                 struct nfs4_fsid nfs4;
35         } fsid_u;
36         __u64                   fileid;
37         struct timespec         atime;
38         struct timespec         mtime;
39         struct timespec         ctime;
40         __u32                   bitmap[2];      /* NFSv4 returned attribute bitmap */
41         __u64                   change_attr;    /* NFSv4 change attribute */
42         __u64                   pre_change_attr;/* pre-op NFSv4 change attribute */
43         unsigned long           timestamp;
44 };
45
46 #define NFS_ATTR_WCC            0x0001          /* pre-op WCC data    */
47 #define NFS_ATTR_FATTR          0x0002          /* post-op attributes */
48 #define NFS_ATTR_FATTR_V3       0x0004          /* NFSv3 attributes */
49 #define NFS_ATTR_FATTR_V4       0x0008
50 #define NFS_ATTR_PRE_CHANGE     0x0010
51
52 /*
53  * Info on the file system
54  */
55 struct nfs_fsinfo {
56         struct nfs_fattr        *fattr; /* Post-op attributes */
57         __u32                   rtmax;  /* max.  read transfer size */
58         __u32                   rtpref; /* pref. read transfer size */
59         __u32                   rtmult; /* reads should be multiple of this */
60         __u32                   wtmax;  /* max.  write transfer size */
61         __u32                   wtpref; /* pref. write transfer size */
62         __u32                   wtmult; /* writes should be multiple of this */
63         __u32                   dtpref; /* pref. readdir transfer size */
64         __u64                   maxfilesize;
65         __u32                   lease_time; /* in seconds */
66 };
67
68 struct nfs_fsstat {
69         struct nfs_fattr        *fattr; /* Post-op attributes */
70         __u64                   tbytes; /* total size in bytes */
71         __u64                   fbytes; /* # of free bytes */
72         __u64                   abytes; /* # of bytes available to user */
73         __u64                   tfiles; /* # of files */
74         __u64                   ffiles; /* # of free files */
75         __u64                   afiles; /* # of files available to user */
76 };
77
78 struct nfs2_fsstat {
79         __u32                   tsize;  /* Server transfer size */
80         __u32                   bsize;  /* Filesystem block size */
81         __u32                   blocks; /* No. of "bsize" blocks on filesystem */
82         __u32                   bfree;  /* No. of free "bsize" blocks */
83         __u32                   bavail; /* No. of available "bsize" blocks */
84 };
85
86 struct nfs_pathconf {
87         struct nfs_fattr        *fattr; /* Post-op attributes */
88         __u32                   max_link; /* max # of hard links */
89         __u32                   max_namelen; /* max name length */
90 };
91
92 struct nfs4_change_info {
93         u32                     atomic;
94         u64                     before;
95         u64                     after;
96 };
97
98 /*
99  * Arguments to the open call.
100  */
101 struct nfs_openargs {
102         struct nfs_fh *         fh;
103         __u32                   seqid;
104         __u32                   share_access;
105         __u64                   clientid;
106         __u32                   id;
107         __u32                   opentype;
108         __u32                   createmode;
109         union {
110                 struct iattr *  attrs;    /* UNCHECKED, GUARDED */
111                 nfs4_verifier   verifier; /* EXCLUSIVE */
112         } u;
113         const struct qstr *     name;
114         const struct nfs_server *server;         /* Needed for ID mapping */
115         const u32 *             bitmask;
116 };
117
118 struct nfs_openres {
119         nfs4_stateid            stateid;
120         struct nfs_fh           fh;
121         struct nfs4_change_info cinfo;
122         __u32                   rflags;
123         struct nfs_fattr *      f_attr;
124         const struct nfs_server *server;
125 };
126
127 /*
128  * Arguments to the open_confirm call.
129  */
130 struct nfs_open_confirmargs {
131         struct nfs_fh *         fh;
132         nfs4_stateid            stateid;
133         __u32                   seqid;
134 };
135
136 struct nfs_open_confirmres {
137         nfs4_stateid            stateid;
138 };
139
140 /*
141  * Arguments to the open_reclaim call.
142  */
143 struct nfs_open_reclaimargs {
144         struct nfs_fh *         fh;
145         __u64                   clientid;
146         __u32                   seqid;
147         __u32                   id;
148         __u32                   share_access;
149         __u32                   claim;
150         const __u32 *           bitmask;
151 };
152
153 /*
154  * Arguments to the close call.
155  */
156 struct nfs_closeargs {
157         struct nfs_fh *         fh;
158         nfs4_stateid            stateid;
159         __u32                   seqid;
160         __u32                   share_access;
161 };
162
163 struct nfs_closeres {
164         nfs4_stateid            stateid;
165 };
166 /*
167  *  * Arguments to the lock,lockt, and locku call.
168  *   */
169 struct nfs_lowner {
170         __u64           clientid;
171         u32                     id;
172 };
173
174 struct nfs_open_to_lock {
175         __u32                   open_seqid;
176         nfs4_stateid            open_stateid;
177         __u32                   lock_seqid;
178         struct nfs_lowner       lock_owner;
179 };
180
181 struct nfs_exist_lock {
182         nfs4_stateid            stateid;
183         __u32                   seqid;
184 };
185
186 struct nfs_lock_opargs {
187         __u32                   reclaim;
188         __u32                   new_lock_owner;
189         union {
190                 struct nfs_open_to_lock *open_lock;
191                 struct nfs_exist_lock   *exist_lock;
192         } u;
193 };
194
195 struct nfs_locku_opargs {
196         __u32                   seqid;
197         nfs4_stateid            stateid;
198 };
199
200 struct nfs_lockargs {
201         struct nfs_fh *         fh;
202         __u32                   type;
203         __u64                   offset; 
204         __u64                   length; 
205         union {
206                 struct nfs_lock_opargs  *lock;    /* LOCK  */
207                 struct nfs_lowner       *lockt;  /* LOCKT */
208                 struct nfs_locku_opargs *locku;  /* LOCKU */
209         } u;
210 };
211
212 struct nfs_lock_denied {
213         __u64                   offset;
214         __u64                   length;
215         __u32                   type;
216         struct nfs_lowner       owner;
217 };
218
219 struct nfs_lockres {
220         union {
221                 nfs4_stateid            stateid;/* LOCK success, LOCKU */
222                 struct nfs_lock_denied  denied; /* LOCK failed, LOCKT success */
223         } u;
224         const struct nfs_server *       server;
225 };
226
227 /*
228  * Arguments to the read call.
229  */
230
231 #define NFS_READ_MAXIOV         (9U)
232 #if (NFS_READ_MAXIOV > (MAX_IOVEC -2))
233 #error "NFS_READ_MAXIOV is too large"
234 #endif
235
236 struct nfs_readargs {
237         struct nfs_fh *         fh;
238         fl_owner_t              lockowner;
239         struct nfs4_state *     state;
240         __u64                   offset;
241         __u32                   count;
242         unsigned int            pgbase;
243         struct page **          pages;
244 };
245
246 struct nfs_readres {
247         struct nfs_fattr *      fattr;
248         __u32                   count;
249         int                     eof;
250 };
251
252 /*
253  * Arguments to the write call.
254  */
255 #define NFS_WRITE_MAXIOV        (9U)
256 #if (NFS_WRITE_MAXIOV > (MAX_IOVEC -2))
257 #error "NFS_WRITE_MAXIOV is too large"
258 #endif
259
260 struct nfs_writeargs {
261         struct nfs_fh *         fh;
262         fl_owner_t              lockowner;
263         struct nfs4_state *     state;
264         __u64                   offset;
265         __u32                   count;
266         enum nfs3_stable_how    stable;
267         unsigned int            pgbase;
268         struct page **          pages;
269 };
270
271 struct nfs_writeverf {
272         enum nfs3_stable_how    committed;
273         __u32                   verifier[2];
274 };
275
276 struct nfs_writeres {
277         struct nfs_fattr *      fattr;
278         struct nfs_writeverf *  verf;
279         __u32                   count;
280 };
281
282 /*
283  * Argument struct for decode_entry function
284  */
285 struct nfs_entry {
286         __u64                   ino;
287         __u64                   cookie,
288                                 prev_cookie;
289         const char *            name;
290         unsigned int            len;
291         int                     eof;
292         struct nfs_fh *         fh;
293         struct nfs_fattr *      fattr;
294 };
295
296 /*
297  * The following types are for NFSv2 only.
298  */
299 struct nfs_sattrargs {
300         struct nfs_fh *         fh;
301         struct iattr *          sattr;
302 };
303
304 struct nfs_diropargs {
305         struct nfs_fh *         fh;
306         const char *            name;
307         unsigned int            len;
308 };
309
310 struct nfs_createargs {
311         struct nfs_fh *         fh;
312         const char *            name;
313         unsigned int            len;
314         struct iattr *          sattr;
315 };
316
317 struct nfs_renameargs {
318         struct nfs_fh *         fromfh;
319         const char *            fromname;
320         unsigned int            fromlen;
321         struct nfs_fh *         tofh;
322         const char *            toname;
323         unsigned int            tolen;
324 };
325
326 struct nfs_setattrargs {
327         struct nfs_fh *                 fh;
328         nfs4_stateid                    stateid;
329         struct iattr *                  iap;
330         const struct nfs_server *       server; /* Needed for name mapping */
331         const u32 *                     bitmask;
332 };
333
334 struct nfs_setattrres {
335         struct nfs_fattr *              fattr;
336         const struct nfs_server *       server;
337 };
338
339 struct nfs_linkargs {
340         struct nfs_fh *         fromfh;
341         struct nfs_fh *         tofh;
342         const char *            toname;
343         unsigned int            tolen;
344 };
345
346 struct nfs_symlinkargs {
347         struct nfs_fh *         fromfh;
348         const char *            fromname;
349         unsigned int            fromlen;
350         const char *            topath;
351         unsigned int            tolen;
352         struct iattr *          sattr;
353 };
354
355 struct nfs_readdirargs {
356         struct nfs_fh *         fh;
357         __u32                   cookie;
358         unsigned int            count;
359         struct page **          pages;
360 };
361
362 struct nfs_diropok {
363         struct nfs_fh *         fh;
364         struct nfs_fattr *      fattr;
365 };
366
367 struct nfs_readlinkargs {
368         struct nfs_fh *         fh;
369         unsigned int            count;
370         struct page **          pages;
371 };
372
373 struct nfs3_sattrargs {
374         struct nfs_fh *         fh;
375         struct iattr *          sattr;
376         unsigned int            guard;
377         struct timespec         guardtime;
378 };
379
380 struct nfs3_diropargs {
381         struct nfs_fh *         fh;
382         const char *            name;
383         unsigned int            len;
384 };
385
386 struct nfs3_accessargs {
387         struct nfs_fh *         fh;
388         __u32                   access;
389 };
390
391 struct nfs3_createargs {
392         struct nfs_fh *         fh;
393         const char *            name;
394         unsigned int            len;
395         struct iattr *          sattr;
396         enum nfs3_createmode    createmode;
397         __u32                   verifier[2];
398 };
399
400 struct nfs3_mkdirargs {
401         struct nfs_fh *         fh;
402         const char *            name;
403         unsigned int            len;
404         struct iattr *          sattr;
405 };
406
407 struct nfs3_symlinkargs {
408         struct nfs_fh *         fromfh;
409         const char *            fromname;
410         unsigned int            fromlen;
411         const char *            topath;
412         unsigned int            tolen;
413         struct iattr *          sattr;
414 };
415
416 struct nfs3_mknodargs {
417         struct nfs_fh *         fh;
418         const char *            name;
419         unsigned int            len;
420         enum nfs3_ftype         type;
421         struct iattr *          sattr;
422         dev_t                   rdev;
423 };
424
425 struct nfs3_renameargs {
426         struct nfs_fh *         fromfh;
427         const char *            fromname;
428         unsigned int            fromlen;
429         struct nfs_fh *         tofh;
430         const char *            toname;
431         unsigned int            tolen;
432 };
433
434 struct nfs3_linkargs {
435         struct nfs_fh *         fromfh;
436         struct nfs_fh *         tofh;
437         const char *            toname;
438         unsigned int            tolen;
439 };
440
441 struct nfs3_readdirargs {
442         struct nfs_fh *         fh;
443         __u64                   cookie;
444         __u32                   verf[2];
445         int                     plus;
446         unsigned int            count;
447         struct page **          pages;
448 };
449
450 struct nfs3_diropres {
451         struct nfs_fattr *      dir_attr;
452         struct nfs_fh *         fh;
453         struct nfs_fattr *      fattr;
454 };
455
456 struct nfs3_accessres {
457         struct nfs_fattr *      fattr;
458         __u32                   access;
459 };
460
461 struct nfs3_readlinkargs {
462         struct nfs_fh *         fh;
463         unsigned int            count;
464         struct page **          pages;
465 };
466
467 struct nfs3_renameres {
468         struct nfs_fattr *      fromattr;
469         struct nfs_fattr *      toattr;
470 };
471
472 struct nfs3_linkres {
473         struct nfs_fattr *      dir_attr;
474         struct nfs_fattr *      fattr;
475 };
476
477 struct nfs3_readdirres {
478         struct nfs_fattr *      dir_attr;
479         __u32 *                 verf;
480         int                     plus;
481 };
482
483 #ifdef CONFIG_NFS_V4
484
485 typedef u64 clientid4;
486
487 struct nfs4_accessargs {
488         const struct nfs_fh *           fh;
489         u32                             access;
490 };
491
492 struct nfs4_accessres {
493         u32                             supported;
494         u32                             access;
495 };
496
497 struct nfs4_create_arg {
498         u32                             ftype;
499         union {
500                 struct qstr *           symlink;    /* NF4LNK */
501                 struct {
502                         u32             specdata1;
503                         u32             specdata2;
504                 } device;    /* NF4BLK, NF4CHR */
505         } u;
506         const struct qstr *             name;
507         const struct nfs_server *       server;
508         const struct iattr *            attrs;
509         const struct nfs_fh *           dir_fh;
510         const u32 *                     bitmask;
511 };
512
513 struct nfs4_create_res {
514         const struct nfs_server *       server;
515         struct nfs_fh *                 fh;
516         struct nfs_fattr *              fattr;
517         struct nfs4_change_info         dir_cinfo;
518 };
519
520 struct nfs4_fsinfo_arg {
521         const struct nfs_fh *           fh;
522         const u32 *                     bitmask;
523 };
524
525 struct nfs4_getattr_arg {
526         const struct nfs_fh *           fh;
527         const u32 *                     bitmask;
528 };
529
530 struct nfs4_getattr_res {
531         const struct nfs_server *       server;
532         struct nfs_fattr *              fattr;
533 };
534
535 struct nfs4_link_arg {
536         const struct nfs_fh *           fh;
537         const struct nfs_fh *           dir_fh;
538         const struct qstr *             name;
539 };
540
541 struct nfs4_lookup_arg {
542         const struct nfs_fh *           dir_fh;
543         const struct qstr *             name;
544         const u32 *                     bitmask;
545 };
546
547 struct nfs4_lookup_res {
548         const struct nfs_server *       server;
549         struct nfs_fattr *              fattr;
550         struct nfs_fh *                 fh;
551 };
552
553 struct nfs4_lookup_root_arg {
554         const u32 *                     bitmask;
555 };
556
557 struct nfs4_pathconf_arg {
558         const struct nfs_fh *           fh;
559         const u32 *                     bitmask;
560 };
561
562 struct nfs4_readdir_arg {
563         const struct nfs_fh *           fh;
564         u64                             cookie;
565         nfs4_verifier                   verifier;
566         u32                             count;
567         struct page **                  pages;  /* zero-copy data */
568         unsigned int                    pgbase; /* zero-copy data */
569 };
570
571 struct nfs4_readdir_res {
572         nfs4_verifier                   verifier;
573         unsigned int                    pgbase;
574 };
575
576 struct nfs4_readlink {
577         const struct nfs_fh *           fh;
578         u32                             count;   /* zero-copy data */
579         struct page **                  pages;   /* zero-copy data */
580 };
581
582 struct nfs4_remove_arg {
583         const struct nfs_fh *           fh;
584         const struct qstr *             name;
585 };
586
587 struct nfs4_rename_arg {
588         const struct nfs_fh *           old_dir;
589         const struct nfs_fh *           new_dir;
590         const struct qstr *             old_name;
591         const struct qstr *             new_name;
592 };
593
594 struct nfs4_rename_res {
595         struct nfs4_change_info         old_cinfo;
596         struct nfs4_change_info         new_cinfo;
597 };
598
599 struct nfs4_setclientid {
600         nfs4_verifier                   sc_verifier;      /* request */
601         char *                          sc_name;          /* request */
602         u32                             sc_prog;          /* request */
603         char                            sc_netid[4];      /* request */
604         char                            sc_uaddr[24];     /* request */
605         u32                             sc_cb_ident;      /* request */
606         struct nfs4_client *            sc_state;         /* response */
607 };
608
609 struct nfs4_statfs_arg {
610         const struct nfs_fh *           fh;
611         const u32 *                     bitmask;
612 };
613
614 struct nfs4_server_caps_res {
615         u32                             attr_bitmask[2];
616         u32                             acl_bitmask;
617         u32                             has_links;
618         u32                             has_symlinks;
619 };
620
621 #endif /* CONFIG_NFS_V4 */
622
623 struct nfs_page;
624
625 struct nfs_read_data {
626         int                     flags;
627         struct rpc_task         task;
628         struct inode            *inode;
629         struct rpc_cred         *cred;
630         struct nfs_fattr        fattr;  /* fattr storage */
631         struct list_head        pages;  /* Coalesced read requests */
632         struct nfs_page         *req;   /* multi ops per nfs_page */
633         struct page             *pagevec[NFS_READ_MAXIOV];
634         struct nfs_readargs args;
635         struct nfs_readres  res;
636 #ifdef CONFIG_NFS_V4
637         unsigned long           timestamp;      /* For lease renewal */
638 #endif
639         void (*complete) (struct nfs_read_data *, int);
640 };
641
642 struct nfs_write_data {
643         int                     flags;
644         struct rpc_task         task;
645         struct inode            *inode;
646         struct rpc_cred         *cred;
647         struct nfs_fattr        fattr;
648         struct nfs_writeverf    verf;
649         struct list_head        pages;          /* Coalesced requests we wish to flush */
650         struct nfs_page         *req;           /* multi ops per nfs_page */
651         struct page             *pagevec[NFS_WRITE_MAXIOV];
652         struct nfs_writeargs    args;           /* argument struct */
653         struct nfs_writeres     res;            /* result struct */
654 #ifdef CONFIG_NFS_V4
655         unsigned long           timestamp;      /* For lease renewal */
656 #endif
657         void (*complete) (struct nfs_write_data *, int);
658 };
659
660 /*
661  * RPC procedure vector for NFSv2/NFSv3 demuxing
662  */
663 struct nfs_rpc_ops {
664         int     version;                /* Protocol version */
665         struct dentry_operations *dentry_ops;
666         struct inode_operations *dir_inode_ops;
667
668         int     (*getroot) (struct nfs_server *, struct nfs_fh *,
669                             struct nfs_fsinfo *);
670         int     (*getattr) (struct inode *, struct nfs_fattr *);
671         int     (*setattr) (struct dentry *, struct nfs_fattr *,
672                             struct iattr *);
673         int     (*lookup)  (struct inode *, struct qstr *,
674                             struct nfs_fh *, struct nfs_fattr *);
675         int     (*access)  (struct inode *, struct rpc_cred *, int);
676         int     (*readlink)(struct inode *, struct page *);
677         int     (*read)    (struct nfs_read_data *, struct file *);
678         int     (*write)   (struct nfs_write_data *, struct file *);
679         int     (*commit)  (struct nfs_write_data *, struct file *);
680         struct inode *  (*create)  (struct inode *, struct qstr *,
681                             struct iattr *, int);
682         int     (*remove)  (struct inode *, struct qstr *);
683         int     (*unlink_setup)  (struct rpc_message *,
684                             struct dentry *, struct qstr *);
685         int     (*unlink_done) (struct dentry *, struct rpc_task *);
686         int     (*rename)  (struct inode *, struct qstr *,
687                             struct inode *, struct qstr *);
688         int     (*link)    (struct inode *, struct inode *, struct qstr *);
689         int     (*symlink) (struct inode *, struct qstr *, struct qstr *,
690                             struct iattr *, struct nfs_fh *,
691                             struct nfs_fattr *);
692         int     (*mkdir)   (struct inode *, struct qstr *, struct iattr *,
693                             struct nfs_fh *, struct nfs_fattr *);
694         int     (*rmdir)   (struct inode *, struct qstr *);
695         int     (*readdir) (struct dentry *, struct rpc_cred *,
696                             u64, struct page *, unsigned int, int);
697         int     (*mknod)   (struct inode *, struct qstr *, struct iattr *,
698                             dev_t, struct nfs_fh *, struct nfs_fattr *);
699         int     (*statfs)  (struct nfs_server *, struct nfs_fh *,
700                             struct nfs_fsstat *);
701         int     (*fsinfo)  (struct nfs_server *, struct nfs_fh *,
702                             struct nfs_fsinfo *);
703         int     (*pathconf) (struct nfs_server *, struct nfs_fh *,
704                              struct nfs_pathconf *);
705         u32 *   (*decode_dirent)(u32 *, struct nfs_entry *, int plus);
706         void    (*read_setup)   (struct nfs_read_data *);
707         void    (*write_setup)  (struct nfs_write_data *, int how);
708         void    (*commit_setup) (struct nfs_write_data *, int how);
709         int     (*file_open)   (struct inode *, struct file *);
710         int     (*file_release) (struct inode *, struct file *);
711         void    (*request_init)(struct nfs_page *, struct file *);
712         int     (*request_compatible)(struct nfs_page *, struct file *, struct page *);
713         int     (*lock)(struct file *, int, struct file_lock *);
714 };
715
716 /*
717  *      NFS_CALL(getattr, inode, (fattr));
718  * into
719  *      NFS_PROTO(inode)->getattr(fattr);
720  */
721 #define NFS_CALL(op, inode, args)       NFS_PROTO(inode)->op args
722
723 /*
724  * Function vectors etc. for the NFS client
725  */
726 extern struct nfs_rpc_ops       nfs_v2_clientops;
727 extern struct nfs_rpc_ops       nfs_v3_clientops;
728 extern struct nfs_rpc_ops       nfs_v4_clientops;
729 extern struct rpc_version       nfs_version2;
730 extern struct rpc_version       nfs_version3;
731 extern struct rpc_version       nfs_version4;
732 extern struct rpc_program       nfs_program;
733 extern struct rpc_stat          nfs_rpcstat;
734
735 #endif