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
64 /* Catch new _KERNEL defn for NetBSD and DJGPP/__CYGWIN32__ */
65 #if defined(__NetBSD__) || \
66 ((defined(DJGPP) || defined(__CYGWIN32__)) && !defined(KERNEL))
67 #include <sys/types.h>
70 #ifndef CODA_MAXSYMLINKS
71 #define CODA_MAXSYMLINKS 10
74 #if defined(DJGPP) || defined(__CYGWIN32__)
76 typedef unsigned long u_long
;
77 typedef unsigned int u_int
;
78 typedef unsigned short u_short
;
81 typedef void * caddr_t
;
83 typedef unsigned __int64 u_quad_t
;
85 typedef unsigned long long u_quad_t
;
94 #else /* DJGPP but not KERNEL */
96 typedef unsigned long long u_quad_t
;
101 #if defined(__linux__)
102 #define cdev_t u_quad_t
104 #if !defined(_UQUAD_T_) && (!defined(__GLIBC__) || __GLIBC__ < 2)
106 typedef unsigned long long u_quad_t
;
108 #else /*__KERNEL__ */
109 typedef unsigned long long u_quad_t
;
110 #endif /* __KERNEL__ */
117 time_t tv_sec
; /* seconds */
118 long tv_nsec
; /* nanoseconds */
122 #ifndef __BIT_TYPES_DEFINED__
123 #define __BIT_TYPES_DEFINED__
124 typedef signed char int8_t;
125 typedef unsigned char u_int8_t
;
126 typedef short int16_t;
127 typedef unsigned short u_int16_t
;
129 typedef unsigned int u_int32_t
;
136 #define CODA_MAXNAMLEN 255
137 #define CODA_MAXPATHLEN 1024
138 #define CODA_MAXSYMLINK 10
140 /* these are Coda's version of O_RDONLY etc combinations
141 * to deal with VFS open modes
143 #define C_O_READ 0x001
144 #define C_O_WRITE 0x002
145 #define C_O_TRUNC 0x010
146 #define C_O_EXCL 0x100
147 #define C_O_CREAT 0x200
149 /* these are to find mode bits in Venus */
150 #define C_M_READ 00400
151 #define C_M_WRITE 00200
153 /* for access Venus will use */
154 #define C_A_C_OK 8 /* Test for writing upon create. */
155 #define C_A_R_OK 4 /* Test for read permission. */
156 #define C_A_W_OK 2 /* Test for write permission. */
157 #define C_A_X_OK 1 /* Test for execute permission. */
158 #define C_A_F_OK 0 /* Test for existence. */
162 #ifndef _VENUS_DIRENT_T_
163 #define _VENUS_DIRENT_T_ 1
164 struct venus_dirent
{
165 unsigned long d_fileno
; /* file number of entry */
166 unsigned short d_reclen
; /* length of this record */
167 unsigned char d_type
; /* file type, see below */
168 unsigned char d_namlen
; /* length of string in d_name */
169 char d_name
[CODA_MAXNAMLEN
+ 1];/* name must be no longer than this */
172 #define DIRSIZ(dp) ((sizeof (struct venus_dirent) - (CODA_MAXNAMLEN+1)) + \
173 (((dp)->d_namlen+1 + 3) &~ 3))
178 #define CDT_UNKNOWN 0
189 * Convert between stat structure types and directory types.
191 #define IFTOCDT(mode) (((mode) & 0170000) >> 12)
192 #define CDTTOIF(dirtype) ((dirtype) << 12)
198 typedef u_long VolumeId
;
199 typedef u_long VnodeId
;
200 typedef u_long Unique_t
;
201 typedef u_long FileVersion
;
205 #define _VICEFID_T_ 1
206 typedef struct ViceFid
{
215 static __inline__ ino_t
coda_f2i(struct ViceFid
*fid
)
219 if (fid
->Vnode
== 0xfffffffe || fid
->Vnode
== 0xffffffff)
220 return ((fid
->Volume
<< 20) | (fid
->Unique
& 0xfffff));
222 return (fid
->Unique
+ (fid
->Vnode
<<10) + (fid
->Volume
<<20));
226 #define coda_f2i(fid)\
227 ((fid) ? ((fid)->Unique + ((fid)->Vnode<<10) + ((fid)->Volume<<20)) : 0)
233 typedef u_int32_t vuid_t
;
234 typedef u_int32_t vgid_t
;
240 vuid_t cr_uid
, cr_euid
, cr_suid
, cr_fsuid
; /* Real, efftve, set, fs uid*/
241 vgid_t cr_groupid
, cr_egid
, cr_sgid
, cr_fsgid
; /* same for groups */
245 #ifndef _VENUS_VATTR_T_
246 #define _VENUS_VATTR_T_
248 * Vnode types. VNON means no type.
250 enum coda_vtype
{ C_VNON
, C_VREG
, C_VDIR
, C_VBLK
, C_VCHR
, C_VLNK
, C_VSOCK
, C_VFIFO
, C_VBAD
};
253 long va_type
; /* vnode type (for create) */
254 u_short va_mode
; /* files access mode and type */
255 short va_nlink
; /* number of references to file */
256 vuid_t va_uid
; /* owner user id */
257 vgid_t va_gid
; /* owner group id */
258 long va_fileid
; /* file id */
259 u_quad_t va_size
; /* file size in bytes */
260 long va_blocksize
; /* blocksize preferred for i/o */
261 struct timespec va_atime
; /* time of last access */
262 struct timespec va_mtime
; /* time of last modification */
263 struct timespec va_ctime
; /* time file changed */
264 u_long va_gen
; /* generation number of file */
265 u_long va_flags
; /* flags defined for file */
266 cdev_t va_rdev
; /* device special file represents */
267 u_quad_t va_bytes
; /* bytes of disk space held by file */
268 u_quad_t va_filerev
; /* file modification number */
273 /* structure used by CODA_STATFS for getting cache information from venus */
283 * Kernel <--> Venus communications.
291 #define CODA_GETATTR 7
292 #define CODA_SETATTR 8
293 #define CODA_ACCESS 9
294 #define CODA_LOOKUP 10
295 #define CODA_CREATE 11
296 #define CODA_REMOVE 12
298 #define CODA_RENAME 14
299 #define CODA_MKDIR 15
300 #define CODA_RMDIR 16
301 #define CODA_READDIR 17
302 #define CODA_SYMLINK 18
303 #define CODA_READLINK 19
304 #define CODA_FSYNC 20
305 #define CODA_INACTIVE 21
307 #define CODA_SIGNAL 23
308 #define CODA_REPLACE 24 /* DOWNCALL */
309 #define CODA_FLUSH 25 /* DOWNCALL */
310 #define CODA_PURGEUSER 26 /* DOWNCALL */
311 #define CODA_ZAPFILE 27 /* DOWNCALL */
312 #define CODA_ZAPDIR 28 /* DOWNCALL */
313 #define CODA_PURGEFID 30 /* DOWNCALL */
314 #define CODA_OPEN_BY_PATH 31
315 #define CODA_RESOLVE 32
316 #define CODA_REINTEGRATE 33
317 #define CODA_STATFS 34
318 #define CODA_MAKE_CINODE 35 /* DOWNCALL */
319 #define CODA_NCALLS 36
321 #define DOWNCALL(opcode) \
322 ((opcode >= CODA_REPLACE && opcode <= CODA_PURGEFID) || \
323 opcode == CODA_MAKE_CINODE)
325 #define VC_MAXDATASIZE 8192
326 #define VC_MAXMSGSIZE sizeof(union inputArgs)+sizeof(union outputArgs) +\
329 #define CIOC_KERNEL_VERSION _IOWR('c', 10, sizeof (int))
332 #define CODA_KERNEL_VERSION 0 /* don't care about kernel version number */
333 #define CODA_KERNEL_VERSION 1 /* The old venus 4.6 compatible interface */
335 #define CODA_KERNEL_VERSION 2 /* venus_lookup gets an extra parameter */
338 * Venus <-> Coda RPC arguments
341 unsigned long opcode
;
342 unsigned long unique
; /* Keep multiple outstanding msgs distinct */
343 u_short pid
; /* Common to all */
344 u_short pgid
; /* Common to all */
345 u_short sid
; /* Common to all */
346 struct coda_cred cred
; /* Common to all */
349 /* Really important that opcode and unique are 1st two fields! */
350 struct coda_out_hdr
{
351 unsigned long opcode
;
352 unsigned long unique
;
353 unsigned long result
;
356 /* coda_root: NO_IN */
357 struct coda_root_out
{
358 struct coda_out_hdr oh
;
362 struct coda_root_in
{
363 struct coda_in_hdr in
;
367 /* Nothing needed for coda_sync */
370 struct coda_open_in
{
371 struct coda_in_hdr ih
;
376 struct coda_open_out
{
377 struct coda_out_hdr oh
;
384 struct coda_close_in
{
385 struct coda_in_hdr ih
;
390 struct coda_close_out
{
391 struct coda_out_hdr out
;
395 struct coda_ioctl_in
{
396 struct coda_in_hdr ih
;
401 char *data
; /* Place holder for data. */
404 struct coda_ioctl_out
{
405 struct coda_out_hdr oh
;
407 caddr_t data
; /* Place holder for data. */
412 struct coda_getattr_in
{
413 struct coda_in_hdr ih
;
417 struct coda_getattr_out
{
418 struct coda_out_hdr oh
;
419 struct coda_vattr attr
;
423 /* coda_setattr: NO_OUT */
424 struct coda_setattr_in
{
425 struct coda_in_hdr ih
;
427 struct coda_vattr attr
;
430 struct coda_setattr_out
{
431 struct coda_out_hdr out
;
434 /* coda_access: NO_OUT */
435 struct coda_access_in
{
436 struct coda_in_hdr ih
;
441 struct coda_access_out
{
442 struct coda_out_hdr out
;
447 #define CLU_CASE_SENSITIVE 0x01
448 #define CLU_CASE_INSENSITIVE 0x02
451 struct coda_lookup_in
{
452 struct coda_in_hdr ih
;
454 int name
; /* Place holder for data. */
458 struct coda_lookup_out
{
459 struct coda_out_hdr oh
;
466 struct coda_create_in
{
467 struct coda_in_hdr ih
;
469 struct coda_vattr attr
;
472 int name
; /* Place holder for data. */
475 struct coda_create_out
{
476 struct coda_out_hdr oh
;
478 struct coda_vattr attr
;
482 /* coda_remove: NO_OUT */
483 struct coda_remove_in
{
484 struct coda_in_hdr ih
;
486 int name
; /* Place holder for data. */
489 struct coda_remove_out
{
490 struct coda_out_hdr out
;
493 /* coda_link: NO_OUT */
494 struct coda_link_in
{
495 struct coda_in_hdr ih
;
496 ViceFid sourceFid
; /* cnode to link *to* */
497 ViceFid destFid
; /* Directory in which to place link */
498 int tname
; /* Place holder for data. */
501 struct coda_link_out
{
502 struct coda_out_hdr out
;
506 /* coda_rename: NO_OUT */
507 struct coda_rename_in
{
508 struct coda_in_hdr ih
;
515 struct coda_rename_out
{
516 struct coda_out_hdr out
;
520 struct coda_mkdir_in
{
521 struct coda_in_hdr ih
;
523 struct coda_vattr attr
;
524 int name
; /* Place holder for data. */
527 struct coda_mkdir_out
{
528 struct coda_out_hdr oh
;
530 struct coda_vattr attr
;
534 /* coda_rmdir: NO_OUT */
535 struct coda_rmdir_in
{
536 struct coda_in_hdr ih
;
538 int name
; /* Place holder for data. */
541 struct coda_rmdir_out
{
542 struct coda_out_hdr out
;
546 struct coda_readdir_in
{
547 struct coda_in_hdr ih
;
553 struct coda_readdir_out
{
554 struct coda_out_hdr oh
;
556 caddr_t data
; /* Place holder for data. */
559 /* coda_symlink: NO_OUT */
560 struct coda_symlink_in
{
561 struct coda_in_hdr ih
;
562 ViceFid VFid
; /* Directory to put symlink in */
564 struct coda_vattr attr
;
568 struct coda_symlink_out
{
569 struct coda_out_hdr out
;
573 struct coda_readlink_in
{
574 struct coda_in_hdr ih
;
578 struct coda_readlink_out
{
579 struct coda_out_hdr oh
;
581 caddr_t data
; /* Place holder for data. */
585 /* coda_fsync: NO_OUT */
586 struct coda_fsync_in
{
587 struct coda_in_hdr ih
;
591 struct coda_fsync_out
{
592 struct coda_out_hdr out
;
595 /* coda_inactive: NO_OUT */
596 struct coda_inactive_in
{
597 struct coda_in_hdr ih
;
602 struct coda_vget_in
{
603 struct coda_in_hdr ih
;
607 struct coda_vget_out
{
608 struct coda_out_hdr oh
;
614 /* CODA_SIGNAL is out-of-band, doesn't need data. */
615 /* CODA_INVALIDATE is a venus->kernel call */
616 /* CODA_FLUSH is a venus->kernel call */
618 /* coda_purgeuser: */
619 /* CODA_PURGEUSER is a venus->kernel call */
620 struct coda_purgeuser_out
{
621 struct coda_out_hdr oh
;
622 struct coda_cred cred
;
626 /* CODA_ZAPFILE is a venus->kernel call */
627 struct coda_zapfile_out
{
628 struct coda_out_hdr oh
;
633 /* CODA_ZAPDIR is a venus->kernel call */
634 struct coda_zapdir_out
{
635 struct coda_out_hdr oh
;
640 /* CODA_ZAPVNODE is a venus->kernel call */
641 struct coda_zapvnode_out
{
642 struct coda_out_hdr oh
;
643 struct coda_cred cred
;
648 /* CODA_PURGEFID is a venus->kernel call */
649 struct coda_purgefid_out
{
650 struct coda_out_hdr oh
;
654 struct coda_make_cinode_out
{
655 struct coda_out_hdr oh
;
657 struct coda_vattr attr
;
662 struct coda_rdwr_in
{
663 struct coda_in_hdr ih
;
669 caddr_t data
; /* Place holder for data. */
672 struct coda_rdwr_out
{
673 struct coda_out_hdr oh
;
676 caddr_t data
; /* Place holder for data. */
681 /* CODA_REPLACE is a venus->kernel call */
682 struct coda_replace_out
{ /* coda_replace is a venus->kernel call */
683 struct coda_out_hdr oh
;
688 /* coda_open_by_path: */
689 struct coda_open_by_path_in
{
690 struct coda_in_hdr ih
;
695 struct coda_open_by_path_out
{
696 struct coda_out_hdr oh
;
700 /* coda_statfs: NO_IN */
701 struct coda_statfs_in
{
702 struct coda_in_hdr in
;
705 struct coda_statfs_out
{
706 struct coda_out_hdr oh
;
707 struct coda_statfs stat
;
711 * Occasionally, we don't cache the fid returned by CODA_LOOKUP.
712 * For instance, if the fid is inconsistent.
713 * This case is handled by setting the top bit of the type result parameter.
715 #define CODA_NOCACHE 0x80000000
718 struct coda_in_hdr ih
; /* NB: every struct below begins with an ih */
719 struct coda_open_in coda_open
;
720 struct coda_close_in coda_close
;
721 struct coda_ioctl_in coda_ioctl
;
722 struct coda_getattr_in coda_getattr
;
723 struct coda_setattr_in coda_setattr
;
724 struct coda_access_in coda_access
;
725 struct coda_lookup_in coda_lookup
;
726 struct coda_create_in coda_create
;
727 struct coda_remove_in coda_remove
;
728 struct coda_link_in coda_link
;
729 struct coda_rename_in coda_rename
;
730 struct coda_mkdir_in coda_mkdir
;
731 struct coda_rmdir_in coda_rmdir
;
732 struct coda_readdir_in coda_readdir
;
733 struct coda_symlink_in coda_symlink
;
734 struct coda_readlink_in coda_readlink
;
735 struct coda_fsync_in coda_fsync
;
736 struct coda_inactive_in coda_inactive
;
737 struct coda_vget_in coda_vget
;
738 struct coda_rdwr_in coda_rdwr
;
739 struct coda_open_by_path_in coda_open_by_path
;
740 struct coda_statfs_in coda_statfs
;
744 struct coda_out_hdr oh
; /* NB: every struct below begins with an oh */
745 struct coda_root_out coda_root
;
746 struct coda_open_out coda_open
;
747 struct coda_ioctl_out coda_ioctl
;
748 struct coda_getattr_out coda_getattr
;
749 struct coda_lookup_out coda_lookup
;
750 struct coda_create_out coda_create
;
751 struct coda_mkdir_out coda_mkdir
;
752 struct coda_readdir_out coda_readdir
;
753 struct coda_readlink_out coda_readlink
;
754 struct coda_vget_out coda_vget
;
755 struct coda_purgeuser_out coda_purgeuser
;
756 struct coda_zapfile_out coda_zapfile
;
757 struct coda_zapdir_out coda_zapdir
;
758 struct coda_zapvnode_out coda_zapvnode
;
759 struct coda_purgefid_out coda_purgefid
;
760 struct coda_rdwr_out coda_rdwr
;
761 struct coda_replace_out coda_replace
;
762 struct coda_make_cinode_out coda_make_cinode
;
763 struct coda_open_by_path_out coda_open_by_path
;
764 struct coda_statfs_out coda_statfs
;
767 union coda_downcalls
{
768 /* CODA_INVALIDATE is a venus->kernel call */
769 /* CODA_FLUSH is a venus->kernel call */
770 struct coda_purgeuser_out purgeuser
;
771 struct coda_zapfile_out zapfile
;
772 struct coda_zapdir_out zapdir
;
773 struct coda_zapvnode_out zapvnode
;
774 struct coda_purgefid_out purgefid
;
775 struct coda_replace_out replace
;
780 * Used for identifying usage of "Control" and pioctls
783 #define PIOCPARM_MASK 0x0000ffff
785 caddr_t in
, out
; /* Data to be transferred in, or out */
786 short in_size
; /* Size of input buffer <= 2K */
787 short out_size
; /* Maximum size of output buffer, <= 2K */
796 #define CODA_CONTROL ".CONTROL"
797 #define CODA_CONTROLLEN 8
802 #define CTL_FILE "/coda/.CONTROL"
805 #define IS_CTL_FID(fidp) ((fidp)->Volume == CTL_VOL &&\
806 (fidp)->Vnode == CTL_VNO &&\
807 (fidp)->Unique == CTL_UNI)