xref: /plan9-contrib/sys/src/cmd/exportfs/exportfs.h (revision 7dd7cddf99dd7472612f1413b4da293630e6b1bc)
1 /*
2  * exportfs.h - definitions for exporting file server
3  */
4 
5 #define DEBUG		if(!dbg);else fprint
6 #define DFD		9
7 #define fidhash(s)	fhash[s%FHASHSIZE]
8 
9 typedef struct Fsrpc Fsrpc;
10 typedef struct Fid Fid;
11 typedef struct File File;
12 typedef struct Proc Proc;
13 typedef struct Qidtab Qidtab;
14 
15 struct Fsrpc
16 {
17 	int	busy;		/* Work buffer has pending rpc to service */
18 	int	pid;		/* Pid of slave process executing the rpc */
19 	int	canint;		/* Interrupt gate */
20 	int	flushtag;	/* Tag on which to reply to flush */
21 	Fcall	work;		/* Plan 9 incoming Fcall */
22 	char	buf[MAXFDATA+MAXMSG];	/* Data buffer */
23 };
24 
25 struct Fid
26 {
27 	int	fid;		/* system fd for i/o */
28 	int	offset;		/* current file offset */
29 	File	*f;		/* File attached to this fid */
30 	int	mode;
31 	int	nr;		/* fid number */
32 	Fsrpc	*mpend;		/* Split transaction mount */
33 	int	mid;		/* Mount id */
34 	Fid	*next;		/* hash link */
35 };
36 
37 struct File
38 {
39 	char	name[NAMELEN];
40 	int	ref;
41 	Qid	qid;
42 	Qidtab	*qidt;
43 	int	inval;
44 	File	*parent;
45 	File	*child;
46 	File	*childlist;
47 };
48 
49 struct Proc
50 {
51 	int	pid;
52 	int	busy;
53 	Proc	*next;
54 };
55 
56 struct Qidtab
57 {
58 	int	ref;
59 	int	type;
60 	int	dev;
61 	ulong	path;
62 	ulong	uniqpath;
63 	Qidtab	*next;
64 };
65 
66 enum
67 {
68 	MAXPROC		= 16,
69 	DIRCHUNK	= (50*DIRLEN),
70 	FHASHSIZE	= 64,
71 	Nr_workbufs 	= 16,
72 	Fidchunk	= 1000,
73 	Npsmpt		= 32,
74 	Nqidbits		= 5,
75 	Nqidtab		= (1<<Nqidbits),
76 };
77 
78 enum
79 {
80 	Ebadfid,
81 	Enotdir,
82 	Edupfid,
83 	Eopen,
84 	Exmnt,
85 	Enoauth,
86 	Emip,
87 	Enopsmt,
88 };
89 
90 Extern Fsrpc	*Workq;
91 Extern int  	dbg;
92 Extern File	*root;
93 Extern File	*psmpt;
94 Extern Fid	**fhash;
95 Extern Fid	*fidfree;
96 Extern Proc	*Proclist;
97 Extern char	psmap[Npsmpt];
98 Extern Qidtab	*qidtab[Nqidtab];
99 
100 /* File system protocol service procedures */
101 void Xattach(Fsrpc*);
102 void Xauth(Fsrpc*);
103 void Xclone(Fsrpc*);
104 void Xclunk(Fsrpc*);
105 void Xclwalk(Fsrpc*);
106 void Xcreate(Fsrpc*);
107 void Xflush(Fsrpc*);
108 void Xnop(Fsrpc*);
109 void Xremove(Fsrpc*);
110 void Xsession(Fsrpc*);
111 void Xstat(Fsrpc*);
112 void Xwalk(Fsrpc*);
113 void Xwstat(Fsrpc*);
114 void slave(Fsrpc*);
115 
116 void	reply(Fcall*, Fcall*, char*);
117 Fid 	*getfid(int);
118 int	freefid(int);
119 Fid	*newfid(int);
120 Fsrpc	*getsbuf(void);
121 void	initroot(void);
122 void	fatal(char*);
123 void	makepath(char*, File*, char*);
124 File	*file(File*, char*);
125 void	freefile(File*);
126 void	slaveopen(Fsrpc*);
127 void	slaveread(Fsrpc*);
128 void	slavewrite(Fsrpc*);
129 void	blockingslave(void);
130 void	reopen(Fid *f);
131 void	fileseek(Fid*, ulong);
132 void	noteproc(int, char*);
133 void	flushaction(void*, char*);
134 void	pushfcall(char*);
135 Qidtab* uniqueqid(Dir*);
136 void	freeqid(Qidtab*);
137