Linux 2.2.0
[davej-history.git] / include / linux / coda.h
blobac3301c8a1cc6e74179ace3fd3f170b1ad6d517f
1 /*
2 You may distribute this file under either of the two licenses that
3 follow at your discretion.
4 */
6 /* BLURB lgpl
8 Coda File System
9 Release 5
11 Copyright (c) 1987-1999 Carnegie Mellon University
12 Additional copyrights listed below
14 This code is distributed "AS IS" without warranty of any kind under
15 the terms of the GNU Library General Public Licence Version 2, as
16 shown in the file LICENSE, or under the license shown below. The
17 technical and financial contributors to Coda are listed in the file
18 CREDITS.
20 Additional copyrights
25 Coda: an Experimental Distributed File System
26 Release 4.0
28 Copyright (c) 1987-1999 Carnegie Mellon University
29 All Rights Reserved
31 Permission to use, copy, modify and distribute this software and its
32 documentation is hereby granted, provided that both the copyright
33 notice and this permission notice appear in all copies of the
34 software, derivative works or modified versions, and any portions
35 thereof, and that both notices appear in supporting documentation, and
36 that credit is given to Carnegie Mellon University in all documents
37 and publicity pertaining to direct or indirect use of this code or its
38 derivatives.
40 CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
41 SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. CARNEGIE MELLON ALLOWS
42 FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION. CARNEGIE MELLON
43 DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER
44 RESULTING DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
45 ANY DERIVATIVE WORK.
47 Carnegie Mellon encourages users of this software to return any
48 improvements or extensions that they make, and to grant Carnegie
49 Mellon the rights to redistribute these changes without encumbrance.
54 * Based on cfs.h from Mach, but revamped for increased simplicity.
55 * Linux modifications by
56 * Peter Braam, Aug 1996
59 #ifndef _CODA_HEADER_
60 #define _CODA_HEADER_
64 /* Catch new _KERNEL defn for NetBSD */
65 #ifdef __NetBSD__
66 #include <sys/types.h>
67 #endif
69 #ifndef CODA_MAXSYMLINKS
70 #define CODA_MAXSYMLINKS 10
71 #endif
73 #if defined(DJGPP) || defined(__CYGWIN32__)
74 #ifdef KERNEL
75 typedef unsigned long u_long;
76 typedef unsigned int u_int;
77 typedef unsigned short u_short;
78 typedef u_long ino_t;
79 typedef u_long dev_t;
80 typedef void * caddr_t;
81 #ifdef DOS
82 typedef unsigned __int64 u_quad_t;
83 #else
84 typedef unsigned long long u_quad_t;
85 #endif
87 #define inline
89 struct timespec {
90 long ts_sec;
91 long ts_nsec;
93 #else /* DJGPP but not KERNEL */
94 #include <sys/types.h>
95 #include <sys/time.h>
96 typedef unsigned long long u_quad_t;
97 #endif /* !KERNEL */
98 #endif /* !DJGPP */
101 #if defined(__linux__)
102 #define cdev_t u_quad_t
103 #if !defined(_UQUAD_T_) && (!defined(__GLIBC__) || __GLIBC__ < 2)
104 #define _UQUAD_T_ 1
105 typedef unsigned long long u_quad_t;
106 #endif
107 #else
108 #define cdev_t dev_t
109 #endif
111 #ifdef __CYGWIN32__
112 typedef unsigned char u_int8_t;
113 struct timespec {
114 time_t tv_sec; /* seconds */
115 long tv_nsec; /* nanoseconds */
117 #endif
121 * Cfs constants
123 #define CODA_MAXNAMLEN 255
124 #define CODA_MAXPATHLEN 1024
125 #define CODA_MAXSYMLINK 10
127 /* these are Coda's version of O_RDONLY etc combinations
128 * to deal with VFS open modes
130 #define C_O_READ 0x001
131 #define C_O_WRITE 0x002
132 #define C_O_TRUNC 0x010
133 #define C_O_EXCL 0x100
134 #define C_O_CREAT 0x200
136 /* these are to find mode bits in Venus */
137 #define C_M_READ 00400
138 #define C_M_WRITE 00200
140 /* for access Venus will use */
141 #define C_A_C_OK 8 /* Test for writing upon create. */
142 #define C_A_R_OK 4 /* Test for read permission. */
143 #define C_A_W_OK 2 /* Test for write permission. */
144 #define C_A_X_OK 1 /* Test for execute permission. */
145 #define C_A_F_OK 0 /* Test for existence. */
149 #ifndef _VENUS_DIRENT_T_
150 #define _VENUS_DIRENT_T_ 1
151 struct venus_dirent {
152 unsigned long d_fileno; /* file number of entry */
153 unsigned short d_reclen; /* length of this record */
154 char d_type; /* file type, see below */
155 char d_namlen; /* length of string in d_name */
156 char d_name[CODA_MAXNAMLEN + 1];/* name must be no longer than this */
158 #undef DIRSIZ
159 #define DIRSIZ(dp) ((sizeof (struct venus_dirent) - (CODA_MAXNAMLEN+1)) + \
160 (((dp)->d_namlen+1 + 3) &~ 3))
163 * File types
165 #define CDT_UNKNOWN 0
166 #define CDT_FIFO 1
167 #define CDT_CHR 2
168 #define CDT_DIR 4
169 #define CDT_BLK 6
170 #define CDT_REG 8
171 #define CDT_LNK 10
172 #define CDT_SOCK 12
173 #define CDT_WHT 14
176 * Convert between stat structure types and directory types.
178 #define IFTOCDT(mode) (((mode) & 0170000) >> 12)
179 #define CDTTOIF(dirtype) ((dirtype) << 12)
181 #endif
183 #ifndef _FID_T_
184 #define _FID_T_ 1
185 typedef u_long VolumeId;
186 typedef u_long VnodeId;
187 typedef u_long Unique_t;
188 typedef u_long FileVersion;
189 #endif
191 #ifndef _VICEFID_T_
192 #define _VICEFID_T_ 1
193 typedef struct ViceFid {
194 VolumeId Volume;
195 VnodeId Vnode;
196 Unique_t Unique;
197 } ViceFid;
198 #endif /* VICEFID */
201 #ifdef __linux__
202 static __inline__ ino_t coda_f2i(struct ViceFid *fid)
204 if ( ! fid )
205 return 0;
206 if (fid->Vnode == 0xfffffffe || fid->Vnode == 0xffffffff)
207 return ((fid->Volume << 20) | (fid->Unique & 0xfffff));
208 else
209 return (fid->Unique + (fid->Vnode<<10) + (fid->Volume<<20));
212 #else
213 #define coda_f2i(fid)\
214 ((fid) ? ((fid)->Unique + ((fid)->Vnode<<10) + ((fid)->Volume<<20)) : 0)
215 #endif
218 #ifndef __BIT_TYPES_DEFINED__
219 #define u_int32_t unsigned int
220 #endif
223 #ifndef _VUID_T_
224 #define _VUID_T_
225 typedef u_int32_t vuid_t;
226 typedef u_int32_t vgid_t;
227 #endif /*_VUID_T_ */
229 #ifndef _CODACRED_T_
230 #define _CODACRED_T_
231 struct coda_cred {
232 vuid_t cr_uid, cr_euid, cr_suid, cr_fsuid;
233 vgid_t cr_groupid, cr_egid, cr_sgid, cr_fsgid;
234 #if defined(CODA_SUPPORTS_SUPPLEMENTARY_GROUPS)
235 int cr_nsupgps;
236 vgid_t cr_supgps[NGROUPS];
237 #endif /* defined(CODA_SUPPORTS_SUPPLEMENTARY_GROUPS) */
239 #endif
241 #ifndef _VENUS_VATTR_T_
242 #define _VENUS_VATTR_T_
244 * Vnode types. VNON means no type.
246 enum coda_vtype { C_VNON, C_VREG, C_VDIR, C_VBLK, C_VCHR, C_VLNK, C_VSOCK, C_VFIFO, C_VBAD };
248 struct coda_vattr {
249 int va_type; /* vnode type (for create) */
250 u_short va_mode; /* files access mode and type */
251 short va_nlink; /* number of references to file */
252 vuid_t va_uid; /* owner user id */
253 vgid_t va_gid; /* owner group id */
254 long va_fileid; /* file id */
255 u_quad_t va_size; /* file size in bytes */
256 long va_blocksize; /* blocksize preferred for i/o */
257 struct timespec va_atime; /* time of last access */
258 struct timespec va_mtime; /* time of last modification */
259 struct timespec va_ctime; /* time file changed */
260 u_long va_gen; /* generation number of file */
261 u_long va_flags; /* flags defined for file */
262 cdev_t va_rdev; /* device special file represents */
263 u_quad_t va_bytes; /* bytes of disk space held by file */
264 u_quad_t va_filerev; /* file modification number */
267 #endif
270 * Kernel <--> Venus communications.
273 #define CODA_ROOT 2
274 #define CODA_SYNC 3
275 #define CODA_OPEN 4
276 #define CODA_CLOSE 5
277 #define CODA_IOCTL 6
278 #define CODA_GETATTR 7
279 #define CODA_SETATTR 8
280 #define CODA_ACCESS 9
281 #define CODA_LOOKUP 10
282 #define CODA_CREATE 11
283 #define CODA_REMOVE 12
284 #define CODA_LINK 13
285 #define CODA_RENAME 14
286 #define CODA_MKDIR 15
287 #define CODA_RMDIR 16
288 #define CODA_READDIR 17
289 #define CODA_SYMLINK 18
290 #define CODA_READLINK 19
291 #define CODA_FSYNC 20
292 #define CODA_INACTIVE 21
293 #define CODA_VGET 22
294 #define CODA_SIGNAL 23
295 #define CODA_REPLACE 24
296 #define CODA_FLUSH 25
297 #define CODA_PURGEUSER 26
298 #define CODA_ZAPFILE 27
299 #define CODA_ZAPDIR 28
300 #define CODA_PURGEFID 30
301 #define CODA_OPEN_BY_PATH 31
302 #define CODA_RESOLVE 32
303 #define CODA_REINTEGRATE 33
304 #define CODA_NCALLS 34
306 #define DOWNCALL(opcode) (opcode >= CODA_REPLACE && opcode <= CODA_PURGEFID)
308 #define VC_MAXDATASIZE 8192
309 #define VC_MAXMSGSIZE sizeof(union inputArgs)+sizeof(union outputArgs) +\
310 VC_MAXDATASIZE
312 #define CIOC_KERNEL_VERSION _IOWR('c', 10, sizeof (int))
313 #if 0
314 /* don't care about kernel version number */
315 #define CODA_KERNEL_VERSION 0
316 /* The old venus 4.6 compatible interface */
317 #define CODA_KERNEL_VERSION 1
318 #endif
319 /* venus_lookup gets an extra parameter to aid windows.*/
320 #define CODA_KERNEL_VERSION 2
323 * Venus <-> Coda RPC arguments
325 struct coda_in_hdr {
326 unsigned long opcode;
327 unsigned long unique; /* Keep multiple outstanding msgs distinct */
328 u_short pid; /* Common to all */
329 u_short pgid; /* Common to all */
330 u_short sid; /* Common to all */
331 struct coda_cred cred; /* Common to all */
334 /* Really important that opcode and unique are 1st two fields! */
335 struct coda_out_hdr {
336 unsigned long opcode;
337 unsigned long unique;
338 unsigned long result;
341 /* coda_root: NO_IN */
342 struct coda_root_out {
343 struct coda_out_hdr oh;
344 ViceFid VFid;
347 struct coda_root_in {
348 struct coda_in_hdr in;
351 /* coda_sync: */
352 /* Nothing needed for coda_sync */
354 /* coda_open: */
355 struct coda_open_in {
356 struct coda_in_hdr ih;
357 ViceFid VFid;
358 int flags;
361 struct coda_open_out {
362 struct coda_out_hdr oh;
363 cdev_t dev;
364 ino_t inode;
368 /* coda_close: */
369 struct coda_close_in {
370 struct coda_in_hdr ih;
371 ViceFid VFid;
372 int flags;
375 struct coda_close_out {
376 struct coda_out_hdr out;
379 /* coda_ioctl: */
380 struct coda_ioctl_in {
381 struct coda_in_hdr ih;
382 ViceFid VFid;
383 int cmd;
384 int len;
385 int rwflag;
386 char *data; /* Place holder for data. */
389 struct coda_ioctl_out {
390 struct coda_out_hdr oh;
391 int len;
392 caddr_t data; /* Place holder for data. */
396 /* coda_getattr: */
397 struct coda_getattr_in {
398 struct coda_in_hdr ih;
399 ViceFid VFid;
402 struct coda_getattr_out {
403 struct coda_out_hdr oh;
404 struct coda_vattr attr;
408 /* coda_setattr: NO_OUT */
409 struct coda_setattr_in {
410 struct coda_in_hdr ih;
411 ViceFid VFid;
412 struct coda_vattr attr;
415 struct coda_setattr_out {
416 struct coda_out_hdr out;
419 /* coda_access: NO_OUT */
420 struct coda_access_in {
421 struct coda_in_hdr ih;
422 ViceFid VFid;
423 int flags;
426 struct coda_access_out {
427 struct coda_out_hdr out;
431 /* lookup flags */
432 #define CLU_CASE_SENSITIVE 0x01
433 #define CLU_CASE_INSENSITIVE 0x02
435 /* coda_lookup: */
436 struct coda_lookup_in {
437 struct coda_in_hdr ih;
438 ViceFid VFid;
439 int name; /* Place holder for data. */
440 int flags;
443 struct coda_lookup_out {
444 struct coda_out_hdr oh;
445 ViceFid VFid;
446 int vtype;
450 /* coda_create: */
451 struct coda_create_in {
452 struct coda_in_hdr ih;
453 ViceFid VFid;
454 struct coda_vattr attr;
455 int excl;
456 int mode;
457 int name; /* Place holder for data. */
460 struct coda_create_out {
461 struct coda_out_hdr oh;
462 ViceFid VFid;
463 struct coda_vattr attr;
467 /* coda_remove: NO_OUT */
468 struct coda_remove_in {
469 struct coda_in_hdr ih;
470 ViceFid VFid;
471 int name; /* Place holder for data. */
474 struct coda_remove_out {
475 struct coda_out_hdr out;
478 /* coda_link: NO_OUT */
479 struct coda_link_in {
480 struct coda_in_hdr ih;
481 ViceFid sourceFid; /* cnode to link *to* */
482 ViceFid destFid; /* Directory in which to place link */
483 int tname; /* Place holder for data. */
486 struct coda_link_out {
487 struct coda_out_hdr out;
491 /* coda_rename: NO_OUT */
492 struct coda_rename_in {
493 struct coda_in_hdr ih;
494 ViceFid sourceFid;
495 int srcname;
496 ViceFid destFid;
497 int destname;
500 struct coda_rename_out {
501 struct coda_out_hdr out;
504 /* coda_mkdir: */
505 struct coda_mkdir_in {
506 struct coda_in_hdr ih;
507 ViceFid VFid;
508 struct coda_vattr attr;
509 int name; /* Place holder for data. */
512 struct coda_mkdir_out {
513 struct coda_out_hdr oh;
514 ViceFid VFid;
515 struct coda_vattr attr;
519 /* coda_rmdir: NO_OUT */
520 struct coda_rmdir_in {
521 struct coda_in_hdr ih;
522 ViceFid VFid;
523 int name; /* Place holder for data. */
526 struct coda_rmdir_out {
527 struct coda_out_hdr out;
530 /* coda_readdir: */
531 struct coda_readdir_in {
532 struct coda_in_hdr ih;
533 ViceFid VFid;
534 int count;
535 int offset;
538 struct coda_readdir_out {
539 struct coda_out_hdr oh;
540 int size;
541 caddr_t data; /* Place holder for data. */
544 /* coda_symlink: NO_OUT */
545 struct coda_symlink_in {
546 struct coda_in_hdr ih;
547 ViceFid VFid; /* Directory to put symlink in */
548 int srcname;
549 struct coda_vattr attr;
550 int tname;
553 struct coda_symlink_out {
554 struct coda_out_hdr out;
557 /* coda_readlink: */
558 struct coda_readlink_in {
559 struct coda_in_hdr ih;
560 ViceFid VFid;
563 struct coda_readlink_out {
564 struct coda_out_hdr oh;
565 int count;
566 caddr_t data; /* Place holder for data. */
570 /* coda_fsync: NO_OUT */
571 struct coda_fsync_in {
572 struct coda_in_hdr ih;
573 ViceFid VFid;
576 struct coda_fsync_out {
577 struct coda_out_hdr out;
580 /* coda_inactive: NO_OUT */
581 struct coda_inactive_in {
582 struct coda_in_hdr ih;
583 ViceFid VFid;
586 /* coda_vget: */
587 struct coda_vget_in {
588 struct coda_in_hdr ih;
589 ViceFid VFid;
592 struct coda_vget_out {
593 struct coda_out_hdr oh;
594 ViceFid VFid;
595 int vtype;
599 /* CODA_SIGNAL is out-of-band, doesn't need data. */
600 /* CODA_INVALIDATE is a venus->kernel call */
601 /* CODA_FLUSH is a venus->kernel call */
603 /* coda_purgeuser: */
604 /* CODA_PURGEUSER is a venus->kernel call */
605 struct coda_purgeuser_out {
606 struct coda_out_hdr oh;
607 struct coda_cred cred;
610 /* coda_zapfile: */
611 /* CODA_ZAPFILE is a venus->kernel call */
612 struct coda_zapfile_out {
613 struct coda_out_hdr oh;
614 ViceFid CodaFid;
617 /* coda_zapdir: */
618 /* CODA_ZAPDIR is a venus->kernel call */
619 struct coda_zapdir_out {
620 struct coda_out_hdr oh;
621 ViceFid CodaFid;
624 /* coda_zapnode: */
625 /* CODA_ZAPVNODE is a venus->kernel call */
626 struct coda_zapvnode_out {
627 struct coda_out_hdr oh;
628 struct coda_cred cred;
629 ViceFid VFid;
632 /* coda_purgefid: */
633 /* CODA_PURGEFID is a venus->kernel call */
634 struct coda_purgefid_out {
635 struct coda_out_hdr oh;
636 ViceFid CodaFid;
639 /* coda_rdwr: */
640 struct coda_rdwr_in {
641 struct coda_in_hdr ih;
642 ViceFid VFid;
643 int rwflag;
644 int count;
645 int offset;
646 int ioflag;
647 caddr_t data; /* Place holder for data. */
650 struct coda_rdwr_out {
651 struct coda_out_hdr oh;
652 int rwflag;
653 int count;
654 caddr_t data; /* Place holder for data. */
658 /* coda_replace: */
659 /* CODA_REPLACE is a venus->kernel call */
660 struct coda_replace_out { /* coda_replace is a venus->kernel call */
661 struct coda_out_hdr oh;
662 ViceFid NewFid;
663 ViceFid OldFid;
666 /* coda_open_by_path: */
667 struct coda_open_by_path_in {
668 struct coda_in_hdr ih;
669 ViceFid VFid;
670 int flags;
673 struct coda_open_by_path_out {
674 struct coda_out_hdr oh;
675 int path;
679 * Occasionally, we don't cache the fid returned by CODA_LOOKUP.
680 * For instance, if the fid is inconsistent.
681 * This case is handled by setting the top bit of the type result parameter.
683 #define CODA_NOCACHE 0x80000000
685 union inputArgs {
686 struct coda_in_hdr ih; /* NB: every struct below begins with an ih */
687 struct coda_open_in coda_open;
688 struct coda_close_in coda_close;
689 struct coda_ioctl_in coda_ioctl;
690 struct coda_getattr_in coda_getattr;
691 struct coda_setattr_in coda_setattr;
692 struct coda_access_in coda_access;
693 struct coda_lookup_in coda_lookup;
694 struct coda_create_in coda_create;
695 struct coda_remove_in coda_remove;
696 struct coda_link_in coda_link;
697 struct coda_rename_in coda_rename;
698 struct coda_mkdir_in coda_mkdir;
699 struct coda_rmdir_in coda_rmdir;
700 struct coda_readdir_in coda_readdir;
701 struct coda_symlink_in coda_symlink;
702 struct coda_readlink_in coda_readlink;
703 struct coda_fsync_in coda_fsync;
704 struct coda_inactive_in coda_inactive;
705 struct coda_vget_in coda_vget;
706 struct coda_rdwr_in coda_rdwr;
707 struct coda_open_by_path_in coda_open_by_path;
710 union outputArgs {
711 struct coda_out_hdr oh; /* NB: every struct below begins with an oh */
712 struct coda_root_out coda_root;
713 struct coda_open_out coda_open;
714 struct coda_ioctl_out coda_ioctl;
715 struct coda_getattr_out coda_getattr;
716 struct coda_lookup_out coda_lookup;
717 struct coda_create_out coda_create;
718 struct coda_mkdir_out coda_mkdir;
719 struct coda_readdir_out coda_readdir;
720 struct coda_readlink_out coda_readlink;
721 struct coda_vget_out coda_vget;
722 struct coda_purgeuser_out coda_purgeuser;
723 struct coda_zapfile_out coda_zapfile;
724 struct coda_zapdir_out coda_zapdir;
725 struct coda_zapvnode_out coda_zapvnode;
726 struct coda_purgefid_out coda_purgefid;
727 struct coda_rdwr_out coda_rdwr;
728 struct coda_replace_out coda_replace;
729 struct coda_open_by_path_out coda_open_by_path;
732 union coda_downcalls {
733 /* CODA_INVALIDATE is a venus->kernel call */
734 /* CODA_FLUSH is a venus->kernel call */
735 struct coda_purgeuser_out purgeuser;
736 struct coda_zapfile_out zapfile;
737 struct coda_zapdir_out zapdir;
738 struct coda_zapvnode_out zapvnode;
739 struct coda_purgefid_out purgefid;
740 struct coda_replace_out replace;
745 * Used for identifying usage of "Control" and pioctls
748 #define PIOCPARM_MASK 0x0000ffff
749 struct ViceIoctl {
750 caddr_t in, out; /* Data to be transferred in, or out */
751 short in_size; /* Size of input buffer <= 2K */
752 short out_size; /* Maximum size of output buffer, <= 2K */
755 #if defined(__CYGWIN32__) || defined(DJGPP)
756 struct PioctlData {
757 unsigned long cmd;
758 const char *path;
759 int follow;
760 struct ViceIoctl vi;
762 #else
763 struct PioctlData {
764 const char *path;
765 int follow;
766 struct ViceIoctl vi;
768 #endif
770 #define CODA_CONTROL ".CONTROL"
771 #define CODA_CONTROLLEN 8
772 #define CTL_VOL -1
773 #define CTL_VNO -1
774 #define CTL_UNI -1
775 #define CTL_INO -1
776 #define CTL_FILE "/coda/.CONTROL"
779 #define IS_CTL_FID(fidp) ((fidp)->Volume == CTL_VOL &&\
780 (fidp)->Vnode == CTL_VNO &&\
781 (fidp)->Unique == CTL_UNI)
782 #endif