Home | History | Annotate | Line # | Download | only in coda
coda.h revision 1.6
      1  1.6  rvb /*	$NetBSD: coda.h,v 1.6 1998/11/11 19:22:08 rvb Exp $	*/
      2  1.2  rvb 
      3  1.1  rvb /*
      4  1.2  rvb  *
      5  1.2  rvb  *             Coda: an Experimental Distributed File System
      6  1.2  rvb  *                              Release 3.1
      7  1.2  rvb  *
      8  1.2  rvb  *           Copyright (c) 1987-1998 Carnegie Mellon University
      9  1.2  rvb  *                          All Rights Reserved
     10  1.2  rvb  *
     11  1.2  rvb  * Permission  to  use, copy, modify and distribute this software and its
     12  1.2  rvb  * documentation is hereby granted,  provided  that  both  the  copyright
     13  1.2  rvb  * notice  and  this  permission  notice  appear  in  all  copies  of the
     14  1.2  rvb  * software, derivative works or  modified  versions,  and  any  portions
     15  1.2  rvb  * thereof, and that both notices appear in supporting documentation, and
     16  1.2  rvb  * that credit is given to Carnegie Mellon University  in  all  documents
     17  1.2  rvb  * and publicity pertaining to direct or indirect use of this code or its
     18  1.2  rvb  * derivatives.
     19  1.2  rvb  *
     20  1.2  rvb  * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS  KNOWN  TO  HAVE  BUGS,
     21  1.2  rvb  * SOME  OF  WHICH MAY HAVE SERIOUS CONSEQUENCES.  CARNEGIE MELLON ALLOWS
     22  1.2  rvb  * FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.   CARNEGIE  MELLON
     23  1.2  rvb  * DISCLAIMS  ANY  LIABILITY  OF  ANY  KIND  FOR  ANY  DAMAGES WHATSOEVER
     24  1.2  rvb  * RESULTING DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE  OR  OF
     25  1.2  rvb  * ANY DERIVATIVE WORK.
     26  1.2  rvb  *
     27  1.2  rvb  * Carnegie  Mellon  encourages  users  of  this  software  to return any
     28  1.2  rvb  * improvements or extensions that  they  make,  and  to  grant  Carnegie
     29  1.2  rvb  * Mellon the rights to redistribute these changes without encumbrance.
     30  1.2  rvb  *
     31  1.4  rvb  * 	@(#) coda/coda.h,v 1.1.1.1 1998/08/29 21:26:46 rvb Exp
     32  1.2  rvb  */
     33  1.1  rvb 
     34  1.6  rvb 
     35  1.1  rvb /*
     36  1.1  rvb  *
     37  1.1  rvb  * Based on cfs.h from Mach, but revamped for increased simplicity.
     38  1.1  rvb  * Linux modifications by Peter Braam, Aug 1996
     39  1.1  rvb  */
     40  1.1  rvb 
     41  1.3  rvb #ifndef _CODA_HEADER_
     42  1.3  rvb #define _CODA_HEADER_
     43  1.1  rvb 
     44  1.1  rvb 
     45  1.1  rvb 
     46  1.1  rvb /* Catch new _KERNEL defn for NetBSD */
     47  1.1  rvb #ifdef __NetBSD__
     48  1.1  rvb #include <sys/types.h>
     49  1.1  rvb #endif
     50  1.1  rvb 
     51  1.5  rvb #ifndef CODA_MAXSYMLINKS
     52  1.5  rvb #define CODA_MAXSYMLINKS 10
     53  1.5  rvb #endif
     54  1.5  rvb 
     55  1.5  rvb #if defined(DJGPP) || defined(__CYGWIN32__)
     56  1.5  rvb #ifdef KERNEL
     57  1.5  rvb typedef unsigned long u_long;
     58  1.5  rvb typedef unsigned int u_int;
     59  1.5  rvb typedef unsigned short u_short;
     60  1.5  rvb typedef u_long ino_t;
     61  1.5  rvb typedef u_long dev_t;
     62  1.5  rvb typedef void * caddr_t;
     63  1.6  rvb #ifdef DOS
     64  1.6  rvb typedef unsigned __int64 u_quad_t;
     65  1.6  rvb #else
     66  1.5  rvb typedef unsigned long long u_quad_t;
     67  1.6  rvb #endif
     68  1.5  rvb 
     69  1.5  rvb #define inline
     70  1.5  rvb 
     71  1.5  rvb struct timespec {
     72  1.5  rvb         long       ts_sec;
     73  1.5  rvb         long       ts_nsec;
     74  1.5  rvb };
     75  1.5  rvb #else  /* DJGPP but not KERNEL */
     76  1.5  rvb #include <sys/types.h>
     77  1.5  rvb #include <sys/time.h>
     78  1.5  rvb typedef unsigned long long u_quad_t;
     79  1.5  rvb #endif /* !KERNEL */
     80  1.5  rvb #endif /* !DJGPP */
     81  1.5  rvb 
     82  1.5  rvb 
     83  1.5  rvb #if defined(__linux__)
     84  1.1  rvb #define cdev_t u_quad_t
     85  1.1  rvb #if !defined(_UQUAD_T_) && (!defined(__GLIBC__) || __GLIBC__ < 2)
     86  1.1  rvb #define _UQUAD_T_ 1
     87  1.1  rvb typedef unsigned long long u_quad_t;
     88  1.5  rvb #endif
     89  1.1  rvb #else
     90  1.1  rvb #define cdev_t dev_t
     91  1.1  rvb #endif
     92  1.1  rvb 
     93  1.1  rvb #ifdef __CYGWIN32__
     94  1.1  rvb typedef unsigned char u_int8_t;
     95  1.1  rvb struct timespec {
     96  1.1  rvb         time_t  tv_sec;         /* seconds */
     97  1.1  rvb         long    tv_nsec;        /* nanoseconds */
     98  1.1  rvb };
     99  1.1  rvb #endif
    100  1.1  rvb 
    101  1.1  rvb 
    102  1.1  rvb /*
    103  1.5  rvb  * Cfs constants
    104  1.1  rvb  */
    105  1.3  rvb #define CODA_MAXNAMLEN   255
    106  1.3  rvb #define CODA_MAXPATHLEN  1024
    107  1.3  rvb #define CODA_MAXSYMLINK  10
    108  1.1  rvb 
    109  1.1  rvb /* these are Coda's version of O_RDONLY etc combinations
    110  1.1  rvb  * to deal with VFS open modes
    111  1.1  rvb  */
    112  1.1  rvb #define	C_O_READ	0x001
    113  1.1  rvb #define	C_O_WRITE       0x002
    114  1.1  rvb #define C_O_TRUNC       0x010
    115  1.1  rvb #define C_O_EXCL	0x100
    116  1.5  rvb #define C_O_CREAT	0x200
    117  1.1  rvb 
    118  1.1  rvb /* these are to find mode bits in Venus */
    119  1.1  rvb #define C_M_READ  00400
    120  1.1  rvb #define C_M_WRITE 00200
    121  1.1  rvb 
    122  1.1  rvb /* for access Venus will use */
    123  1.5  rvb #define C_A_C_OK    8               /* Test for writing upon create.  */
    124  1.1  rvb #define C_A_R_OK    4               /* Test for read permission.  */
    125  1.1  rvb #define C_A_W_OK    2               /* Test for write permission.  */
    126  1.1  rvb #define C_A_X_OK    1               /* Test for execute permission.  */
    127  1.1  rvb #define C_A_F_OK    0               /* Test for existence.  */
    128  1.1  rvb 
    129  1.1  rvb 
    130  1.1  rvb 
    131  1.1  rvb #ifndef _VENUS_DIRENT_T_
    132  1.1  rvb #define _VENUS_DIRENT_T_ 1
    133  1.1  rvb struct venus_dirent {
    134  1.1  rvb         unsigned long	d_fileno;		/* file number of entry */
    135  1.1  rvb         unsigned short	d_reclen;		/* length of this record */
    136  1.1  rvb         char 		d_type;			/* file type, see below */
    137  1.1  rvb         char		d_namlen;		/* length of string in d_name */
    138  1.3  rvb         char		d_name[CODA_MAXNAMLEN + 1];/* name must be no longer than this */
    139  1.1  rvb };
    140  1.1  rvb #undef DIRSIZ
    141  1.3  rvb #define DIRSIZ(dp)      ((sizeof (struct venus_dirent) - (CODA_MAXNAMLEN+1)) + \
    142  1.1  rvb                          (((dp)->d_namlen+1 + 3) &~ 3))
    143  1.1  rvb 
    144  1.1  rvb /*
    145  1.1  rvb  * File types
    146  1.1  rvb  */
    147  1.1  rvb #define	CDT_UNKNOWN	 0
    148  1.5  rvb #define	CDT_FIFO	 1
    149  1.1  rvb #define	CDT_CHR		 2
    150  1.1  rvb #define	CDT_DIR		 4
    151  1.1  rvb #define	CDT_BLK		 6
    152  1.1  rvb #define	CDT_REG		 8
    153  1.1  rvb #define	CDT_LNK		10
    154  1.5  rvb #define	CDT_SOCK	12
    155  1.1  rvb #define	CDT_WHT		14
    156  1.1  rvb 
    157  1.1  rvb /*
    158  1.1  rvb  * Convert between stat structure types and directory types.
    159  1.1  rvb  */
    160  1.1  rvb #define	IFTOCDT(mode)	(((mode) & 0170000) >> 12)
    161  1.1  rvb #define	CDTTOIF(dirtype)	((dirtype) << 12)
    162  1.1  rvb 
    163  1.1  rvb #endif
    164  1.1  rvb 
    165  1.1  rvb #ifndef	_FID_T_
    166  1.1  rvb #define _FID_T_	1
    167  1.1  rvb typedef u_long VolumeId;
    168  1.1  rvb typedef u_long VnodeId;
    169  1.1  rvb typedef u_long Unique_t;
    170  1.1  rvb typedef u_long FileVersion;
    171  1.1  rvb #endif
    172  1.1  rvb 
    173  1.1  rvb #ifndef	_VICEFID_T_
    174  1.1  rvb #define _VICEFID_T_	1
    175  1.1  rvb typedef struct ViceFid {
    176  1.1  rvb     VolumeId Volume;
    177  1.1  rvb     VnodeId Vnode;
    178  1.1  rvb     Unique_t Unique;
    179  1.1  rvb } ViceFid;
    180  1.1  rvb #endif	/* VICEFID */
    181  1.1  rvb 
    182  1.5  rvb 
    183  1.5  rvb #ifdef __linux__
    184  1.5  rvb static __inline__ ino_t  coda_f2i(struct ViceFid *fid)
    185  1.1  rvb {
    186  1.5  rvb 	if ( ! fid )
    187  1.5  rvb 		return 0;
    188  1.5  rvb 	if (fid->Vnode == 0xfffffffe || fid->Vnode == 0xffffffff)
    189  1.5  rvb 		return ((fid->Volume << 20) | (fid->Unique & 0xfffff));
    190  1.5  rvb 	else
    191  1.5  rvb 		return (fid->Unique + (fid->Vnode<<10) + (fid->Volume<<20));
    192  1.1  rvb }
    193  1.5  rvb 
    194  1.5  rvb #else
    195  1.5  rvb #define coda_f2i(fid)\
    196  1.6  rvb 	((fid) ? ((fid)->Unique + ((fid)->Vnode<<10) + ((fid)->Volume<<20)) : 0)
    197  1.1  rvb #endif
    198  1.1  rvb 
    199  1.5  rvb 
    200  1.5  rvb #ifndef __BIT_TYPES_DEFINED__
    201  1.5  rvb #define u_int32_t unsigned int
    202  1.5  rvb #endif
    203  1.5  rvb 
    204  1.5  rvb 
    205  1.1  rvb #ifndef _VUID_T_
    206  1.1  rvb #define _VUID_T_
    207  1.5  rvb typedef u_int32_t vuid_t;
    208  1.5  rvb typedef u_int32_t vgid_t;
    209  1.1  rvb #endif /*_VUID_T_ */
    210  1.1  rvb 
    211  1.1  rvb #ifndef _CODACRED_T_
    212  1.1  rvb #define _CODACRED_T_
    213  1.1  rvb struct coda_cred {
    214  1.1  rvb     vuid_t cr_uid, cr_euid, cr_suid, cr_fsuid; /* Real, efftve, set, fs uid*/
    215  1.5  rvb     vgid_t cr_groupid,     cr_egid, cr_sgid, cr_fsgid; /* same for groups */
    216  1.1  rvb };
    217  1.1  rvb #endif
    218  1.1  rvb 
    219  1.1  rvb #ifndef _VENUS_VATTR_T_
    220  1.1  rvb #define _VENUS_VATTR_T_
    221  1.1  rvb /*
    222  1.1  rvb  * Vnode types.  VNON means no type.
    223  1.1  rvb  */
    224  1.1  rvb enum coda_vtype	{ C_VNON, C_VREG, C_VDIR, C_VBLK, C_VCHR, C_VLNK, C_VSOCK, C_VFIFO, C_VBAD };
    225  1.1  rvb 
    226  1.1  rvb struct coda_vattr {
    227  1.5  rvb 	int     	va_type;	/* vnode type (for create) */
    228  1.1  rvb 	u_short		va_mode;	/* files access mode and type */
    229  1.1  rvb 	short		va_nlink;	/* number of references to file */
    230  1.1  rvb 	vuid_t		va_uid;		/* owner user id */
    231  1.1  rvb 	vgid_t		va_gid;		/* owner group id */
    232  1.1  rvb 	long		va_fileid;	/* file id */
    233  1.1  rvb 	u_quad_t	va_size;	/* file size in bytes */
    234  1.1  rvb 	long		va_blocksize;	/* blocksize preferred for i/o */
    235  1.1  rvb 	struct timespec	va_atime;	/* time of last access */
    236  1.1  rvb 	struct timespec	va_mtime;	/* time of last modification */
    237  1.1  rvb 	struct timespec	va_ctime;	/* time file changed */
    238  1.1  rvb 	u_long		va_gen;		/* generation number of file */
    239  1.1  rvb 	u_long		va_flags;	/* flags defined for file */
    240  1.1  rvb 	cdev_t	        va_rdev;	/* device special file represents */
    241  1.1  rvb 	u_quad_t	va_bytes;	/* bytes of disk space held by file */
    242  1.1  rvb 	u_quad_t	va_filerev;	/* file modification number */
    243  1.1  rvb };
    244  1.1  rvb 
    245  1.1  rvb #endif
    246  1.1  rvb 
    247  1.1  rvb /*
    248  1.1  rvb  * Kernel <--> Venus communications.
    249  1.1  rvb  */
    250  1.1  rvb 
    251  1.5  rvb #define CODA_ROOT	2
    252  1.5  rvb #define CODA_SYNC	3
    253  1.5  rvb #define CODA_OPEN	4
    254  1.5  rvb #define CODA_CLOSE	5
    255  1.5  rvb #define CODA_IOCTL	6
    256  1.5  rvb #define CODA_GETATTR	7
    257  1.5  rvb #define CODA_SETATTR	8
    258  1.5  rvb #define CODA_ACCESS	9
    259  1.5  rvb #define CODA_LOOKUP	10
    260  1.5  rvb #define CODA_CREATE	11
    261  1.5  rvb #define CODA_REMOVE	12
    262  1.5  rvb #define CODA_LINK	13
    263  1.5  rvb #define CODA_RENAME	14
    264  1.5  rvb #define CODA_MKDIR	15
    265  1.5  rvb #define CODA_RMDIR	16
    266  1.5  rvb #define CODA_READDIR	17
    267  1.5  rvb #define CODA_SYMLINK	18
    268  1.5  rvb #define CODA_READLINK	19
    269  1.5  rvb #define CODA_FSYNC	20
    270  1.5  rvb #define CODA_INACTIVE	21
    271  1.5  rvb #define CODA_VGET	22
    272  1.5  rvb #define CODA_SIGNAL	23
    273  1.5  rvb #define CODA_REPLACE	24
    274  1.5  rvb #define CODA_FLUSH       25
    275  1.5  rvb #define CODA_PURGEUSER   26
    276  1.5  rvb #define CODA_ZAPFILE     27
    277  1.5  rvb #define CODA_ZAPDIR      28
    278  1.5  rvb #define CODA_PURGEFID    30
    279  1.5  rvb #define CODA_OPEN_BY_PATH 31
    280  1.5  rvb #define CODA_RESOLVE     32
    281  1.5  rvb #define CODA_REINTEGRATE 33
    282  1.5  rvb #define CODA_NCALLS 34
    283  1.1  rvb 
    284  1.3  rvb #define DOWNCALL(opcode) (opcode >= CODA_REPLACE && opcode <= CODA_PURGEFID)
    285  1.1  rvb 
    286  1.1  rvb #define VC_MAXDATASIZE	    8192
    287  1.1  rvb #define VC_MAXMSGSIZE      sizeof(union inputArgs)+sizeof(union outputArgs) +\
    288  1.1  rvb                             VC_MAXDATASIZE
    289  1.1  rvb 
    290  1.6  rvb #define CIOC_KERNEL_VERSION _IOWR('c', 10, sizeof (int))
    291  1.6  rvb #if	0
    292  1.6  rvb 	/* don't care about kernel version number */
    293  1.6  rvb #define CODA_KERNEL_VERSION 0
    294  1.6  rvb 	/* The old venus 4.6 compatible interface */
    295  1.6  rvb #define CODA_KERNEL_VERSION 1
    296  1.6  rvb #endif
    297  1.6  rvb 	/* venus_lookup gets an extra parameter to aid windows.*/
    298  1.6  rvb #define CODA_KERNEL_VERSION 2
    299  1.1  rvb 
    300  1.1  rvb /*
    301  1.1  rvb  *        Venus <-> Coda  RPC arguments
    302  1.1  rvb  */
    303  1.3  rvb struct coda_in_hdr {
    304  1.1  rvb     unsigned long opcode;
    305  1.1  rvb     unsigned long unique;	    /* Keep multiple outstanding msgs distinct */
    306  1.1  rvb     u_short pid;		    /* Common to all */
    307  1.1  rvb     u_short pgid;		    /* Common to all */
    308  1.1  rvb     u_short sid;                    /* Common to all */
    309  1.1  rvb     struct coda_cred cred;	    /* Common to all */
    310  1.1  rvb };
    311  1.1  rvb 
    312  1.1  rvb /* Really important that opcode and unique are 1st two fields! */
    313  1.3  rvb struct coda_out_hdr {
    314  1.1  rvb     unsigned long opcode;
    315  1.1  rvb     unsigned long unique;
    316  1.1  rvb     unsigned long result;
    317  1.1  rvb };
    318  1.1  rvb 
    319  1.3  rvb /* coda_root: NO_IN */
    320  1.3  rvb struct coda_root_out {
    321  1.3  rvb     struct coda_out_hdr oh;
    322  1.1  rvb     ViceFid VFid;
    323  1.1  rvb };
    324  1.1  rvb 
    325  1.3  rvb struct coda_root_in {
    326  1.3  rvb     struct coda_in_hdr in;
    327  1.1  rvb };
    328  1.1  rvb 
    329  1.3  rvb /* coda_sync: */
    330  1.3  rvb /* Nothing needed for coda_sync */
    331  1.1  rvb 
    332  1.3  rvb /* coda_open: */
    333  1.3  rvb struct coda_open_in {
    334  1.3  rvb     struct coda_in_hdr ih;
    335  1.1  rvb     ViceFid	VFid;
    336  1.1  rvb     int	flags;
    337  1.1  rvb };
    338  1.1  rvb 
    339  1.3  rvb struct coda_open_out {
    340  1.3  rvb     struct coda_out_hdr oh;
    341  1.1  rvb     cdev_t	dev;
    342  1.1  rvb     ino_t	inode;
    343  1.1  rvb };
    344  1.1  rvb 
    345  1.1  rvb 
    346  1.3  rvb /* coda_close: */
    347  1.3  rvb struct coda_close_in {
    348  1.3  rvb     struct coda_in_hdr ih;
    349  1.1  rvb     ViceFid	VFid;
    350  1.1  rvb     int	flags;
    351  1.1  rvb };
    352  1.1  rvb 
    353  1.3  rvb struct coda_close_out {
    354  1.3  rvb     struct coda_out_hdr out;
    355  1.1  rvb };
    356  1.1  rvb 
    357  1.3  rvb /* coda_ioctl: */
    358  1.3  rvb struct coda_ioctl_in {
    359  1.3  rvb     struct coda_in_hdr ih;
    360  1.1  rvb     ViceFid VFid;
    361  1.1  rvb     int	cmd;
    362  1.1  rvb     int	len;
    363  1.1  rvb     int	rwflag;
    364  1.1  rvb     char *data;			/* Place holder for data. */
    365  1.1  rvb };
    366  1.1  rvb 
    367  1.3  rvb struct coda_ioctl_out {
    368  1.3  rvb     struct coda_out_hdr oh;
    369  1.1  rvb     int	len;
    370  1.1  rvb     caddr_t	data;		/* Place holder for data. */
    371  1.1  rvb };
    372  1.1  rvb 
    373  1.1  rvb 
    374  1.3  rvb /* coda_getattr: */
    375  1.3  rvb struct coda_getattr_in {
    376  1.3  rvb     struct coda_in_hdr ih;
    377  1.1  rvb     ViceFid VFid;
    378  1.1  rvb };
    379  1.1  rvb 
    380  1.3  rvb struct coda_getattr_out {
    381  1.3  rvb     struct coda_out_hdr oh;
    382  1.1  rvb     struct coda_vattr attr;
    383  1.1  rvb };
    384  1.1  rvb 
    385  1.1  rvb 
    386  1.3  rvb /* coda_setattr: NO_OUT */
    387  1.3  rvb struct coda_setattr_in {
    388  1.3  rvb     struct coda_in_hdr ih;
    389  1.1  rvb     ViceFid VFid;
    390  1.1  rvb     struct coda_vattr attr;
    391  1.1  rvb };
    392  1.1  rvb 
    393  1.3  rvb struct coda_setattr_out {
    394  1.3  rvb     struct coda_out_hdr out;
    395  1.1  rvb };
    396  1.1  rvb 
    397  1.3  rvb /* coda_access: NO_OUT */
    398  1.3  rvb struct coda_access_in {
    399  1.3  rvb     struct coda_in_hdr ih;
    400  1.1  rvb     ViceFid	VFid;
    401  1.1  rvb     int	flags;
    402  1.1  rvb };
    403  1.1  rvb 
    404  1.3  rvb struct coda_access_out {
    405  1.3  rvb     struct coda_out_hdr out;
    406  1.1  rvb };
    407  1.1  rvb 
    408  1.6  rvb 
    409  1.6  rvb /* lookup flags */
    410  1.6  rvb #define CLU_CASE_SENSITIVE     0x01
    411  1.6  rvb #define CLU_CASE_INSENSITIVE   0x02
    412  1.6  rvb 
    413  1.3  rvb /* coda_lookup: */
    414  1.3  rvb struct  coda_lookup_in {
    415  1.3  rvb     struct coda_in_hdr ih;
    416  1.1  rvb     ViceFid	VFid;
    417  1.1  rvb     int         name;		/* Place holder for data. */
    418  1.6  rvb     int         flags;
    419  1.1  rvb };
    420  1.1  rvb 
    421  1.3  rvb struct coda_lookup_out {
    422  1.3  rvb     struct coda_out_hdr oh;
    423  1.1  rvb     ViceFid VFid;
    424  1.1  rvb     int	vtype;
    425  1.1  rvb };
    426  1.1  rvb 
    427  1.1  rvb 
    428  1.3  rvb /* coda_create: */
    429  1.3  rvb struct coda_create_in {
    430  1.3  rvb     struct coda_in_hdr ih;
    431  1.1  rvb     ViceFid VFid;
    432  1.1  rvb     struct coda_vattr attr;
    433  1.1  rvb     int excl;
    434  1.1  rvb     int mode;
    435  1.1  rvb     int 	name;		/* Place holder for data. */
    436  1.1  rvb };
    437  1.1  rvb 
    438  1.3  rvb struct coda_create_out {
    439  1.3  rvb     struct coda_out_hdr oh;
    440  1.1  rvb     ViceFid VFid;
    441  1.1  rvb     struct coda_vattr attr;
    442  1.1  rvb };
    443  1.1  rvb 
    444  1.1  rvb 
    445  1.3  rvb /* coda_remove: NO_OUT */
    446  1.3  rvb struct coda_remove_in {
    447  1.3  rvb     struct coda_in_hdr ih;
    448  1.1  rvb     ViceFid	VFid;
    449  1.1  rvb     int name;		/* Place holder for data. */
    450  1.1  rvb };
    451  1.1  rvb 
    452  1.3  rvb struct coda_remove_out {
    453  1.3  rvb     struct coda_out_hdr out;
    454  1.1  rvb };
    455  1.1  rvb 
    456  1.3  rvb /* coda_link: NO_OUT */
    457  1.3  rvb struct coda_link_in {
    458  1.3  rvb     struct coda_in_hdr ih;
    459  1.1  rvb     ViceFid sourceFid;          /* cnode to link *to* */
    460  1.1  rvb     ViceFid destFid;            /* Directory in which to place link */
    461  1.1  rvb     int tname;		/* Place holder for data. */
    462  1.1  rvb };
    463  1.1  rvb 
    464  1.3  rvb struct coda_link_out {
    465  1.3  rvb     struct coda_out_hdr out;
    466  1.1  rvb };
    467  1.1  rvb 
    468  1.1  rvb 
    469  1.3  rvb /* coda_rename: NO_OUT */
    470  1.3  rvb struct coda_rename_in {
    471  1.3  rvb     struct coda_in_hdr ih;
    472  1.1  rvb     ViceFid	sourceFid;
    473  1.1  rvb     int 	srcname;
    474  1.1  rvb     ViceFid destFid;
    475  1.1  rvb     int 	destname;
    476  1.1  rvb };
    477  1.1  rvb 
    478  1.3  rvb struct coda_rename_out {
    479  1.3  rvb     struct coda_out_hdr out;
    480  1.1  rvb };
    481  1.1  rvb 
    482  1.3  rvb /* coda_mkdir: */
    483  1.3  rvb struct coda_mkdir_in {
    484  1.3  rvb     struct coda_in_hdr ih;
    485  1.1  rvb     ViceFid	VFid;
    486  1.1  rvb     struct coda_vattr attr;
    487  1.1  rvb     int	   name;		/* Place holder for data. */
    488  1.1  rvb };
    489  1.1  rvb 
    490  1.3  rvb struct coda_mkdir_out {
    491  1.3  rvb     struct coda_out_hdr oh;
    492  1.1  rvb     ViceFid VFid;
    493  1.1  rvb     struct coda_vattr attr;
    494  1.1  rvb };
    495  1.1  rvb 
    496  1.1  rvb 
    497  1.3  rvb /* coda_rmdir: NO_OUT */
    498  1.3  rvb struct coda_rmdir_in {
    499  1.3  rvb     struct coda_in_hdr ih;
    500  1.1  rvb     ViceFid	VFid;
    501  1.1  rvb     int name;		/* Place holder for data. */
    502  1.1  rvb };
    503  1.1  rvb 
    504  1.3  rvb struct coda_rmdir_out {
    505  1.3  rvb     struct coda_out_hdr out;
    506  1.1  rvb };
    507  1.1  rvb 
    508  1.3  rvb /* coda_readdir: */
    509  1.3  rvb struct coda_readdir_in {
    510  1.3  rvb     struct coda_in_hdr ih;
    511  1.1  rvb     ViceFid	VFid;
    512  1.1  rvb     int	count;
    513  1.1  rvb     int	offset;
    514  1.1  rvb };
    515  1.1  rvb 
    516  1.3  rvb struct coda_readdir_out {
    517  1.3  rvb     struct coda_out_hdr oh;
    518  1.1  rvb     int	size;
    519  1.1  rvb     caddr_t	data;		/* Place holder for data. */
    520  1.1  rvb };
    521  1.1  rvb 
    522  1.3  rvb /* coda_symlink: NO_OUT */
    523  1.3  rvb struct coda_symlink_in {
    524  1.3  rvb     struct coda_in_hdr ih;
    525  1.1  rvb     ViceFid	VFid;          /* Directory to put symlink in */
    526  1.1  rvb     int srcname;
    527  1.1  rvb     struct coda_vattr attr;
    528  1.1  rvb     int tname;
    529  1.1  rvb };
    530  1.1  rvb 
    531  1.3  rvb struct coda_symlink_out {
    532  1.3  rvb     struct coda_out_hdr out;
    533  1.1  rvb };
    534  1.1  rvb 
    535  1.3  rvb /* coda_readlink: */
    536  1.3  rvb struct coda_readlink_in {
    537  1.3  rvb     struct coda_in_hdr ih;
    538  1.1  rvb     ViceFid VFid;
    539  1.1  rvb };
    540  1.1  rvb 
    541  1.3  rvb struct coda_readlink_out {
    542  1.3  rvb     struct coda_out_hdr oh;
    543  1.1  rvb     int	count;
    544  1.1  rvb     caddr_t	data;		/* Place holder for data. */
    545  1.1  rvb };
    546  1.1  rvb 
    547  1.1  rvb 
    548  1.3  rvb /* coda_fsync: NO_OUT */
    549  1.3  rvb struct coda_fsync_in {
    550  1.3  rvb     struct coda_in_hdr ih;
    551  1.1  rvb     ViceFid VFid;
    552  1.1  rvb };
    553  1.1  rvb 
    554  1.3  rvb struct coda_fsync_out {
    555  1.3  rvb     struct coda_out_hdr out;
    556  1.1  rvb };
    557  1.1  rvb 
    558  1.3  rvb /* coda_inactive: NO_OUT */
    559  1.3  rvb struct coda_inactive_in {
    560  1.3  rvb     struct coda_in_hdr ih;
    561  1.1  rvb     ViceFid VFid;
    562  1.1  rvb };
    563  1.1  rvb 
    564  1.3  rvb /* coda_vget: */
    565  1.3  rvb struct coda_vget_in {
    566  1.3  rvb     struct coda_in_hdr ih;
    567  1.1  rvb     ViceFid VFid;
    568  1.1  rvb };
    569  1.1  rvb 
    570  1.3  rvb struct coda_vget_out {
    571  1.3  rvb     struct coda_out_hdr oh;
    572  1.1  rvb     ViceFid VFid;
    573  1.1  rvb     int	vtype;
    574  1.1  rvb };
    575  1.1  rvb 
    576  1.1  rvb 
    577  1.3  rvb /* CODA_SIGNAL is out-of-band, doesn't need data. */
    578  1.3  rvb /* CODA_INVALIDATE is a venus->kernel call */
    579  1.3  rvb /* CODA_FLUSH is a venus->kernel call */
    580  1.3  rvb 
    581  1.3  rvb /* coda_purgeuser: */
    582  1.3  rvb /* CODA_PURGEUSER is a venus->kernel call */
    583  1.3  rvb struct coda_purgeuser_out {
    584  1.3  rvb     struct coda_out_hdr oh;
    585  1.1  rvb     struct coda_cred cred;
    586  1.1  rvb };
    587  1.1  rvb 
    588  1.3  rvb /* coda_zapfile: */
    589  1.3  rvb /* CODA_ZAPFILE is a venus->kernel call */
    590  1.3  rvb struct coda_zapfile_out {
    591  1.3  rvb     struct coda_out_hdr oh;
    592  1.1  rvb     ViceFid CodaFid;
    593  1.1  rvb };
    594  1.1  rvb 
    595  1.3  rvb /* coda_zapdir: */
    596  1.3  rvb /* CODA_ZAPDIR is a venus->kernel call */
    597  1.3  rvb struct coda_zapdir_out {
    598  1.3  rvb     struct coda_out_hdr oh;
    599  1.1  rvb     ViceFid CodaFid;
    600  1.1  rvb };
    601  1.1  rvb 
    602  1.3  rvb /* coda_zapnode: */
    603  1.3  rvb /* CODA_ZAPVNODE is a venus->kernel call */
    604  1.3  rvb struct coda_zapvnode_out {
    605  1.3  rvb     struct coda_out_hdr oh;
    606  1.1  rvb     struct coda_cred cred;
    607  1.1  rvb     ViceFid VFid;
    608  1.1  rvb };
    609  1.1  rvb 
    610  1.3  rvb /* coda_purgefid: */
    611  1.3  rvb /* CODA_PURGEFID is a venus->kernel call */
    612  1.3  rvb struct coda_purgefid_out {
    613  1.3  rvb     struct coda_out_hdr oh;
    614  1.1  rvb     ViceFid CodaFid;
    615  1.1  rvb };
    616  1.1  rvb 
    617  1.3  rvb /* coda_rdwr: */
    618  1.3  rvb struct coda_rdwr_in {
    619  1.3  rvb     struct coda_in_hdr ih;
    620  1.1  rvb     ViceFid	VFid;
    621  1.1  rvb     int	rwflag;
    622  1.1  rvb     int	count;
    623  1.1  rvb     int	offset;
    624  1.1  rvb     int	ioflag;
    625  1.1  rvb     caddr_t	data;		/* Place holder for data. */
    626  1.1  rvb };
    627  1.1  rvb 
    628  1.3  rvb struct coda_rdwr_out {
    629  1.3  rvb     struct coda_out_hdr oh;
    630  1.1  rvb     int	rwflag;
    631  1.1  rvb     int	count;
    632  1.1  rvb     caddr_t	data;	/* Place holder for data. */
    633  1.1  rvb };
    634  1.1  rvb 
    635  1.1  rvb 
    636  1.3  rvb /* coda_replace: */
    637  1.3  rvb /* CODA_REPLACE is a venus->kernel call */
    638  1.3  rvb struct coda_replace_out { /* coda_replace is a venus->kernel call */
    639  1.3  rvb     struct coda_out_hdr oh;
    640  1.1  rvb     ViceFid NewFid;
    641  1.1  rvb     ViceFid OldFid;
    642  1.1  rvb };
    643  1.1  rvb 
    644  1.5  rvb /* coda_open_by_path: */
    645  1.5  rvb struct coda_open_by_path_in {
    646  1.5  rvb     struct coda_in_hdr ih;
    647  1.5  rvb     ViceFid	VFid;
    648  1.5  rvb     int	flags;
    649  1.5  rvb };
    650  1.5  rvb 
    651  1.5  rvb struct coda_open_by_path_out {
    652  1.5  rvb     struct coda_out_hdr oh;
    653  1.5  rvb 	int path;
    654  1.5  rvb };
    655  1.5  rvb 
    656  1.1  rvb /*
    657  1.5  rvb  * Occasionally, we don't cache the fid returned by CODA_LOOKUP.
    658  1.5  rvb  * For instance, if the fid is inconsistent.
    659  1.5  rvb  * This case is handled by setting the top bit of the type result parameter.
    660  1.1  rvb  */
    661  1.3  rvb #define CODA_NOCACHE          0x80000000
    662  1.1  rvb 
    663  1.1  rvb union inputArgs {
    664  1.3  rvb     struct coda_in_hdr ih;		/* NB: every struct below begins with an ih */
    665  1.3  rvb     struct coda_open_in coda_open;
    666  1.3  rvb     struct coda_close_in coda_close;
    667  1.3  rvb     struct coda_ioctl_in coda_ioctl;
    668  1.3  rvb     struct coda_getattr_in coda_getattr;
    669  1.3  rvb     struct coda_setattr_in coda_setattr;
    670  1.3  rvb     struct coda_access_in coda_access;
    671  1.3  rvb     struct coda_lookup_in coda_lookup;
    672  1.3  rvb     struct coda_create_in coda_create;
    673  1.3  rvb     struct coda_remove_in coda_remove;
    674  1.3  rvb     struct coda_link_in coda_link;
    675  1.3  rvb     struct coda_rename_in coda_rename;
    676  1.3  rvb     struct coda_mkdir_in coda_mkdir;
    677  1.3  rvb     struct coda_rmdir_in coda_rmdir;
    678  1.3  rvb     struct coda_readdir_in coda_readdir;
    679  1.3  rvb     struct coda_symlink_in coda_symlink;
    680  1.3  rvb     struct coda_readlink_in coda_readlink;
    681  1.3  rvb     struct coda_fsync_in coda_fsync;
    682  1.3  rvb     struct coda_inactive_in coda_inactive;
    683  1.3  rvb     struct coda_vget_in coda_vget;
    684  1.3  rvb     struct coda_rdwr_in coda_rdwr;
    685  1.5  rvb 	struct coda_open_by_path_in coda_open_by_path;
    686  1.1  rvb };
    687  1.1  rvb 
    688  1.1  rvb union outputArgs {
    689  1.3  rvb     struct coda_out_hdr oh;		/* NB: every struct below begins with an oh */
    690  1.3  rvb     struct coda_root_out coda_root;
    691  1.3  rvb     struct coda_open_out coda_open;
    692  1.3  rvb     struct coda_ioctl_out coda_ioctl;
    693  1.3  rvb     struct coda_getattr_out coda_getattr;
    694  1.3  rvb     struct coda_lookup_out coda_lookup;
    695  1.3  rvb     struct coda_create_out coda_create;
    696  1.3  rvb     struct coda_mkdir_out coda_mkdir;
    697  1.3  rvb     struct coda_readdir_out coda_readdir;
    698  1.3  rvb     struct coda_readlink_out coda_readlink;
    699  1.3  rvb     struct coda_vget_out coda_vget;
    700  1.3  rvb     struct coda_purgeuser_out coda_purgeuser;
    701  1.3  rvb     struct coda_zapfile_out coda_zapfile;
    702  1.3  rvb     struct coda_zapdir_out coda_zapdir;
    703  1.3  rvb     struct coda_zapvnode_out coda_zapvnode;
    704  1.3  rvb     struct coda_purgefid_out coda_purgefid;
    705  1.3  rvb     struct coda_rdwr_out coda_rdwr;
    706  1.3  rvb     struct coda_replace_out coda_replace;
    707  1.5  rvb 	struct coda_open_by_path_out coda_open_by_path;
    708  1.1  rvb };
    709  1.1  rvb 
    710  1.3  rvb union coda_downcalls {
    711  1.3  rvb     /* CODA_INVALIDATE is a venus->kernel call */
    712  1.3  rvb     /* CODA_FLUSH is a venus->kernel call */
    713  1.3  rvb     struct coda_purgeuser_out purgeuser;
    714  1.3  rvb     struct coda_zapfile_out zapfile;
    715  1.3  rvb     struct coda_zapdir_out zapdir;
    716  1.3  rvb     struct coda_zapvnode_out zapvnode;
    717  1.3  rvb     struct coda_purgefid_out purgefid;
    718  1.3  rvb     struct coda_replace_out replace;
    719  1.1  rvb };
    720  1.1  rvb 
    721  1.1  rvb 
    722  1.1  rvb /*
    723  1.1  rvb  * Used for identifying usage of "Control" and pioctls
    724  1.1  rvb  */
    725  1.1  rvb 
    726  1.1  rvb #define PIOCPARM_MASK 0x0000ffff
    727  1.1  rvb struct ViceIoctl {
    728  1.1  rvb         caddr_t in, out;        /* Data to be transferred in, or out */
    729  1.1  rvb         short in_size;          /* Size of input buffer <= 2K */
    730  1.1  rvb         short out_size;         /* Maximum size of output buffer, <= 2K */
    731  1.1  rvb };
    732  1.1  rvb 
    733  1.6  rvb #if defined(__CYGWIN32__) || defined(DJGPP)
    734  1.1  rvb struct PioctlData {
    735  1.6  rvb 	unsigned long cmd;
    736  1.1  rvb         const char *path;
    737  1.1  rvb         int follow;
    738  1.1  rvb         struct ViceIoctl vi;
    739  1.1  rvb };
    740  1.6  rvb #else
    741  1.6  rvb struct PioctlData {
    742  1.6  rvb         const char *path;
    743  1.6  rvb         int follow;
    744  1.6  rvb         struct ViceIoctl vi;
    745  1.6  rvb };
    746  1.6  rvb #endif
    747  1.1  rvb 
    748  1.3  rvb #define	CODA_CONTROL		".CONTROL"
    749  1.3  rvb #define CODA_CONTROLLEN           8
    750  1.1  rvb #define	CTL_VOL			-1
    751  1.1  rvb #define	CTL_VNO			-1
    752  1.1  rvb #define	CTL_UNI			-1
    753  1.1  rvb #define CTL_INO                 -1
    754  1.1  rvb #define	CTL_FILE		"/coda/.CONTROL"
    755  1.1  rvb 
    756  1.1  rvb 
    757  1.1  rvb #define	IS_CTL_FID(fidp)	((fidp)->Volume == CTL_VOL &&\
    758  1.1  rvb 				 (fidp)->Vnode == CTL_VNO &&\
    759  1.1  rvb 				 (fidp)->Unique == CTL_UNI)
    760  1.1  rvb #endif
    761  1.1  rvb 
    762