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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
/*
* exportfs.h - definitions for exporting file server
*/
#define DEBUG if(!dbg){}else fprint
#define DFD 9
#define fidhash(s) fhash[s%FHASHSIZE]
typedef struct Fsrpc Fsrpc;
typedef struct Fid Fid;
typedef struct File File;
typedef struct Proc Proc;
typedef struct Qidtab Qidtab;
struct Fsrpc
{
int busy; /* Work buffer has pending rpc to service */
uintptr pid; /* Pid of slave process executing the rpc */
int canint; /* Interrupt gate */
int flushtag; /* Tag on which to reply to flush */
Fcall work; /* Plan 9 incoming Fcall */
uchar *buf; /* Data buffer */
};
struct Fid
{
int fid; /* system fd for i/o */
File *f; /* File attached to this fid */
int mode;
int nr; /* fid number */
int mid; /* Mount id */
Fid *next; /* hash link */
/* for preaddir -- ARRGH! */
Dir *dir; /* buffer for reading directories */
int ndir; /* number of entries in dir */
int cdir; /* number of consumed entries in dir */
int gdir; /* glue index */
vlong offset; /* offset in virtual directory */
};
struct File
{
char *name;
int ref;
Qid qid;
Qidtab *qidt;
int inval;
File *parent;
File *child;
File *childlist;
};
struct Proc
{
uintptr pid;
int busy;
Proc *next;
};
struct Qidtab
{
int ref;
int type;
int dev;
vlong path;
vlong uniqpath;
Qidtab *next;
};
enum
{
MAXPROC = 50,
FHASHSIZE = 64,
Nr_workbufs = 50,
Fidchunk = 1000,
Npsmpt = 32,
Nqidbits = 5,
Nqidtab = (1<<Nqidbits),
};
char Ebadfid[];
char Enotdir[];
char Edupfid[];
char Eopen[];
char Exmnt[];
char Enomem[];
char Emip[];
char Enopsmt[];
Extern Fsrpc *Workq;
Extern int dbg;
Extern File *root;
Extern File *psmpt;
Extern Fid **fhash;
Extern Fid *fidfree;
Extern Proc *Proclist;
Extern char psmap[Npsmpt];
Extern Qidtab *qidtab[Nqidtab];
Extern ulong messagesize;
Extern char Enomem[];
Extern int srvfd;
Extern char* patternfile;
/* File system protocol service procedures */
void Xattach(Fsrpc*);
void Xauth(Fsrpc*);
void Xclunk(Fsrpc*);
void Xcreate(Fsrpc*);
void Xflush(Fsrpc*);
void Xnop(Fsrpc*);
void Xremove(Fsrpc*);
void Xstat(Fsrpc*);
void Xversion(Fsrpc*);
void Xwalk(Fsrpc*);
void Xwstat(Fsrpc*);
void slave(Fsrpc*);
void reply(Fcall*, Fcall*, char*);
Fid *getfid(int);
int freefid(int);
Fid *newfid(int);
Fsrpc *getsbuf(void);
void initroot(void);
void fatal(char*, ...);
char* makepath(File*, char*);
File *file(File*, char*);
void freefile(File*);
void slaveopen(Fsrpc*);
void slaveread(Fsrpc*);
void slavewrite(Fsrpc*);
void blockingslave(void);
void reopen(Fid *f);
void noteproc(int, char*);
void flushaction(void*, char*);
void pushfcall(char*);
Qidtab* uniqueqid(Dir*);
void freeqid(Qidtab*);
char* estrdup(char*);
void* emallocz(uint);
int readmessage(int, char*, int);
void exclusions(void);
int excludefile(char*);
int preaddir(Fid*, uchar*, int, vlong);
|