1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59#ifndef _CODA_HEADER_
60#define _CODA_HEADER_
61
62#include <linux/config.h>
63
64
65#if defined(__NetBSD__) || \
66 ((defined(DJGPP) || defined(__CYGWIN32__)) && !defined(KERNEL))
67#include <sys/types.h>
68#endif
69
70#ifndef CODA_MAXSYMLINKS
71#define CODA_MAXSYMLINKS 10
72#endif
73
74#if defined(DJGPP) || defined(__CYGWIN32__)
75#ifdef KERNEL
76typedef unsigned long u_long;
77typedef unsigned int u_int;
78typedef unsigned short u_short;
79typedef u_long ino_t;
80typedef u_long dev_t;
81typedef void * caddr_t;
82#ifdef DOS
83typedef unsigned __int64 u_quad_t;
84#else
85typedef unsigned long long u_quad_t;
86#endif
87
88#define inline
89
90struct timespec {
91 long ts_sec;
92 long ts_nsec;
93};
94#else
95#include <sys/time.h>
96typedef unsigned long long u_quad_t;
97#endif
98#endif
99
100
101#if defined(__linux__)
102#include <linux/time.h>
103#define cdev_t u_quad_t
104#ifndef __KERNEL__
105#if !defined(_UQUAD_T_) && (!defined(__GLIBC__) || __GLIBC__ < 2)
106#define _UQUAD_T_ 1
107typedef unsigned long long u_quad_t;
108#endif
109#else
110typedef unsigned long long u_quad_t;
111#endif
112#else
113#define cdev_t dev_t
114#endif
115
116#ifdef __CYGWIN32__
117struct timespec {
118 time_t tv_sec;
119 long tv_nsec;
120};
121#endif
122
123#ifndef __BIT_TYPES_DEFINED__
124#define __BIT_TYPES_DEFINED__
125typedef signed char int8_t;
126typedef unsigned char u_int8_t;
127typedef short int16_t;
128typedef unsigned short u_int16_t;
129typedef int int32_t;
130typedef unsigned int u_int32_t;
131#endif
132
133
134
135
136
137#define CODA_MAXNAMLEN 255
138#define CODA_MAXPATHLEN 1024
139#define CODA_MAXSYMLINK 10
140
141
142
143
144#define C_O_READ 0x001
145#define C_O_WRITE 0x002
146#define C_O_TRUNC 0x010
147#define C_O_EXCL 0x100
148#define C_O_CREAT 0x200
149
150
151#define C_M_READ 00400
152#define C_M_WRITE 00200
153
154
155#define C_A_C_OK 8
156#define C_A_R_OK 4
157#define C_A_W_OK 2
158#define C_A_X_OK 1
159#define C_A_F_OK 0
160
161
162
163#ifndef _VENUS_DIRENT_T_
164#define _VENUS_DIRENT_T_ 1
165struct venus_dirent {
166 u_int32_t d_fileno;
167 u_int16_t d_reclen;
168 u_int8_t d_type;
169 u_int8_t d_namlen;
170 char d_name[CODA_MAXNAMLEN + 1];
171};
172#undef DIRSIZ
173#define DIRSIZ(dp) ((sizeof (struct venus_dirent) - (CODA_MAXNAMLEN+1)) + \
174 (((dp)->d_namlen+1 + 3) &~ 3))
175
176
177
178
179#define CDT_UNKNOWN 0
180#define CDT_FIFO 1
181#define CDT_CHR 2
182#define CDT_DIR 4
183#define CDT_BLK 6
184#define CDT_REG 8
185#define CDT_LNK 10
186#define CDT_SOCK 12
187#define CDT_WHT 14
188
189
190
191
192#define IFTOCDT(mode) (((mode) & 0170000) >> 12)
193#define CDTTOIF(dirtype) ((dirtype) << 12)
194
195#endif
196
197#ifndef _VUID_T_
198#define _VUID_T_
199typedef u_int32_t vuid_t;
200typedef u_int32_t vgid_t;
201#endif
202
203#ifdef CONFIG_CODA_FS_OLD_API
204struct CodaFid {
205 u_int32_t opaque[3];
206};
207
208static __inline__ ino_t coda_f2i(struct CodaFid *fid)
209{
210 if ( ! fid )
211 return 0;
212 if (fid->opaque[1] == 0xfffffffe || fid->opaque[1] == 0xffffffff)
213 return ((fid->opaque[0] << 20) | (fid->opaque[2] & 0xfffff));
214 else
215 return (fid->opaque[2] + (fid->opaque[1]<<10) + (fid->opaque[0]<<20));
216}
217
218struct coda_cred {
219 vuid_t cr_uid, cr_euid, cr_suid, cr_fsuid;
220 vgid_t cr_groupid, cr_egid, cr_sgid, cr_fsgid;
221};
222
223#else
224
225struct CodaFid {
226 u_int32_t opaque[4];
227};
228
229#define coda_f2i(fid)\
230 (fid ? (fid->opaque[3] ^ (fid->opaque[2]<<10) ^ (fid->opaque[1]<<20) ^ fid->opaque[0]) : 0)
231
232#endif
233
234#ifndef _VENUS_VATTR_T_
235#define _VENUS_VATTR_T_
236
237
238
239enum coda_vtype { C_VNON, C_VREG, C_VDIR, C_VBLK, C_VCHR, C_VLNK, C_VSOCK, C_VFIFO, C_VBAD };
240
241struct coda_vattr {
242 long va_type;
243 u_short va_mode;
244 short va_nlink;
245 vuid_t va_uid;
246 vgid_t va_gid;
247 long va_fileid;
248 u_quad_t va_size;
249 long va_blocksize;
250 struct timespec va_atime;
251 struct timespec va_mtime;
252 struct timespec va_ctime;
253 u_long va_gen;
254 u_long va_flags;
255 cdev_t va_rdev;
256 u_quad_t va_bytes;
257 u_quad_t va_filerev;
258};
259
260#endif
261
262
263struct coda_statfs {
264 int32_t f_blocks;
265 int32_t f_bfree;
266 int32_t f_bavail;
267 int32_t f_files;
268 int32_t f_ffree;
269};
270
271
272
273
274
275#define CODA_ROOT 2
276#define CODA_OPEN_BY_FD 3
277#define CODA_OPEN 4
278#define CODA_CLOSE 5
279#define CODA_IOCTL 6
280#define CODA_GETATTR 7
281#define CODA_SETATTR 8
282#define CODA_ACCESS 9
283#define CODA_LOOKUP 10
284#define CODA_CREATE 11
285#define CODA_REMOVE 12
286#define CODA_LINK 13
287#define CODA_RENAME 14
288#define CODA_MKDIR 15
289#define CODA_RMDIR 16
290#define CODA_SYMLINK 18
291#define CODA_READLINK 19
292#define CODA_FSYNC 20
293#define CODA_VGET 22
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_STATFS 34
305#define CODA_STORE 35
306#define CODA_RELEASE 36
307#define CODA_NCALLS 37
308
309#define DOWNCALL(opcode) (opcode >= CODA_REPLACE && opcode <= CODA_PURGEFID)
310
311#define VC_MAXDATASIZE 8192
312#define VC_MAXMSGSIZE sizeof(union inputArgs)+sizeof(union outputArgs) +\
313 VC_MAXDATASIZE
314
315#define CIOC_KERNEL_VERSION _IOWR('c', 10, size_t)
316
317#if 0
318#define CODA_KERNEL_VERSION 0
319#define CODA_KERNEL_VERSION 1
320#endif
321#ifdef CONFIG_CODA_FS_OLD_API
322#define CODA_KERNEL_VERSION 2
323#else
324#define CODA_KERNEL_VERSION 3
325#endif
326
327
328
329
330struct coda_in_hdr {
331 u_int32_t opcode;
332 u_int32_t unique;
333#ifdef CONFIG_CODA_FS_OLD_API
334 u_int16_t pid;
335 u_int16_t pgid;
336 u_int16_t sid;
337 struct coda_cred cred;
338#else
339 pid_t pid;
340 pid_t pgid;
341 vuid_t uid;
342#endif
343};
344
345
346struct coda_out_hdr {
347 u_int32_t opcode;
348 u_int32_t unique;
349 u_int32_t result;
350};
351
352
353struct coda_root_out {
354 struct coda_out_hdr oh;
355 struct CodaFid VFid;
356};
357
358struct coda_root_in {
359 struct coda_in_hdr in;
360};
361
362
363struct coda_open_in {
364 struct coda_in_hdr ih;
365 struct CodaFid VFid;
366 int flags;
367};
368
369struct coda_open_out {
370 struct coda_out_hdr oh;
371 cdev_t dev;
372 ino_t inode;
373};
374
375
376
377struct coda_store_in {
378 struct coda_in_hdr ih;
379 struct CodaFid VFid;
380 int flags;
381};
382
383struct coda_store_out {
384 struct coda_out_hdr out;
385};
386
387
388struct coda_release_in {
389 struct coda_in_hdr ih;
390 struct CodaFid VFid;
391 int flags;
392};
393
394struct coda_release_out {
395 struct coda_out_hdr out;
396};
397
398
399struct coda_close_in {
400 struct coda_in_hdr ih;
401 struct CodaFid VFid;
402 int flags;
403};
404
405struct coda_close_out {
406 struct coda_out_hdr out;
407};
408
409
410struct coda_ioctl_in {
411 struct coda_in_hdr ih;
412 struct CodaFid VFid;
413 int cmd;
414 int len;
415 int rwflag;
416 char *data;
417};
418
419struct coda_ioctl_out {
420 struct coda_out_hdr oh;
421 int len;
422 caddr_t data;
423};
424
425
426
427struct coda_getattr_in {
428 struct coda_in_hdr ih;
429 struct CodaFid VFid;
430};
431
432struct coda_getattr_out {
433 struct coda_out_hdr oh;
434 struct coda_vattr attr;
435};
436
437
438
439struct coda_setattr_in {
440 struct coda_in_hdr ih;
441 struct CodaFid VFid;
442 struct coda_vattr attr;
443};
444
445struct coda_setattr_out {
446 struct coda_out_hdr out;
447};
448
449
450struct coda_access_in {
451 struct coda_in_hdr ih;
452 struct CodaFid VFid;
453 int flags;
454};
455
456struct coda_access_out {
457 struct coda_out_hdr out;
458};
459
460
461
462#define CLU_CASE_SENSITIVE 0x01
463#define CLU_CASE_INSENSITIVE 0x02
464
465
466struct coda_lookup_in {
467 struct coda_in_hdr ih;
468 struct CodaFid VFid;
469 int name;
470 int flags;
471};
472
473struct coda_lookup_out {
474 struct coda_out_hdr oh;
475 struct CodaFid VFid;
476 int vtype;
477};
478
479
480
481struct coda_create_in {
482 struct coda_in_hdr ih;
483 struct CodaFid VFid;
484 struct coda_vattr attr;
485 int excl;
486 int mode;
487 int name;
488};
489
490struct coda_create_out {
491 struct coda_out_hdr oh;
492 struct CodaFid VFid;
493 struct coda_vattr attr;
494};
495
496
497
498struct coda_remove_in {
499 struct coda_in_hdr ih;
500 struct CodaFid VFid;
501 int name;
502};
503
504struct coda_remove_out {
505 struct coda_out_hdr out;
506};
507
508
509struct coda_link_in {
510 struct coda_in_hdr ih;
511 struct CodaFid sourceFid;
512 struct CodaFid destFid;
513 int tname;
514};
515
516struct coda_link_out {
517 struct coda_out_hdr out;
518};
519
520
521
522struct coda_rename_in {
523 struct coda_in_hdr ih;
524 struct CodaFid sourceFid;
525 int srcname;
526 struct CodaFid destFid;
527 int destname;
528};
529
530struct coda_rename_out {
531 struct coda_out_hdr out;
532};
533
534
535struct coda_mkdir_in {
536 struct coda_in_hdr ih;
537 struct CodaFid VFid;
538 struct coda_vattr attr;
539 int name;
540};
541
542struct coda_mkdir_out {
543 struct coda_out_hdr oh;
544 struct CodaFid VFid;
545 struct coda_vattr attr;
546};
547
548
549
550struct coda_rmdir_in {
551 struct coda_in_hdr ih;
552 struct CodaFid VFid;
553 int name;
554};
555
556struct coda_rmdir_out {
557 struct coda_out_hdr out;
558};
559
560
561struct coda_symlink_in {
562 struct coda_in_hdr ih;
563 struct CodaFid VFid;
564 int srcname;
565 struct coda_vattr attr;
566 int tname;
567};
568
569struct coda_symlink_out {
570 struct coda_out_hdr out;
571};
572
573
574struct coda_readlink_in {
575 struct coda_in_hdr ih;
576 struct CodaFid VFid;
577};
578
579struct coda_readlink_out {
580 struct coda_out_hdr oh;
581 int count;
582 caddr_t data;
583};
584
585
586
587struct coda_fsync_in {
588 struct coda_in_hdr ih;
589 struct CodaFid VFid;
590};
591
592struct coda_fsync_out {
593 struct coda_out_hdr out;
594};
595
596
597struct coda_vget_in {
598 struct coda_in_hdr ih;
599 struct CodaFid VFid;
600};
601
602struct coda_vget_out {
603 struct coda_out_hdr oh;
604 struct CodaFid VFid;
605 int vtype;
606};
607
608
609
610
611
612
613
614
615struct coda_purgeuser_out {
616 struct coda_out_hdr oh;
617#ifdef CONFIG_CODA_FS_OLD_API
618 struct coda_cred cred;
619#else
620 vuid_t uid;
621#endif
622};
623
624
625
626struct coda_zapfile_out {
627 struct coda_out_hdr oh;
628 struct CodaFid CodaFid;
629};
630
631
632
633struct coda_zapdir_out {
634 struct coda_out_hdr oh;
635 struct CodaFid CodaFid;
636};
637
638
639
640struct coda_purgefid_out {
641 struct coda_out_hdr oh;
642 struct CodaFid CodaFid;
643};
644
645
646
647struct coda_replace_out {
648 struct coda_out_hdr oh;
649 struct CodaFid NewFid;
650 struct CodaFid OldFid;
651};
652
653
654struct coda_open_by_fd_in {
655 struct coda_in_hdr ih;
656 struct CodaFid VFid;
657 int flags;
658};
659
660struct coda_open_by_fd_out {
661 struct coda_out_hdr oh;
662 int fd;
663
664#ifdef __KERNEL__
665 struct file *fh;
666#endif
667};
668
669
670struct coda_open_by_path_in {
671 struct coda_in_hdr ih;
672 struct CodaFid VFid;
673 int flags;
674};
675
676struct coda_open_by_path_out {
677 struct coda_out_hdr oh;
678 int path;
679};
680
681
682struct coda_statfs_in {
683 struct coda_in_hdr in;
684};
685
686struct coda_statfs_out {
687 struct coda_out_hdr oh;
688 struct coda_statfs stat;
689};
690
691
692
693
694
695
696#define CODA_NOCACHE 0x80000000
697
698union inputArgs {
699 struct coda_in_hdr ih;
700 struct coda_open_in coda_open;
701 struct coda_store_in coda_store;
702 struct coda_release_in coda_release;
703 struct coda_close_in coda_close;
704 struct coda_ioctl_in coda_ioctl;
705 struct coda_getattr_in coda_getattr;
706 struct coda_setattr_in coda_setattr;
707 struct coda_access_in coda_access;
708 struct coda_lookup_in coda_lookup;
709 struct coda_create_in coda_create;
710 struct coda_remove_in coda_remove;
711 struct coda_link_in coda_link;
712 struct coda_rename_in coda_rename;
713 struct coda_mkdir_in coda_mkdir;
714 struct coda_rmdir_in coda_rmdir;
715 struct coda_symlink_in coda_symlink;
716 struct coda_readlink_in coda_readlink;
717 struct coda_fsync_in coda_fsync;
718 struct coda_vget_in coda_vget;
719 struct coda_open_by_fd_in coda_open_by_fd;
720 struct coda_open_by_path_in coda_open_by_path;
721 struct coda_statfs_in coda_statfs;
722};
723
724union outputArgs {
725 struct coda_out_hdr oh;
726 struct coda_root_out coda_root;
727 struct coda_open_out coda_open;
728 struct coda_ioctl_out coda_ioctl;
729 struct coda_getattr_out coda_getattr;
730 struct coda_lookup_out coda_lookup;
731 struct coda_create_out coda_create;
732 struct coda_mkdir_out coda_mkdir;
733 struct coda_readlink_out coda_readlink;
734 struct coda_vget_out coda_vget;
735 struct coda_purgeuser_out coda_purgeuser;
736 struct coda_zapfile_out coda_zapfile;
737 struct coda_zapdir_out coda_zapdir;
738 struct coda_purgefid_out coda_purgefid;
739 struct coda_replace_out coda_replace;
740 struct coda_open_by_fd_out coda_open_by_fd;
741 struct coda_open_by_path_out coda_open_by_path;
742 struct coda_statfs_out coda_statfs;
743};
744
745union coda_downcalls {
746
747
748 struct coda_purgeuser_out purgeuser;
749 struct coda_zapfile_out zapfile;
750 struct coda_zapdir_out zapdir;
751 struct coda_purgefid_out purgefid;
752 struct coda_replace_out replace;
753};
754
755
756
757
758
759
760#define PIOCPARM_MASK 0x0000ffff
761struct ViceIoctl {
762 void __user *in;
763 void __user *out;
764 short in_size;
765 short out_size;
766};
767
768struct PioctlData {
769 const char __user *path;
770 int follow;
771 struct ViceIoctl vi;
772};
773
774#define CODA_CONTROL ".CONTROL"
775#define CODA_CONTROLLEN 8
776#define CTL_INO -1
777
778
779
780#define CODA_MOUNT_VERSION 1
781
782struct coda_mount_data {
783 int version;
784 int fd;
785};
786
787#endif
788
789