3 * Coda: an Experimental Distributed File System
6 * Copyright (c) 1987-1998 Carnegie Mellon University
9 * Permission to use, copy, modify and distribute this software and its
10 * documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation, and
14 * that credit is given to Carnegie Mellon University in all documents
15 * and publicity pertaining to direct or indirect use of this code or its
18 * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
19 * SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. CARNEGIE MELLON ALLOWS
20 * FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION. CARNEGIE MELLON
21 * DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER
22 * RESULTING DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
23 * ANY DERIVATIVE WORK.
25 * Carnegie Mellon encourages users of this software to return any
26 * improvements or extensions that they make, and to grant Carnegie
27 * Mellon the rights to redistribute these changes without encumbrance.
29 * @(#) src/sys/coda/coda.h,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
30 * $FreeBSD: src/sys/coda/coda.h,v 1.9 1999/12/29 04:54:30 peter Exp $
31 * $DragonFly: src/sys/vfs/coda/Attic/coda.h,v 1.2 2003/06/17 04:28:19 dillon Exp $
38 * Based on cfs.h from Mach, but revamped for increased simplicity.
39 * Linux modifications by Peter Braam, Aug 1996
47 /* Catch new _KERNEL defn for NetBSD */
49 #include <sys/types.h>
52 #ifndef CODA_MAXSYMLINKS
53 #define CODA_MAXSYMLINKS 10
56 #if defined(DJGPP) || defined(__CYGWIN32__)
58 typedef unsigned long u_long;
59 typedef unsigned int u_int;
60 typedef unsigned short u_short;
63 typedef void * caddr_t;
65 typedef unsigned __int64 u_quad_t;
67 typedef unsigned long long u_quad_t;
76 #else /* DJGPP but not _KERNEL */
77 #include <sys/types.h>
79 typedef unsigned long long u_quad_t;
84 #if defined(__linux__)
85 #define cdev_t u_quad_t
86 #if !defined(_UQUAD_T_) && (!defined(__GLIBC__) || __GLIBC__ < 2)
88 typedef unsigned long long u_quad_t;
95 typedef unsigned char u_int8_t;
97 time_t tv_sec; /* seconds */
98 long tv_nsec; /* nanoseconds */
106 #define CODA_MAXNAMLEN 255
107 #define CODA_MAXPATHLEN 1024
108 #define CODA_MAXSYMLINK 10
110 /* these are Coda's version of O_RDONLY etc combinations
111 * to deal with VFS open modes
113 #define C_O_READ 0x001
114 #define C_O_WRITE 0x002
115 #define C_O_TRUNC 0x010
116 #define C_O_EXCL 0x100
117 #define C_O_CREAT 0x200
119 /* these are to find mode bits in Venus */
120 #define C_M_READ 00400
121 #define C_M_WRITE 00200
123 /* for access Venus will use */
124 #define C_A_C_OK 8 /* Test for writing upon create. */
125 #define C_A_R_OK 4 /* Test for read permission. */
126 #define C_A_W_OK 2 /* Test for write permission. */
127 #define C_A_X_OK 1 /* Test for execute permission. */
128 #define C_A_F_OK 0 /* Test for existence. */
132 #ifndef _VENUS_DIRENT_T_
133 #define _VENUS_DIRENT_T_ 1
134 struct venus_dirent {
135 unsigned long d_fileno; /* file number of entry */
136 unsigned short d_reclen; /* length of this record */
137 char d_type; /* file type, see below */
138 char d_namlen; /* length of string in d_name */
139 char d_name[CODA_MAXNAMLEN + 1];/* name must be no longer than this */
142 #define DIRSIZ(dp) ((sizeof (struct venus_dirent) - (CODA_MAXNAMLEN+1)) + \
143 (((dp)->d_namlen+1 + 3) &~ 3))
148 #define CDT_UNKNOWN 0
159 * Convert between stat structure types and directory types.
161 #define IFTOCDT(mode) (((mode) & 0170000) >> 12)
162 #define CDTTOIF(dirtype) ((dirtype) << 12)
168 typedef u_long VolumeId;
169 typedef u_long VnodeId;
170 typedef u_long Unique_t;
171 typedef u_long FileVersion;
175 #define _VICEFID_T_ 1
176 typedef struct ViceFid {
185 static __inline__ ino_t coda_f2i(struct ViceFid *fid)
189 if (fid->Vnode == 0xfffffffe || fid->Vnode == 0xffffffff)
190 return ((fid->Volume << 20) | (fid->Unique & 0xfffff));
192 return (fid->Unique + (fid->Vnode<<10) + (fid->Volume<<20));
196 #define coda_f2i(fid)\
197 ((fid) ? ((fid)->Unique + ((fid)->Vnode<<10) + ((fid)->Volume<<20)) : 0)
201 #ifndef __BIT_TYPES_DEFINED__
202 #define u_int32_t unsigned int
208 typedef u_int32_t vuid_t;
209 typedef u_int32_t vgid_t;
215 vuid_t cr_uid, cr_euid, cr_suid, cr_fsuid; /* Real, efftve, set, fs uid*/
216 vgid_t cr_groupid, cr_egid, cr_sgid, cr_fsgid; /* same for groups */
220 #ifndef _VENUS_VATTR_T_
221 #define _VENUS_VATTR_T_
223 * Vnode types. VNON means no type.
225 enum coda_vtype { C_VNON, C_VREG, C_VDIR, C_VBLK, C_VCHR, C_VLNK, C_VSOCK, C_VFIFO, C_VBAD };
228 int va_type; /* vnode type (for create) */
229 u_short va_mode; /* files access mode and type */
230 short va_nlink; /* number of references to file */
231 vuid_t va_uid; /* owner user id */
232 vgid_t va_gid; /* owner group id */
233 long va_fileid; /* file id */
234 u_quad_t va_size; /* file size in bytes */
235 long va_blocksize; /* blocksize preferred for i/o */
236 struct timespec va_atime; /* time of last access */
237 struct timespec va_mtime; /* time of last modification */
238 struct timespec va_ctime; /* time file changed */
239 u_long va_gen; /* generation number of file */
240 u_long va_flags; /* flags defined for file */
241 cdev_t va_rdev; /* device special file represents */
242 u_quad_t va_bytes; /* bytes of disk space held by file */
243 u_quad_t va_filerev; /* file modification number */
249 * Kernel <--> Venus communications.
257 #define CODA_GETATTR 7
258 #define CODA_SETATTR 8
259 #define CODA_ACCESS 9
260 #define CODA_LOOKUP 10
261 #define CODA_CREATE 11
262 #define CODA_REMOVE 12
264 #define CODA_RENAME 14
265 #define CODA_MKDIR 15
266 #define CODA_RMDIR 16
267 #define CODA_READDIR 17
268 #define CODA_SYMLINK 18
269 #define CODA_READLINK 19
270 #define CODA_FSYNC 20
271 #define CODA_INACTIVE 21
273 #define CODA_SIGNAL 23
274 #define CODA_REPLACE 24
275 #define CODA_FLUSH 25
276 #define CODA_PURGEUSER 26
277 #define CODA_ZAPFILE 27
278 #define CODA_ZAPDIR 28
279 #define CODA_PURGEFID 30
280 #define CODA_OPEN_BY_PATH 31
281 #define CODA_RESOLVE 32
282 #define CODA_REINTEGRATE 33
283 #define CODA_NCALLS 34
285 #define DOWNCALL(opcode) (opcode >= CODA_REPLACE && opcode <= CODA_PURGEFID)
287 #define VC_MAXDATASIZE 8192
288 #define VC_MAXMSGSIZE sizeof(union inputArgs)+sizeof(union outputArgs) +\
291 #define CIOC_KERNEL_VERSION _IOWR('c', 10, sizeof (int))
293 /* don't care about kernel version number */
294 #define CODA_KERNEL_VERSION 0
295 /* The old venus 4.6 compatible interface */
296 #define CODA_KERNEL_VERSION 1
298 /* venus_lookup gets an extra parameter to aid windows.*/
299 #define CODA_KERNEL_VERSION 2
302 * Venus <-> Coda RPC arguments
305 unsigned long opcode;
306 unsigned long unique; /* Keep multiple outstanding msgs distinct */
307 u_short pid; /* Common to all */
308 u_short pgid; /* Common to all */
309 u_short sid; /* Common to all */
310 struct coda_cred cred; /* Common to all */
313 /* Really important that opcode and unique are 1st two fields! */
314 struct coda_out_hdr {
315 unsigned long opcode;
316 unsigned long unique;
317 unsigned long result;
320 /* coda_root: NO_IN */
321 struct coda_root_out {
322 struct coda_out_hdr oh;
326 struct coda_root_in {
327 struct coda_in_hdr in;
331 /* Nothing needed for coda_sync */
334 struct coda_open_in {
335 struct coda_in_hdr ih;
340 struct coda_open_out {
341 struct coda_out_hdr oh;
348 struct coda_close_in {
349 struct coda_in_hdr ih;
354 struct coda_close_out {
355 struct coda_out_hdr out;
359 struct coda_ioctl_in {
360 struct coda_in_hdr ih;
365 char *data; /* Place holder for data. */
368 struct coda_ioctl_out {
369 struct coda_out_hdr oh;
371 caddr_t data; /* Place holder for data. */
376 struct coda_getattr_in {
377 struct coda_in_hdr ih;
381 struct coda_getattr_out {
382 struct coda_out_hdr oh;
383 struct coda_vattr attr;
387 /* coda_setattr: NO_OUT */
388 struct coda_setattr_in {
389 struct coda_in_hdr ih;
391 struct coda_vattr attr;
394 struct coda_setattr_out {
395 struct coda_out_hdr out;
398 /* coda_access: NO_OUT */
399 struct coda_access_in {
400 struct coda_in_hdr ih;
405 struct coda_access_out {
406 struct coda_out_hdr out;
411 #define CLU_CASE_SENSITIVE 0x01
412 #define CLU_CASE_INSENSITIVE 0x02
415 struct coda_lookup_in {
416 struct coda_in_hdr ih;
418 int name; /* Place holder for data. */
422 struct coda_lookup_out {
423 struct coda_out_hdr oh;
430 struct coda_create_in {
431 struct coda_in_hdr ih;
433 struct coda_vattr attr;
436 int name; /* Place holder for data. */
439 struct coda_create_out {
440 struct coda_out_hdr oh;
442 struct coda_vattr attr;
446 /* coda_remove: NO_OUT */
447 struct coda_remove_in {
448 struct coda_in_hdr ih;
450 int name; /* Place holder for data. */
453 struct coda_remove_out {
454 struct coda_out_hdr out;
457 /* coda_link: NO_OUT */
458 struct coda_link_in {
459 struct coda_in_hdr ih;
460 ViceFid sourceFid; /* cnode to link *to* */
461 ViceFid destFid; /* Directory in which to place link */
462 int tname; /* Place holder for data. */
465 struct coda_link_out {
466 struct coda_out_hdr out;
470 /* coda_rename: NO_OUT */
471 struct coda_rename_in {
472 struct coda_in_hdr ih;
479 struct coda_rename_out {
480 struct coda_out_hdr out;
484 struct coda_mkdir_in {
485 struct coda_in_hdr ih;
487 struct coda_vattr attr;
488 int name; /* Place holder for data. */
491 struct coda_mkdir_out {
492 struct coda_out_hdr oh;
494 struct coda_vattr attr;
498 /* coda_rmdir: NO_OUT */
499 struct coda_rmdir_in {
500 struct coda_in_hdr ih;
502 int name; /* Place holder for data. */
505 struct coda_rmdir_out {
506 struct coda_out_hdr out;
510 struct coda_readdir_in {
511 struct coda_in_hdr ih;
517 struct coda_readdir_out {
518 struct coda_out_hdr oh;
520 caddr_t data; /* Place holder for data. */
523 /* coda_symlink: NO_OUT */
524 struct coda_symlink_in {
525 struct coda_in_hdr ih;
526 ViceFid VFid; /* Directory to put symlink in */
528 struct coda_vattr attr;
532 struct coda_symlink_out {
533 struct coda_out_hdr out;
537 struct coda_readlink_in {
538 struct coda_in_hdr ih;
542 struct coda_readlink_out {
543 struct coda_out_hdr oh;
545 caddr_t data; /* Place holder for data. */
549 /* coda_fsync: NO_OUT */
550 struct coda_fsync_in {
551 struct coda_in_hdr ih;
555 struct coda_fsync_out {
556 struct coda_out_hdr out;
559 /* coda_inactive: NO_OUT */
560 struct coda_inactive_in {
561 struct coda_in_hdr ih;
566 struct coda_vget_in {
567 struct coda_in_hdr ih;
571 struct coda_vget_out {
572 struct coda_out_hdr oh;
578 /* CODA_SIGNAL is out-of-band, doesn't need data. */
579 /* CODA_INVALIDATE is a venus->kernel call */
580 /* CODA_FLUSH is a venus->kernel call */
582 /* coda_purgeuser: */
583 /* CODA_PURGEUSER is a venus->kernel call */
584 struct coda_purgeuser_out {
585 struct coda_out_hdr oh;
586 struct coda_cred cred;
590 /* CODA_ZAPFILE is a venus->kernel call */
591 struct coda_zapfile_out {
592 struct coda_out_hdr oh;
597 /* CODA_ZAPDIR is a venus->kernel call */
598 struct coda_zapdir_out {
599 struct coda_out_hdr oh;
604 /* CODA_ZAPVNODE is a venus->kernel call */
605 struct coda_zapvnode_out {
606 struct coda_out_hdr oh;
607 struct coda_cred cred;
612 /* CODA_PURGEFID is a venus->kernel call */
613 struct coda_purgefid_out {
614 struct coda_out_hdr oh;
619 struct coda_rdwr_in {
620 struct coda_in_hdr ih;
626 caddr_t data; /* Place holder for data. */
629 struct coda_rdwr_out {
630 struct coda_out_hdr oh;
633 caddr_t data; /* Place holder for data. */
638 /* CODA_REPLACE is a venus->kernel call */
639 struct coda_replace_out { /* coda_replace is a venus->kernel call */
640 struct coda_out_hdr oh;
645 /* coda_open_by_path: */
646 struct coda_open_by_path_in {
647 struct coda_in_hdr ih;
652 struct coda_open_by_path_out {
653 struct coda_out_hdr oh;
658 * Occasionally, we don't cache the fid returned by CODA_LOOKUP.
659 * For instance, if the fid is inconsistent.
660 * This case is handled by setting the top bit of the type result parameter.
662 #define CODA_NOCACHE 0x80000000
665 struct coda_in_hdr ih; /* NB: every struct below begins with an ih */
666 struct coda_open_in coda_open;
667 struct coda_close_in coda_close;
668 struct coda_ioctl_in coda_ioctl;
669 struct coda_getattr_in coda_getattr;
670 struct coda_setattr_in coda_setattr;
671 struct coda_access_in coda_access;
672 struct coda_lookup_in coda_lookup;
673 struct coda_create_in coda_create;
674 struct coda_remove_in coda_remove;
675 struct coda_link_in coda_link;
676 struct coda_rename_in coda_rename;
677 struct coda_mkdir_in coda_mkdir;
678 struct coda_rmdir_in coda_rmdir;
679 struct coda_readdir_in coda_readdir;
680 struct coda_symlink_in coda_symlink;
681 struct coda_readlink_in coda_readlink;
682 struct coda_fsync_in coda_fsync;
683 struct coda_inactive_in coda_inactive;
684 struct coda_vget_in coda_vget;
685 struct coda_rdwr_in coda_rdwr;
686 struct coda_open_by_path_in coda_open_by_path;
690 struct coda_out_hdr oh; /* NB: every struct below begins with an oh */
691 struct coda_root_out coda_root;
692 struct coda_open_out coda_open;
693 struct coda_ioctl_out coda_ioctl;
694 struct coda_getattr_out coda_getattr;
695 struct coda_lookup_out coda_lookup;
696 struct coda_create_out coda_create;
697 struct coda_mkdir_out coda_mkdir;
698 struct coda_readdir_out coda_readdir;
699 struct coda_readlink_out coda_readlink;
700 struct coda_vget_out coda_vget;
701 struct coda_purgeuser_out coda_purgeuser;
702 struct coda_zapfile_out coda_zapfile;
703 struct coda_zapdir_out coda_zapdir;
704 struct coda_zapvnode_out coda_zapvnode;
705 struct coda_purgefid_out coda_purgefid;
706 struct coda_rdwr_out coda_rdwr;
707 struct coda_replace_out coda_replace;
708 struct coda_open_by_path_out coda_open_by_path;
711 union coda_downcalls {
712 /* CODA_INVALIDATE is a venus->kernel call */
713 /* CODA_FLUSH is a venus->kernel call */
714 struct coda_purgeuser_out purgeuser;
715 struct coda_zapfile_out zapfile;
716 struct coda_zapdir_out zapdir;
717 struct coda_zapvnode_out zapvnode;
718 struct coda_purgefid_out purgefid;
719 struct coda_replace_out replace;
724 * Used for identifying usage of "Control" and pioctls
727 #define PIOCPARM_MASK 0x0000ffff
729 caddr_t in, out; /* Data to be transferred in, or out */
730 short in_size; /* Size of input buffer <= 2K */
731 short out_size; /* Maximum size of output buffer, <= 2K */
734 #if defined(__CYGWIN32__) || defined(DJGPP)
749 #define CODA_CONTROL ".CONTROL"
750 #define CODA_CONTROLLEN 8
755 #define CTL_FILE "/coda/.CONTROL"
758 #define IS_CTL_FID(fidp) ((fidp)->Volume == CTL_VOL &&\
759 (fidp)->Vnode == CTL_VNO &&\
760 (fidp)->Unique == CTL_UNI)