[PATCH] NFSv4: Client-side xdr for reading NFSv4 acls
[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/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         const struct nfs_fh *   fh;
103         __u32                   seqid;
104         int                     open_flags;
105         __u64                   clientid;
106         __u32                   id;
107         union {
108                 struct iattr *  attrs;    /* UNCHECKED, GUARDED */
109                 nfs4_verifier   verifier; /* EXCLUSIVE */
110                 nfs4_stateid    delegation;             /* CLAIM_DELEGATE_CUR */
111                 int             delegation_type;        /* CLAIM_PREVIOUS */
112         } u;
113         const struct qstr *     name;
114         const struct nfs_server *server;         /* Needed for ID mapping */
115         const u32 *             bitmask;
116         __u32                   claim;
117 };
118
119 struct nfs_openres {
120         nfs4_stateid            stateid;
121         struct nfs_fh           fh;
122         struct nfs4_change_info cinfo;
123         __u32                   rflags;
124         struct nfs_fattr *      f_attr;
125         const struct nfs_server *server;
126         int                     delegation_type;
127         nfs4_stateid            delegation;
128         __u32                   do_recall;
129         __u64                   maxsize;
130 };
131
132 /*
133  * Arguments to the open_confirm call.
134  */
135 struct nfs_open_confirmargs {
136         const struct nfs_fh *   fh;
137         nfs4_stateid            stateid;
138         __u32                   seqid;
139 };
140
141 struct nfs_open_confirmres {
142         nfs4_stateid            stateid;
143 };
144
145 /*
146  * Arguments to the close call.
147  */
148 struct nfs_closeargs {
149         struct nfs_fh *         fh;
150         nfs4_stateid            stateid;
151         __u32                   seqid;
152         int                     open_flags;
153 };
154
155 struct nfs_closeres {
156         nfs4_stateid            stateid;
157 };
158 /*
159  *  * Arguments to the lock,lockt, and locku call.
160  *   */
161 struct nfs_lowner {
162         __u64           clientid;
163         u32                     id;
164 };
165
166 struct nfs_open_to_lock {
167         __u32                   open_seqid;
168         nfs4_stateid            open_stateid;
169         __u32                   lock_seqid;
170         struct nfs_lowner       lock_owner;
171 };
172
173 struct nfs_exist_lock {
174         nfs4_stateid            stateid;
175         __u32                   seqid;
176 };
177
178 struct nfs_lock_opargs {
179         __u32                   reclaim;
180         __u32                   new_lock_owner;
181         union {
182                 struct nfs_open_to_lock *open_lock;
183                 struct nfs_exist_lock   *exist_lock;
184         } u;
185 };
186
187 struct nfs_locku_opargs {
188         __u32                   seqid;
189         nfs4_stateid            stateid;
190 };
191
192 struct nfs_lockargs {
193         struct nfs_fh *         fh;
194         __u32                   type;
195         __u64                   offset; 
196         __u64                   length; 
197         union {
198                 struct nfs_lock_opargs  *lock;    /* LOCK  */
199                 struct nfs_lowner       *lockt;  /* LOCKT */
200                 struct nfs_locku_opargs *locku;  /* LOCKU */
201         } u;
202 };
203
204 struct nfs_lock_denied {
205         __u64                   offset;
206         __u64                   length;
207         __u32                   type;
208         struct nfs_lowner       owner;
209 };
210
211 struct nfs_lockres {
212         union {
213                 nfs4_stateid            stateid;/* LOCK success, LOCKU */
214                 struct nfs_lock_denied  denied; /* LOCK failed, LOCKT success */
215         } u;
216         const struct nfs_server *       server;
217 };
218
219 struct nfs4_delegreturnargs {
220         const struct nfs_fh *fhandle;
221         const nfs4_stateid *stateid;
222 };
223
224 /*
225  * Arguments to the read call.
226  */
227
228 #define NFS_READ_MAXIOV         (9U)
229 #if (NFS_READ_MAXIOV > (MAX_IOVEC -2))
230 #error "NFS_READ_MAXIOV is too large"
231 #endif
232
233 struct nfs_readargs {
234         struct nfs_fh *         fh;
235         struct nfs_open_context *context;
236         __u64                   offset;
237         __u32                   count;
238         unsigned int            pgbase;
239         struct page **          pages;
240 };
241
242 struct nfs_readres {
243         struct nfs_fattr *      fattr;
244         __u32                   count;
245         int                     eof;
246 };
247
248 /*
249  * Arguments to the write call.
250  */
251 #define NFS_WRITE_MAXIOV        (9U)
252 #if (NFS_WRITE_MAXIOV > (MAX_IOVEC -2))
253 #error "NFS_WRITE_MAXIOV is too large"
254 #endif
255
256 struct nfs_writeargs {
257         struct nfs_fh *         fh;
258         struct nfs_open_context *context;
259         __u64                   offset;
260         __u32                   count;
261         enum nfs3_stable_how    stable;
262         unsigned int            pgbase;
263         struct page **          pages;
264 };
265
266 struct nfs_writeverf {
267         enum nfs3_stable_how    committed;
268         __u32                   verifier[2];
269 };
270
271 struct nfs_writeres {
272         struct nfs_fattr *      fattr;
273         struct nfs_writeverf *  verf;
274         __u32                   count;
275 };
276
277 /*
278  * Argument struct for decode_entry function
279  */
280 struct nfs_entry {
281         __u64                   ino;
282         __u64                   cookie,
283                                 prev_cookie;
284         const char *            name;
285         unsigned int            len;
286         int                     eof;
287         struct nfs_fh *         fh;
288         struct nfs_fattr *      fattr;
289 };
290
291 /*
292  * The following types are for NFSv2 only.
293  */
294 struct nfs_sattrargs {
295         struct nfs_fh *         fh;
296         struct iattr *          sattr;
297 };
298
299 struct nfs_diropargs {
300         struct nfs_fh *         fh;
301         const char *            name;
302         unsigned int            len;
303 };
304
305 struct nfs_createargs {
306         struct nfs_fh *         fh;
307         const char *            name;
308         unsigned int            len;
309         struct iattr *          sattr;
310 };
311
312 struct nfs_renameargs {
313         struct nfs_fh *         fromfh;
314         const char *            fromname;
315         unsigned int            fromlen;
316         struct nfs_fh *         tofh;
317         const char *            toname;
318         unsigned int            tolen;
319 };
320
321 struct nfs_setattrargs {
322         struct nfs_fh *                 fh;
323         nfs4_stateid                    stateid;
324         struct iattr *                  iap;
325         const struct nfs_server *       server; /* Needed for name mapping */
326         const u32 *                     bitmask;
327 };
328
329 struct nfs_getaclargs {
330         struct nfs_fh *                 fh;
331         size_t                          acl_len;
332         unsigned int                    acl_pgbase;
333         struct page **                  acl_pages;
334 };
335
336 struct nfs_setattrres {
337         struct nfs_fattr *              fattr;
338         const struct nfs_server *       server;
339 };
340
341 struct nfs_linkargs {
342         struct nfs_fh *         fromfh;
343         struct nfs_fh *         tofh;
344         const char *            toname;
345         unsigned int            tolen;
346 };
347
348 struct nfs_symlinkargs {
349         struct nfs_fh *         fromfh;
350         const char *            fromname;
351         unsigned int            fromlen;
352         const char *            topath;
353         unsigned int            tolen;
354         struct iattr *          sattr;
355 };
356
357 struct nfs_readdirargs {
358         struct nfs_fh *         fh;
359         __u32                   cookie;
360         unsigned int            count;
361         struct page **          pages;
362 };
363
364 struct nfs_diropok {
365         struct nfs_fh *         fh;
366         struct nfs_fattr *      fattr;
367 };
368
369 struct nfs_readlinkargs {
370         struct nfs_fh *         fh;
371         unsigned int            pgbase;
372         unsigned int            pglen;
373         struct page **          pages;
374 };
375
376 struct nfs3_sattrargs {
377         struct nfs_fh *         fh;
378         struct iattr *          sattr;
379         unsigned int            guard;
380         struct timespec         guardtime;
381 };
382
383 struct nfs3_diropargs {
384         struct nfs_fh *         fh;
385         const char *            name;
386         unsigned int            len;
387 };
388
389 struct nfs3_accessargs {
390         struct nfs_fh *         fh;
391         __u32                   access;
392 };
393
394 struct nfs3_createargs {
395         struct nfs_fh *         fh;
396         const char *            name;
397         unsigned int            len;
398         struct iattr *          sattr;
399         enum nfs3_createmode    createmode;
400         __u32                   verifier[2];
401 };
402
403 struct nfs3_mkdirargs {
404         struct nfs_fh *         fh;
405         const char *            name;
406         unsigned int            len;
407         struct iattr *          sattr;
408 };
409
410 struct nfs3_symlinkargs {
411         struct nfs_fh *         fromfh;
412         const char *            fromname;
413         unsigned int            fromlen;
414         const char *            topath;
415         unsigned int            tolen;
416         struct iattr *          sattr;
417 };
418
419 struct nfs3_mknodargs {
420         struct nfs_fh *         fh;
421         const char *            name;
422         unsigned int            len;
423         enum nfs3_ftype         type;
424         struct iattr *          sattr;
425         dev_t                   rdev;
426 };
427
428 struct nfs3_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 nfs3_linkargs {
438         struct nfs_fh *         fromfh;
439         struct nfs_fh *         tofh;
440         const char *            toname;
441         unsigned int            tolen;
442 };
443
444 struct nfs3_readdirargs {
445         struct nfs_fh *         fh;
446         __u64                   cookie;
447         __u32                   verf[2];
448         int                     plus;
449         unsigned int            count;
450         struct page **          pages;
451 };
452
453 struct nfs3_diropres {
454         struct nfs_fattr *      dir_attr;
455         struct nfs_fh *         fh;
456         struct nfs_fattr *      fattr;
457 };
458
459 struct nfs3_accessres {
460         struct nfs_fattr *      fattr;
461         __u32                   access;
462 };
463
464 struct nfs3_readlinkargs {
465         struct nfs_fh *         fh;
466         unsigned int            pgbase;
467         unsigned int            pglen;
468         struct page **          pages;
469 };
470
471 struct nfs3_renameres {
472         struct nfs_fattr *      fromattr;
473         struct nfs_fattr *      toattr;
474 };
475
476 struct nfs3_linkres {
477         struct nfs_fattr *      dir_attr;
478         struct nfs_fattr *      fattr;
479 };
480
481 struct nfs3_readdirres {
482         struct nfs_fattr *      dir_attr;
483         __u32 *                 verf;
484         int                     plus;
485 };
486
487 #ifdef CONFIG_NFS_V4
488
489 typedef u64 clientid4;
490
491 struct nfs4_accessargs {
492         const struct nfs_fh *           fh;
493         u32                             access;
494 };
495
496 struct nfs4_accessres {
497         u32                             supported;
498         u32                             access;
499 };
500
501 struct nfs4_create_arg {
502         u32                             ftype;
503         union {
504                 struct qstr *           symlink;    /* NF4LNK */
505                 struct {
506                         u32             specdata1;
507                         u32             specdata2;
508                 } device;    /* NF4BLK, NF4CHR */
509         } u;
510         const struct qstr *             name;
511         const struct nfs_server *       server;
512         const struct iattr *            attrs;
513         const struct nfs_fh *           dir_fh;
514         const u32 *                     bitmask;
515 };
516
517 struct nfs4_create_res {
518         const struct nfs_server *       server;
519         struct nfs_fh *                 fh;
520         struct nfs_fattr *              fattr;
521         struct nfs4_change_info         dir_cinfo;
522 };
523
524 struct nfs4_fsinfo_arg {
525         const struct nfs_fh *           fh;
526         const u32 *                     bitmask;
527 };
528
529 struct nfs4_getattr_arg {
530         const struct nfs_fh *           fh;
531         const u32 *                     bitmask;
532 };
533
534 struct nfs4_getattr_res {
535         const struct nfs_server *       server;
536         struct nfs_fattr *              fattr;
537 };
538
539 struct nfs4_link_arg {
540         const struct nfs_fh *           fh;
541         const struct nfs_fh *           dir_fh;
542         const struct qstr *             name;
543 };
544
545 struct nfs4_lookup_arg {
546         const struct nfs_fh *           dir_fh;
547         const struct qstr *             name;
548         const u32 *                     bitmask;
549 };
550
551 struct nfs4_lookup_res {
552         const struct nfs_server *       server;
553         struct nfs_fattr *              fattr;
554         struct nfs_fh *                 fh;
555 };
556
557 struct nfs4_lookup_root_arg {
558         const u32 *                     bitmask;
559 };
560
561 struct nfs4_pathconf_arg {
562         const struct nfs_fh *           fh;
563         const u32 *                     bitmask;
564 };
565
566 struct nfs4_readdir_arg {
567         const struct nfs_fh *           fh;
568         u64                             cookie;
569         nfs4_verifier                   verifier;
570         u32                             count;
571         struct page **                  pages;  /* zero-copy data */
572         unsigned int                    pgbase; /* zero-copy data */
573         const u32 *                     bitmask;
574 };
575
576 struct nfs4_readdir_res {
577         nfs4_verifier                   verifier;
578         unsigned int                    pgbase;
579 };
580
581 struct nfs4_readlink {
582         const struct nfs_fh *           fh;
583         unsigned int                    pgbase;
584         unsigned int                    pglen;   /* zero-copy data */
585         struct page **                  pages;   /* zero-copy data */
586 };
587
588 struct nfs4_remove_arg {
589         const struct nfs_fh *           fh;
590         const struct qstr *             name;
591 };
592
593 struct nfs4_rename_arg {
594         const struct nfs_fh *           old_dir;
595         const struct nfs_fh *           new_dir;
596         const struct qstr *             old_name;
597         const struct qstr *             new_name;
598 };
599
600 struct nfs4_rename_res {
601         struct nfs4_change_info         old_cinfo;
602         struct nfs4_change_info         new_cinfo;
603 };
604
605 struct nfs4_setclientid {
606         const nfs4_verifier *           sc_verifier;      /* request */
607         unsigned int                    sc_name_len;
608         char                            sc_name[32];      /* request */
609         u32                             sc_prog;          /* request */
610         unsigned int                    sc_netid_len;
611         char                            sc_netid[4];      /* request */
612         unsigned int                    sc_uaddr_len;
613         char                            sc_uaddr[24];     /* request */
614         u32                             sc_cb_ident;      /* request */
615 };
616
617 struct nfs4_statfs_arg {
618         const struct nfs_fh *           fh;
619         const u32 *                     bitmask;
620 };
621
622 struct nfs4_server_caps_res {
623         u32                             attr_bitmask[2];
624         u32                             acl_bitmask;
625         u32                             has_links;
626         u32                             has_symlinks;
627 };
628
629 #endif /* CONFIG_NFS_V4 */
630
631 struct nfs_page;
632
633 struct nfs_read_data {
634         int                     flags;
635         struct rpc_task         task;
636         struct inode            *inode;
637         struct rpc_cred         *cred;
638         struct nfs_fattr        fattr;  /* fattr storage */
639         struct list_head        pages;  /* Coalesced read requests */
640         struct nfs_page         *req;   /* multi ops per nfs_page */
641         struct page             *pagevec[NFS_READ_MAXIOV];
642         struct nfs_readargs args;
643         struct nfs_readres  res;
644 #ifdef CONFIG_NFS_V4
645         unsigned long           timestamp;      /* For lease renewal */
646 #endif
647         void (*complete) (struct nfs_read_data *, int);
648 };
649
650 struct nfs_write_data {
651         int                     flags;
652         struct rpc_task         task;
653         struct inode            *inode;
654         struct rpc_cred         *cred;
655         struct nfs_fattr        fattr;
656         struct nfs_writeverf    verf;
657         struct list_head        pages;          /* Coalesced requests we wish to flush */
658         struct nfs_page         *req;           /* multi ops per nfs_page */
659         struct page             *pagevec[NFS_WRITE_MAXIOV];
660         struct nfs_writeargs    args;           /* argument struct */
661         struct nfs_writeres     res;            /* result struct */
662 #ifdef CONFIG_NFS_V4
663         unsigned long           timestamp;      /* For lease renewal */
664 #endif
665         void (*complete) (struct nfs_write_data *, int);
666 };
667
668 struct nfs_access_entry;
669
670 /*
671  * RPC procedure vector for NFSv2/NFSv3 demuxing
672  */
673 struct nfs_rpc_ops {
674         int     version;                /* Protocol version */
675         struct dentry_operations *dentry_ops;
676         struct inode_operations *dir_inode_ops;
677         struct inode_operations *file_inode_ops;
678
679         int     (*getroot) (struct nfs_server *, struct nfs_fh *,
680                             struct nfs_fsinfo *);
681         int     (*getattr) (struct nfs_server *, struct nfs_fh *,
682                             struct nfs_fattr *);
683         int     (*setattr) (struct dentry *, struct nfs_fattr *,
684                             struct iattr *);
685         int     (*lookup)  (struct inode *, struct qstr *,
686                             struct nfs_fh *, struct nfs_fattr *);
687         int     (*access)  (struct inode *, struct nfs_access_entry *);
688         int     (*readlink)(struct inode *, struct page *, unsigned int,
689                             unsigned int);
690         int     (*read)    (struct nfs_read_data *);
691         int     (*write)   (struct nfs_write_data *);
692         int     (*commit)  (struct nfs_write_data *);
693         int     (*create)  (struct inode *, struct dentry *,
694                             struct iattr *, int);
695         int     (*remove)  (struct inode *, struct qstr *);
696         int     (*unlink_setup)  (struct rpc_message *,
697                             struct dentry *, struct qstr *);
698         int     (*unlink_done) (struct dentry *, struct rpc_task *);
699         int     (*rename)  (struct inode *, struct qstr *,
700                             struct inode *, struct qstr *);
701         int     (*link)    (struct inode *, struct inode *, struct qstr *);
702         int     (*symlink) (struct inode *, struct qstr *, struct qstr *,
703                             struct iattr *, struct nfs_fh *,
704                             struct nfs_fattr *);
705         int     (*mkdir)   (struct inode *, struct dentry *, struct iattr *);
706         int     (*rmdir)   (struct inode *, struct qstr *);
707         int     (*readdir) (struct dentry *, struct rpc_cred *,
708                             u64, struct page *, unsigned int, int);
709         int     (*mknod)   (struct inode *, struct dentry *, struct iattr *,
710                             dev_t);
711         int     (*statfs)  (struct nfs_server *, struct nfs_fh *,
712                             struct nfs_fsstat *);
713         int     (*fsinfo)  (struct nfs_server *, struct nfs_fh *,
714                             struct nfs_fsinfo *);
715         int     (*pathconf) (struct nfs_server *, struct nfs_fh *,
716                              struct nfs_pathconf *);
717         u32 *   (*decode_dirent)(u32 *, struct nfs_entry *, int plus);
718         void    (*read_setup)   (struct nfs_read_data *);
719         void    (*write_setup)  (struct nfs_write_data *, int how);
720         void    (*commit_setup) (struct nfs_write_data *, int how);
721         int     (*file_open)   (struct inode *, struct file *);
722         int     (*file_release) (struct inode *, struct file *);
723         int     (*lock)(struct file *, int, struct file_lock *);
724         void    (*clear_acl_cache)(struct inode *);
725 };
726
727 /*
728  *      NFS_CALL(getattr, inode, (fattr));
729  * into
730  *      NFS_PROTO(inode)->getattr(fattr);
731  */
732 #define NFS_CALL(op, inode, args)       NFS_PROTO(inode)->op args
733
734 /*
735  * Function vectors etc. for the NFS client
736  */
737 extern struct nfs_rpc_ops       nfs_v2_clientops;
738 extern struct nfs_rpc_ops       nfs_v3_clientops;
739 extern struct nfs_rpc_ops       nfs_v4_clientops;
740 extern struct rpc_version       nfs_version2;
741 extern struct rpc_version       nfs_version3;
742 extern struct rpc_version       nfs_version4;
743
744 #endif