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