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