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
62 #include <linux/config.h>
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 #include <linux/time.h>
103 #define cdev_t u_quad_t
105 #if !defined(_UQUAD_T_) && (!defined(__GLIBC__) || __GLIBC__ < 2)
107 typedef unsigned long long u_quad_t
;
109 #else /*__KERNEL__ */
110 typedef unsigned long long u_quad_t
;
111 #endif /* __KERNEL__ */
118 time_t tv_sec
; /* seconds */
119 long tv_nsec
; /* nanoseconds */
123 #ifndef __BIT_TYPES_DEFINED__
124 #define __BIT_TYPES_DEFINED__
125 typedef signed char int8_t;
126 typedef unsigned char u_int8_t
;
127 typedef short int16_t;
128 typedef unsigned short u_int16_t
;
130 typedef unsigned int u_int32_t
;
137 #define CODA_MAXNAMLEN 255
138 #define CODA_MAXPATHLEN 1024
139 #define CODA_MAXSYMLINK 10
141 /* these are Coda's version of O_RDONLY etc combinations
142 * to deal with VFS open modes
144 #define C_O_READ 0x001
145 #define C_O_WRITE 0x002
146 #define C_O_TRUNC 0x010
147 #define C_O_EXCL 0x100
148 #define C_O_CREAT 0x200
150 /* these are to find mode bits in Venus */
151 #define C_M_READ 00400
152 #define C_M_WRITE 00200
154 /* for access Venus will use */
155 #define C_A_C_OK 8 /* Test for writing upon create. */
156 #define C_A_R_OK 4 /* Test for read permission. */
157 #define C_A_W_OK 2 /* Test for write permission. */
158 #define C_A_X_OK 1 /* Test for execute permission. */
159 #define C_A_F_OK 0 /* Test for existence. */
163 #ifndef _VENUS_DIRENT_T_
164 #define _VENUS_DIRENT_T_ 1
165 struct venus_dirent
{
166 u_int32_t d_fileno
; /* file number of entry */
167 u_int16_t d_reclen
; /* length of this record */
168 u_int8_t d_type
; /* file type, see below */
169 u_int8_t d_namlen
; /* length of string in d_name */
170 char d_name
[CODA_MAXNAMLEN
+ 1];/* name must be no longer than this */
173 #define DIRSIZ(dp) ((sizeof (struct venus_dirent) - (CODA_MAXNAMLEN+1)) + \
174 (((dp)->d_namlen+1 + 3) &~ 3))
179 #define CDT_UNKNOWN 0
190 * Convert between stat structure types and directory types.
192 #define IFTOCDT(mode) (((mode) & 0170000) >> 12)
193 #define CDTTOIF(dirtype) ((dirtype) << 12)
199 typedef u_int32_t vuid_t
;
200 typedef u_int32_t vgid_t
;
203 #ifdef CODA_FS_OLD_API
208 static __inline__ ino_t
coda_f2i(struct CodaFid
*fid
)
212 if (fid
->opaque
[1] == 0xfffffffe || fid
->opaque
[1] == 0xffffffff)
213 return ((fid
->opaque
[0] << 20) | (fid
->opaque
[2] & 0xfffff));
215 return (fid
->opaque
[2] + (fid
->opaque
[1]<<10) + (fid
->opaque
[0]<<20));
219 vuid_t cr_uid
, cr_euid
, cr_suid
, cr_fsuid
; /* Real, efftve, set, fs uid*/
220 vgid_t cr_groupid
, cr_egid
, cr_sgid
, cr_fsgid
; /* same for groups */
223 #else /* not defined(CODA_FS_OLD_API) */
229 #define coda_f2i(fid)\
230 (fid ? (fid->opaque[3] ^ (fid->opaque[2]<<10) ^ (fid->opaque[1]<<20) ^ fid->opaque[0]) : 0)
234 #ifndef _VENUS_VATTR_T_
235 #define _VENUS_VATTR_T_
237 * Vnode types. VNON means no type.
239 enum coda_vtype
{ C_VNON
, C_VREG
, C_VDIR
, C_VBLK
, C_VCHR
, C_VLNK
, C_VSOCK
, C_VFIFO
, C_VBAD
};
242 long va_type
; /* vnode type (for create) */
243 u_short va_mode
; /* files access mode and type */
244 short va_nlink
; /* number of references to file */
245 vuid_t va_uid
; /* owner user id */
246 vgid_t va_gid
; /* owner group id */
247 long va_fileid
; /* file id */
248 u_quad_t va_size
; /* file size in bytes */
249 long va_blocksize
; /* blocksize preferred for i/o */
250 struct timespec va_atime
; /* time of last access */
251 struct timespec va_mtime
; /* time of last modification */
252 struct timespec va_ctime
; /* time file changed */
253 u_long va_gen
; /* generation number of file */
254 u_long va_flags
; /* flags defined for file */
255 cdev_t va_rdev
; /* device special file represents */
256 u_quad_t va_bytes
; /* bytes of disk space held by file */
257 u_quad_t va_filerev
; /* file modification number */
262 /* structure used by CODA_STATFS for getting cache information from venus */
272 * Kernel <--> Venus communications.
276 #define CODA_OPEN_BY_FD 3
280 #define CODA_GETATTR 7
281 #define CODA_SETATTR 8
282 #define CODA_ACCESS 9
283 #define CODA_LOOKUP 10
284 #define CODA_CREATE 11
285 #define CODA_REMOVE 12
287 #define CODA_RENAME 14
288 #define CODA_MKDIR 15
289 #define CODA_RMDIR 16
290 #define CODA_SYMLINK 18
291 #define CODA_READLINK 19
292 #define CODA_FSYNC 20
294 #define CODA_SIGNAL 23
295 #define CODA_REPLACE 24 /* DOWNCALL */
296 #define CODA_FLUSH 25 /* DOWNCALL */
297 #define CODA_PURGEUSER 26 /* DOWNCALL */
298 #define CODA_ZAPFILE 27 /* DOWNCALL */
299 #define CODA_ZAPDIR 28 /* DOWNCALL */
300 #define CODA_PURGEFID 30 /* DOWNCALL */
301 #define CODA_OPEN_BY_PATH 31
302 #define CODA_RESOLVE 32
303 #define CODA_REINTEGRATE 33
304 #define CODA_STATFS 34
305 #define CODA_STORE 35
306 #define CODA_RELEASE 36
307 #define CODA_NCALLS 37
309 #define DOWNCALL(opcode) (opcode >= CODA_REPLACE && opcode <= CODA_PURGEFID)
311 #define VC_MAXDATASIZE 8192
312 #define VC_MAXMSGSIZE sizeof(union inputArgs)+sizeof(union outputArgs) +\
315 #define CIOC_KERNEL_VERSION _IOWR('c', 10, size_t)
318 #define CODA_KERNEL_VERSION 0 /* don't care about kernel version number */
319 #define CODA_KERNEL_VERSION 1 /* The old venus 4.6 compatible interface */
321 #ifdef CODA_FS_OLD_API
322 #define CODA_KERNEL_VERSION 2 /* venus_lookup got an extra parameter */
324 #define CODA_KERNEL_VERSION 3 /* 128-bit file identifiers */
328 * Venus <-> Coda RPC arguments
332 u_int32_t unique
; /* Keep multiple outstanding msgs distinct */
333 #ifdef CODA_FS_OLD_API
334 u_int16_t pid
; /* Common to all */
335 u_int16_t pgid
; /* Common to all */
336 u_int16_t sid
; /* Common to all */
337 struct coda_cred cred
; /* Common to all */
345 /* Really important that opcode and unique are 1st two fields! */
346 struct coda_out_hdr
{
352 /* coda_root: NO_IN */
353 struct coda_root_out
{
354 struct coda_out_hdr oh
;
358 struct coda_root_in
{
359 struct coda_in_hdr in
;
363 struct coda_open_in
{
364 struct coda_in_hdr ih
;
369 struct coda_open_out
{
370 struct coda_out_hdr oh
;
377 struct coda_store_in
{
378 struct coda_in_hdr ih
;
383 struct coda_store_out
{
384 struct coda_out_hdr out
;
388 struct coda_release_in
{
389 struct coda_in_hdr ih
;
394 struct coda_release_out
{
395 struct coda_out_hdr out
;
399 struct coda_close_in
{
400 struct coda_in_hdr ih
;
405 struct coda_close_out
{
406 struct coda_out_hdr out
;
410 struct coda_ioctl_in
{
411 struct coda_in_hdr ih
;
416 char *data
; /* Place holder for data. */
419 struct coda_ioctl_out
{
420 struct coda_out_hdr oh
;
422 caddr_t data
; /* Place holder for data. */
427 struct coda_getattr_in
{
428 struct coda_in_hdr ih
;
432 struct coda_getattr_out
{
433 struct coda_out_hdr oh
;
434 struct coda_vattr attr
;
438 /* coda_setattr: NO_OUT */
439 struct coda_setattr_in
{
440 struct coda_in_hdr ih
;
442 struct coda_vattr attr
;
445 struct coda_setattr_out
{
446 struct coda_out_hdr out
;
449 /* coda_access: NO_OUT */
450 struct coda_access_in
{
451 struct coda_in_hdr ih
;
456 struct coda_access_out
{
457 struct coda_out_hdr out
;
462 #define CLU_CASE_SENSITIVE 0x01
463 #define CLU_CASE_INSENSITIVE 0x02
466 struct coda_lookup_in
{
467 struct coda_in_hdr ih
;
469 int name
; /* Place holder for data. */
473 struct coda_lookup_out
{
474 struct coda_out_hdr oh
;
481 struct coda_create_in
{
482 struct coda_in_hdr ih
;
484 struct coda_vattr attr
;
487 int name
; /* Place holder for data. */
490 struct coda_create_out
{
491 struct coda_out_hdr oh
;
493 struct coda_vattr attr
;
497 /* coda_remove: NO_OUT */
498 struct coda_remove_in
{
499 struct coda_in_hdr ih
;
501 int name
; /* Place holder for data. */
504 struct coda_remove_out
{
505 struct coda_out_hdr out
;
508 /* coda_link: NO_OUT */
509 struct coda_link_in
{
510 struct coda_in_hdr ih
;
511 struct CodaFid sourceFid
; /* cnode to link *to* */
512 struct CodaFid destFid
; /* Directory in which to place link */
513 int tname
; /* Place holder for data. */
516 struct coda_link_out
{
517 struct coda_out_hdr out
;
521 /* coda_rename: NO_OUT */
522 struct coda_rename_in
{
523 struct coda_in_hdr ih
;
524 struct CodaFid sourceFid
;
526 struct CodaFid destFid
;
530 struct coda_rename_out
{
531 struct coda_out_hdr out
;
535 struct coda_mkdir_in
{
536 struct coda_in_hdr ih
;
538 struct coda_vattr attr
;
539 int name
; /* Place holder for data. */
542 struct coda_mkdir_out
{
543 struct coda_out_hdr oh
;
545 struct coda_vattr attr
;
549 /* coda_rmdir: NO_OUT */
550 struct coda_rmdir_in
{
551 struct coda_in_hdr ih
;
553 int name
; /* Place holder for data. */
556 struct coda_rmdir_out
{
557 struct coda_out_hdr out
;
560 /* coda_symlink: NO_OUT */
561 struct coda_symlink_in
{
562 struct coda_in_hdr ih
;
563 struct CodaFid VFid
; /* Directory to put symlink in */
565 struct coda_vattr attr
;
569 struct coda_symlink_out
{
570 struct coda_out_hdr out
;
574 struct coda_readlink_in
{
575 struct coda_in_hdr ih
;
579 struct coda_readlink_out
{
580 struct coda_out_hdr oh
;
582 caddr_t data
; /* Place holder for data. */
586 /* coda_fsync: NO_OUT */
587 struct coda_fsync_in
{
588 struct coda_in_hdr ih
;
592 struct coda_fsync_out
{
593 struct coda_out_hdr out
;
597 struct coda_vget_in
{
598 struct coda_in_hdr ih
;
602 struct coda_vget_out
{
603 struct coda_out_hdr oh
;
609 /* CODA_SIGNAL is out-of-band, doesn't need data. */
610 /* CODA_INVALIDATE is a venus->kernel call */
611 /* CODA_FLUSH is a venus->kernel call */
613 /* coda_purgeuser: */
614 /* CODA_PURGEUSER is a venus->kernel call */
615 struct coda_purgeuser_out
{
616 struct coda_out_hdr oh
;
617 #ifdef CODA_FS_OLD_API
618 struct coda_cred cred
;
625 /* CODA_ZAPFILE is a venus->kernel call */
626 struct coda_zapfile_out
{
627 struct coda_out_hdr oh
;
628 struct CodaFid CodaFid
;
632 /* CODA_ZAPDIR is a venus->kernel call */
633 struct coda_zapdir_out
{
634 struct coda_out_hdr oh
;
635 struct CodaFid CodaFid
;
639 /* CODA_PURGEFID is a venus->kernel call */
640 struct coda_purgefid_out
{
641 struct coda_out_hdr oh
;
642 struct CodaFid CodaFid
;
646 /* CODA_REPLACE is a venus->kernel call */
647 struct coda_replace_out
{ /* coda_replace is a venus->kernel call */
648 struct coda_out_hdr oh
;
649 struct CodaFid NewFid
;
650 struct CodaFid OldFid
;
653 /* coda_open_by_fd: */
654 struct coda_open_by_fd_in
{
655 struct coda_in_hdr ih
;
660 struct coda_open_by_fd_out
{
661 struct coda_out_hdr oh
;
665 struct file
*fh
; /* not passed from userspace but used in-kernel only */
669 /* coda_open_by_path: */
670 struct coda_open_by_path_in
{
671 struct coda_in_hdr ih
;
676 struct coda_open_by_path_out
{
677 struct coda_out_hdr oh
;
681 /* coda_statfs: NO_IN */
682 struct coda_statfs_in
{
683 struct coda_in_hdr in
;
686 struct coda_statfs_out
{
687 struct coda_out_hdr oh
;
688 struct coda_statfs stat
;
692 * Occasionally, we don't cache the fid returned by CODA_LOOKUP.
693 * For instance, if the fid is inconsistent.
694 * This case is handled by setting the top bit of the type result parameter.
696 #define CODA_NOCACHE 0x80000000
699 struct coda_in_hdr ih
; /* NB: every struct below begins with an ih */
700 struct coda_open_in coda_open
;
701 struct coda_store_in coda_store
;
702 struct coda_release_in coda_release
;
703 struct coda_close_in coda_close
;
704 struct coda_ioctl_in coda_ioctl
;
705 struct coda_getattr_in coda_getattr
;
706 struct coda_setattr_in coda_setattr
;
707 struct coda_access_in coda_access
;
708 struct coda_lookup_in coda_lookup
;
709 struct coda_create_in coda_create
;
710 struct coda_remove_in coda_remove
;
711 struct coda_link_in coda_link
;
712 struct coda_rename_in coda_rename
;
713 struct coda_mkdir_in coda_mkdir
;
714 struct coda_rmdir_in coda_rmdir
;
715 struct coda_symlink_in coda_symlink
;
716 struct coda_readlink_in coda_readlink
;
717 struct coda_fsync_in coda_fsync
;
718 struct coda_vget_in coda_vget
;
719 struct coda_open_by_fd_in coda_open_by_fd
;
720 struct coda_open_by_path_in coda_open_by_path
;
721 struct coda_statfs_in coda_statfs
;
725 struct coda_out_hdr oh
; /* NB: every struct below begins with an oh */
726 struct coda_root_out coda_root
;
727 struct coda_open_out coda_open
;
728 struct coda_ioctl_out coda_ioctl
;
729 struct coda_getattr_out coda_getattr
;
730 struct coda_lookup_out coda_lookup
;
731 struct coda_create_out coda_create
;
732 struct coda_mkdir_out coda_mkdir
;
733 struct coda_readlink_out coda_readlink
;
734 struct coda_vget_out coda_vget
;
735 struct coda_purgeuser_out coda_purgeuser
;
736 struct coda_zapfile_out coda_zapfile
;
737 struct coda_zapdir_out coda_zapdir
;
738 struct coda_purgefid_out coda_purgefid
;
739 struct coda_replace_out coda_replace
;
740 struct coda_open_by_fd_out coda_open_by_fd
;
741 struct coda_open_by_path_out coda_open_by_path
;
742 struct coda_statfs_out coda_statfs
;
745 union coda_downcalls
{
746 /* CODA_INVALIDATE is a venus->kernel call */
747 /* CODA_FLUSH is a venus->kernel call */
748 struct coda_purgeuser_out purgeuser
;
749 struct coda_zapfile_out zapfile
;
750 struct coda_zapdir_out zapdir
;
751 struct coda_purgefid_out purgefid
;
752 struct coda_replace_out replace
;
757 * Used for identifying usage of "Control" and pioctls
760 #define PIOCPARM_MASK 0x0000ffff
762 caddr_t in
, out
; /* Data to be transferred in, or out */
763 short in_size
; /* Size of input buffer <= 2K */
764 short out_size
; /* Maximum size of output buffer, <= 2K */
773 #define CODA_CONTROL ".CONTROL"
774 #define CODA_CONTROLLEN 8
777 /* Data passed to mount */
779 #define CODA_MOUNT_VERSION 1
781 struct coda_mount_data
{
783 int fd
; /* Opened device */