Dr Andrew Scott G7VAV

My photo
 
June 2025
Mo Tu We Th Fr Sa Su
26 27 28 29 30 31 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 1 2 3 4 5 6


nfs_prot.x
001: /* @(#)nfs_prot.x       2.1 88/08/01 4.0 RPCSRC */
002: 
003: /*
004:  * nfs_prot.x 1.2 87/10/12
005:  * Copyright (c) 2010, Oracle America, Inc.
006:  *
007:  * Redistribution and use in source and binary forms, with or without
008:  * modification, are permitted provided that the following conditions are
009:  * met:
010:  *
011:  *     * Redistributions of source code must retain the above copyright
012:  *       notice, this list of conditions and the following disclaimer.
013:  *     * Redistributions in binary form must reproduce the above
014:  *       copyright notice, this list of conditions and the following
015:  *       disclaimer in the documentation and/or other materials
016:  *       provided with the distribution.
017:  *     * Neither the name of the "Oracle America, Inc." nor the names of its
018:  *       contributors may be used to endorse or promote products derived
019:  *       from this software without specific prior written permission.
020:  *
021:  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
022:  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
023:  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
024:  *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
025:  *   COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
026:  *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
027:  *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
028:  *   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
029:  *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
030:  *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
031:  *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
032:  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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;   /* size kludge for named pipes */
041: 
042: /*
043:  * File types
044:  */
045: const NFSMODE_FMT  = 0170000;   /* type of file */
046: const NFSMODE_DIR  = 0040000;   /* directory */
047: const NFSMODE_CHR  = 0020000;   /* character special */
048: const NFSMODE_BLK  = 0060000;   /* block special */
049: const NFSMODE_REG  = 0100000;   /* regular */
050: const NFSMODE_LNK  = 0120000;   /* symbolic link */
051: const NFSMODE_SOCK = 0140000;   /* socket */
052: const NFSMODE_FIFO = 0010000;   /* fifo */
053: 
054: /*
055:  * Error status
056:  */
057: enum nfsstat {
058:         NFS_OK= 0,              /* no error */
059:         NFSERR_PERM=1,          /* Not owner */
060:         NFSERR_NOENT=2,         /* No such file or directory */
061:         NFSERR_IO=5,            /* I/O error */
062:         NFSERR_NXIO=6,          /* No such device or address */
063:         NFSERR_ACCES=13,        /* Permission denied */
064:         NFSERR_EXIST=17,        /* File exists */
065:         NFSERR_NODEV=19,        /* No such device */
066:         NFSERR_NOTDIR=20,       /* Not a directory*/
067:         NFSERR_ISDIR=21,        /* Is a directory */
068:         NFSERR_FBIG=27,         /* File too large */
069:         NFSERR_NOSPC=28,        /* No space left on device */
070:         NFSERR_ROFS=30,         /* Read-only file system */
071:         NFSERR_NAMETOOLONG=63,  /* File name too long */
072:         NFSERR_NOTEMPTY=66,     /* Directory not empty */
073:         NFSERR_DQUOT=69,        /* Disc quota exceeded */
074:         NFSERR_STALE=70,        /* Stale NFS file handle */
075:         NFSERR_WFLUSH=99        /* write cache flushed */
076: };
077: 
078: /*
079:  * File types
080:  */
081: enum ftype {
082:         NFNON = 0,      /* non-file */
083:         NFREG = 1,      /* regular file */
084:         NFDIR = 2,      /* directory */
085:         NFBLK = 3,      /* block special */
086:         NFCHR = 4,      /* character special */
087:         NFLNK = 5,      /* symbolic link */
088:         NFSOCK = 6,     /* unix domain sockets */
089:         NFBAD = 7,      /* unused */
090:         NFFIFO = 8      /* named pipe */
091: };
092: 
093: /*
094:  * File access handle
095:  */
096: struct nfs_fh {
097:         opaque data[NFS_FHSIZE];
098: };
099: 
100: /*
101:  * Timeval
102:  */
103: struct nfstime {
104:         unsigned seconds;
105:         unsigned useconds;
106: };
107: 
108: 
109: /*
110:  * File attributes
111:  */
112: struct fattr {
113:         ftype type;             /* file type */
114:         unsigned mode;          /* protection mode bits */
115:         unsigned nlink;         /* # hard links */
116:         unsigned uid;           /* owner user id */
117:         unsigned gid;           /* owner group id */
118:         unsigned size;          /* file size in bytes */
119:         unsigned blocksize;     /* preferred block size */
120:         unsigned rdev;          /* special device # */
121:         unsigned blocks;        /* Kb of disk used by file */
122:         unsigned fsid;          /* device # */
123:         unsigned fileid;        /* inode # */
124:         nfstime atime;          /* time of last access */
125:         nfstime mtime;          /* time of last modification */
126:         nfstime ctime;          /* time of last change */
127: };
128: 
129: /*
130:  * File attributes which can be set
131:  */
132: struct sattr {
133:         unsigned mode;  /* protection mode bits */
134:         unsigned uid;   /* owner user id */
135:         unsigned gid;   /* owner group id */
136:         unsigned size;  /* file size in bytes */
137:         nfstime atime;  /* time of last access */
138:         nfstime mtime;  /* time of last modification */
139: };
140: 
141: 
142: typedef string filename<NFS_MAXNAMLEN>;
143: typedef string nfspath<NFS_MAXPATHLEN>;
144: 
145: /*
146:  * Reply status with file attributes
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:  * Arguments for directory operations
162:  */
163: struct diropargs {
164:         nfs_fh  dir;    /* directory file handle */
165:         filename name;          /* name (up to NFS_MAXNAMLEN bytes) */
166: };
167: 
168: struct diropokres {
169:         nfs_fh file;
170:         fattr attributes;
171: };
172: 
173: /*
174:  * Results from directory operation
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:  * Arguments to remote read
192:  */
193: struct readargs {
194:         nfs_fh file;            /* handle for file */
195:         unsigned offset;        /* byte offset in file */
196:         unsigned count;         /* immediate read count */
197:         unsigned totalcount;    /* total read count (from this offset)*/
198: };
199: 
200: /*
201:  * Status OK portion of remote read reply
202:  */
203: struct readokres {
204:         fattr   attributes;     /* attributes, need for pagin*/
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:  * Arguments to remote write
217:  */
218: struct writeargs {
219:         nfs_fh  file;           /* handle for file */
220:         unsigned beginoffset;   /* beginning byte offset in file */
221:         unsigned offset;        /* current byte offset in file */
222:         unsigned totalcount;    /* total write count (to this offset)*/
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:  * Arguments to readdir
252:  */
253: struct readdirargs {
254:         nfs_fh dir;             /* directory handle */
255:         nfscookie cookie;
256:         unsigned count;         /* number of directory bytes to read */
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; /* preferred transfer size in bytes */
280:         unsigned bsize; /* fundamental file system block size */
281:         unsigned blocks;        /* total blocks in file system */
282:         unsigned bfree; /* free blocks in fs */
283:         unsigned bavail;        /* free blocks avail to non-superuser */
284: };
285: 
286: union statfsres switch (nfsstat status) {
287: case NFS_OK:
288:         statfsokres reply;
289: default:
290:         void;
291: };
292: 
293: /*
294:  * Remote file service routines
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: 


for client (none)
© Andrew Scott 2006 - 2025,
All Rights Reserved
http://www.andrew-scott.uk/
Andrew Scott
http://www.andrew-scott.co.uk/