coda.h revision 1.1.1.1 1 /*
2
3 Coda: an Experimental Distributed File System
4 Release 3.1
5
6 Copyright (c) 1987-1998 Carnegie Mellon University
7 All Rights Reserved
8
9 Permission to use, copy, modify and distribute this software and its
10 documentation is hereby granted, provided that both the copyright
11 notice and this permission notice appear in all copies of the
12 software, derivative works or modified versions, and any portions
13 thereof, and that both notices appear in supporting documentation, and
14 that credit is given to Carnegie Mellon University in all documents
15 and publicity pertaining to direct or indirect use of this code or its
16 derivatives.
17
18 CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
19 SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. CARNEGIE MELLON ALLOWS
20 FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION. CARNEGIE MELLON
21 DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER
22 RESULTING DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
23 ANY DERIVATIVE WORK.
24
25 Carnegie Mellon encourages users of this software to return any
26 improvements or extensions that they make, and to grant Carnegie
27 Mellon the rights to redistribute these changes without encumbrance.
28 */
29
30 /* $Header: /tank/opengrok/rsync2/NetBSD/src/sys/coda/coda.h,v 1.1.1.1 1998/08/29 21:26:46 rvb Exp $ */
31
32 /*
33 *
34 * Based on cfs.h from Mach, but revamped for increased simplicity.
35 * Linux modifications by Peter Braam, Aug 1996
36 */
37
38 #ifndef _CFS_HEADER_
39 #define _CFS_HEADER_
40
41
42
43 /* Catch new _KERNEL defn for NetBSD */
44 #ifdef __NetBSD__
45 #include <sys/types.h>
46 #endif
47
48 #if defined(__linux__) || defined(__CYGWIN32__)
49 #define cdev_t u_quad_t
50 #if !defined(_UQUAD_T_) && (!defined(__GLIBC__) || __GLIBC__ < 2)
51 #define _UQUAD_T_ 1
52 typedef unsigned long long u_quad_t;
53 #endif
54 #else
55 #define cdev_t dev_t
56 #endif
57
58 #ifdef __CYGWIN32__
59 typedef unsigned char u_int8_t;
60 struct timespec {
61 time_t tv_sec; /* seconds */
62 long tv_nsec; /* nanoseconds */
63 };
64 #endif
65
66
67 /*
68 * Cfs constants
69 */
70 #define CFS_MAXNAMLEN 255
71 #define CFS_MAXPATHLEN 1024
72 #define CFS_MAXSYMLINK 10
73
74 /* these are Coda's version of O_RDONLY etc combinations
75 * to deal with VFS open modes
76 */
77 #define C_O_READ 0x001
78 #define C_O_WRITE 0x002
79 #define C_O_TRUNC 0x010
80 #define C_O_EXCL 0x100
81
82 /* these are to find mode bits in Venus */
83 #define C_M_READ 00400
84 #define C_M_WRITE 00200
85
86 /* for access Venus will use */
87 #define C_A_R_OK 4 /* Test for read permission. */
88 #define C_A_W_OK 2 /* Test for write permission. */
89 #define C_A_X_OK 1 /* Test for execute permission. */
90 #define C_A_F_OK 0 /* Test for existence. */
91
92
93
94 #ifndef _VENUS_DIRENT_T_
95 #define _VENUS_DIRENT_T_ 1
96 struct venus_dirent {
97 unsigned long d_fileno; /* file number of entry */
98 unsigned short d_reclen; /* length of this record */
99 char d_type; /* file type, see below */
100 char d_namlen; /* length of string in d_name */
101 char d_name[CFS_MAXNAMLEN + 1];/* name must be no longer than this */
102 };
103 #undef DIRSIZ
104 #define DIRSIZ(dp) ((sizeof (struct venus_dirent) - (CFS_MAXNAMLEN+1)) + \
105 (((dp)->d_namlen+1 + 3) &~ 3))
106
107 /*
108 * File types
109 */
110 #define CDT_UNKNOWN 0
111 #define CDT_FIFO 1
112 #define CDT_CHR 2
113 #define CDT_DIR 4
114 #define CDT_BLK 6
115 #define CDT_REG 8
116 #define CDT_LNK 10
117 #define CDT_SOCK 12
118 #define CDT_WHT 14
119
120 /*
121 * Convert between stat structure types and directory types.
122 */
123 #define IFTOCDT(mode) (((mode) & 0170000) >> 12)
124 #define CDTTOIF(dirtype) ((dirtype) << 12)
125
126 #endif
127
128 #ifndef _FID_T_
129 #define _FID_T_ 1
130 typedef u_long VolumeId;
131 typedef u_long VnodeId;
132 typedef u_long Unique_t;
133 typedef u_long FileVersion;
134 #endif
135
136 #ifndef _VICEFID_T_
137 #define _VICEFID_T_ 1
138 typedef struct ViceFid {
139 VolumeId Volume;
140 VnodeId Vnode;
141 Unique_t Unique;
142 } ViceFid;
143 #endif /* VICEFID */
144
145 #ifdef __linux__
146 static inline ino_t coda_f2i(struct ViceFid *fid)
147 {
148 if ( fid ) {
149 return (fid->Unique + (fid->Vnode << 10) + (fid->Volume << 20));
150 } else {
151 return 0;
152 }
153 }
154 #endif
155
156 #ifndef _VUID_T_
157 #define _VUID_T_
158 typedef u_long vuid_t;
159 typedef u_long vgid_t;
160 #endif /*_VUID_T_ */
161
162 #ifndef _CODACRED_T_
163 #define _CODACRED_T_
164 struct coda_cred {
165 vuid_t cr_uid, cr_euid, cr_suid, cr_fsuid; /* Real, efftve, set, fs uid*/
166 #if defined(__NetBSD__) || defined(__FreeBSD__)
167 vgid_t cr_groupid, cr_egid, cr_sgid, cr_fsgid; /* same for groups */
168 #else
169 vgid_t cr_gid, cr_egid, cr_sgid, cr_fsgid; /* same for groups */
170 #endif
171 };
172 #endif
173
174 #ifndef _VENUS_VATTR_T_
175 #define _VENUS_VATTR_T_
176 /*
177 * Vnode types. VNON means no type.
178 */
179 enum coda_vtype { C_VNON, C_VREG, C_VDIR, C_VBLK, C_VCHR, C_VLNK, C_VSOCK, C_VFIFO, C_VBAD };
180
181 struct coda_vattr {
182 enum coda_vtype va_type; /* vnode type (for create) */
183 u_short va_mode; /* files access mode and type */
184 short va_nlink; /* number of references to file */
185 vuid_t va_uid; /* owner user id */
186 vgid_t va_gid; /* owner group id */
187 long va_fileid; /* file id */
188 u_quad_t va_size; /* file size in bytes */
189 long va_blocksize; /* blocksize preferred for i/o */
190 struct timespec va_atime; /* time of last access */
191 struct timespec va_mtime; /* time of last modification */
192 struct timespec va_ctime; /* time file changed */
193 u_long va_gen; /* generation number of file */
194 u_long va_flags; /* flags defined for file */
195 cdev_t va_rdev; /* device special file represents */
196 u_quad_t va_bytes; /* bytes of disk space held by file */
197 u_quad_t va_filerev; /* file modification number */
198 };
199
200 #endif
201
202 /*
203 * Kernel <--> Venus communications.
204 */
205
206 #define CFS_ROOT ((u_long) 2)
207 #define CFS_SYNC ((u_long) 3)
208 #define CFS_OPEN ((u_long) 4)
209 #define CFS_CLOSE ((u_long) 5)
210 #define CFS_IOCTL ((u_long) 6)
211 #define CFS_GETATTR ((u_long) 7)
212 #define CFS_SETATTR ((u_long) 8)
213 #define CFS_ACCESS ((u_long) 9)
214 #define CFS_LOOKUP ((u_long) 10)
215 #define CFS_CREATE ((u_long) 11)
216 #define CFS_REMOVE ((u_long) 12)
217 #define CFS_LINK ((u_long) 13)
218 #define CFS_RENAME ((u_long) 14)
219 #define CFS_MKDIR ((u_long) 15)
220 #define CFS_RMDIR ((u_long) 16)
221 #define CFS_READDIR ((u_long) 17)
222 #define CFS_SYMLINK ((u_long) 18)
223 #define CFS_READLINK ((u_long) 19)
224 #define CFS_FSYNC ((u_long) 20)
225 #define CFS_INACTIVE ((u_long) 21)
226 #define CFS_VGET ((u_long) 22)
227 #define CFS_SIGNAL ((u_long) 23)
228 #define CFS_REPLACE ((u_long) 24)
229 #define CFS_FLUSH ((u_long) 25)
230 #define CFS_PURGEUSER ((u_long) 26)
231 #define CFS_ZAPFILE ((u_long) 27)
232 #define CFS_ZAPDIR ((u_long) 28)
233 #define CFS_ZAPVNODE ((u_long) 29)
234 #define CFS_PURGEFID ((u_long) 30)
235 #define CFS_NCALLS 31
236
237 #define DOWNCALL(opcode) (opcode >= CFS_REPLACE && opcode <= CFS_PURGEFID)
238
239 #define VC_MAXDATASIZE 8192
240 #define VC_MAXMSGSIZE sizeof(union inputArgs)+sizeof(union outputArgs) +\
241 VC_MAXDATASIZE
242
243
244
245 /*
246 * Venus <-> Coda RPC arguments
247 */
248 struct cfs_in_hdr {
249 unsigned long opcode;
250 unsigned long unique; /* Keep multiple outstanding msgs distinct */
251 u_short pid; /* Common to all */
252 u_short pgid; /* Common to all */
253 u_short sid; /* Common to all */
254 struct coda_cred cred; /* Common to all */
255 };
256
257 /* Really important that opcode and unique are 1st two fields! */
258 struct cfs_out_hdr {
259 unsigned long opcode;
260 unsigned long unique;
261 unsigned long result;
262 };
263
264 /* cfs_root: NO_IN */
265 struct cfs_root_out {
266 struct cfs_out_hdr oh;
267 ViceFid VFid;
268 };
269
270 struct cfs_root_in {
271 struct cfs_in_hdr in;
272 };
273
274 /* cfs_sync: */
275 /* Nothing needed for cfs_sync */
276
277 /* cfs_open: */
278 struct cfs_open_in {
279 struct cfs_in_hdr ih;
280 ViceFid VFid;
281 int flags;
282 };
283
284 struct cfs_open_out {
285 struct cfs_out_hdr oh;
286 cdev_t dev;
287 ino_t inode;
288 };
289
290
291 /* cfs_close: */
292 struct cfs_close_in {
293 struct cfs_in_hdr ih;
294 ViceFid VFid;
295 int flags;
296 };
297
298 struct cfs_close_out {
299 struct cfs_out_hdr out;
300 };
301
302 /* cfs_ioctl: */
303 struct cfs_ioctl_in {
304 struct cfs_in_hdr ih;
305 ViceFid VFid;
306 int cmd;
307 int len;
308 int rwflag;
309 char *data; /* Place holder for data. */
310 };
311
312 struct cfs_ioctl_out {
313 struct cfs_out_hdr oh;
314 int len;
315 caddr_t data; /* Place holder for data. */
316 };
317
318
319 /* cfs_getattr: */
320 struct cfs_getattr_in {
321 struct cfs_in_hdr ih;
322 ViceFid VFid;
323 };
324
325 struct cfs_getattr_out {
326 struct cfs_out_hdr oh;
327 struct coda_vattr attr;
328 };
329
330
331 /* cfs_setattr: NO_OUT */
332 struct cfs_setattr_in {
333 struct cfs_in_hdr ih;
334 ViceFid VFid;
335 struct coda_vattr attr;
336 };
337
338 struct cfs_setattr_out {
339 struct cfs_out_hdr out;
340 };
341
342 /* cfs_access: NO_OUT */
343 struct cfs_access_in {
344 struct cfs_in_hdr ih;
345 ViceFid VFid;
346 int flags;
347 };
348
349 struct cfs_access_out {
350 struct cfs_out_hdr out;
351 };
352
353 /* cfs_lookup: */
354 struct cfs_lookup_in {
355 struct cfs_in_hdr ih;
356 ViceFid VFid;
357 int name; /* Place holder for data. */
358 };
359
360 struct cfs_lookup_out {
361 struct cfs_out_hdr oh;
362 ViceFid VFid;
363 int vtype;
364 };
365
366
367 /* cfs_create: */
368 struct cfs_create_in {
369 struct cfs_in_hdr ih;
370 ViceFid VFid;
371 struct coda_vattr attr;
372 int excl;
373 int mode;
374 int name; /* Place holder for data. */
375 };
376
377 struct cfs_create_out {
378 struct cfs_out_hdr oh;
379 ViceFid VFid;
380 struct coda_vattr attr;
381 };
382
383
384 /* cfs_remove: NO_OUT */
385 struct cfs_remove_in {
386 struct cfs_in_hdr ih;
387 ViceFid VFid;
388 int name; /* Place holder for data. */
389 };
390
391 struct cfs_remove_out {
392 struct cfs_out_hdr out;
393 };
394
395 /* cfs_link: NO_OUT */
396 struct cfs_link_in {
397 struct cfs_in_hdr ih;
398 ViceFid sourceFid; /* cnode to link *to* */
399 ViceFid destFid; /* Directory in which to place link */
400 int tname; /* Place holder for data. */
401 };
402
403 struct cfs_link_out {
404 struct cfs_out_hdr out;
405 };
406
407
408 /* cfs_rename: NO_OUT */
409 struct cfs_rename_in {
410 struct cfs_in_hdr ih;
411 ViceFid sourceFid;
412 int srcname;
413 ViceFid destFid;
414 int destname;
415 };
416
417 struct cfs_rename_out {
418 struct cfs_out_hdr out;
419 };
420
421 /* cfs_mkdir: */
422 struct cfs_mkdir_in {
423 struct cfs_in_hdr ih;
424 ViceFid VFid;
425 struct coda_vattr attr;
426 int name; /* Place holder for data. */
427 };
428
429 struct cfs_mkdir_out {
430 struct cfs_out_hdr oh;
431 ViceFid VFid;
432 struct coda_vattr attr;
433 };
434
435
436 /* cfs_rmdir: NO_OUT */
437 struct cfs_rmdir_in {
438 struct cfs_in_hdr ih;
439 ViceFid VFid;
440 int name; /* Place holder for data. */
441 };
442
443 struct cfs_rmdir_out {
444 struct cfs_out_hdr out;
445 };
446
447 /* cfs_readdir: */
448 struct cfs_readdir_in {
449 struct cfs_in_hdr ih;
450 ViceFid VFid;
451 int count;
452 int offset;
453 };
454
455 struct cfs_readdir_out {
456 struct cfs_out_hdr oh;
457 int size;
458 caddr_t data; /* Place holder for data. */
459 };
460
461 /* cfs_symlink: NO_OUT */
462 struct cfs_symlink_in {
463 struct cfs_in_hdr ih;
464 ViceFid VFid; /* Directory to put symlink in */
465 int srcname;
466 struct coda_vattr attr;
467 int tname;
468 };
469
470 struct cfs_symlink_out {
471 struct cfs_out_hdr out;
472 };
473
474 /* cfs_readlink: */
475 struct cfs_readlink_in {
476 struct cfs_in_hdr ih;
477 ViceFid VFid;
478 };
479
480 struct cfs_readlink_out {
481 struct cfs_out_hdr oh;
482 int count;
483 caddr_t data; /* Place holder for data. */
484 };
485
486
487 /* cfs_fsync: NO_OUT */
488 struct cfs_fsync_in {
489 struct cfs_in_hdr ih;
490 ViceFid VFid;
491 };
492
493 struct cfs_fsync_out {
494 struct cfs_out_hdr out;
495 };
496
497 /* cfs_inactive: NO_OUT */
498 struct cfs_inactive_in {
499 struct cfs_in_hdr ih;
500 ViceFid VFid;
501 };
502
503 /* cfs_vget: */
504 struct cfs_vget_in {
505 struct cfs_in_hdr ih;
506 ViceFid VFid;
507 };
508
509 struct cfs_vget_out {
510 struct cfs_out_hdr oh;
511 ViceFid VFid;
512 int vtype;
513 };
514
515
516 /* CFS_SIGNAL is out-of-band, doesn't need data. */
517 /* CFS_INVALIDATE is a venus->kernel call */
518 /* CFS_FLUSH is a venus->kernel call */
519
520 /* cfs_purgeuser: */
521 /* CFS_PURGEUSER is a venus->kernel call */
522 struct cfs_purgeuser_out {
523 struct cfs_out_hdr oh;
524 struct coda_cred cred;
525 };
526
527 /* cfs_zapfile: */
528 /* CFS_ZAPFILE is a venus->kernel call */
529 struct cfs_zapfile_out {
530 struct cfs_out_hdr oh;
531 ViceFid CodaFid;
532 };
533
534 /* cfs_zapdir: */
535 /* CFS_ZAPDIR is a venus->kernel call */
536 struct cfs_zapdir_out {
537 struct cfs_out_hdr oh;
538 ViceFid CodaFid;
539 };
540
541 /* cfs_zapnode: */
542 /* CFS_ZAPVNODE is a venus->kernel call */
543 struct cfs_zapvnode_out {
544 struct cfs_out_hdr oh;
545 struct coda_cred cred;
546 ViceFid VFid;
547 };
548
549 /* cfs_purgefid: */
550 /* CFS_PURGEFID is a venus->kernel call */
551 struct cfs_purgefid_out {
552 struct cfs_out_hdr oh;
553 ViceFid CodaFid;
554 };
555
556 /* cfs_rdwr: */
557 struct cfs_rdwr_in {
558 struct cfs_in_hdr ih;
559 ViceFid VFid;
560 int rwflag;
561 int count;
562 int offset;
563 int ioflag;
564 caddr_t data; /* Place holder for data. */
565 };
566
567 struct cfs_rdwr_out {
568 struct cfs_out_hdr oh;
569 int rwflag;
570 int count;
571 caddr_t data; /* Place holder for data. */
572 };
573
574
575 /* cfs_replace: */
576 /* CFS_REPLACE is a venus->kernel call */
577 struct cfs_replace_out { /* cfs_replace is a venus->kernel call */
578 struct cfs_out_hdr oh;
579 ViceFid NewFid;
580 ViceFid OldFid;
581 };
582
583 /*
584 * Occasionally, don't cache the fid returned by CFS_LOOKUP. For instance, if
585 * the fid is inconsistent. This case is handled by setting the top bit of the
586 * return result parameter.
587 */
588 #define CFS_NOCACHE 0x80000000
589
590 union inputArgs {
591 struct cfs_in_hdr ih; /* NB: every struct below begins with an ih */
592 struct cfs_open_in cfs_open;
593 struct cfs_close_in cfs_close;
594 struct cfs_ioctl_in cfs_ioctl;
595 struct cfs_getattr_in cfs_getattr;
596 struct cfs_setattr_in cfs_setattr;
597 struct cfs_access_in cfs_access;
598 struct cfs_lookup_in cfs_lookup;
599 struct cfs_create_in cfs_create;
600 struct cfs_remove_in cfs_remove;
601 struct cfs_link_in cfs_link;
602 struct cfs_rename_in cfs_rename;
603 struct cfs_mkdir_in cfs_mkdir;
604 struct cfs_rmdir_in cfs_rmdir;
605 struct cfs_readdir_in cfs_readdir;
606 struct cfs_symlink_in cfs_symlink;
607 struct cfs_readlink_in cfs_readlink;
608 struct cfs_fsync_in cfs_fsync;
609 struct cfs_inactive_in cfs_inactive;
610 struct cfs_vget_in cfs_vget;
611 struct cfs_rdwr_in cfs_rdwr;
612 };
613
614 union outputArgs {
615 struct cfs_out_hdr oh; /* NB: every struct below begins with an oh */
616 struct cfs_root_out cfs_root;
617 struct cfs_open_out cfs_open;
618 struct cfs_ioctl_out cfs_ioctl;
619 struct cfs_getattr_out cfs_getattr;
620 struct cfs_lookup_out cfs_lookup;
621 struct cfs_create_out cfs_create;
622 struct cfs_mkdir_out cfs_mkdir;
623 struct cfs_readdir_out cfs_readdir;
624 struct cfs_readlink_out cfs_readlink;
625 struct cfs_vget_out cfs_vget;
626 struct cfs_purgeuser_out cfs_purgeuser;
627 struct cfs_zapfile_out cfs_zapfile;
628 struct cfs_zapdir_out cfs_zapdir;
629 struct cfs_zapvnode_out cfs_zapvnode;
630 struct cfs_purgefid_out cfs_purgefid;
631 struct cfs_rdwr_out cfs_rdwr;
632 struct cfs_replace_out cfs_replace;
633 };
634
635 union cfs_downcalls {
636 /* CFS_INVALIDATE is a venus->kernel call */
637 /* CFS_FLUSH is a venus->kernel call */
638 struct cfs_purgeuser_out purgeuser;
639 struct cfs_zapfile_out zapfile;
640 struct cfs_zapdir_out zapdir;
641 struct cfs_zapvnode_out zapvnode;
642 struct cfs_purgefid_out purgefid;
643 struct cfs_replace_out replace;
644 };
645
646
647 /*
648 * Used for identifying usage of "Control" and pioctls
649 */
650
651 #define PIOCPARM_MASK 0x0000ffff
652 struct ViceIoctl {
653 caddr_t in, out; /* Data to be transferred in, or out */
654 short in_size; /* Size of input buffer <= 2K */
655 short out_size; /* Maximum size of output buffer, <= 2K */
656 };
657
658 struct PioctlData {
659 const char *path;
660 int follow;
661 struct ViceIoctl vi;
662 };
663
664 #define CFS_CONTROL ".CONTROL"
665 #define CFS_CONTROLLEN 8
666 #define CTL_VOL -1
667 #define CTL_VNO -1
668 #define CTL_UNI -1
669 #define CTL_INO -1
670 #define CTL_FILE "/coda/.CONTROL"
671
672
673 #define IS_CTL_FID(fidp) ((fidp)->Volume == CTL_VOL &&\
674 (fidp)->Vnode == CTL_VNO &&\
675 (fidp)->Unique == CTL_UNI)
676 #endif
677
678