nfs_prot.x
001:
002:
003:
004:
005:
006:
007:
008:
009:
010:
011:
012:
013:
014:
015:
016:
017:
018:
019:
020:
021:
022:
023:
024:
025:
026:
027:
028:
029:
030:
031:
032:
033:
034: const NFS_PORT = 2049;
035: const NFS_MAXDATA = 8192;
036: const NFS_MAXPATHLEN = 1024;
037: const NFS_MAXNAMLEN = 255;
038: const NFS_FHSIZE = 32;
039: const NFS_COOKIESIZE = 4;
040: const NFS_FIFO_DEV = -1;
041:
042:
043:
044:
045: const NFSMODE_FMT = 0170000;
046: const NFSMODE_DIR = 0040000;
047: const NFSMODE_CHR = 0020000;
048: const NFSMODE_BLK = 0060000;
049: const NFSMODE_REG = 0100000;
050: const NFSMODE_LNK = 0120000;
051: const NFSMODE_SOCK = 0140000;
052: const NFSMODE_FIFO = 0010000;
053:
054:
055:
056:
057: enum nfsstat {
058: NFS_OK= 0,
059: NFSERR_PERM=1,
060: NFSERR_NOENT=2,
061: NFSERR_IO=5,
062: NFSERR_NXIO=6,
063: NFSERR_ACCES=13,
064: NFSERR_EXIST=17,
065: NFSERR_NODEV=19,
066: NFSERR_NOTDIR=20,
067: NFSERR_ISDIR=21,
068: NFSERR_FBIG=27,
069: NFSERR_NOSPC=28,
070: NFSERR_ROFS=30,
071: NFSERR_NAMETOOLONG=63,
072: NFSERR_NOTEMPTY=66,
073: NFSERR_DQUOT=69,
074: NFSERR_STALE=70,
075: NFSERR_WFLUSH=99
076: };
077:
078:
079:
080:
081: enum ftype {
082: NFNON = 0,
083: NFREG = 1,
084: NFDIR = 2,
085: NFBLK = 3,
086: NFCHR = 4,
087: NFLNK = 5,
088: NFSOCK = 6,
089: NFBAD = 7,
090: NFFIFO = 8
091: };
092:
093:
094:
095:
096: struct nfs_fh {
097: opaque data[NFS_FHSIZE];
098: };
099:
100:
101:
102:
103: struct nfstime {
104: unsigned seconds;
105: unsigned useconds;
106: };
107:
108:
109:
110:
111:
112: struct fattr {
113: ftype type;
114: unsigned mode;
115: unsigned nlink;
116: unsigned uid;
117: unsigned gid;
118: unsigned size;
119: unsigned blocksize;
120: unsigned rdev;
121: unsigned blocks;
122: unsigned fsid;
123: unsigned fileid;
124: nfstime atime;
125: nfstime mtime;
126: nfstime ctime;
127: };
128:
129:
130:
131:
132: struct sattr {
133: unsigned mode;
134: unsigned uid;
135: unsigned gid;
136: unsigned size;
137: nfstime atime;
138: nfstime mtime;
139: };
140:
141:
142: typedef string filename<NFS_MAXNAMLEN>;
143: typedef string nfspath<NFS_MAXPATHLEN>;
144:
145:
146:
147:
148: union attrstat switch (nfsstat status) {
149: case NFS_OK:
150: fattr attributes;
151: default:
152: void;
153: };
154:
155: struct sattrargs {
156: nfs_fh file;
157: sattr attributes;
158: };
159:
160:
161:
162:
163: struct diropargs {
164: nfs_fh dir;
165: filename name;
166: };
167:
168: struct diropokres {
169: nfs_fh file;
170: fattr attributes;
171: };
172:
173:
174:
175:
176: union diropres switch (nfsstat status) {
177: case NFS_OK:
178: diropokres diropres;
179: default:
180: void;
181: };
182:
183: union readlinkres switch (nfsstat status) {
184: case NFS_OK:
185: nfspath data;
186: default:
187: void;
188: };
189:
190:
191:
192:
193: struct readargs {
194: nfs_fh file;
195: unsigned offset;
196: unsigned count;
197: unsigned totalcount;
198: };
199:
200:
201:
202:
203: struct readokres {
204: fattr attributes;
205: opaque data<NFS_MAXDATA>;
206: };
207:
208: union readres switch (nfsstat status) {
209: case NFS_OK:
210: readokres reply;
211: default:
212: void;
213: };
214:
215:
216:
217:
218: struct writeargs {
219: nfs_fh file;
220: unsigned beginoffset;
221: unsigned offset;
222: unsigned totalcount;
223: opaque data<NFS_MAXDATA>;
224: };
225:
226: struct createargs {
227: diropargs where;
228: sattr attributes;
229: };
230:
231: struct renameargs {
232: diropargs from;
233: diropargs to;
234: };
235:
236: struct linkargs {
237: nfs_fh from;
238: diropargs to;
239: };
240:
241: struct symlinkargs {
242: diropargs from;
243: nfspath to;
244: sattr attributes;
245: };
246:
247:
248: typedef opaque nfscookie[NFS_COOKIESIZE];
249:
250:
251:
252:
253: struct readdirargs {
254: nfs_fh dir;
255: nfscookie cookie;
256: unsigned count;
257: };
258:
259: struct entry {
260: unsigned fileid;
261: filename name;
262: nfscookie cookie;
263: entry *nextentry;
264: };
265:
266: struct dirlist {
267: entry *entries;
268: bool eof;
269: };
270:
271: union readdirres switch (nfsstat status) {
272: case NFS_OK:
273: dirlist reply;
274: default:
275: void;
276: };
277:
278: struct statfsokres {
279: unsigned tsize;
280: unsigned bsize;
281: unsigned blocks;
282: unsigned bfree;
283: unsigned bavail;
284: };
285:
286: union statfsres switch (nfsstat status) {
287: case NFS_OK:
288: statfsokres reply;
289: default:
290: void;
291: };
292:
293:
294:
295:
296: program NFS_PROGRAM {
297: version NFS_VERSION {
298: void
299: NFSPROC_NULL(void) = 0;
300:
301: attrstat
302: NFSPROC_GETATTR(nfs_fh) = 1;
303:
304: attrstat
305: NFSPROC_SETATTR(sattrargs) = 2;
306:
307: void
308: NFSPROC_ROOT(void) = 3;
309:
310: diropres
311: NFSPROC_LOOKUP(diropargs) = 4;
312:
313: readlinkres
314: NFSPROC_READLINK(nfs_fh) = 5;
315:
316: readres
317: NFSPROC_READ(readargs) = 6;
318:
319: void
320: NFSPROC_WRITECACHE(void) = 7;
321:
322: attrstat
323: NFSPROC_WRITE(writeargs) = 8;
324:
325: diropres
326: NFSPROC_CREATE(createargs) = 9;
327:
328: nfsstat
329: NFSPROC_REMOVE(diropargs) = 10;
330:
331: nfsstat
332: NFSPROC_RENAME(renameargs) = 11;
333:
334: nfsstat
335: NFSPROC_LINK(linkargs) = 12;
336:
337: nfsstat
338: NFSPROC_SYMLINK(symlinkargs) = 13;
339:
340: diropres
341: NFSPROC_MKDIR(createargs) = 14;
342:
343: nfsstat
344: NFSPROC_RMDIR(diropargs) = 15;
345:
346: readdirres
347: NFSPROC_READDIR(readdirargs) = 16;
348:
349: statfsres
350: NFSPROC_STATFS(nfs_fh) = 17;
351: } = 2;
352: } = 100003;
353:
© Andrew Scott 2006 -
2025,
All Rights Reserved