2 You may distribute this file under either of the two licenses that
3 follow at your discretion.
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
25 Coda: an Experimental Distributed File System
28 Copyright (c) 1987-1999 Carnegie Mellon University
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
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
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
63 /* Catch new _KERNEL defn for NetBSD and DJGPP/__CYGWIN32__ */
64 #if defined(__NetBSD__) || \
65 ((defined(DJGPP) || defined(__CYGWIN32__)) && !defined(KERNEL))
66 #include <sys/types.h>
69 #ifndef CODA_MAXSYMLINKS
70 #define CODA_MAXSYMLINKS 10
73 #if defined(DJGPP) || defined(__CYGWIN32__)
75 typedef unsigned long u_long;
76 typedef unsigned int u_int;
77 typedef unsigned short u_short;
80 typedef void * caddr_t;
82 typedef unsigned __int64 u_quad_t;
84 typedef unsigned long long u_quad_t;
93 #else /* DJGPP but not KERNEL */
95 typedef unsigned long long u_quad_t;
100 #if defined(__linux__)
101 #include <linux/time.h>
102 #define cdev_t u_quad_t
103 #if !defined(_UQUAD_T_) && (!defined(__GLIBC__) || __GLIBC__ < 2)
105 typedef unsigned long long u_quad_t;
113 time_t tv_sec; /* seconds */
114 long tv_nsec; /* nanoseconds */
118 #ifndef __BIT_TYPES_DEFINED__
119 #define __BIT_TYPES_DEFINED__
120 typedef signed char int8_t;
121 typedef unsigned char u_int8_t;
122 typedef short int16_t;
123 typedef unsigned short u_int16_t;
125 typedef unsigned int u_int32_t;
132 #define CODA_MAXNAMLEN 255
133 #define CODA_MAXPATHLEN 1024
134 #define CODA_MAXSYMLINK 10
136 /* these are Coda's version of O_RDONLY etc combinations
137 * to deal with VFS open modes
139 #define C_O_READ 0x001
140 #define C_O_WRITE 0x002
141 #define C_O_TRUNC 0x010
142 #define C_O_EXCL 0x100
143 #define C_O_CREAT 0x200
145 /* these are to find mode bits in Venus */
146 #define C_M_READ 00400
147 #define C_M_WRITE 00200
149 /* for access Venus will use */
150 #define C_A_C_OK 8 /* Test for writing upon create. */
151 #define C_A_R_OK 4 /* Test for read permission. */
152 #define C_A_W_OK 2 /* Test for write permission. */
153 #define C_A_X_OK 1 /* Test for execute permission. */
154 #define C_A_F_OK 0 /* Test for existence. */
158 #ifndef _VENUS_DIRENT_T_
159 #define _VENUS_DIRENT_T_ 1
160 struct venus_dirent {
161 u_int32_t d_fileno; /* file number of entry */
162 u_int16_t d_reclen; /* length of this record */
163 u_int8_t d_type; /* file type, see below */
164 u_int8_t d_namlen; /* length of string in d_name */
165 char d_name[CODA_MAXNAMLEN + 1];/* name must be no longer than this */
168 #define DIRSIZ(dp) ((sizeof (struct venus_dirent) - (CODA_MAXNAMLEN+1)) + \
169 (((dp)->d_namlen+1 + 3) &~ 3))
174 #define CDT_UNKNOWN 0
185 * Convert between stat structure types and directory types.
187 #define IFTOCDT(mode) (((mode) & 0170000) >> 12)
188 #define CDTTOIF(dirtype) ((dirtype) << 12)
194 typedef u_int32_t vuid_t;
195 typedef u_int32_t vgid_t;
202 #define coda_f2i(fid)\
203 (fid ? (fid->opaque[3] ^ (fid->opaque[2]<<10) ^ (fid->opaque[1]<<20) ^ fid->opaque[0]) : 0)
205 #ifndef _VENUS_VATTR_T_
206 #define _VENUS_VATTR_T_
208 * Vnode types. VNON means no type.
210 enum coda_vtype { C_VNON, C_VREG, C_VDIR, C_VBLK, C_VCHR, C_VLNK, C_VSOCK, C_VFIFO, C_VBAD };
213 long va_type; /* vnode type (for create) */
214 u_short va_mode; /* files access mode and type */
215 short va_nlink; /* number of references to file */
216 vuid_t va_uid; /* owner user id */
217 vgid_t va_gid; /* owner group id */
218 long va_fileid; /* file id */
219 u_quad_t va_size; /* file size in bytes */
220 long va_blocksize; /* blocksize preferred for i/o */
221 struct timespec va_atime; /* time of last access */
222 struct timespec va_mtime; /* time of last modification */
223 struct timespec va_ctime; /* time file changed */
224 u_long va_gen; /* generation number of file */
225 u_long va_flags; /* flags defined for file */
226 cdev_t va_rdev; /* device special file represents */
227 u_quad_t va_bytes; /* bytes of disk space held by file */
228 u_quad_t va_filerev; /* file modification number */
233 /* structure used by CODA_STATFS for getting cache information from venus */
243 * Kernel <--> Venus communications.
247 #define CODA_OPEN_BY_FD 3
251 #define CODA_GETATTR 7
252 #define CODA_SETATTR 8
253 #define CODA_ACCESS 9
254 #define CODA_LOOKUP 10
255 #define CODA_CREATE 11
256 #define CODA_REMOVE 12
258 #define CODA_RENAME 14
259 #define CODA_MKDIR 15
260 #define CODA_RMDIR 16
261 #define CODA_SYMLINK 18
262 #define CODA_READLINK 19
263 #define CODA_FSYNC 20
265 #define CODA_SIGNAL 23
266 #define CODA_REPLACE 24 /* DOWNCALL */
267 #define CODA_FLUSH 25 /* DOWNCALL */
268 #define CODA_PURGEUSER 26 /* DOWNCALL */
269 #define CODA_ZAPFILE 27 /* DOWNCALL */
270 #define CODA_ZAPDIR 28 /* DOWNCALL */
271 #define CODA_PURGEFID 30 /* DOWNCALL */
272 #define CODA_OPEN_BY_PATH 31
273 #define CODA_RESOLVE 32
274 #define CODA_REINTEGRATE 33
275 #define CODA_STATFS 34
276 #define CODA_STORE 35
277 #define CODA_RELEASE 36
278 #define CODA_NCALLS 37
280 #define DOWNCALL(opcode) (opcode >= CODA_REPLACE && opcode <= CODA_PURGEFID)
282 #define VC_MAXDATASIZE 8192
283 #define VC_MAXMSGSIZE sizeof(union inputArgs)+sizeof(union outputArgs) +\
286 #define CIOC_KERNEL_VERSION _IOWR('c', 10, size_t)
288 #define CODA_KERNEL_VERSION 3 /* 128-bit file identifiers */
291 * Venus <-> Coda RPC arguments
295 u_int32_t unique; /* Keep multiple outstanding msgs distinct */
301 /* Really important that opcode and unique are 1st two fields! */
302 struct coda_out_hdr {
308 /* coda_root: NO_IN */
309 struct coda_root_out {
310 struct coda_out_hdr oh;
314 struct coda_root_in {
315 struct coda_in_hdr in;
319 struct coda_open_in {
320 struct coda_in_hdr ih;
325 struct coda_open_out {
326 struct coda_out_hdr oh;
333 struct coda_store_in {
334 struct coda_in_hdr ih;
339 struct coda_store_out {
340 struct coda_out_hdr out;
344 struct coda_release_in {
345 struct coda_in_hdr ih;
350 struct coda_release_out {
351 struct coda_out_hdr out;
355 struct coda_close_in {
356 struct coda_in_hdr ih;
361 struct coda_close_out {
362 struct coda_out_hdr out;
366 struct coda_ioctl_in {
367 struct coda_in_hdr ih;
372 char *data; /* Place holder for data. */
375 struct coda_ioctl_out {
376 struct coda_out_hdr oh;
378 caddr_t data; /* Place holder for data. */
383 struct coda_getattr_in {
384 struct coda_in_hdr ih;
388 struct coda_getattr_out {
389 struct coda_out_hdr oh;
390 struct coda_vattr attr;
394 /* coda_setattr: NO_OUT */
395 struct coda_setattr_in {
396 struct coda_in_hdr ih;
398 struct coda_vattr attr;
401 struct coda_setattr_out {
402 struct coda_out_hdr out;
405 /* coda_access: NO_OUT */
406 struct coda_access_in {
407 struct coda_in_hdr ih;
412 struct coda_access_out {
413 struct coda_out_hdr out;
418 #define CLU_CASE_SENSITIVE 0x01
419 #define CLU_CASE_INSENSITIVE 0x02
422 struct coda_lookup_in {
423 struct coda_in_hdr ih;
425 int name; /* Place holder for data. */
429 struct coda_lookup_out {
430 struct coda_out_hdr oh;
437 struct coda_create_in {
438 struct coda_in_hdr ih;
440 struct coda_vattr attr;
443 int name; /* Place holder for data. */
446 struct coda_create_out {
447 struct coda_out_hdr oh;
449 struct coda_vattr attr;
453 /* coda_remove: NO_OUT */
454 struct coda_remove_in {
455 struct coda_in_hdr ih;
457 int name; /* Place holder for data. */
460 struct coda_remove_out {
461 struct coda_out_hdr out;
464 /* coda_link: NO_OUT */
465 struct coda_link_in {
466 struct coda_in_hdr ih;
467 struct CodaFid sourceFid; /* cnode to link *to* */
468 struct CodaFid destFid; /* Directory in which to place link */
469 int tname; /* Place holder for data. */
472 struct coda_link_out {
473 struct coda_out_hdr out;
477 /* coda_rename: NO_OUT */
478 struct coda_rename_in {
479 struct coda_in_hdr ih;
480 struct CodaFid sourceFid;
482 struct CodaFid destFid;
486 struct coda_rename_out {
487 struct coda_out_hdr out;
491 struct coda_mkdir_in {
492 struct coda_in_hdr ih;
494 struct coda_vattr attr;
495 int name; /* Place holder for data. */
498 struct coda_mkdir_out {
499 struct coda_out_hdr oh;
501 struct coda_vattr attr;
505 /* coda_rmdir: NO_OUT */
506 struct coda_rmdir_in {
507 struct coda_in_hdr ih;
509 int name; /* Place holder for data. */
512 struct coda_rmdir_out {
513 struct coda_out_hdr out;
516 /* coda_symlink: NO_OUT */
517 struct coda_symlink_in {
518 struct coda_in_hdr ih;
519 struct CodaFid VFid; /* Directory to put symlink in */
521 struct coda_vattr attr;
525 struct coda_symlink_out {
526 struct coda_out_hdr out;
530 struct coda_readlink_in {
531 struct coda_in_hdr ih;
535 struct coda_readlink_out {
536 struct coda_out_hdr oh;
538 caddr_t data; /* Place holder for data. */
542 /* coda_fsync: NO_OUT */
543 struct coda_fsync_in {
544 struct coda_in_hdr ih;
548 struct coda_fsync_out {
549 struct coda_out_hdr out;
553 struct coda_vget_in {
554 struct coda_in_hdr ih;
558 struct coda_vget_out {
559 struct coda_out_hdr oh;
565 /* CODA_SIGNAL is out-of-band, doesn't need data. */
566 /* CODA_INVALIDATE is a venus->kernel call */
567 /* CODA_FLUSH is a venus->kernel call */
569 /* coda_purgeuser: */
570 /* CODA_PURGEUSER is a venus->kernel call */
571 struct coda_purgeuser_out {
572 struct coda_out_hdr oh;
577 /* CODA_ZAPFILE is a venus->kernel call */
578 struct coda_zapfile_out {
579 struct coda_out_hdr oh;
580 struct CodaFid CodaFid;
584 /* CODA_ZAPDIR is a venus->kernel call */
585 struct coda_zapdir_out {
586 struct coda_out_hdr oh;
587 struct CodaFid CodaFid;
591 /* CODA_PURGEFID is a venus->kernel call */
592 struct coda_purgefid_out {
593 struct coda_out_hdr oh;
594 struct CodaFid CodaFid;
598 /* CODA_REPLACE is a venus->kernel call */
599 struct coda_replace_out { /* coda_replace is a venus->kernel call */
600 struct coda_out_hdr oh;
601 struct CodaFid NewFid;
602 struct CodaFid OldFid;
605 /* coda_open_by_fd: */
606 struct coda_open_by_fd_in {
607 struct coda_in_hdr ih;
612 struct coda_open_by_fd_out {
613 struct coda_out_hdr oh;
618 /* coda_open_by_path: */
619 struct coda_open_by_path_in {
620 struct coda_in_hdr ih;
625 struct coda_open_by_path_out {
626 struct coda_out_hdr oh;
630 /* coda_statfs: NO_IN */
631 struct coda_statfs_in {
632 struct coda_in_hdr in;
635 struct coda_statfs_out {
636 struct coda_out_hdr oh;
637 struct coda_statfs stat;
641 * Occasionally, we don't cache the fid returned by CODA_LOOKUP.
642 * For instance, if the fid is inconsistent.
643 * This case is handled by setting the top bit of the type result parameter.
645 #define CODA_NOCACHE 0x80000000
648 struct coda_in_hdr ih; /* NB: every struct below begins with an ih */
649 struct coda_open_in coda_open;
650 struct coda_store_in coda_store;
651 struct coda_release_in coda_release;
652 struct coda_close_in coda_close;
653 struct coda_ioctl_in coda_ioctl;
654 struct coda_getattr_in coda_getattr;
655 struct coda_setattr_in coda_setattr;
656 struct coda_access_in coda_access;
657 struct coda_lookup_in coda_lookup;
658 struct coda_create_in coda_create;
659 struct coda_remove_in coda_remove;
660 struct coda_link_in coda_link;
661 struct coda_rename_in coda_rename;
662 struct coda_mkdir_in coda_mkdir;
663 struct coda_rmdir_in coda_rmdir;
664 struct coda_symlink_in coda_symlink;
665 struct coda_readlink_in coda_readlink;
666 struct coda_fsync_in coda_fsync;
667 struct coda_vget_in coda_vget;
668 struct coda_open_by_fd_in coda_open_by_fd;
669 struct coda_open_by_path_in coda_open_by_path;
670 struct coda_statfs_in coda_statfs;
674 struct coda_out_hdr oh; /* NB: every struct below begins with an oh */
675 struct coda_root_out coda_root;
676 struct coda_open_out coda_open;
677 struct coda_ioctl_out coda_ioctl;
678 struct coda_getattr_out coda_getattr;
679 struct coda_lookup_out coda_lookup;
680 struct coda_create_out coda_create;
681 struct coda_mkdir_out coda_mkdir;
682 struct coda_readlink_out coda_readlink;
683 struct coda_vget_out coda_vget;
684 struct coda_purgeuser_out coda_purgeuser;
685 struct coda_zapfile_out coda_zapfile;
686 struct coda_zapdir_out coda_zapdir;
687 struct coda_purgefid_out coda_purgefid;
688 struct coda_replace_out coda_replace;
689 struct coda_open_by_fd_out coda_open_by_fd;
690 struct coda_open_by_path_out coda_open_by_path;
691 struct coda_statfs_out coda_statfs;
694 union coda_downcalls {
695 /* CODA_INVALIDATE is a venus->kernel call */
696 /* CODA_FLUSH is a venus->kernel call */
697 struct coda_purgeuser_out purgeuser;
698 struct coda_zapfile_out zapfile;
699 struct coda_zapdir_out zapdir;
700 struct coda_purgefid_out purgefid;
701 struct coda_replace_out replace;
706 * Used for identifying usage of "Control" and pioctls
709 #define PIOCPARM_MASK 0x0000ffff
711 void *in; /* Data to be transferred in */
712 void *out; /* Data to be transferred out */
713 u_short in_size; /* Size of input buffer <= 2K */
714 u_short out_size; /* Maximum size of output buffer, <= 2K */
723 #define CODA_CONTROL ".CONTROL"
724 #define CODA_CONTROLLEN 8
727 /* Data passed to mount */
729 #define CODA_MOUNT_VERSION 1
731 struct coda_mount_data {
733 int fd; /* Opened device */
736 #endif /* _CODA_HEADER_ */