xref: /plan9/sys/src/cmd/cwfs/all.h (revision 01a344a29f2ff35133953eaef092a50fc8c3163b)
1 #include <u.h>
2 #include <libc.h>
3 #include <ctype.h>
4 #define Tfile Tfilescsi		/* avoid name conflict */
5 #include <disk.h>
6 #undef	Tfile
7 #include <bio.h>
8 #include <ip.h>
9 
10 #include "dat.h"
11 #include "portfns.h"
12 
13 #define malloc(n)	ialloc(n, 0)
14 
15 #define	CHAT(cp) ((cons.flags&chatflag) || \
16 			((cp) && (((Chan*)(cp))->flags&chatflag)))
17 #define	QID9P1(a,b)	(Qid9p1){a,b}
18 
19 #define SECOND(n)	(n)
20 #define MINUTE(n)	((n)*SECOND(60))
21 #define HOUR(n)		((n)*MINUTE(60))
22 #define DAY(n)		((n)*HOUR(24))
23 
24 enum {
25 	QPDIR		= 0x80000000L,
26 	QPNONE		= 0,
27 	QPROOT		= 1,
28 	QPSUPER		= 2,
29 
30 	/*
31 	 * perm argument in 9P create
32 	 */
33 	PDIR		= 1L<<31,	/* is a directory */
34 	PAPND		= 1L<<30,	/* is append only */
35 	PLOCK		= 1L<<29,	/* is locked on open */
36 
37 	FID1		= 1,
38 	FID2		= 2,
39 
40 	MAXBIAS		= SECOND(20),
41 	TLOCK		= MINUTE(5),
42 };
43 
44 Uid*	uid;
45 short*	gidspace;
46 Lock	printing;
47 Time	tim;
48 File*	files;
49 Wpath*	wpaths;
50 Lock	wpathlock;
51 char*	errstr9p[MAXERR];
52 Chan*	chans;
53 RWLock	mainlock;
54 Timet	fs_mktime;
55 Timet	boottime;
56 Queue*	serveq;
57 Queue*	raheadq;
58 Rabuf*	rabuffree;
59 QLock	reflock;
60 Lock	rabuflock;
61 Tlock	tlocks[NTLOCK];
62 Lock	tlocklock;
63 Device*	devnone;
64 Startsb	startsb[5];
65 int	mballocs[MAXCAT];
66 
67 /* from config block */
68 char	service[50];		/* my name */
69 Filsys	filsys[30];		/* named file systems */
70 /*
71  * these are only documentation, but putting them in the config block makes
72  * them visible.  the real values are compiled into cwfs.
73  */
74 typedef struct Fspar Fspar;
75 struct Fspar {
76 	char*	name;
77 	long	actual;		/* compiled-in value */
78 	long	declared;
79 } fspar[];
80 
81 ulong	roflag;
82 ulong	errorflag;
83 ulong	chatflag;
84 ulong	attachflag;
85 ulong	authdebugflag;
86 ulong	authdisableflag;
87 int	noattach;
88 int	wstatallow;		/* set to circumvent wstat permissions */
89 int	writeallow;		/* set to circumvent write permissions */
90 int	duallow;		/* single user to allow du */
91 int	readonly;		/* disable writes if true */
92 
93 int	noauth;			/* Debug */
94 
95 int	rawreadok;		/* allow reading raw data */
96 
97 File*	flist[5003];		/* base of file structures */
98 Lock	flock;			/* manipulate flist */
99 
100 long	growacct[1000];
101 
102 struct
103 {
104 	RWLock	uidlock;
105 	Iobuf*	uidbuf;
106 	int	flen;
107 	int	find;
108 } uidgc;
109 
110 extern	char	statecall[];
111 extern	char*	wormscode[];
112 extern	char*	tagnames[];
113