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 $
37 * Based on cfs.h from Mach, but revamped for increased simplicity.
38 * Linux modifications by Peter Braam, Aug 1996
44 #include "opt_coda.h" /* for CODA_COMPAT_5 option */
46 /* Avoid CODA_COMPAT_5 redefinition in coda5 module */
47 #if defined (CODA5_MODULE) && !defined(CODA_COMPAT_5)
51 /* Catch new _KERNEL defn for NetBSD */
53 #include <sys/types.h>
56 #ifndef CODA_MAXSYMLINKS
57 #define CODA_MAXSYMLINKS 10
60 #if defined(DJGPP) || defined(__CYGWIN32__)
62 typedef unsigned long u_long;
63 typedef unsigned int u_int;
64 typedef unsigned short u_short;
66 typedef u_long struct cdev *;
67 typedef void * caddr_t;
69 typedef unsigned __int64 u_quad_t;
71 typedef unsigned long long u_quad_t;
80 #else /* DJGPP but not _KERNEL */
81 #include <sys/types.h>
83 typedef unsigned long long u_quad_t;
88 #if defined(__linux__)
89 #define cdev_t u_quad_t
90 #if !defined(_UQUAD_T_) && (!defined(__GLIBC__) || __GLIBC__ < 2)
92 typedef unsigned long long u_quad_t;
99 typedef unsigned char u_int8_t;
101 time_t tv_sec; /* seconds */
102 long tv_nsec; /* nanoseconds */
110 #define CODA_MAXNAMLEN 255
111 #define CODA_MAXPATHLEN 1024
112 #define CODA_MAXSYMLINK 10
114 /* these are Coda's version of O_RDONLY etc combinations
115 * to deal with VFS open modes
117 #define C_O_READ 0x001
118 #define C_O_WRITE 0x002
119 #define C_O_TRUNC 0x010
120 #define C_O_EXCL 0x100
121 #define C_O_CREAT 0x200
123 /* these are to find mode bits in Venus */
124 #define C_M_READ 00400
125 #define C_M_WRITE 00200
127 /* for access Venus will use */
128 #define C_A_C_OK 8 /* Test for writing upon create. */
129 #define C_A_R_OK 4 /* Test for read permission. */
130 #define C_A_W_OK 2 /* Test for write permission. */
131 #define C_A_X_OK 1 /* Test for execute permission. */
132 #define C_A_F_OK 0 /* Test for existence. */
136 #ifndef _VENUS_DIRENT_T_
137 #define _VENUS_DIRENT_T_ 1
138 struct venus_dirent {
139 unsigned long d_fileno; /* file number of entry */
140 unsigned short d_reclen; /* length of this record */
141 char d_type; /* file type, see below */
142 char d_namlen; /* length of string in d_name */
143 char d_name[CODA_MAXNAMLEN + 1];/* name must be no longer than this */
146 #define DIRSIZ(dp) ((sizeof (struct venus_dirent) - (CODA_MAXNAMLEN+1)) + \
147 (((dp)->d_namlen+1 + 3) &~ 3))
152 #define CDT_UNKNOWN 0
163 * Convert between stat structure types and directory types.
165 #define IFTOCDT(mode) (((mode) & 0170000) >> 12)
166 #define CDTTOIF(dirtype) ((dirtype) << 12)
178 static __inline__ ino_t coda_f2i(CodaFid *fid)
181 return (fid->Unique + (fid->Vnode<<10) + (fid->Volume<<20));
184 static __inline__ char * coda_f2s(CodaFid *fid)
186 static char fid_str [35];
187 snprintf (fid_str, 35, "[%lx.%lx.%lx]", fid->Volume,
188 fid->Vnode, fid->Unique);
192 static __inline__ int coda_fid_eq (CodaFid *fid1, CodaFid *fid2)
194 return (fid1->Volume == fid2->Volume &&
195 fid1->Vnode == fid2->Vnode &&
196 fid1->Unique == fid2->Unique);
200 u_int32_t cr_uid, cr_euid, cr_suid, cr_fsuid; /* Real, efftve, set, fs uid*/
201 u_int32_t cr_groupid, cr_egid, cr_sgid, cr_fsgid; /* same for groups */
204 #else /* CODA_COMPAT_5 */
210 static __inline__ ino_t coda_f2i(CodaFid *fid)
214 return (fid->opaque[3] ^ (fid->opaque[2]<<10) ^ (fid->opaque[1]<<20) ^ fid->opaque[0]);
217 static __inline__ char * coda_f2s(CodaFid *fid)
219 static char fid_str [35];
220 snprintf (fid_str, 35, "[%x.%x.%x.%x]", fid->opaque[0],
221 fid->opaque[1], fid->opaque[2], fid->opaque[3]);
225 static __inline__ int coda_fid_eq (CodaFid *fid1, CodaFid *fid2)
227 return (fid1->opaque[0] == fid2->opaque[0] &&
228 fid1->opaque[1] == fid2->opaque[1] &&
229 fid1->opaque[2] == fid2->opaque[2] &&
230 fid1->opaque[3] == fid2->opaque[3]);
233 #endif /* CODA_COMPAT_5 */
235 #ifndef _VENUS_VATTR_T_
236 #define _VENUS_VATTR_T_
238 * Vnode types. VNON means no type.
240 enum coda_vtype { C_VNON, C_VREG, C_VDIR, C_VBLK, C_VCHR, C_VLNK, C_VSOCK, C_VFIFO, C_VBAD };
243 int va_type; /* vnode type (for create) */
244 u_short va_mode; /* files access mode and type */
245 short va_nlink; /* number of references to file */
246 uid_t va_uid; /* owner user id */
247 gid_t va_gid; /* owner group id */
248 long va_fileid; /* file id */
249 u_quad_t va_size; /* file size in bytes */
250 long va_blocksize; /* blocksize preferred for i/o */
251 struct timespec va_atime; /* time of last access */
252 struct timespec va_mtime; /* time of last modification */
253 struct timespec va_ctime; /* time file changed */
254 u_long va_gen; /* generation number of file */
255 u_long va_flags; /* flags defined for file */
256 cdev_t va_rdev; /* device special file represents */
257 u_quad_t va_bytes; /* bytes of disk space held by file */
258 u_quad_t va_filerev; /* file modification number */
263 /* structure used by CODA_STATFS for getting cache information from venus */
273 * Kernel <--> Venus communications.
277 #define CODA_OPEN_BY_FD 3
281 #define CODA_GETATTR 7
282 #define CODA_SETATTR 8
283 #define CODA_ACCESS 9
284 #define CODA_LOOKUP 10
285 #define CODA_CREATE 11
286 #define CODA_REMOVE 12
288 #define CODA_RENAME 14
289 #define CODA_MKDIR 15
290 #define CODA_RMDIR 16
291 #define CODA_READDIR 17
292 #define CODA_SYMLINK 18
293 #define CODA_READLINK 19
294 #define CODA_FSYNC 20
295 #define CODA_INACTIVE 21
297 #define CODA_SIGNAL 23
298 #define CODA_REPLACE 24
299 #define CODA_FLUSH 25
300 #define CODA_PURGEUSER 26
301 #define CODA_ZAPFILE 27
302 #define CODA_ZAPDIR 28
303 #define CODA_PURGEFID 30
304 #define CODA_OPEN_BY_PATH 31
305 #define CODA_RESOLVE 32
306 #define CODA_REINTEGRATE 33
307 #define CODA_STATFS 34
308 #define CODA_NCALLS 35
310 #define DOWNCALL(opcode) (opcode >= CODA_REPLACE && opcode <= CODA_PURGEFID)
312 #define VC_MAXDATASIZE 8192
313 #define VC_MAXMSGSIZE sizeof(union inputArgs)+sizeof(union outputArgs) +\
316 #define CIOC_KERNEL_VERSION _IOWR('c', 10, sizeof (int))
318 /* don't care about kernel version number */
319 #define CODA_KERNEL_VERSION 0
320 /* The old venus 4.6 compatible interface */
321 #define CODA_KERNEL_VERSION 1
322 #endif /* realms/cells */
324 /* venus_lookup gets an extra parameter to aid windows.*/
325 #define CODA_KERNEL_VERSION 2
327 /* 128-bit fids for realms */
328 #define CODA_KERNEL_VERSION 3
332 * Venus <-> Coda RPC arguments
336 unsigned long opcode;
337 unsigned long unique; /* Keep multiple outstanding msgs distinct */
338 u_short pid; /* Common to all */
339 u_short pgid; /* Common to all */
340 u_short sid; /* Common to all */
341 struct coda_cred cred; /* Common to all */
346 u_int32_t unique; /* Keep multiple outstanding msgs distinct */
347 pid_t pid; /* Common to all */
348 pid_t pgid; /* Common to all */
349 uid_t uid; /* Common to all */
353 /* Really important that opcode and unique are 1st two fields! */
354 struct coda_out_hdr {
355 unsigned long opcode;
356 unsigned long unique;
357 unsigned long result;
360 /* coda_root: NO_IN */
361 struct coda_root_out {
362 struct coda_out_hdr oh;
366 struct coda_root_in {
367 struct coda_in_hdr in;
371 /* Nothing needed for coda_sync */
374 struct coda_open_in {
375 struct coda_in_hdr ih;
380 struct coda_open_out {
381 struct coda_out_hdr oh;
388 struct coda_close_in {
389 struct coda_in_hdr ih;
394 struct coda_close_out {
395 struct coda_out_hdr out;
399 struct coda_ioctl_in {
400 struct coda_in_hdr ih;
405 char *data; /* Place holder for data. */
408 struct coda_ioctl_out {
409 struct coda_out_hdr oh;
411 caddr_t data; /* Place holder for data. */
416 struct coda_getattr_in {
417 struct coda_in_hdr ih;
421 struct coda_getattr_out {
422 struct coda_out_hdr oh;
423 struct coda_vattr attr;
427 /* coda_setattr: NO_OUT */
428 struct coda_setattr_in {
429 struct coda_in_hdr ih;
431 struct coda_vattr attr;
434 struct coda_setattr_out {
435 struct coda_out_hdr out;
438 /* coda_access: NO_OUT */
439 struct coda_access_in {
440 struct coda_in_hdr ih;
445 struct coda_access_out {
446 struct coda_out_hdr out;
451 #define CLU_CASE_SENSITIVE 0x01
452 #define CLU_CASE_INSENSITIVE 0x02
455 struct coda_lookup_in {
456 struct coda_in_hdr ih;
458 int name; /* Place holder for data. */
462 struct coda_lookup_out {
463 struct coda_out_hdr oh;
470 struct coda_create_in {
471 struct coda_in_hdr ih;
473 struct coda_vattr attr;
476 int name; /* Place holder for data. */
479 struct coda_create_out {
480 struct coda_out_hdr oh;
482 struct coda_vattr attr;
486 /* coda_remove: NO_OUT */
487 struct coda_remove_in {
488 struct coda_in_hdr ih;
490 int name; /* Place holder for data. */
493 struct coda_remove_out {
494 struct coda_out_hdr out;
497 /* coda_link: NO_OUT */
498 struct coda_link_in {
499 struct coda_in_hdr ih;
500 CodaFid sourceFid; /* cnode to link *to* */
501 CodaFid destFid; /* Directory in which to place link */
502 int tname; /* Place holder for data. */
505 struct coda_link_out {
506 struct coda_out_hdr out;
510 /* coda_rename: NO_OUT */
511 struct coda_rename_in {
512 struct coda_in_hdr ih;
519 struct coda_rename_out {
520 struct coda_out_hdr out;
524 struct coda_mkdir_in {
525 struct coda_in_hdr ih;
527 struct coda_vattr attr;
528 int name; /* Place holder for data. */
531 struct coda_mkdir_out {
532 struct coda_out_hdr oh;
534 struct coda_vattr attr;
538 /* coda_rmdir: NO_OUT */
539 struct coda_rmdir_in {
540 struct coda_in_hdr ih;
542 int name; /* Place holder for data. */
545 struct coda_rmdir_out {
546 struct coda_out_hdr out;
550 struct coda_readdir_in {
551 struct coda_in_hdr ih;
557 struct coda_readdir_out {
558 struct coda_out_hdr oh;
560 caddr_t data; /* Place holder for data. */
563 /* coda_symlink: NO_OUT */
564 struct coda_symlink_in {
565 struct coda_in_hdr ih;
566 CodaFid Fid; /* Directory to put symlink in */
568 struct coda_vattr attr;
572 struct coda_symlink_out {
573 struct coda_out_hdr out;
577 struct coda_readlink_in {
578 struct coda_in_hdr ih;
582 struct coda_readlink_out {
583 struct coda_out_hdr oh;
585 caddr_t data; /* Place holder for data. */
589 /* coda_fsync: NO_OUT */
590 struct coda_fsync_in {
591 struct coda_in_hdr ih;
595 struct coda_fsync_out {
596 struct coda_out_hdr out;
599 /* coda_inactive: NO_OUT */
600 struct coda_inactive_in {
601 struct coda_in_hdr ih;
606 struct coda_vget_in {
607 struct coda_in_hdr ih;
611 struct coda_vget_out {
612 struct coda_out_hdr oh;
618 /* CODA_SIGNAL is out-of-band, doesn't need data. */
619 /* CODA_INVALIDATE is a venus->kernel call */
620 /* CODA_FLUSH is a venus->kernel call */
622 /* coda_purgeuser: */
623 /* CODA_PURGEUSER is a venus->kernel call */
624 struct coda_purgeuser_out {
625 struct coda_out_hdr oh;
627 struct coda_cred cred;
634 /* CODA_ZAPFILE is a venus->kernel call */
635 struct coda_zapfile_out {
636 struct coda_out_hdr oh;
641 /* CODA_ZAPDIR is a venus->kernel call */
642 struct coda_zapdir_out {
643 struct coda_out_hdr oh;
648 /* CODA_ZAPVNODE is a venus->kernel call */
649 struct coda_zapvnode_out {
650 struct coda_out_hdr oh;
652 struct coda_cred cred;
658 /* CODA_PURGEFID is a venus->kernel call */
659 struct coda_purgefid_out {
660 struct coda_out_hdr oh;
665 /* CODA_REPLACE is a venus->kernel call */
666 struct coda_replace_out { /* coda_replace is a venus->kernel call */
667 struct coda_out_hdr oh;
672 /* coda_open_by_fd: */
673 struct coda_open_by_fd_in {
674 struct coda_in_hdr ih;
679 struct coda_open_by_fd_out {
680 struct coda_out_hdr oh;
685 /* coda_open_by_path: */
686 struct coda_open_by_path_in {
687 struct coda_in_hdr ih;
692 struct coda_open_by_path_out {
693 struct coda_out_hdr oh;
697 /* coda_statfs: NO_IN */
698 struct coda_statfs_in {
699 struct coda_in_hdr ih;
702 struct coda_statfs_out {
703 struct coda_out_hdr oh;
704 struct coda_statfs stat;
708 * Occasionally, we don't cache the fid returned by CODA_LOOKUP.
709 * For instance, if the fid is inconsistent.
710 * This case is handled by setting the top bit of the type result parameter.
712 #define CODA_NOCACHE 0x80000000
715 struct coda_in_hdr ih; /* NB: every struct below begins with an ih */
716 struct coda_open_in coda_open;
717 struct coda_close_in coda_close;
718 struct coda_ioctl_in coda_ioctl;
719 struct coda_getattr_in coda_getattr;
720 struct coda_setattr_in coda_setattr;
721 struct coda_access_in coda_access;
722 struct coda_lookup_in coda_lookup;
723 struct coda_create_in coda_create;
724 struct coda_remove_in coda_remove;
725 struct coda_link_in coda_link;
726 struct coda_rename_in coda_rename;
727 struct coda_mkdir_in coda_mkdir;
728 struct coda_rmdir_in coda_rmdir;
729 struct coda_readdir_in coda_readdir;
730 struct coda_symlink_in coda_symlink;
731 struct coda_readlink_in coda_readlink;
732 struct coda_fsync_in coda_fsync;
733 struct coda_vget_in coda_vget;
734 struct coda_open_by_fd_in coda_open_by_fd;
735 struct coda_open_by_path_in coda_open_by_path;
736 struct coda_statfs_in coda_statfs;
740 struct coda_out_hdr oh; /* NB: every struct below begins with an oh */
741 struct coda_root_out coda_root;
742 struct coda_open_out coda_open;
743 struct coda_ioctl_out coda_ioctl;
744 struct coda_getattr_out coda_getattr;
745 struct coda_lookup_out coda_lookup;
746 struct coda_create_out coda_create;
747 struct coda_mkdir_out coda_mkdir;
748 struct coda_readdir_out coda_readdir;
749 struct coda_readlink_out coda_readlink;
750 struct coda_vget_out coda_vget;
751 struct coda_purgeuser_out coda_purgeuser;
752 struct coda_zapfile_out coda_zapfile;
753 struct coda_zapdir_out coda_zapdir;
754 struct coda_zapvnode_out coda_zapvnode;
755 struct coda_purgefid_out coda_purgefid;
756 struct coda_replace_out coda_replace;
757 struct coda_open_by_fd_out coda_open_by_fd;
758 struct coda_open_by_path_out coda_open_by_path;
759 struct coda_statfs_out coda_statfs;
762 union coda_downcalls {
763 /* CODA_INVALIDATE is a venus->kernel call */
764 /* CODA_FLUSH is a venus->kernel call */
765 struct coda_purgeuser_out purgeuser;
766 struct coda_zapfile_out zapfile;
767 struct coda_zapdir_out zapdir;
768 struct coda_zapvnode_out zapvnode;
769 struct coda_purgefid_out purgefid;
770 struct coda_replace_out replace;
775 * Used for identifying usage of "Control" and pioctls
778 #define PIOCPARM_MASK 0x0000ffff
780 caddr_t in, out; /* Data to be transferred in, or out */
781 short in_size; /* Size of input buffer <= 2K */
782 short out_size; /* Maximum size of output buffer, <= 2K */
785 #if defined(__CYGWIN32__) || defined(DJGPP)
800 #define CODA_CONTROL ".CONTROL"
801 #define CODA_CONTROLLEN 8
803 #define CTL_FILE "/coda/.CONTROL"
806 #define CTL_FID { -1, -1, -1 }
807 #define IS_CTL_FID(fidp) ((fidp)->Volume == -1 &&\
808 (fidp)->Vnode == -1 &&\
809 (fidp)->Unique == -1)
810 #define INVAL_FID { 0, 0, 0 }
812 #define CTL_FID { { -1, -1, -1, -1 } }
813 #define IS_CTL_FID(fidp) ((fidp)->opaque[0] == -1 &&\
814 (fidp)->opaque[1] == -1 &&\
815 (fidp)->opaque[2] == -1 &&\
816 (fidp)->opaque[3] == -1)
817 #define INVAL_FID { { 0, 0, 0, 0 } }
820 /* Data passed to mount */
822 #define CODA_MOUNT_VERSION 1
824 struct coda_mount_data {
826 int fd; /* Opened device */