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