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