blob: c9f6a86640b564e97b75b7eed02077070d29283f (
plain)
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
|
enum
{
FHSIZE = 32
};
typedef struct Accept Accept;
typedef struct Auth Auth;
typedef struct Authunix Authunix;
typedef struct Chalstuff Chalstuff;
typedef uchar Fhandle[FHSIZE];
typedef struct Fid Fid;
typedef struct Procmap Procmap;
typedef struct Progmap Progmap;
typedef struct Reject Reject;
typedef struct Rpccall Rpccall;
typedef struct Rpccache Rpccache;
typedef struct Sattr Sattr;
typedef struct Session Session;
typedef struct String String;
typedef struct Strnode Strnode;
typedef struct Unixid Unixid;
typedef struct Unixidmap Unixidmap;
typedef struct Unixmap Unixmap;
typedef struct Unixscmap Unixscmap;
typedef struct Xfid Xfid;
typedef struct Xfile Xfile;
struct String
{
ulong n;
char * s;
};
struct Progmap
{
int progno;
int vers;
void (*init)(int, char**);
Procmap *pmap;
};
struct Procmap
{
int procno;
int (*procp)(int, Rpccall*, Rpccall*);
};
struct Auth
{
ulong flavor;
ulong count;
void * data;
};
struct Authunix
{
ulong stamp;
String mach;
ulong uid;
ulong gid;
int gidlen;
ulong gids[10];
};
struct Accept
{
Auth averf;
ulong astat;
union{
void * results; /* SUCCESS */
struct{ /* PROG_MISMATCH */
ulong plow; /* acceptable version numbers */
ulong phigh;
};
};
};
struct Reject
{
ulong rstat;
union{
struct{ /* RPC_MISMATCH */
ulong rlow; /* acceptable rpc version numbers */
ulong rhigh;
};
ulong authstat; /* AUTH_ERROR */
};
};
struct Rpccall
{
/* corresponds to Udphdr */
uchar prefix0[12];
ulong host; /* ipv4 subset: prefixed to RPC message */
uchar prefix1[12];
ulong lhost; /* ipv4 subset: prefixed to RPC message */
/* ignore ifcaddr */
ulong port; /* prefixed to RPC message */
ulong lport; /* prefixed to RPC message */
ulong xid; /* transaction id */
ulong mtype; /* CALL or REPLY */
union{
struct{ /* CALL */
ulong rpcvers; /* must be equal to two (2) */
ulong prog; /* program number */
ulong vers; /* program version */
ulong proc; /* procedure number */
Auth cred; /* authentication credentials */
Auth verf; /* authentication verifier */
Unixidmap *up;
char * user;
void * args; /* procedure-specific */
};
struct{ /* REPLY */
ulong stat; /* MSG_ACCEPTED or MSG_DENIED */
union{
Accept;
Reject;
};
};
};
};
struct Rpccache
{
Rpccache *prev;
Rpccache *next;
ulong host;
ulong port;
ulong xid;
int n;
uchar data[4];
};
struct Sattr
{
ulong mode;
ulong uid;
ulong gid;
ulong size;
ulong atime; /* sec's */
ulong ausec; /* microsec's */
ulong mtime;
ulong musec;
};
struct Strnode
{
Strnode *next; /* in hash bucket */
char str[4];
};
struct Unixid
{
Unixid *next;
char * name;
int id;
};
struct Unixmap
{
char * file;
int style;
long timestamp;
Unixid *ids;
};
struct Unixidmap
{
Unixidmap *next;
int flag;
char * server;
char * client;
Reprog *sexp;
Reprog *cexp;
Unixmap u;
Unixmap g;
};
struct Unixscmap
{
Unixscmap *next;
char * server;
ulong clientip;
Unixidmap *map;
};
struct Xfile
{
Xfile * next; /* hash chain */
Session *s;
Qid qid; /* from stat */
Xfile * parent;
Xfile * child; /* if directory */
Xfile * sib; /* siblings */
char * name; /* path element */
Xfid * users;
};
enum
{
Oread = 1,
Owrite = 2,
Open = 3,
Trunc = 4
};
struct Xfid
{
Xfid * next; /* Xfile's user list */
Xfile * xp;
char * uid;
Fid * urfid;
Fid * opfid;
ulong mode; /* open mode, if opfid is non-zero */
ulong offset;
};
struct Fid
{
Fid ** owner; /* null for root fids */
Fid * prev;
Fid * next;
long tstale; /* auto-clunk */
};
enum
{
Maxfdata = 8192,
Maxstatdata = 2048,
};
struct Session
{
Session *next;
char * service; /* for dial */
int fd;
#define CHALLEN 1
char cchal[CHALLEN]; /* client challenge */
char schal[CHALLEN]; /* server challenge */
char authid[ANAMELEN]; /* server encryption uid */
char authdom[DOMLEN]; /* server encryption domain */
char * spec; /* for attach */
Xfile * root; /* to answer mount rpc */
ushort tag;
Fcall f;
uchar data[IOHDRSZ+Maxfdata];
uchar statbuf[Maxstatdata];
Fid * free; /* available */
Fid list; /* active, most-recently-used order */
Fid fids[1000];
int noauth;
};
struct Chalstuff
{
Chalstuff *next;
Xfid * xf;
long tstale;
Chalstate;
};
extern int rpcdebug;
extern int p9debug;
extern int chatty;
extern void (*rpcalarm)(void);
extern long starttime;
extern long nfstime;
extern char * config;
extern int staletime;
extern int messagesize;
extern char * commonopts;
|