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 * $Id: coda.h,v 1.3 1998/09/11 18:50:17 rvb Exp $
36 * Based on cfs.h from Mach, but revamped for increased simplicity.
37 * Linux modifications by Peter Braam, Aug 1996
43 /* Catch new _KERNEL defn for NetBSD */
45 #include <sys/types.h>
48 #if defined(__linux__) || defined(__CYGWIN32__)
49 #define cdev_t u_quad_t
50 #if !defined(_UQUAD_T_) && (!defined(__GLIBC__) || __GLIBC__ < 2)
52 typedef unsigned long long u_quad_t;
59 typedef unsigned char u_int8_t;
61 time_t tv_sec; /* seconds */
62 long tv_nsec; /* nanoseconds */
70 #define CODA_MAXNAMLEN 255
71 #define CODA_MAXPATHLEN 1024
72 #define CODA_MAXSYMLINK 10
74 /* these are Coda's version of O_RDONLY etc combinations
75 * to deal with VFS open modes
77 #define C_O_READ 0x001
78 #define C_O_WRITE 0x002
79 #define C_O_TRUNC 0x010
80 #define C_O_EXCL 0x100
82 /* these are to find mode bits in Venus */
83 #define C_M_READ 00400
84 #define C_M_WRITE 00200
86 /* for access Venus will use */
87 #define C_A_R_OK 4 /* Test for read permission. */
88 #define C_A_W_OK 2 /* Test for write permission. */
89 #define C_A_X_OK 1 /* Test for execute permission. */
90 #define C_A_F_OK 0 /* Test for existence. */
94 #ifndef _VENUS_DIRENT_T_
95 #define _VENUS_DIRENT_T_ 1
97 unsigned long d_fileno; /* file number of entry */
98 unsigned short d_reclen; /* length of this record */
99 char d_type; /* file type, see below */
100 char d_namlen; /* length of string in d_name */
101 char d_name[CODA_MAXNAMLEN + 1];/* name must be no longer than this */
104 #define DIRSIZ(dp) ((sizeof (struct venus_dirent) - (CODA_MAXNAMLEN+1)) + \
105 (((dp)->d_namlen+1 + 3) &~ 3))
110 #define CDT_UNKNOWN 0
121 * Convert between stat structure types and directory types.
123 #define IFTOCDT(mode) (((mode) & 0170000) >> 12)
124 #define CDTTOIF(dirtype) ((dirtype) << 12)
130 typedef u_long VolumeId;
131 typedef u_long VnodeId;
132 typedef u_long Unique_t;
133 typedef u_long FileVersion;
137 #define _VICEFID_T_ 1
138 typedef struct ViceFid {
146 static inline ino_t coda_f2i(struct ViceFid *fid)
149 return (fid->Unique + (fid->Vnode << 10) + (fid->Volume << 20));
158 typedef u_long vuid_t;
159 typedef u_long vgid_t;
165 vuid_t cr_uid, cr_euid, cr_suid, cr_fsuid; /* Real, efftve, set, fs uid*/
166 #if defined(__NetBSD__) || defined(__FreeBSD__)
167 vgid_t cr_groupid, cr_egid, cr_sgid, cr_fsgid; /* same for groups */
169 vgid_t cr_gid, cr_egid, cr_sgid, cr_fsgid; /* same for groups */
174 #ifndef _VENUS_VATTR_T_
175 #define _VENUS_VATTR_T_
177 * Vnode types. VNON means no type.
179 enum coda_vtype { C_VNON, C_VREG, C_VDIR, C_VBLK, C_VCHR, C_VLNK, C_VSOCK, C_VFIFO, C_VBAD };
182 enum coda_vtype va_type; /* vnode type (for create) */
183 u_short va_mode; /* files access mode and type */
184 short va_nlink; /* number of references to file */
185 vuid_t va_uid; /* owner user id */
186 vgid_t va_gid; /* owner group id */
187 long va_fileid; /* file id */
188 u_quad_t va_size; /* file size in bytes */
189 long va_blocksize; /* blocksize preferred for i/o */
190 struct timespec va_atime; /* time of last access */
191 struct timespec va_mtime; /* time of last modification */
192 struct timespec va_ctime; /* time file changed */
193 u_long va_gen; /* generation number of file */
194 u_long va_flags; /* flags defined for file */
195 cdev_t va_rdev; /* device special file represents */
196 u_quad_t va_bytes; /* bytes of disk space held by file */
197 u_quad_t va_filerev; /* file modification number */
203 * Kernel <--> Venus communications.
206 #define CODA_ROOT ((u_long) 2)
207 #define CODA_SYNC ((u_long) 3)
208 #define CODA_OPEN ((u_long) 4)
209 #define CODA_CLOSE ((u_long) 5)
210 #define CODA_IOCTL ((u_long) 6)
211 #define CODA_GETATTR ((u_long) 7)
212 #define CODA_SETATTR ((u_long) 8)
213 #define CODA_ACCESS ((u_long) 9)
214 #define CODA_LOOKUP ((u_long) 10)
215 #define CODA_CREATE ((u_long) 11)
216 #define CODA_REMOVE ((u_long) 12)
217 #define CODA_LINK ((u_long) 13)
218 #define CODA_RENAME ((u_long) 14)
219 #define CODA_MKDIR ((u_long) 15)
220 #define CODA_RMDIR ((u_long) 16)
221 #define CODA_READDIR ((u_long) 17)
222 #define CODA_SYMLINK ((u_long) 18)
223 #define CODA_READLINK ((u_long) 19)
224 #define CODA_FSYNC ((u_long) 20)
225 #define CODA_INACTIVE ((u_long) 21)
226 #define CODA_VGET ((u_long) 22)
227 #define CODA_SIGNAL ((u_long) 23)
228 #define CODA_REPLACE ((u_long) 24)
229 #define CODA_FLUSH ((u_long) 25)
230 #define CODA_PURGEUSER ((u_long) 26)
231 #define CODA_ZAPFILE ((u_long) 27)
232 #define CODA_ZAPDIR ((u_long) 28)
233 #define CODA_ZAPVNODE ((u_long) 29)
234 #define CODA_PURGEFID ((u_long) 30)
235 #define CODA_NCALLS 31
237 #define DOWNCALL(opcode) (opcode >= CODA_REPLACE && opcode <= CODA_PURGEFID)
239 #define VC_MAXDATASIZE 8192
240 #define VC_MAXMSGSIZE sizeof(union inputArgs)+sizeof(union outputArgs) +\
246 * Venus <-> Coda RPC arguments
249 unsigned long opcode;
250 unsigned long unique; /* Keep multiple outstanding msgs distinct */
251 u_short pid; /* Common to all */
252 u_short pgid; /* Common to all */
253 u_short sid; /* Common to all */
254 struct coda_cred cred; /* Common to all */
257 /* Really important that opcode and unique are 1st two fields! */
258 struct coda_out_hdr {
259 unsigned long opcode;
260 unsigned long unique;
261 unsigned long result;
264 /* coda_root: NO_IN */
265 struct coda_root_out {
266 struct coda_out_hdr oh;
270 struct coda_root_in {
271 struct coda_in_hdr in;
275 /* Nothing needed for coda_sync */
278 struct coda_open_in {
279 struct coda_in_hdr ih;
284 struct coda_open_out {
285 struct coda_out_hdr oh;
292 struct coda_close_in {
293 struct coda_in_hdr ih;
298 struct coda_close_out {
299 struct coda_out_hdr out;
303 struct coda_ioctl_in {
304 struct coda_in_hdr ih;
309 char *data; /* Place holder for data. */
312 struct coda_ioctl_out {
313 struct coda_out_hdr oh;
315 caddr_t data; /* Place holder for data. */
320 struct coda_getattr_in {
321 struct coda_in_hdr ih;
325 struct coda_getattr_out {
326 struct coda_out_hdr oh;
327 struct coda_vattr attr;
331 /* coda_setattr: NO_OUT */
332 struct coda_setattr_in {
333 struct coda_in_hdr ih;
335 struct coda_vattr attr;
338 struct coda_setattr_out {
339 struct coda_out_hdr out;
342 /* coda_access: NO_OUT */
343 struct coda_access_in {
344 struct coda_in_hdr ih;
349 struct coda_access_out {
350 struct coda_out_hdr out;
354 struct coda_lookup_in {
355 struct coda_in_hdr ih;
357 int name; /* Place holder for data. */
360 struct coda_lookup_out {
361 struct coda_out_hdr oh;
368 struct coda_create_in {
369 struct coda_in_hdr ih;
371 struct coda_vattr attr;
374 int name; /* Place holder for data. */
377 struct coda_create_out {
378 struct coda_out_hdr oh;
380 struct coda_vattr attr;
384 /* coda_remove: NO_OUT */
385 struct coda_remove_in {
386 struct coda_in_hdr ih;
388 int name; /* Place holder for data. */
391 struct coda_remove_out {
392 struct coda_out_hdr out;
395 /* coda_link: NO_OUT */
396 struct coda_link_in {
397 struct coda_in_hdr ih;
398 ViceFid sourceFid; /* cnode to link *to* */
399 ViceFid destFid; /* Directory in which to place link */
400 int tname; /* Place holder for data. */
403 struct coda_link_out {
404 struct coda_out_hdr out;
408 /* coda_rename: NO_OUT */
409 struct coda_rename_in {
410 struct coda_in_hdr ih;
417 struct coda_rename_out {
418 struct coda_out_hdr out;
422 struct coda_mkdir_in {
423 struct coda_in_hdr ih;
425 struct coda_vattr attr;
426 int name; /* Place holder for data. */
429 struct coda_mkdir_out {
430 struct coda_out_hdr oh;
432 struct coda_vattr attr;
436 /* coda_rmdir: NO_OUT */
437 struct coda_rmdir_in {
438 struct coda_in_hdr ih;
440 int name; /* Place holder for data. */
443 struct coda_rmdir_out {
444 struct coda_out_hdr out;
448 struct coda_readdir_in {
449 struct coda_in_hdr ih;
455 struct coda_readdir_out {
456 struct coda_out_hdr oh;
458 caddr_t data; /* Place holder for data. */
461 /* coda_symlink: NO_OUT */
462 struct coda_symlink_in {
463 struct coda_in_hdr ih;
464 ViceFid VFid; /* Directory to put symlink in */
466 struct coda_vattr attr;
470 struct coda_symlink_out {
471 struct coda_out_hdr out;
475 struct coda_readlink_in {
476 struct coda_in_hdr ih;
480 struct coda_readlink_out {
481 struct coda_out_hdr oh;
483 caddr_t data; /* Place holder for data. */
487 /* coda_fsync: NO_OUT */
488 struct coda_fsync_in {
489 struct coda_in_hdr ih;
493 struct coda_fsync_out {
494 struct coda_out_hdr out;
497 /* coda_inactive: NO_OUT */
498 struct coda_inactive_in {
499 struct coda_in_hdr ih;
504 struct coda_vget_in {
505 struct coda_in_hdr ih;
509 struct coda_vget_out {
510 struct coda_out_hdr oh;
516 /* CODA_SIGNAL is out-of-band, doesn't need data. */
517 /* CODA_INVALIDATE is a venus->kernel call */
518 /* CODA_FLUSH is a venus->kernel call */
520 /* coda_purgeuser: */
521 /* CODA_PURGEUSER is a venus->kernel call */
522 struct coda_purgeuser_out {
523 struct coda_out_hdr oh;
524 struct coda_cred cred;
528 /* CODA_ZAPFILE is a venus->kernel call */
529 struct coda_zapfile_out {
530 struct coda_out_hdr oh;
535 /* CODA_ZAPDIR is a venus->kernel call */
536 struct coda_zapdir_out {
537 struct coda_out_hdr oh;
542 /* CODA_ZAPVNODE is a venus->kernel call */
543 struct coda_zapvnode_out {
544 struct coda_out_hdr oh;
545 struct coda_cred cred;
550 /* CODA_PURGEFID is a venus->kernel call */
551 struct coda_purgefid_out {
552 struct coda_out_hdr oh;
557 struct coda_rdwr_in {
558 struct coda_in_hdr ih;
564 caddr_t data; /* Place holder for data. */
567 struct coda_rdwr_out {
568 struct coda_out_hdr oh;
571 caddr_t data; /* Place holder for data. */
576 /* CODA_REPLACE is a venus->kernel call */
577 struct coda_replace_out { /* coda_replace is a venus->kernel call */
578 struct coda_out_hdr oh;
584 * Occasionally, don't cache the fid returned by CODA_LOOKUP. For instance, if
585 * the fid is inconsistent. This case is handled by setting the top bit of the
586 * return result parameter.
588 #define CODA_NOCACHE 0x80000000
591 struct coda_in_hdr ih; /* NB: every struct below begins with an ih */
592 struct coda_open_in coda_open;
593 struct coda_close_in coda_close;
594 struct coda_ioctl_in coda_ioctl;
595 struct coda_getattr_in coda_getattr;
596 struct coda_setattr_in coda_setattr;
597 struct coda_access_in coda_access;
598 struct coda_lookup_in coda_lookup;
599 struct coda_create_in coda_create;
600 struct coda_remove_in coda_remove;
601 struct coda_link_in coda_link;
602 struct coda_rename_in coda_rename;
603 struct coda_mkdir_in coda_mkdir;
604 struct coda_rmdir_in coda_rmdir;
605 struct coda_readdir_in coda_readdir;
606 struct coda_symlink_in coda_symlink;
607 struct coda_readlink_in coda_readlink;
608 struct coda_fsync_in coda_fsync;
609 struct coda_inactive_in coda_inactive;
610 struct coda_vget_in coda_vget;
611 struct coda_rdwr_in coda_rdwr;
615 struct coda_out_hdr oh; /* NB: every struct below begins with an oh */
616 struct coda_root_out coda_root;
617 struct coda_open_out coda_open;
618 struct coda_ioctl_out coda_ioctl;
619 struct coda_getattr_out coda_getattr;
620 struct coda_lookup_out coda_lookup;
621 struct coda_create_out coda_create;
622 struct coda_mkdir_out coda_mkdir;
623 struct coda_readdir_out coda_readdir;
624 struct coda_readlink_out coda_readlink;
625 struct coda_vget_out coda_vget;
626 struct coda_purgeuser_out coda_purgeuser;
627 struct coda_zapfile_out coda_zapfile;
628 struct coda_zapdir_out coda_zapdir;
629 struct coda_zapvnode_out coda_zapvnode;
630 struct coda_purgefid_out coda_purgefid;
631 struct coda_rdwr_out coda_rdwr;
632 struct coda_replace_out coda_replace;
635 union coda_downcalls {
636 /* CODA_INVALIDATE is a venus->kernel call */
637 /* CODA_FLUSH is a venus->kernel call */
638 struct coda_purgeuser_out purgeuser;
639 struct coda_zapfile_out zapfile;
640 struct coda_zapdir_out zapdir;
641 struct coda_zapvnode_out zapvnode;
642 struct coda_purgefid_out purgefid;
643 struct coda_replace_out replace;
648 * Used for identifying usage of "Control" and pioctls
651 #define PIOCPARM_MASK 0x0000ffff
653 caddr_t in, out; /* Data to be transferred in, or out */
654 short in_size; /* Size of input buffer <= 2K */
655 short out_size; /* Maximum size of output buffer, <= 2K */
664 #define CODA_CONTROL ".CONTROL"
665 #define CODA_CONTROLLEN 8
670 #define CTL_FILE "/coda/.CONTROL"
673 #define IS_CTL_FID(fidp) ((fidp)->Volume == CTL_VOL &&\
674 (fidp)->Vnode == CTL_VNO &&\
675 (fidp)->Unique == CTL_UNI)