Automatic merge of rsync://rsync.kernel.org/pub/scm/linux/kernel/git/gregkh/driver...
[linux-2.6/verdex.git] / include / linux / nfs_xdr.h
blob47037d9521cb04e5fdac5d76a03eb8892089a57f
1 #ifndef _LINUX_NFS_XDR_H
2 #define _LINUX_NFS_XDR_H
4 #include <linux/sunrpc/xprt.h>
6 struct nfs4_fsid {
7 __u64 major;
8 __u64 minor;
9 };
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;
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
53 * Info on the file system
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 */
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 */
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 */
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 */
92 struct nfs4_change_info {
93 u32 atomic;
94 u64 before;
95 u64 after;
99 * Arguments to the open call.
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;
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;
133 * Arguments to the open_confirm call.
135 struct nfs_open_confirmargs {
136 const struct nfs_fh * fh;
137 nfs4_stateid stateid;
138 __u32 seqid;
141 struct nfs_open_confirmres {
142 nfs4_stateid stateid;
146 * Arguments to the close call.
148 struct nfs_closeargs {
149 struct nfs_fh * fh;
150 nfs4_stateid stateid;
151 __u32 seqid;
152 int open_flags;
155 struct nfs_closeres {
156 nfs4_stateid stateid;
159 * * Arguments to the lock,lockt, and locku call.
160 * */
161 struct nfs_lowner {
162 __u64 clientid;
163 u32 id;
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;
173 struct nfs_exist_lock {
174 nfs4_stateid stateid;
175 __u32 seqid;
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;
187 struct nfs_locku_opargs {
188 __u32 seqid;
189 nfs4_stateid stateid;
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;
204 struct nfs_lock_denied {
205 __u64 offset;
206 __u64 length;
207 __u32 type;
208 struct nfs_lowner owner;
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;
219 struct nfs4_delegreturnargs {
220 const struct nfs_fh *fhandle;
221 const nfs4_stateid *stateid;
225 * Arguments to the read call.
228 #define NFS_READ_MAXIOV (9U)
229 #if (NFS_READ_MAXIOV > (MAX_IOVEC -2))
230 #error "NFS_READ_MAXIOV is too large"
231 #endif
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;
242 struct nfs_readres {
243 struct nfs_fattr * fattr;
244 __u32 count;
245 int eof;
249 * Arguments to the write call.
251 #define NFS_WRITE_MAXIOV (9U)
252 #if (NFS_WRITE_MAXIOV > (MAX_IOVEC -2))
253 #error "NFS_WRITE_MAXIOV is too large"
254 #endif
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;
266 struct nfs_writeverf {
267 enum nfs3_stable_how committed;
268 __u32 verifier[2];
271 struct nfs_writeres {
272 struct nfs_fattr * fattr;
273 struct nfs_writeverf * verf;
274 __u32 count;
278 * Argument struct for decode_entry function
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;
292 * The following types are for NFSv2 only.
294 struct nfs_sattrargs {
295 struct nfs_fh * fh;
296 struct iattr * sattr;
299 struct nfs_diropargs {
300 struct nfs_fh * fh;
301 const char * name;
302 unsigned int len;
305 struct nfs_createargs {
306 struct nfs_fh * fh;
307 const char * name;
308 unsigned int len;
309 struct iattr * sattr;
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;
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;
329 struct nfs_setattrres {
330 struct nfs_fattr * fattr;
331 const struct nfs_server * server;
334 struct nfs_linkargs {
335 struct nfs_fh * fromfh;
336 struct nfs_fh * tofh;
337 const char * toname;
338 unsigned int tolen;
341 struct nfs_symlinkargs {
342 struct nfs_fh * fromfh;
343 const char * fromname;
344 unsigned int fromlen;
345 const char * topath;
346 unsigned int tolen;
347 struct iattr * sattr;
350 struct nfs_readdirargs {
351 struct nfs_fh * fh;
352 __u32 cookie;
353 unsigned int count;
354 struct page ** pages;
357 struct nfs_diropok {
358 struct nfs_fh * fh;
359 struct nfs_fattr * fattr;
362 struct nfs_readlinkargs {
363 struct nfs_fh * fh;
364 unsigned int pgbase;
365 unsigned int pglen;
366 struct page ** pages;
369 struct nfs3_sattrargs {
370 struct nfs_fh * fh;
371 struct iattr * sattr;
372 unsigned int guard;
373 struct timespec guardtime;
376 struct nfs3_diropargs {
377 struct nfs_fh * fh;
378 const char * name;
379 unsigned int len;
382 struct nfs3_accessargs {
383 struct nfs_fh * fh;
384 __u32 access;
387 struct nfs3_createargs {
388 struct nfs_fh * fh;
389 const char * name;
390 unsigned int len;
391 struct iattr * sattr;
392 enum nfs3_createmode createmode;
393 __u32 verifier[2];
396 struct nfs3_mkdirargs {
397 struct nfs_fh * fh;
398 const char * name;
399 unsigned int len;
400 struct iattr * sattr;
403 struct nfs3_symlinkargs {
404 struct nfs_fh * fromfh;
405 const char * fromname;
406 unsigned int fromlen;
407 const char * topath;
408 unsigned int tolen;
409 struct iattr * sattr;
412 struct nfs3_mknodargs {
413 struct nfs_fh * fh;
414 const char * name;
415 unsigned int len;
416 enum nfs3_ftype type;
417 struct iattr * sattr;
418 dev_t rdev;
421 struct nfs3_renameargs {
422 struct nfs_fh * fromfh;
423 const char * fromname;
424 unsigned int fromlen;
425 struct nfs_fh * tofh;
426 const char * toname;
427 unsigned int tolen;
430 struct nfs3_linkargs {
431 struct nfs_fh * fromfh;
432 struct nfs_fh * tofh;
433 const char * toname;
434 unsigned int tolen;
437 struct nfs3_readdirargs {
438 struct nfs_fh * fh;
439 __u64 cookie;
440 __u32 verf[2];
441 int plus;
442 unsigned int count;
443 struct page ** pages;
446 struct nfs3_diropres {
447 struct nfs_fattr * dir_attr;
448 struct nfs_fh * fh;
449 struct nfs_fattr * fattr;
452 struct nfs3_accessres {
453 struct nfs_fattr * fattr;
454 __u32 access;
457 struct nfs3_readlinkargs {
458 struct nfs_fh * fh;
459 unsigned int pgbase;
460 unsigned int pglen;
461 struct page ** pages;
464 struct nfs3_renameres {
465 struct nfs_fattr * fromattr;
466 struct nfs_fattr * toattr;
469 struct nfs3_linkres {
470 struct nfs_fattr * dir_attr;
471 struct nfs_fattr * fattr;
474 struct nfs3_readdirres {
475 struct nfs_fattr * dir_attr;
476 __u32 * verf;
477 int plus;
480 #ifdef CONFIG_NFS_V4
482 typedef u64 clientid4;
484 struct nfs4_accessargs {
485 const struct nfs_fh * fh;
486 u32 access;
489 struct nfs4_accessres {
490 u32 supported;
491 u32 access;
494 struct nfs4_create_arg {
495 u32 ftype;
496 union {
497 struct qstr * symlink; /* NF4LNK */
498 struct {
499 u32 specdata1;
500 u32 specdata2;
501 } device; /* NF4BLK, NF4CHR */
502 } u;
503 const struct qstr * name;
504 const struct nfs_server * server;
505 const struct iattr * attrs;
506 const struct nfs_fh * dir_fh;
507 const u32 * bitmask;
510 struct nfs4_create_res {
511 const struct nfs_server * server;
512 struct nfs_fh * fh;
513 struct nfs_fattr * fattr;
514 struct nfs4_change_info dir_cinfo;
517 struct nfs4_fsinfo_arg {
518 const struct nfs_fh * fh;
519 const u32 * bitmask;
522 struct nfs4_getattr_arg {
523 const struct nfs_fh * fh;
524 const u32 * bitmask;
527 struct nfs4_getattr_res {
528 const struct nfs_server * server;
529 struct nfs_fattr * fattr;
532 struct nfs4_link_arg {
533 const struct nfs_fh * fh;
534 const struct nfs_fh * dir_fh;
535 const struct qstr * name;
538 struct nfs4_lookup_arg {
539 const struct nfs_fh * dir_fh;
540 const struct qstr * name;
541 const u32 * bitmask;
544 struct nfs4_lookup_res {
545 const struct nfs_server * server;
546 struct nfs_fattr * fattr;
547 struct nfs_fh * fh;
550 struct nfs4_lookup_root_arg {
551 const u32 * bitmask;
554 struct nfs4_pathconf_arg {
555 const struct nfs_fh * fh;
556 const u32 * bitmask;
559 struct nfs4_readdir_arg {
560 const struct nfs_fh * fh;
561 u64 cookie;
562 nfs4_verifier verifier;
563 u32 count;
564 struct page ** pages; /* zero-copy data */
565 unsigned int pgbase; /* zero-copy data */
566 const u32 * bitmask;
569 struct nfs4_readdir_res {
570 nfs4_verifier verifier;
571 unsigned int pgbase;
574 struct nfs4_readlink {
575 const struct nfs_fh * fh;
576 unsigned int pgbase;
577 unsigned int pglen; /* zero-copy data */
578 struct page ** pages; /* zero-copy data */
581 struct nfs4_remove_arg {
582 const struct nfs_fh * fh;
583 const struct qstr * name;
586 struct nfs4_rename_arg {
587 const struct nfs_fh * old_dir;
588 const struct nfs_fh * new_dir;
589 const struct qstr * old_name;
590 const struct qstr * new_name;
593 struct nfs4_rename_res {
594 struct nfs4_change_info old_cinfo;
595 struct nfs4_change_info new_cinfo;
598 struct nfs4_setclientid {
599 const nfs4_verifier * sc_verifier; /* request */
600 unsigned int sc_name_len;
601 char sc_name[32]; /* request */
602 u32 sc_prog; /* request */
603 unsigned int sc_netid_len;
604 char sc_netid[4]; /* request */
605 unsigned int sc_uaddr_len;
606 char sc_uaddr[24]; /* request */
607 u32 sc_cb_ident; /* request */
610 struct nfs4_statfs_arg {
611 const struct nfs_fh * fh;
612 const u32 * bitmask;
615 struct nfs4_server_caps_res {
616 u32 attr_bitmask[2];
617 u32 acl_bitmask;
618 u32 has_links;
619 u32 has_symlinks;
622 #endif /* CONFIG_NFS_V4 */
624 struct nfs_page;
626 struct nfs_read_data {
627 int flags;
628 struct rpc_task task;
629 struct inode *inode;
630 struct rpc_cred *cred;
631 struct nfs_fattr fattr; /* fattr storage */
632 struct list_head pages; /* Coalesced read requests */
633 struct nfs_page *req; /* multi ops per nfs_page */
634 struct page *pagevec[NFS_READ_MAXIOV];
635 struct nfs_readargs args;
636 struct nfs_readres res;
637 #ifdef CONFIG_NFS_V4
638 unsigned long timestamp; /* For lease renewal */
639 #endif
640 void (*complete) (struct nfs_read_data *, int);
643 struct nfs_write_data {
644 int flags;
645 struct rpc_task task;
646 struct inode *inode;
647 struct rpc_cred *cred;
648 struct nfs_fattr fattr;
649 struct nfs_writeverf verf;
650 struct list_head pages; /* Coalesced requests we wish to flush */
651 struct nfs_page *req; /* multi ops per nfs_page */
652 struct page *pagevec[NFS_WRITE_MAXIOV];
653 struct nfs_writeargs args; /* argument struct */
654 struct nfs_writeres res; /* result struct */
655 #ifdef CONFIG_NFS_V4
656 unsigned long timestamp; /* For lease renewal */
657 #endif
658 void (*complete) (struct nfs_write_data *, int);
661 struct nfs_access_entry;
664 * RPC procedure vector for NFSv2/NFSv3 demuxing
666 struct nfs_rpc_ops {
667 int version; /* Protocol version */
668 struct dentry_operations *dentry_ops;
669 struct inode_operations *dir_inode_ops;
671 int (*getroot) (struct nfs_server *, struct nfs_fh *,
672 struct nfs_fsinfo *);
673 int (*getattr) (struct nfs_server *, struct nfs_fh *,
674 struct nfs_fattr *);
675 int (*setattr) (struct dentry *, struct nfs_fattr *,
676 struct iattr *);
677 int (*lookup) (struct inode *, struct qstr *,
678 struct nfs_fh *, struct nfs_fattr *);
679 int (*access) (struct inode *, struct nfs_access_entry *);
680 int (*readlink)(struct inode *, struct page *, unsigned int,
681 unsigned int);
682 int (*read) (struct nfs_read_data *);
683 int (*write) (struct nfs_write_data *);
684 int (*commit) (struct nfs_write_data *);
685 int (*create) (struct inode *, struct dentry *,
686 struct iattr *, int);
687 int (*remove) (struct inode *, struct qstr *);
688 int (*unlink_setup) (struct rpc_message *,
689 struct dentry *, struct qstr *);
690 int (*unlink_done) (struct dentry *, struct rpc_task *);
691 int (*rename) (struct inode *, struct qstr *,
692 struct inode *, struct qstr *);
693 int (*link) (struct inode *, struct inode *, struct qstr *);
694 int (*symlink) (struct inode *, struct qstr *, struct qstr *,
695 struct iattr *, struct nfs_fh *,
696 struct nfs_fattr *);
697 int (*mkdir) (struct inode *, struct dentry *, struct iattr *);
698 int (*rmdir) (struct inode *, struct qstr *);
699 int (*readdir) (struct dentry *, struct rpc_cred *,
700 u64, struct page *, unsigned int, int);
701 int (*mknod) (struct inode *, struct dentry *, struct iattr *,
702 dev_t);
703 int (*statfs) (struct nfs_server *, struct nfs_fh *,
704 struct nfs_fsstat *);
705 int (*fsinfo) (struct nfs_server *, struct nfs_fh *,
706 struct nfs_fsinfo *);
707 int (*pathconf) (struct nfs_server *, struct nfs_fh *,
708 struct nfs_pathconf *);
709 u32 * (*decode_dirent)(u32 *, struct nfs_entry *, int plus);
710 void (*read_setup) (struct nfs_read_data *);
711 void (*write_setup) (struct nfs_write_data *, int how);
712 void (*commit_setup) (struct nfs_write_data *, int how);
713 int (*file_open) (struct inode *, struct file *);
714 int (*file_release) (struct inode *, struct file *);
715 int (*lock)(struct file *, int, struct file_lock *);
719 * NFS_CALL(getattr, inode, (fattr));
720 * into
721 * NFS_PROTO(inode)->getattr(fattr);
723 #define NFS_CALL(op, inode, args) NFS_PROTO(inode)->op args
726 * Function vectors etc. for the NFS client
728 extern struct nfs_rpc_ops nfs_v2_clientops;
729 extern struct nfs_rpc_ops nfs_v3_clientops;
730 extern struct nfs_rpc_ops nfs_v4_clientops;
731 extern struct rpc_version nfs_version2;
732 extern struct rpc_version nfs_version3;
733 extern struct rpc_version nfs_version4;
735 #endif