BSD 4_4 release
[unix-history] / usr / src / lib / librpc / rpcsvc / nfs_prot.x
CommitLineData
ad787160
C
1/* @(#)nfs_prot.x 2.1 88/08/01 4.0 RPCSRC */
2
1c15e888 3/*
ad787160
C
4 * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
5 * unrestricted use provided that this legend is included on all tape
6 * media and as a part of the software program in whole or part. Users
7 * may copy or modify Sun RPC without charge, but are not authorized
8 * to license or distribute it to anyone else except as part of a product or
9 * program developed by the user.
10 *
11 * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
12 * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
13 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
14 *
15 * Sun RPC is provided with no support and without any obligation on the
16 * part of Sun Microsystems, Inc. to assist in its use, correction,
17 * modification or enhancement.
18 *
19 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
20 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
21 * OR ANY PART THEREOF.
22 *
23 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
24 * or profits or other special, indirect and consequential damages, even if
25 * Sun has been advised of the possibility of such damages.
26 *
27 * Sun Microsystems, Inc.
28 * 2550 Garcia Avenue
29 * Mountain View, California 94043
1c15e888
C
30 */
31
ad787160
C
32/*
33 * nfs_prot.x 1.2 87/10/12
34 * Copyright 1987 Sun Microsystems, Inc.
35 */
1c15e888
C
36const NFS_PORT = 2049;
37const NFS_MAXDATA = 8192;
38const NFS_MAXPATHLEN = 1024;
39const NFS_MAXNAMLEN = 255;
40const NFS_FHSIZE = 32;
41const NFS_COOKIESIZE = 4;
42const NFS_FIFO_DEV = -1; /* size kludge for named pipes */
43
44/*
45 * File types
46 */
47const NFSMODE_FMT = 0170000; /* type of file */
48const NFSMODE_DIR = 0040000; /* directory */
49const NFSMODE_CHR = 0020000; /* character special */
50const NFSMODE_BLK = 0060000; /* block special */
51const NFSMODE_REG = 0100000; /* regular */
52const NFSMODE_LNK = 0120000; /* symbolic link */
53const NFSMODE_SOCK = 0140000; /* socket */
54const NFSMODE_FIFO = 0010000; /* fifo */
55
56/*
57 * Error status
58 */
59enum nfsstat {
60 NFS_OK= 0, /* no error */
61 NFSERR_PERM=1, /* Not owner */
62 NFSERR_NOENT=2, /* No such file or directory */
63 NFSERR_IO=5, /* I/O error */
64 NFSERR_NXIO=6, /* No such device or address */
65 NFSERR_ACCES=13, /* Permission denied */
66 NFSERR_EXIST=17, /* File exists */
67 NFSERR_NODEV=19, /* No such device */
68 NFSERR_NOTDIR=20, /* Not a directory*/
69 NFSERR_ISDIR=21, /* Is a directory */
70 NFSERR_FBIG=27, /* File too large */
71 NFSERR_NOSPC=28, /* No space left on device */
72 NFSERR_ROFS=30, /* Read-only file system */
73 NFSERR_NAMETOOLONG=63, /* File name too long */
74 NFSERR_NOTEMPTY=66, /* Directory not empty */
75 NFSERR_DQUOT=69, /* Disc quota exceeded */
76 NFSERR_STALE=70, /* Stale NFS file handle */
77 NFSERR_WFLUSH=99 /* write cache flushed */
78};
79
80/*
81 * File types
82 */
83enum ftype {
84 NFNON = 0, /* non-file */
85 NFREG = 1, /* regular file */
86 NFDIR = 2, /* directory */
87 NFBLK = 3, /* block special */
88 NFCHR = 4, /* character special */
89 NFLNK = 5, /* symbolic link */
90 NFSOCK = 6, /* unix domain sockets */
91 NFBAD = 7, /* unused */
92 NFFIFO = 8 /* named pipe */
93};
94
95/*
96 * File access handle
97 */
98struct nfs_fh {
99 opaque data[NFS_FHSIZE];
100};
101
102/*
103 * Timeval
104 */
105struct nfstime {
106 unsigned seconds;
107 unsigned useconds;
108};
109
110
111/*
112 * File attributes
113 */
114struct fattr {
115 ftype type; /* file type */
116 unsigned mode; /* protection mode bits */
117 unsigned nlink; /* # hard links */
118 unsigned uid; /* owner user id */
119 unsigned gid; /* owner group id */
120 unsigned size; /* file size in bytes */
121 unsigned blocksize; /* prefered block size */
122 unsigned rdev; /* special device # */
123 unsigned blocks; /* Kb of disk used by file */
124 unsigned fsid; /* device # */
125 unsigned fileid; /* inode # */
126 nfstime atime; /* time of last access */
127 nfstime mtime; /* time of last modification */
128 nfstime ctime; /* time of last change */
129};
130
131/*
132 * File attributes which can be set
133 */
134struct sattr {
135 unsigned mode; /* protection mode bits */
136 unsigned uid; /* owner user id */
137 unsigned gid; /* owner group id */
138 unsigned size; /* file size in bytes */
139 nfstime atime; /* time of last access */
140 nfstime mtime; /* time of last modification */
141};
142
143
144typedef string filename<NFS_MAXNAMLEN>;
145typedef string nfspath<NFS_MAXPATHLEN>;
146
147/*
148 * Reply status with file attributes
149 */
150union attrstat switch (nfsstat status) {
151case NFS_OK:
152 fattr attributes;
153default:
154 void;
155};
156
157struct sattrargs {
158 nfs_fh file;
159 sattr attributes;
160};
161
162/*
163 * Arguments for directory operations
164 */
165struct diropargs {
166 nfs_fh dir; /* directory file handle */
167 filename name; /* name (up to NFS_MAXNAMLEN bytes) */
168};
169
170struct diropokres {
171 nfs_fh file;
172 fattr attributes;
173};
174
175/*
176 * Results from directory operation
177 */
178union diropres switch (nfsstat status) {
179case NFS_OK:
180 diropokres diropres;
181default:
182 void;
183};
184
185union readlinkres switch (nfsstat status) {
186case NFS_OK:
187 nfspath data;
188default:
189 void;
190};
191
192/*
193 * Arguments to remote read
194 */
195struct readargs {
196 nfs_fh file; /* handle for file */
197 unsigned offset; /* byte offset in file */
198 unsigned count; /* immediate read count */
199 unsigned totalcount; /* total read count (from this offset)*/
200};
201
202/*
203 * Status OK portion of remote read reply
204 */
205struct readokres {
206 fattr attributes; /* attributes, need for pagin*/
207 opaque data<NFS_MAXDATA>;
208};
209
210union readres switch (nfsstat status) {
211case NFS_OK:
212 readokres reply;
213default:
214 void;
215};
216
217/*
218 * Arguments to remote write
219 */
220struct writeargs {
221 nfs_fh file; /* handle for file */
222 unsigned beginoffset; /* beginning byte offset in file */
223 unsigned offset; /* current byte offset in file */
224 unsigned totalcount; /* total write count (to this offset)*/
225 opaque data<NFS_MAXDATA>;
226};
227
228struct createargs {
229 diropargs where;
230 sattr attributes;
231};
232
233struct renameargs {
234 diropargs from;
235 diropargs to;
236};
237
238struct linkargs {
239 nfs_fh from;
240 diropargs to;
241};
242
243struct symlinkargs {
244 diropargs from;
245 nfspath to;
246 sattr attributes;
247};
248
249
250typedef opaque nfscookie[NFS_COOKIESIZE];
251
252/*
253 * Arguments to readdir
254 */
255struct readdirargs {
256 nfs_fh dir; /* directory handle */
257 nfscookie cookie;
258 unsigned count; /* number of directory bytes to read */
259};
260
261struct entry {
262 unsigned fileid;
263 filename name;
264 nfscookie cookie;
265 entry *nextentry;
266};
267
268struct dirlist {
269 entry *entries;
270 bool eof;
271};
272
273union readdirres switch (nfsstat status) {
274case NFS_OK:
275 dirlist reply;
276default:
277 void;
278};
279
280struct statfsokres {
281 unsigned tsize; /* preferred transfer size in bytes */
282 unsigned bsize; /* fundamental file system block size */
283 unsigned blocks; /* total blocks in file system */
284 unsigned bfree; /* free blocks in fs */
285 unsigned bavail; /* free blocks avail to non-superuser */
286};
287
288union statfsres switch (nfsstat status) {
289case NFS_OK:
290 statfsokres reply;
291default:
292 void;
293};
294
295/*
296 * Remote file service routines
297 */
298program NFS_PROGRAM {
299 version NFS_VERSION {
300 void
301 NFSPROC_NULL(void) = 0;
302
303 attrstat
304 NFSPROC_GETATTR(nfs_fh) = 1;
305
306 attrstat
307 NFSPROC_SETATTR(sattrargs) = 2;
308
309 void
310 NFSPROC_ROOT(void) = 3;
311
312 diropres
313 NFSPROC_LOOKUP(diropargs) = 4;
314
315 readlinkres
316 NFSPROC_READLINK(nfs_fh) = 5;
317
318 readres
319 NFSPROC_READ(readargs) = 6;
320
321 void
322 NFSPROC_WRITECACHE(void) = 7;
323
324 attrstat
325 NFSPROC_WRITE(writeargs) = 8;
326
327 diropres
328 NFSPROC_CREATE(createargs) = 9;
329
330 nfsstat
331 NFSPROC_REMOVE(diropargs) = 10;
332
333 nfsstat
334 NFSPROC_RENAME(renameargs) = 11;
335
336 nfsstat
337 NFSPROC_LINK(linkargs) = 12;
338
339 nfsstat
340 NFSPROC_SYMLINK(symlinkargs) = 13;
341
342 diropres
343 NFSPROC_MKDIR(createargs) = 14;
344
345 nfsstat
346 NFSPROC_RMDIR(diropargs) = 15;
347
348 readdirres
349 NFSPROC_READDIR(readdirargs) = 16;
350
351 statfsres
352 NFSPROC_STATFS(nfs_fh) = 17;
353 } = 2;
354} = 100003;
ad787160 355