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 */
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 */
94 #include <sys/types.h>
96 typedef unsigned long long u_quad_t
;
101 #if defined(__linux__)
102 #define cdev_t u_quad_t
103 #if !defined(_UQUAD_T_) && (!defined(__GLIBC__) || __GLIBC__ < 2)
105 typedef unsigned long long u_quad_t
;
112 typedef unsigned char u_int8_t
;
114 time_t tv_sec
; /* seconds */
115 long tv_nsec
; /* nanoseconds */
123 #define CODA_MAXNAMLEN 255
124 #define CODA_MAXPATHLEN 1024
125 #define CODA_MAXSYMLINK 10
127 /* these are Coda's version of O_RDONLY etc combinations
128 * to deal with VFS open modes
130 #define C_O_READ 0x001
131 #define C_O_WRITE 0x002
132 #define C_O_TRUNC 0x010
133 #define C_O_EXCL 0x100
134 #define C_O_CREAT 0x200
136 /* these are to find mode bits in Venus */
137 #define C_M_READ 00400
138 #define C_M_WRITE 00200
140 /* for access Venus will use */
141 #define C_A_C_OK 8 /* Test for writing upon create. */
142 #define C_A_R_OK 4 /* Test for read permission. */
143 #define C_A_W_OK 2 /* Test for write permission. */
144 #define C_A_X_OK 1 /* Test for execute permission. */
145 #define C_A_F_OK 0 /* Test for existence. */
149 #ifndef _VENUS_DIRENT_T_
150 #define _VENUS_DIRENT_T_ 1
151 struct venus_dirent
{
152 unsigned long d_fileno
; /* file number of entry */
153 unsigned short d_reclen
; /* length of this record */
154 char d_type
; /* file type, see below */
155 char d_namlen
; /* length of string in d_name */
156 char d_name
[CODA_MAXNAMLEN
+ 1];/* name must be no longer than this */
159 #define DIRSIZ(dp) ((sizeof (struct venus_dirent) - (CODA_MAXNAMLEN+1)) + \
160 (((dp)->d_namlen+1 + 3) &~ 3))
165 #define CDT_UNKNOWN 0
176 * Convert between stat structure types and directory types.
178 #define IFTOCDT(mode) (((mode) & 0170000) >> 12)
179 #define CDTTOIF(dirtype) ((dirtype) << 12)
185 typedef u_long VolumeId
;
186 typedef u_long VnodeId
;
187 typedef u_long Unique_t
;
188 typedef u_long FileVersion
;
192 #define _VICEFID_T_ 1
193 typedef struct ViceFid
{
202 static __inline__ ino_t
coda_f2i(struct ViceFid
*fid
)
206 if (fid
->Vnode
== 0xfffffffe || fid
->Vnode
== 0xffffffff)
207 return ((fid
->Volume
<< 20) | (fid
->Unique
& 0xfffff));
209 return (fid
->Unique
+ (fid
->Vnode
<<10) + (fid
->Volume
<<20));
213 #define coda_f2i(fid)\
214 ((fid) ? ((fid)->Unique + ((fid)->Vnode<<10) + ((fid)->Volume<<20)) : 0)
218 #ifndef __BIT_TYPES_DEFINED__
219 #define u_int32_t unsigned int
225 typedef u_int32_t vuid_t
;
226 typedef u_int32_t vgid_t
;
232 vuid_t cr_uid
, cr_euid
, cr_suid
, cr_fsuid
;
233 vgid_t cr_groupid
, cr_egid
, cr_sgid
, cr_fsgid
;
234 #if defined(CODA_SUPPORTS_SUPPLEMENTARY_GROUPS)
236 vgid_t cr_supgps
[NGROUPS
];
237 #endif /* defined(CODA_SUPPORTS_SUPPLEMENTARY_GROUPS) */
241 #ifndef _VENUS_VATTR_T_
242 #define _VENUS_VATTR_T_
244 * Vnode types. VNON means no type.
246 enum coda_vtype
{ C_VNON
, C_VREG
, C_VDIR
, C_VBLK
, C_VCHR
, C_VLNK
, C_VSOCK
, C_VFIFO
, C_VBAD
};
249 int va_type
; /* vnode type (for create) */
250 u_short va_mode
; /* files access mode and type */
251 short va_nlink
; /* number of references to file */
252 vuid_t va_uid
; /* owner user id */
253 vgid_t va_gid
; /* owner group id */
254 long va_fileid
; /* file id */
255 u_quad_t va_size
; /* file size in bytes */
256 long va_blocksize
; /* blocksize preferred for i/o */
257 struct timespec va_atime
; /* time of last access */
258 struct timespec va_mtime
; /* time of last modification */
259 struct timespec va_ctime
; /* time file changed */
260 u_long va_gen
; /* generation number of file */
261 u_long va_flags
; /* flags defined for file */
262 cdev_t va_rdev
; /* device special file represents */
263 u_quad_t va_bytes
; /* bytes of disk space held by file */
264 u_quad_t va_filerev
; /* file modification number */
270 * Kernel <--> Venus communications.
278 #define CODA_GETATTR 7
279 #define CODA_SETATTR 8
280 #define CODA_ACCESS 9
281 #define CODA_LOOKUP 10
282 #define CODA_CREATE 11
283 #define CODA_REMOVE 12
285 #define CODA_RENAME 14
286 #define CODA_MKDIR 15
287 #define CODA_RMDIR 16
288 #define CODA_READDIR 17
289 #define CODA_SYMLINK 18
290 #define CODA_READLINK 19
291 #define CODA_FSYNC 20
292 #define CODA_INACTIVE 21
294 #define CODA_SIGNAL 23
295 #define CODA_REPLACE 24
296 #define CODA_FLUSH 25
297 #define CODA_PURGEUSER 26
298 #define CODA_ZAPFILE 27
299 #define CODA_ZAPDIR 28
300 #define CODA_PURGEFID 30
301 #define CODA_OPEN_BY_PATH 31
302 #define CODA_RESOLVE 32
303 #define CODA_REINTEGRATE 33
304 #define CODA_NCALLS 34
306 #define DOWNCALL(opcode) (opcode >= CODA_REPLACE && opcode <= CODA_PURGEFID)
308 #define VC_MAXDATASIZE 8192
309 #define VC_MAXMSGSIZE sizeof(union inputArgs)+sizeof(union outputArgs) +\
312 #define CIOC_KERNEL_VERSION _IOWR('c', 10, sizeof (int))
314 /* don't care about kernel version number */
315 #define CODA_KERNEL_VERSION 0
316 /* The old venus 4.6 compatible interface */
317 #define CODA_KERNEL_VERSION 1
319 /* venus_lookup gets an extra parameter to aid windows.*/
320 #define CODA_KERNEL_VERSION 2
323 * Venus <-> Coda RPC arguments
326 unsigned long opcode
;
327 unsigned long unique
; /* Keep multiple outstanding msgs distinct */
328 u_short pid
; /* Common to all */
329 u_short pgid
; /* Common to all */
330 u_short sid
; /* Common to all */
331 struct coda_cred cred
; /* Common to all */
334 /* Really important that opcode and unique are 1st two fields! */
335 struct coda_out_hdr
{
336 unsigned long opcode
;
337 unsigned long unique
;
338 unsigned long result
;
341 /* coda_root: NO_IN */
342 struct coda_root_out
{
343 struct coda_out_hdr oh
;
347 struct coda_root_in
{
348 struct coda_in_hdr in
;
352 /* Nothing needed for coda_sync */
355 struct coda_open_in
{
356 struct coda_in_hdr ih
;
361 struct coda_open_out
{
362 struct coda_out_hdr oh
;
369 struct coda_close_in
{
370 struct coda_in_hdr ih
;
375 struct coda_close_out
{
376 struct coda_out_hdr out
;
380 struct coda_ioctl_in
{
381 struct coda_in_hdr ih
;
386 char *data
; /* Place holder for data. */
389 struct coda_ioctl_out
{
390 struct coda_out_hdr oh
;
392 caddr_t data
; /* Place holder for data. */
397 struct coda_getattr_in
{
398 struct coda_in_hdr ih
;
402 struct coda_getattr_out
{
403 struct coda_out_hdr oh
;
404 struct coda_vattr attr
;
408 /* coda_setattr: NO_OUT */
409 struct coda_setattr_in
{
410 struct coda_in_hdr ih
;
412 struct coda_vattr attr
;
415 struct coda_setattr_out
{
416 struct coda_out_hdr out
;
419 /* coda_access: NO_OUT */
420 struct coda_access_in
{
421 struct coda_in_hdr ih
;
426 struct coda_access_out
{
427 struct coda_out_hdr out
;
432 #define CLU_CASE_SENSITIVE 0x01
433 #define CLU_CASE_INSENSITIVE 0x02
436 struct coda_lookup_in
{
437 struct coda_in_hdr ih
;
439 int name
; /* Place holder for data. */
443 struct coda_lookup_out
{
444 struct coda_out_hdr oh
;
451 struct coda_create_in
{
452 struct coda_in_hdr ih
;
454 struct coda_vattr attr
;
457 int name
; /* Place holder for data. */
460 struct coda_create_out
{
461 struct coda_out_hdr oh
;
463 struct coda_vattr attr
;
467 /* coda_remove: NO_OUT */
468 struct coda_remove_in
{
469 struct coda_in_hdr ih
;
471 int name
; /* Place holder for data. */
474 struct coda_remove_out
{
475 struct coda_out_hdr out
;
478 /* coda_link: NO_OUT */
479 struct coda_link_in
{
480 struct coda_in_hdr ih
;
481 ViceFid sourceFid
; /* cnode to link *to* */
482 ViceFid destFid
; /* Directory in which to place link */
483 int tname
; /* Place holder for data. */
486 struct coda_link_out
{
487 struct coda_out_hdr out
;
491 /* coda_rename: NO_OUT */
492 struct coda_rename_in
{
493 struct coda_in_hdr ih
;
500 struct coda_rename_out
{
501 struct coda_out_hdr out
;
505 struct coda_mkdir_in
{
506 struct coda_in_hdr ih
;
508 struct coda_vattr attr
;
509 int name
; /* Place holder for data. */
512 struct coda_mkdir_out
{
513 struct coda_out_hdr oh
;
515 struct coda_vattr attr
;
519 /* coda_rmdir: NO_OUT */
520 struct coda_rmdir_in
{
521 struct coda_in_hdr ih
;
523 int name
; /* Place holder for data. */
526 struct coda_rmdir_out
{
527 struct coda_out_hdr out
;
531 struct coda_readdir_in
{
532 struct coda_in_hdr ih
;
538 struct coda_readdir_out
{
539 struct coda_out_hdr oh
;
541 caddr_t data
; /* Place holder for data. */
544 /* coda_symlink: NO_OUT */
545 struct coda_symlink_in
{
546 struct coda_in_hdr ih
;
547 ViceFid VFid
; /* Directory to put symlink in */
549 struct coda_vattr attr
;
553 struct coda_symlink_out
{
554 struct coda_out_hdr out
;
558 struct coda_readlink_in
{
559 struct coda_in_hdr ih
;
563 struct coda_readlink_out
{
564 struct coda_out_hdr oh
;
566 caddr_t data
; /* Place holder for data. */
570 /* coda_fsync: NO_OUT */
571 struct coda_fsync_in
{
572 struct coda_in_hdr ih
;
576 struct coda_fsync_out
{
577 struct coda_out_hdr out
;
580 /* coda_inactive: NO_OUT */
581 struct coda_inactive_in
{
582 struct coda_in_hdr ih
;
587 struct coda_vget_in
{
588 struct coda_in_hdr ih
;
592 struct coda_vget_out
{
593 struct coda_out_hdr oh
;
599 /* CODA_SIGNAL is out-of-band, doesn't need data. */
600 /* CODA_INVALIDATE is a venus->kernel call */
601 /* CODA_FLUSH is a venus->kernel call */
603 /* coda_purgeuser: */
604 /* CODA_PURGEUSER is a venus->kernel call */
605 struct coda_purgeuser_out
{
606 struct coda_out_hdr oh
;
607 struct coda_cred cred
;
611 /* CODA_ZAPFILE is a venus->kernel call */
612 struct coda_zapfile_out
{
613 struct coda_out_hdr oh
;
618 /* CODA_ZAPDIR is a venus->kernel call */
619 struct coda_zapdir_out
{
620 struct coda_out_hdr oh
;
625 /* CODA_ZAPVNODE is a venus->kernel call */
626 struct coda_zapvnode_out
{
627 struct coda_out_hdr oh
;
628 struct coda_cred cred
;
633 /* CODA_PURGEFID is a venus->kernel call */
634 struct coda_purgefid_out
{
635 struct coda_out_hdr oh
;
640 struct coda_rdwr_in
{
641 struct coda_in_hdr ih
;
647 caddr_t data
; /* Place holder for data. */
650 struct coda_rdwr_out
{
651 struct coda_out_hdr oh
;
654 caddr_t data
; /* Place holder for data. */
659 /* CODA_REPLACE is a venus->kernel call */
660 struct coda_replace_out
{ /* coda_replace is a venus->kernel call */
661 struct coda_out_hdr oh
;
666 /* coda_open_by_path: */
667 struct coda_open_by_path_in
{
668 struct coda_in_hdr ih
;
673 struct coda_open_by_path_out
{
674 struct coda_out_hdr oh
;
679 * Occasionally, we don't cache the fid returned by CODA_LOOKUP.
680 * For instance, if the fid is inconsistent.
681 * This case is handled by setting the top bit of the type result parameter.
683 #define CODA_NOCACHE 0x80000000
686 struct coda_in_hdr ih
; /* NB: every struct below begins with an ih */
687 struct coda_open_in coda_open
;
688 struct coda_close_in coda_close
;
689 struct coda_ioctl_in coda_ioctl
;
690 struct coda_getattr_in coda_getattr
;
691 struct coda_setattr_in coda_setattr
;
692 struct coda_access_in coda_access
;
693 struct coda_lookup_in coda_lookup
;
694 struct coda_create_in coda_create
;
695 struct coda_remove_in coda_remove
;
696 struct coda_link_in coda_link
;
697 struct coda_rename_in coda_rename
;
698 struct coda_mkdir_in coda_mkdir
;
699 struct coda_rmdir_in coda_rmdir
;
700 struct coda_readdir_in coda_readdir
;
701 struct coda_symlink_in coda_symlink
;
702 struct coda_readlink_in coda_readlink
;
703 struct coda_fsync_in coda_fsync
;
704 struct coda_inactive_in coda_inactive
;
705 struct coda_vget_in coda_vget
;
706 struct coda_rdwr_in coda_rdwr
;
707 struct coda_open_by_path_in coda_open_by_path
;
711 struct coda_out_hdr oh
; /* NB: every struct below begins with an oh */
712 struct coda_root_out coda_root
;
713 struct coda_open_out coda_open
;
714 struct coda_ioctl_out coda_ioctl
;
715 struct coda_getattr_out coda_getattr
;
716 struct coda_lookup_out coda_lookup
;
717 struct coda_create_out coda_create
;
718 struct coda_mkdir_out coda_mkdir
;
719 struct coda_readdir_out coda_readdir
;
720 struct coda_readlink_out coda_readlink
;
721 struct coda_vget_out coda_vget
;
722 struct coda_purgeuser_out coda_purgeuser
;
723 struct coda_zapfile_out coda_zapfile
;
724 struct coda_zapdir_out coda_zapdir
;
725 struct coda_zapvnode_out coda_zapvnode
;
726 struct coda_purgefid_out coda_purgefid
;
727 struct coda_rdwr_out coda_rdwr
;
728 struct coda_replace_out coda_replace
;
729 struct coda_open_by_path_out coda_open_by_path
;
732 union coda_downcalls
{
733 /* CODA_INVALIDATE is a venus->kernel call */
734 /* CODA_FLUSH is a venus->kernel call */
735 struct coda_purgeuser_out purgeuser
;
736 struct coda_zapfile_out zapfile
;
737 struct coda_zapdir_out zapdir
;
738 struct coda_zapvnode_out zapvnode
;
739 struct coda_purgefid_out purgefid
;
740 struct coda_replace_out replace
;
745 * Used for identifying usage of "Control" and pioctls
748 #define PIOCPARM_MASK 0x0000ffff
750 caddr_t in
, out
; /* Data to be transferred in, or out */
751 short in_size
; /* Size of input buffer <= 2K */
752 short out_size
; /* Maximum size of output buffer, <= 2K */
755 #if defined(__CYGWIN32__) || defined(DJGPP)
770 #define CODA_CONTROL ".CONTROL"
771 #define CODA_CONTROLLEN 8
776 #define CTL_FILE "/coda/.CONTROL"
779 #define IS_CTL_FID(fidp) ((fidp)->Volume == CTL_VOL &&\
780 (fidp)->Vnode == CTL_VNO &&\
781 (fidp)->Unique == CTL_UNI)