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
|
/*
* This document was extracted by hand from RFC 1094. Several errors
* and omissions were corrected. Additional sources for this protocol
* specification include:
*
* https://pubs.opengroup.org/onlinepubs/9629799/chap7.htm
*
* Note that RFC 1094's official date of publication (March 1989) is
* before the IETF required its RFCs to carry an explicit copyright
* or other IP ownership notice.
*/
pragma header nfs2;
const NFS_MAXDATA = 8192;
const NFS_MAXPATHLEN = 1024;
const NFS_MAXNAMLEN = 255;
const NFS_COOKIESIZE = 4;
const NFS_FHSIZE = 32;
/*
* RFC 1094 calls the following enum "stat". That name conflicts with
* the Linux kernel's "struct stat" because in C, struct, union, and
* enum tags all share a single tag namespace. Details are specified
* in the C11 standard, Section 6.2.3.
*/
enum nfsstat {
NFS_OK = 0,
NFSERR_PERM = 1,
NFSERR_NOENT = 2,
NFSERR_IO = 5,
NFSERR_NXIO = 6,
NFSERR_ACCES = 13,
NFSERR_EXIST = 17,
NFSERR_NODEV = 19,
NFSERR_NOTDIR = 20,
NFSERR_ISDIR = 21,
NFSERR_FBIG = 27,
NFSERR_NOSPC = 28,
NFSERR_ROFS = 30,
NFSERR_NAMETOOLONG = 63,
NFSERR_NOTEMPTY = 66,
NFSERR_DQUOT = 69,
NFSERR_STALE = 70,
NFSERR_WFLUSH = 99
};
pragma big_endian nfsstat;
enum ftype {
NFNON = 0,
NFREG = 1,
NFDIR = 2,
NFBLK = 3,
NFCHR = 4,
NFLNK = 5
};
typedef opaque fhandle[NFS_FHSIZE];
typedef opaque nfscookie[NFS_COOKIESIZE];
struct timeval {
unsigned int seconds;
unsigned int useconds;
};
struct fattr {
ftype type;
unsigned int mode;
unsigned int nlink;
unsigned int uid;
unsigned int gid;
unsigned int size;
unsigned int blocksize;
unsigned int rdev;
unsigned int blocks;
unsigned int fsid;
unsigned int fileid;
timeval atime;
timeval mtime;
timeval ctime;
};
struct sattr {
unsigned int mode;
unsigned int uid;
unsigned int gid;
unsigned int size;
timeval atime;
timeval mtime;
};
typedef string filename<NFS_MAXNAMLEN>;
typedef string path<NFS_MAXPATHLEN>;
union attrstat switch (nfsstat status) {
case NFS_OK:
fattr attributes;
default:
void;
};
struct diropargs {
fhandle dir;
filename name;
};
struct diropok {
fhandle file;
fattr attributes;
};
union diropres switch (nfsstat status) {
case NFS_OK:
diropok diropok;
default:
void;
};
struct sattrargs {
fhandle file;
sattr attributes;
};
union readlinkres switch (nfsstat status) {
case NFS_OK:
path data;
default:
void;
};
pragma pages readlinkres data;
struct readargs {
fhandle file;
unsigned int offset;
unsigned int count;
unsigned int totalcount;
};
struct readresok {
fattr attributes;
opaque data<NFS_MAXDATA>;
};
pragma pages readresok data;
union readres switch (nfsstat status) {
case NFS_OK:
readresok readresok;
default:
void;
};
struct writeargs {
fhandle file;
unsigned int beginoffset;
unsigned int offset;
unsigned int totalcount;
opaque data<NFS_MAXDATA>;
};
pragma pages writeargs data;
struct createargs {
diropargs where;
sattr attributes;
};
struct renameargs {
diropargs from;
diropargs to;
};
struct linkargs {
fhandle from;
diropargs to;
};
struct symlinkargs {
diropargs from;
path to;
sattr attributes;
};
pragma pages symlinkargs to;
struct readdirargs {
fhandle dir;
nfscookie cookie;
unsigned int count;
};
struct entry {
unsigned int fileid;
filename name;
nfscookie cookie;
entry *nextentry;
};
struct readdirok {
entry *entries;
bool eof;
};
/*
* A spike encoding the entry list through the aggregate codec. The
* list encodes as the value-follows form -- each entry prefixed by
* TRUE, the sequence closed by FALSE -- and the encode hooks stream it
* straight from the directory during reply encoding rather than from a
* materialized array. The struct definitions above are the verbatim
* RFC 1094 types; only this pragma selects the hook-driven codec.
*/
pragma aggregate readdirok entries;
union readdirres switch (nfsstat status) {
case NFS_OK:
readdirok readdirok;
default:
void;
};
struct info {
unsigned int tsize;
unsigned int bsize;
unsigned int blocks;
unsigned int bfree;
unsigned int bavail;
};
union statfsres switch (nfsstat status) {
case NFS_OK:
info info;
default:
void;
};
program NFS_PROGRAM {
version NFS_VERSION {
void NFSPROC_NULL(void) = 0;
attrstat NFSPROC_GETATTR(fhandle) = 1;
attrstat NFSPROC_SETATTR(sattrargs) = 2;
void NFSPROC_ROOT(void) = 3;
diropres NFSPROC_LOOKUP(diropargs) = 4;
readlinkres NFSPROC_READLINK(fhandle) = 5;
readres NFSPROC_READ(readargs) = 6;
void NFSPROC_WRITECACHE(void) = 7;
attrstat NFSPROC_WRITE(writeargs) = 8;
diropres NFSPROC_CREATE(createargs) = 9;
nfsstat NFSPROC_REMOVE(diropargs) = 10;
nfsstat NFSPROC_RENAME(renameargs) = 11;
nfsstat NFSPROC_LINK(linkargs) = 12;
nfsstat NFSPROC_SYMLINK(symlinkargs) = 13;
diropres NFSPROC_MKDIR(createargs) = 14;
nfsstat NFSPROC_RMDIR(diropargs) = 15;
readdirres NFSPROC_READDIR(readdirargs) = 16;
statfsres NFSPROC_STATFS(fhandle) = 17;
} = 2;
} = 100003;
|