xref: /openbsd-src/usr.sbin/amd/rpcx/nfs_prot.h (revision b2ea75c1b17e1a9a339660e7ed45cd24946b230e)
1 /*	$OpenBSD: nfs_prot.h,v 1.2 1996/03/25 15:54:58 niklas Exp $	*/
2 
3 /*
4  * Copyright (c) 1990 Jan-Simon Pendry
5  * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
6  * Copyright (c) 1990, 1993
7  *	The Regents of the University of California.  All rights reserved.
8  *
9  * This code is derived from software contributed to Berkeley by
10  * Jan-Simon Pendry at Imperial College, London.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  *    notice, this list of conditions and the following disclaimer in the
19  *    documentation and/or other materials provided with the distribution.
20  * 3. All advertising materials mentioning features or use of this software
21  *    must display the following acknowledgement:
22  *	This product includes software developed by the University of
23  *	California, Berkeley and its contributors.
24  * 4. Neither the name of the University nor the names of its contributors
25  *    may be used to endorse or promote products derived from this software
26  *    without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38  * SUCH DAMAGE.
39  *
40  *	from: @(#)nfs_prot.h	8.1 (Berkeley) 6/6/93
41  */
42 
43 #if NFS_PROTOCOL_VERSION >= 3
44 #include <nfs/nfsproto.h>
45 #endif
46 
47 #define	xdr_nfsstat xdr_enum
48 #define	xdr_ftype xdr_enum
49 
50 #define NFS_PORT 2049
51 #ifndef NFS_MAXDATA
52 #define NFS_MAXDATA 8192
53 #endif
54 #define NFS_MAXPATHLEN 1024
55 #define NFS_MAXNAMLEN 255
56 #define NFS_FHSIZE 32
57 #define NFS_COOKIESIZE 4
58 #define NFS_FIFO_DEV -1
59 #define NFSMODE_FMT 0170000
60 #define NFSMODE_DIR 0040000
61 #define NFSMODE_CHR 0020000
62 #define NFSMODE_BLK 0060000
63 #define NFSMODE_REG 0100000
64 #define NFSMODE_LNK 0120000
65 #define NFSMODE_SOCK 0140000
66 #define NFSMODE_FIFO 0010000
67 
68 #if NFS_PROTOCOL_VERSION < 3
69 enum nfsstat {
70 	NFS_OK = 0,
71 	NFSERR_PERM = 1,
72 	NFSERR_NOENT = 2,
73 	NFSERR_IO = 5,
74 	NFSERR_NXIO = 6,
75 	NFSERR_ACCES = 13,
76 	NFSERR_EXIST = 17,
77 	NFSERR_NODEV = 19,
78 	NFSERR_NOTDIR = 20,
79 	NFSERR_ISDIR = 21,
80 	NFSERR_FBIG = 27,
81 	NFSERR_NOSPC = 28,
82 	NFSERR_ROFS = 30,
83 	NFSERR_NAMETOOLONG = 63,
84 	NFSERR_NOTEMPTY = 66,
85 	NFSERR_DQUOT = 69,
86 	NFSERR_STALE = 70,
87 	NFSERR_WFLUSH = 99
88 };
89 typedef enum nfsstat nfsstat;
90 #else
91 typedef int nfsstat;
92 #endif
93 
94 bool_t xdr_nfsstat();
95 
96 
97 #if NFS_PROTOCOL_VERSION < 3
98 enum ftype {
99 	NFNON = 0,
100 	NFREG = 1,
101 	NFDIR = 2,
102 	NFBLK = 3,
103 	NFCHR = 4,
104 	NFLNK = 5,
105 	NFSOCK = 6,
106 	NFBAD = 7,
107 	NFFIFO = 8
108 };
109 typedef enum ftype ftype;
110 #else
111 typedef int ftype;
112 #endif
113 
114 /* static bool_t xdr_ftype(); */
115 
116 
117 struct nfs_fh {
118 	char data[NFS_FHSIZE];
119 };
120 typedef struct nfs_fh nfs_fh;
121 bool_t xdr_nfs_fh();
122 
123 
124 struct nfstime {
125 	u_int seconds;
126 	u_int useconds;
127 };
128 typedef struct nfstime nfstime;
129 /* static bool_t xdr_nfstime(); */
130 
131 
132 struct fattr {
133 	ftype type;
134 	u_int mode;
135 	u_int nlink;
136 	u_int uid;
137 	u_int gid;
138 	u_int size;
139 	u_int blocksize;
140 	u_int rdev;
141 	u_int blocks;
142 	u_int fsid;
143 	u_int fileid;
144 	nfstime atime;
145 	nfstime mtime;
146 	nfstime ctime;
147 };
148 typedef struct fattr fattr;
149 /* static bool_t xdr_fattr(); */
150 
151 
152 struct sattr {
153 	u_int mode;
154 	u_int uid;
155 	u_int gid;
156 	u_int size;
157 	nfstime atime;
158 	nfstime mtime;
159 };
160 typedef struct sattr sattr;
161 /* static bool_t xdr_sattr(); */
162 
163 
164 typedef char *filename;
165 /* static bool_t xdr_filename(); */
166 
167 
168 typedef char *nfspath;
169 bool_t xdr_nfspath();
170 
171 
172 struct attrstat {
173 	nfsstat status;
174 	union {
175 		fattr attributes;
176 	} attrstat_u;
177 };
178 typedef struct attrstat attrstat;
179 bool_t xdr_attrstat();
180 
181 
182 struct sattrargs {
183 	nfs_fh file;
184 	sattr attributes;
185 };
186 typedef struct sattrargs sattrargs;
187 bool_t xdr_sattrargs();
188 
189 
190 struct diropargs {
191 	nfs_fh dir;
192 	filename name;
193 };
194 typedef struct diropargs diropargs;
195 bool_t xdr_diropargs();
196 
197 
198 struct diropokres {
199 	nfs_fh file;
200 	fattr attributes;
201 };
202 typedef struct diropokres diropokres;
203 bool_t xdr_diropokres();
204 
205 
206 struct diropres {
207 	nfsstat status;
208 	union {
209 		diropokres diropres;
210 	} diropres_u;
211 };
212 typedef struct diropres diropres;
213 bool_t xdr_diropres();
214 
215 
216 struct readlinkres {
217 	nfsstat status;
218 	union {
219 		nfspath data;
220 	} readlinkres_u;
221 };
222 typedef struct readlinkres readlinkres;
223 bool_t xdr_readlinkres();
224 
225 
226 struct readargs {
227 	nfs_fh file;
228 	u_int offset;
229 	u_int count;
230 	u_int totalcount;
231 };
232 typedef struct readargs readargs;
233 bool_t xdr_readargs();
234 
235 
236 struct readokres {
237 	fattr attributes;
238 	struct {
239 		u_int data_len;
240 		char *data_val;
241 	} data;
242 };
243 typedef struct readokres readokres;
244 bool_t xdr_readokres();
245 
246 
247 struct readres {
248 	nfsstat status;
249 	union {
250 		readokres reply;
251 	} readres_u;
252 };
253 typedef struct readres readres;
254 bool_t xdr_readres();
255 
256 
257 struct writeargs {
258 	nfs_fh file;
259 	u_int beginoffset;
260 	u_int offset;
261 	u_int totalcount;
262 	struct {
263 		u_int data_len;
264 		char *data_val;
265 	} data;
266 };
267 typedef struct writeargs writeargs;
268 bool_t xdr_writeargs();
269 
270 
271 struct createargs {
272 	diropargs where;
273 	sattr attributes;
274 };
275 typedef struct createargs createargs;
276 bool_t xdr_createargs();
277 
278 
279 struct renameargs {
280 	diropargs from;
281 	diropargs to;
282 };
283 typedef struct renameargs renameargs;
284 bool_t xdr_renameargs();
285 
286 
287 struct linkargs {
288 	nfs_fh from;
289 	diropargs to;
290 };
291 typedef struct linkargs linkargs;
292 bool_t xdr_linkargs();
293 
294 
295 struct symlinkargs {
296 	diropargs from;
297 	nfspath to;
298 	sattr attributes;
299 };
300 typedef struct symlinkargs symlinkargs;
301 bool_t xdr_symlinkargs();
302 
303 
304 typedef char nfscookie[NFS_COOKIESIZE];
305 /* static bool_t xdr_nfscookie(); */
306 
307 
308 struct readdirargs {
309 	nfs_fh dir;
310 	nfscookie cookie;
311 	u_int count;
312 };
313 typedef struct readdirargs readdirargs;
314 bool_t xdr_readdirargs();
315 
316 
317 struct entry {
318 	u_int fileid;
319 	filename name;
320 	nfscookie cookie;
321 	struct entry *nextentry;
322 };
323 typedef struct entry entry;
324 /* static bool_t xdr_entry(); */
325 
326 
327 struct dirlist {
328 	entry *entries;
329 	bool_t eof;
330 };
331 typedef struct dirlist dirlist;
332 /* static bool_t xdr_dirlist(); */
333 
334 
335 struct readdirres {
336 	nfsstat status;
337 	union {
338 		dirlist reply;
339 	} readdirres_u;
340 };
341 typedef struct readdirres readdirres;
342 bool_t xdr_readdirres();
343 
344 
345 struct statfsokres {
346 	u_int tsize;
347 	u_int bsize;
348 	u_int blocks;
349 	u_int bfree;
350 	u_int bavail;
351 };
352 typedef struct statfsokres statfsokres;
353 bool_t xdr_statfsokres();
354 
355 
356 struct statfsres {
357 	nfsstat status;
358 	union {
359 		statfsokres reply;
360 	} statfsres_u;
361 };
362 typedef struct statfsres statfsres;
363 bool_t xdr_statfsres();
364 
365 
366 #define NFS_PROGRAM ((u_long)100003)
367 #define NFS_VERSION ((u_long)2)
368 
369 /* Undef the version 3 ones, and define the v2 ones */
370 #undef NFSPROC_NULL
371 #define NFSPROC_NULL ((u_long)0)
372 #undef NFSPROC_GETATTR
373 #define NFSPROC_GETATTR ((u_long)1)
374 #undef NFSPROC_SETATTR
375 #define NFSPROC_SETATTR ((u_long)2)
376 #undef NFSPROC_ROOT
377 #define NFSPROC_ROOT ((u_long)3)
378 #undef NFSPROC_LOOKUP
379 #define NFSPROC_LOOKUP ((u_long)4)
380 #undef NFSPROC_READLINK
381 #define NFSPROC_READLINK ((u_long)5)
382 #undef NFSPROC_READ
383 #define NFSPROC_READ ((u_long)6)
384 #undef NFSPROC_WRITECACHE
385 #define NFSPROC_WRITECACHE ((u_long)7)
386 #undef NFSPROC_WRITE
387 #define NFSPROC_WRITE ((u_long)8)
388 #undef NFSPROC_CREATE
389 #define NFSPROC_CREATE ((u_long)9)
390 #undef NFSPROC_REMOVE
391 #define NFSPROC_REMOVE ((u_long)10)
392 #undef NFSPROC_RENAME
393 #define NFSPROC_RENAME ((u_long)11)
394 #undef NFSPROC_LINK
395 #define NFSPROC_LINK ((u_long)12)
396 #undef NFSPROC_SYMLINK
397 #define NFSPROC_SYMLINK ((u_long)13)
398 #undef NFSPROC_MKDIR
399 #define NFSPROC_MKDIR ((u_long)14)
400 #undef NFSPROC_RMDIR
401 #define NFSPROC_RMDIR ((u_long)15)
402 #undef NFSPROC_READDIR
403 #define NFSPROC_READDIR ((u_long)16)
404 #undef NFSPROC_STATFS
405 #define NFSPROC_STATFS ((u_long)17)
406 
407 extern voidp nfsproc_null_2();
408 extern attrstat *nfsproc_getattr_2();
409 extern attrstat *nfsproc_setattr_2();
410 extern voidp nfsproc_root_2();
411 extern diropres *nfsproc_lookup_2();
412 extern readlinkres *nfsproc_readlink_2();
413 extern readres *nfsproc_read_2();
414 extern voidp nfsproc_writecache_2();
415 extern attrstat *nfsproc_write_2();
416 extern diropres *nfsproc_create_2();
417 extern nfsstat *nfsproc_remove_2();
418 extern nfsstat *nfsproc_rename_2();
419 extern nfsstat *nfsproc_link_2();
420 extern nfsstat *nfsproc_symlink_2();
421 extern diropres *nfsproc_mkdir_2();
422 extern nfsstat *nfsproc_rmdir_2();
423 extern readdirres *nfsproc_readdir_2();
424 extern statfsres *nfsproc_statfs_2();
425