xref: /netbsd-src/external/bsd/am-utils/dist/conf/nfs_prot/nfs_prot_svr4.h (revision 8bae5d409deb915cf7c8f0539fae22ff2cb8a313)
1 /*	$NetBSD: nfs_prot_svr4.h,v 1.1.1.3 2015/01/17 16:34:16 christos Exp $	*/
2 
3 /*
4  * Copyright (c) 1997-2014 Erez Zadok
5  * Copyright (c) 1990 Jan-Simon Pendry
6  * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
7  * Copyright (c) 1990 The Regents of the University of California.
8  * All rights reserved.
9  *
10  * This code is derived from software contributed to Berkeley by
11  * Jan-Simon Pendry at Imperial College, London.
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following conditions
15  * are met:
16  * 1. Redistributions of source code must retain the above copyright
17  *    notice, this list of conditions and the following disclaimer.
18  * 2. Redistributions in binary form must reproduce the above copyright
19  *    notice, this list of conditions and the following disclaimer in the
20  *    documentation and/or other materials provided with the distribution.
21  * 3. Neither the name of the University nor the names of its contributors
22  *    may be used to endorse or promote products derived from this software
23  *    without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35  * SUCH DAMAGE.
36  *
37  *
38  * File: am-utils/conf/nfs_prot/nfs_prot_svr4.h
39  *
40  */
41 
42 #ifndef _AMU_NFS_PROT_H
43 #define _AMU_NFS_PROT_H
44 
45 /*
46  * Do NOT include <rpcsvc/nfs_prot.h> to get NFS V2 specs, because
47  * it will result in conflicts with <nfs/nfs.h>.  The latter is a must
48  * for NFS V3 specs.
49  */
50 
51 #ifdef HAVE_NFS_NFS_H
52 # include <nfs/nfs.h>
53 #endif /* HAVE_NFS_NFS_H */
54 
55 #ifdef HAVE_RPCSVC_MOUNT_H
56 # include <rpcsvc/mount.h>
57 #endif /* HAVE_RPCSVC_MOUNT_H */
58 
59 #ifdef HAVE_RPC_RPC_H
60 # include <rpc/rpc.h>
61 #endif /* HAVE_RPC_RPC_H */
62 
63 
64 /*
65  * MACROS
66  */
67 
68 #define	NFS_PORT 2049
69 #define	NFS_MAXDATA 8192
70 #define	NFS_MAXPATHLEN 1024
71 #define	NFS_MAXNAMLEN 255
72 #define	NFS_FHSIZE 32
73 #define	NFS_COOKIESIZE 4
74 
75 #define	NFSMODE_FMT 0170000
76 #define	NFSMODE_DIR 0040000
77 #define	NFSMODE_CHR 0020000
78 #define	NFSMODE_BLK 0060000
79 #define	NFSMODE_REG 0100000
80 #define	NFSMODE_LNK 0120000
81 #define	NFSMODE_SOCK 0140000
82 #define	NFSMODE_FIFO 0010000
83 
84 #define	NFSPROC_NULL ((unsigned long)(0))
85 #define	NFSPROC_GETATTR ((unsigned long)(1))
86 #define	NFSPROC_SETATTR ((unsigned long)(2))
87 #define	NFSPROC_ROOT ((unsigned long)(3))
88 #define	NFSPROC_LOOKUP ((unsigned long)(4))
89 #define	NFSPROC_READLINK ((unsigned long)(5))
90 #define	NFSPROC_READ ((unsigned long)(6))
91 #define	NFSPROC_WRITECACHE ((unsigned long)(7))
92 #define	NFSPROC_WRITE ((unsigned long)(8))
93 #define	NFSPROC_CREATE ((unsigned long)(9))
94 #define	NFSPROC_REMOVE ((unsigned long)(10))
95 #define	NFSPROC_RENAME ((unsigned long)(11))
96 #define	NFSPROC_LINK ((unsigned long)(12))
97 #define	NFSPROC_SYMLINK ((unsigned long)(13))
98 #define	NFSPROC_MKDIR ((unsigned long)(14))
99 #define	NFSPROC_RMDIR ((unsigned long)(15))
100 #define	NFSPROC_READDIR ((unsigned long)(16))
101 #define	NFSPROC_STATFS ((unsigned long)(17))
102 
103 /* map field names */
104 #define ml_hostname ml_name
105 #define ml_directory ml_path
106 #define ml_next ml_nxt
107 #define gr_next g_next
108 #define gr_name g_name
109 #define ex_dir ex_name
110 
111 /*
112  * TYPEDEFS:
113  */
114 typedef char *dirpath;
115 typedef char *filename;
116 typedef char *nfspath;
117 typedef char nfscookie[NFS_COOKIESIZE];
118 typedef enum nfsftype nfsftype;
119 typedef enum nfsstat nfsstat;
120 typedef struct attrstat nfsattrstat;
121 typedef struct createargs nfscreateargs;
122 typedef struct dirlist nfsdirlist;
123 typedef struct diropargs nfsdiropargs;
124 typedef struct diropokres nfsdiropokres;
125 typedef struct diropres nfsdiropres;
126 typedef struct entry nfsentry;
127 typedef struct fattr nfsfattr;
128 typedef struct linkargs nfslinkargs;
129 typedef struct nfs_fh nfs_fh;
130 typedef struct nfstime nfstime;
131 typedef struct readargs nfsreadargs;
132 typedef struct readdirargs nfsreaddirargs;
133 typedef struct readdirres nfsreaddirres;
134 typedef struct readlinkres nfsreadlinkres;
135 typedef struct readokres nfsreadokres;
136 typedef struct readres nfsreadres;
137 typedef struct renameargs nfsrenameargs;
138 typedef struct sattr nfssattr;
139 typedef struct sattrargs nfssattrargs;
140 typedef struct statfsokres nfsstatfsokres;
141 typedef struct statfsres nfsstatfsres;
142 typedef struct symlinkargs nfssymlinkargs;
143 typedef struct writeargs nfswriteargs;
144 
145 typedef char *name;
146 typedef fhandle_t fhandle;
147 typedef struct exports *exports;
148 typedef struct exports exportnode;
149 typedef struct fhstatus fhstatus;
150 typedef struct groups *groups;
151 typedef struct groups groupnode;
152 typedef struct mountlist *mountlist;
153 typedef struct mountlist mountbody;
154 
155 
156 /*
157  * EXTERNALS:
158  */
159 
160 extern bool_t xdr_nfsstat(XDR *, nfsstat *);
161 extern bool_t xdr_ftype(XDR *, nfsftype *);
162 extern bool_t xdr_nfs_fh(XDR *, nfs_fh *);
163 extern bool_t xdr_nfstime(XDR *, nfstime *);
164 extern bool_t xdr_fattr(XDR *, nfsfattr *);
165 extern bool_t xdr_sattr(XDR *, nfssattr *);
166 extern bool_t xdr_filename(XDR *, filename *);
167 extern bool_t xdr_nfspath(XDR *, nfspath *);
168 extern bool_t xdr_attrstat(XDR *, nfsattrstat *);
169 extern bool_t xdr_sattrargs(XDR *, nfssattrargs *);
170 extern bool_t xdr_diropargs(XDR *, nfsdiropargs *);
171 extern bool_t xdr_diropokres(XDR *, nfsdiropokres *);
172 extern bool_t xdr_diropres(XDR *, nfsdiropres *);
173 extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres *);
174 extern bool_t xdr_readargs(XDR *, nfsreadargs *);
175 extern bool_t xdr_readokres(XDR *, nfsreadokres *);
176 extern bool_t xdr_readres(XDR *, nfsreadres *);
177 extern bool_t xdr_writeargs(XDR *, nfswriteargs *);
178 extern bool_t xdr_createargs(XDR *, nfscreateargs *);
179 extern bool_t xdr_renameargs(XDR *, nfsrenameargs *);
180 extern bool_t xdr_linkargs(XDR *, nfslinkargs *);
181 extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs *);
182 extern bool_t xdr_nfscookie(XDR *, nfscookie);
183 extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs *);
184 extern bool_t xdr_entry(XDR *, nfsentry *);
185 extern bool_t xdr_dirlist(XDR *, nfsdirlist *);
186 extern bool_t xdr_readdirres(XDR *, nfsreaddirres *);
187 extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres *);
188 extern bool_t xdr_statfsres(XDR *, nfsstatfsres *);
189 
190 extern nfsattrstat *nfsproc_getattr_2(nfs_fh *, CLIENT *);
191 extern nfsattrstat *nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *);
192 extern nfsattrstat *nfsproc_setattr_2(nfssattrargs *, CLIENT *);
193 extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *);
194 extern nfsattrstat *nfsproc_write_2(nfswriteargs *, CLIENT *);
195 extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *);
196 extern nfsdiropres *nfsproc_create_2(nfscreateargs *, CLIENT *);
197 extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *);
198 extern nfsdiropres *nfsproc_lookup_2(nfsdiropargs *, CLIENT *);
199 extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *);
200 extern nfsdiropres *nfsproc_mkdir_2(nfscreateargs *, CLIENT *);
201 extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *);
202 extern nfsstat *nfsproc_link_2(nfslinkargs *, CLIENT *);
203 extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *);
204 extern nfsstat *nfsproc_remove_2(nfsdiropargs *, CLIENT *);
205 extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *);
206 extern nfsstat *nfsproc_rename_2(nfsrenameargs *, CLIENT *);
207 extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *);
208 extern nfsstat *nfsproc_rmdir_2(nfsdiropargs *, CLIENT *);
209 extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *);
210 extern nfsstat *nfsproc_symlink_2(nfssymlinkargs *, CLIENT *);
211 extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *);
212 extern nfsreaddirres *nfsproc_readdir_2(nfsreaddirargs *, CLIENT *);
213 extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *);
214 extern nfsreadlinkres *nfsproc_readlink_2(nfs_fh *, CLIENT *);
215 extern nfsreadlinkres *nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *);
216 extern nfsreadres *nfsproc_read_2(nfsreadargs *, CLIENT *);
217 extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *);
218 extern nfsstatfsres *nfsproc_statfs_2(nfs_fh *, CLIENT *);
219 extern nfsstatfsres *nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *);
220 extern void *nfsproc_null_2(void *, CLIENT *);
221 extern void *nfsproc_null_2_svc(void *, struct svc_req *);
222 extern void *nfsproc_root_2(void *, CLIENT *);
223 extern void *nfsproc_root_2_svc(void *, struct svc_req *);
224 extern void *nfsproc_writecache_2(void *, CLIENT *);
225 extern void *nfsproc_writecache_2_svc(void *, struct svc_req *);
226 extern int nfs_program_2_freeresult(SVCXPRT *, xdrproc_t, caddr_t);
227 
228 
229 /*
230  * ENUMS:
231  */
232 
233 
234 /*
235  * STRUCTURES:
236  */
237 
238 struct nfs_fh {
239   char fh_data[NFS_FHSIZE];
240 };
241 
242 struct nfstime {
243   u_int nt_seconds;
244   u_int nt_useconds;
245 };
246 
247 struct fattr {
248   nfsftype na_type;
249   u_int na_mode;
250   u_int na_nlink;
251   u_int na_uid;
252   u_int na_gid;
253   u_int na_size;
254   u_int na_blocksize;
255   u_int na_rdev;
256   u_int na_blocks;
257   u_int na_fsid;
258   u_int na_fileid;
259   nfstime na_atime;
260   nfstime na_mtime;
261   nfstime na_ctime;
262 };
263 
264 struct sattr {
265   u_int sa_mode;
266   u_int sa_uid;
267   u_int sa_gid;
268   u_int sa_size;
269   nfstime sa_atime;
270   nfstime sa_mtime;
271 };
272 
273 struct attrstat {
274   nfsstat ns_status;
275   union {
276     nfsfattr ns_attr_u;
277   } ns_u;
278 };
279 
280 struct sattrargs {
281   nfs_fh sag_fhandle;
282   nfssattr sag_attributes;
283 };
284 
285 struct diropargs {
286   nfs_fh da_fhandle;		/* was dir */
287   filename da_name;
288 };
289 
290 struct diropokres {
291   nfs_fh drok_fhandle;
292   nfsfattr drok_attributes;
293 };
294 
295 struct diropres {
296   nfsstat dr_status;		/* was status */
297   union {
298     nfsdiropokres dr_drok_u;	/* was diropres */
299   } dr_u;			/* was diropres_u */
300 };
301 
302 struct readlinkres {
303   nfsstat rlr_status;
304   union {
305     nfspath rlr_data_u;
306   } rlr_u;
307 };
308 
309 struct readargs {
310   nfs_fh ra_fhandle;
311   u_int ra_offset;
312   u_int ra_count;
313   u_int ra_totalcount;
314 };
315 
316 struct readokres {
317   nfsfattr raok_attributes;
318   struct {
319     u_int raok_len_u;
320     char *raok_val_u;
321   } raok_u;
322 };
323 
324 struct readres {
325   nfsstat rr_status;
326   union {
327     nfsreadokres rr_reply_u;
328   } rr_u;
329 };
330 
331 struct writeargs {
332   nfs_fh wra_fhandle;
333   u_int wra_beginoffset;
334   u_int wra_offset;
335   u_int wra_totalcount;
336   struct {
337     u_int wra_len_u;
338     char *wra_val_u;
339   } wra_u;
340 };
341 
342 struct createargs {
343   nfsdiropargs ca_where;
344   nfssattr ca_attributes;
345 };
346 
347 struct renameargs {
348   nfsdiropargs rna_from;
349   nfsdiropargs rna_to;
350 };
351 
352 struct linkargs {
353   nfs_fh la_fhandle;
354   nfsdiropargs la_to;
355 };
356 
357 struct symlinkargs {
358   nfsdiropargs sla_from;
359   nfspath sla_to;
360   nfssattr sla_attributes;
361 };
362 
363 struct readdirargs {
364   nfs_fh rda_fhandle;
365   nfscookie rda_cookie;
366   u_int rda_count;
367 };
368 
369 struct entry {
370   u_int ne_fileid;
371   filename ne_name;
372   nfscookie ne_cookie;
373   nfsentry *ne_nextentry;
374 };
375 
376 struct dirlist {
377   nfsentry *dl_entries;
378   bool_t dl_eof;
379 };
380 
381 struct readdirres {
382   nfsstat rdr_status;
383   union {
384     nfsdirlist rdr_reply_u;
385   } rdr_u;
386 };
387 
388 struct statfsokres {
389   u_int sfrok_tsize;
390   u_int sfrok_bsize;
391   u_int sfrok_blocks;
392   u_int sfrok_bfree;
393   u_int sfrok_bavail;
394 };
395 
396 struct statfsres {
397   nfsstat sfr_status;
398   union {
399     nfsstatfsokres sfr_reply_u;
400   } sfr_u;
401 };
402 
403 #endif /* not _AMU_NFS_PROT_H */
404