xref: /plan9-contrib/sys/src/cmd/disk/kfs/dat.h (revision 219b2ee8daee37f4aad58d63f21287faa8e4ffdc)
1 typedef	struct	Chan	Chan;
2 typedef struct	Command	Command;
3 typedef	struct	Conf	Conf;
4 typedef	struct	Cons	Cons;
5 typedef struct	Devcall	Devcall;
6 
7 #include "portdat.h"
8 
9 struct	Chan
10 {
11 	int	type;
12 	int	chan;			/* fd request came in on */
13 	char	whoname[NAMELEN];
14 	int	flags;
15 	long	whotime;
16 	File*	flist;			/* base of file structures */
17 	Lock	flock;			/* manipulate flist */
18 	RWlock	reflock;		/* lock for Tflush */
19 };
20 
21 /*
22  * console cons.flag flags
23  */
24 enum
25 {
26 	Fchat	= (1<<0),	/* print out filsys rpc traffic */
27 	Fuid	= (1<<2),	/* print out uids */
28 				/* debugging flags for drivers */
29 };
30 
31 struct	Cons
32 {
33 	int	flags;		/* overall flags for all channels */
34 	int	uid;		/* botch -- used to get uid on cons_create */
35 	int	gid;		/* botch -- used to get gid on cons_create */
36 	int	allow;		/* no-protection flag */
37 	long	offset;		/* used to read files, c.f. fchar */
38 	char*	arg;		/* pointer to remaining line */
39 
40 	Chan	*chan;
41 
42 	Filter	work;		/* thruput in messages */
43 	Filter	rate;		/* thruput in bytes */
44 	Filter	bhit;		/* getbufs that hit */
45 	Filter	bread;		/* getbufs that miss and read */
46 	Filter	binit;		/* getbufs that miss and dont read */
47 	Filter	tags[MAXTAG];	/* reads of each type of block */
48 };
49 
50 struct	Conf
51 {
52 	ulong	niobuf;		/* number of iobufs to allocate */
53 	ulong	nuid;		/* distinct uids */
54 	ulong	uidspace;	/* space for uid names -- derrived from nuid */
55 	ulong	gidspace;	/* space for gid names -- derrived from nuid */
56 	ulong	nserve;		/* server processes */
57 	ulong	nfile;		/* number of fid -- system wide */
58 	ulong	nwpath;		/* number of active paths, derrived from nfile */
59 	ulong	bootsize;	/* number of bytes reserved for booting */
60 };
61 
62 struct	Command
63 {
64 	char	*string;
65 	void	(*func)(void);
66 	char	*args;
67 };
68 
69 struct Devcall
70 {
71 	void	(*init)(Device);
72 	void	(*ream)(Device);
73 	int	(*check)(Device);
74 	long	(*super)(Device);
75 	long	(*root)(Device);
76 	long	(*size)(Device);
77 	int	(*read)(Device, long, void*);
78 	int	(*write)(Device, long, void*);
79 };
80 
81 /*
82  * device types
83  */
84 enum
85 {
86 	Devnone 	= 0,
87 	Devwren,
88 	MAXDEV
89 };
90 
91 /*
92  * file systems
93  */
94 enum
95 {
96 	MAXFILSYS = 4
97 };
98 
99 /*
100  * should be in portdat.h
101  */
102 #define	QPDIR	0x80000000L
103 #define	QPNONE	0
104 #define	QPROOT	1
105 #define	QPSUPER	2
106 
107 /*
108  * perm argument in p9 create
109  */
110 #define	PDIR	(1L<<31)	/* is a directory */
111 #define	PAPND	(1L<<30)	/* is append only */
112 #define	PLOCK	(1L<<29)	/* is locked on open */
113 
114 #define	NOF	(-1)
115 
116 #define	FID1		1
117 #define	FID2		2
118 
119 #define SECOND(n) 	(n)
120 #define MINUTE(n)	(n*SECOND(60))
121 #define HOUR(n)		(n*MINUTE(60))
122 #define DAY(n)		(n*HOUR(24))
123 #define	TLOCK		MINUTE(5)
124 
125 #define	CHAT(cp)	(chat)
126 #define	QID(a,b)	(Qid){a,b}
127 
128 extern	Uid*	uid;
129 extern	char*	uidspace;
130 extern	short*	gidspace;
131 extern	File*	files;
132 extern	Wpath*	wpaths;
133 extern	Lock	wpathlock;
134 extern	char*	errstr[MAXERR];
135 extern	void	(*p9call[MAXSYSCALL])(Chan*, Fcall*, Fcall*);
136 extern	Chan*	chans;
137 extern	RWlock	mainlock;
138 extern	Lock	newfplock;
139 extern	long	boottime;
140 extern	Tlock	*tlocks;
141 extern	Device	devnone;
142 extern	Filsys	filsys[];
143 extern	char	service[];
144 extern	char*	tagnames[];
145 extern	Conf	conf;
146 extern	Cons	cons;
147 extern	Command	command[];
148 extern	Chan	*chan;
149 extern	Devcall	devcall[];
150 extern	char	*progname;
151 extern	char	*procname;
152 extern	long	niob;
153 extern	long	nhiob;
154 extern	Hiob	*hiob;
155 extern	int	chat;
156 extern	int	writeallow;
157 extern	int	wstatallow;
158