1 /*	$NetBSD: nfs_prot_ultrix.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_ultrix.h
43  *
44  */
45 
46 #ifndef _AMU_NFS_PROT_H
47 #define _AMU_NFS_PROT_H
48 
49 #ifdef HAVE_NFS_NFS_H
50 # include <nfs/nfs.h>
51 #endif /* HAVE_NFS_NFS_H */
52 
53 /*
54  * MACROS
55  */
56 
57 #if 0
58 /* <nfs/nfs.h> */
59 #define NFS_PORT 2049
60 #define NFS_MAXDATA 8192
61 #define NFS_MAXPATHLEN 1024
62 #define NFS_MAXNAMLEN 255
63 #define NFS_FHSIZE 32
64 #endif /* 0 */
65 /* sizeof(u_long) */
66 #define NFS_COOKIESIZE 4
67 #if 0
68 /* defaults: libamu/amu.h */
69 #define	MNTPATHLEN 1024
70 #define	MNTNAMLEN 255
71 #endif /* 0 */
72 
73 #define NFSMODE_FMT 0170000
74 #define NFSMODE_DIR 0040000
75 #define NFSMODE_CHR 0020000
76 #define NFSMODE_BLK 0060000
77 #define NFSMODE_REG 0100000
78 #define NFSMODE_LNK 0120000
79 #define NFSMODE_SOCK 0140000
80 #define NFSMODE_FIFO 0010000
81 
82 #if 0
83 /* <nfs/nfs.h> */
84 #ifndef NFS_PROGRAM
85 # define NFS_PROGRAM ((u_long)100003)
86 #endif /* not NFS_PROGRAM */
87 #ifndef NFS_VERSION
88 # define NFS_VERSION ((u_long)2)
89 #endif /* not NFS_VERSION */
90 #endif /* 0 */
91 
92 /* could use (u_long)RFS_* with RFS_* from <nfs/nfs.h> */
93 #define NFSPROC_NULL ((u_long)0)
94 #define NFSPROC_GETATTR ((u_long)1)
95 #define NFSPROC_SETATTR ((u_long)2)
96 #define NFSPROC_ROOT ((u_long)3)
97 #define NFSPROC_LOOKUP ((u_long)4)
98 #define NFSPROC_READLINK ((u_long)5)
99 #define NFSPROC_READ ((u_long)6)
100 #define NFSPROC_WRITECACHE ((u_long)7)
101 #define NFSPROC_WRITE ((u_long)8)
102 #define NFSPROC_CREATE ((u_long)9)
103 #define NFSPROC_REMOVE ((u_long)10)
104 #define NFSPROC_RENAME ((u_long)11)
105 #define NFSPROC_LINK ((u_long)12)
106 #define NFSPROC_SYMLINK ((u_long)13)
107 #define NFSPROC_MKDIR ((u_long)14)
108 #define NFSPROC_RMDIR ((u_long)15)
109 #define NFSPROC_READDIR ((u_long)16)
110 #define NFSPROC_STATFS ((u_long)17)
111 
112 /* map field names */
113 #define ml_hostname	ml_name
114 #define ml_directory	ml_path
115 #define ml_next		ml_nxt
116 #define	gr_next		g_next
117 #define gr_name		g_name
118 #define ex_dir		ex_name
119 
120 #define ca_where	ca_da
121 #define ca_attributes	ca_sa
122 #define drok_attributes	drok_attr
123 #define fh_data		fh_pad
124 #define na_fileid	na_nodeid
125 #define la_fhandle	la_from
126 #define nt_seconds	tv_sec
127 #define nt_useconds	tv_usec
128 #define ra_totalcount	ra_totcount
129 #define rlr_status	rl_status
130 #define rlr_u		rl_u
131 #define sla_to		sla_tnm
132 #define sla_attributes	sla_sa
133 #define sag_fhandle	saa_fh
134 #define sag_attributes	saa_sa
135 
136 
137 /*
138  * TYPEDEFS:
139  */
140 typedef char *dirpath;
141 typedef char *filename;
142 typedef char *name;
143 typedef char *nfspath;
144 typedef char nfscookie[NFS_COOKIESIZE];
145 typedef enum nfsftype nfsftype;
146 typedef enum nfsstat nfsstat;
147 typedef fhandle_t fhandle;
148 typedef struct nfsattrstat nfsattrstat;
149 typedef struct nfscreatargs nfscreateargs;
150 typedef struct nfsdirlist nfsdirlist;
151 typedef struct nfsdiropargs nfsdiropargs;
152 typedef struct nfsdrok nfsdiropokres;
153 typedef struct nfsdiropres nfsdiropres;
154 typedef struct nfsentry nfsentry;
155 typedef struct exports *exports;
156 typedef struct exports exportnode;
157 typedef struct nfsfattr nfsfattr;
158 typedef struct fhstatus fhstatus;
159 typedef struct groups *groups;
160 typedef struct groups groupnode;
161 typedef struct nfslinkargs nfslinkargs;
162 typedef struct mountlist *mountlist;
163 typedef struct mountlist mountbody;
164 typedef struct timeval nfstime;
165 typedef struct nfsreadargs nfsreadargs;
166 typedef struct nfsreaddirargs nfsreaddirargs;
167 typedef struct nfsreaddirres nfsreaddirres;
168 typedef struct nfsreadlinkres nfsreadlinkres;
169 typedef struct nfsreadokres nfsreadokres;
170 typedef struct nfsreadres nfsreadres;
171 typedef struct nfsrnmargs nfsrenameargs;
172 typedef struct nfssattr nfssattr;
173 typedef struct nfssaargs nfssattrargs;
174 typedef struct nfsstatfsokres nfsstatfsokres;
175 typedef struct nfsstatfsres nfsstatfsres;
176 typedef struct nfsslargs nfssymlinkargs;
177 typedef struct writeargs nfswriteargs;
178 
179 
180 /*
181  * EXTERNALS:
182  */
183 
184 extern void *nfsproc_null_2_svc(void *, struct svc_req *);
185 extern nfsattrstat *nfsproc_getattr_2_svc(fhandle_t *, struct svc_req *);
186 extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *);
187 extern void *nfsproc_root_2_svc(void *, struct svc_req *);
188 extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *);
189 extern nfsreadlinkres *nfsproc_readlink_2_svc(fhandle_t *, struct svc_req *);
190 extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *);
191 extern void *nfsproc_writecache_2_svc(void *, struct svc_req *);
192 extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *);
193 extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *);
194 extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *);
195 extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *);
196 extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *);
197 extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *);
198 extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *);
199 extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *);
200 extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *);
201 extern nfsstatfsres *nfsproc_statfs_2_svc(fhandle_t *, struct svc_req *);
202 
203 extern bool_t xdr_nfsstat(XDR *, nfsstat*);
204 extern bool_t xdr_ftype(XDR *, nfsftype*);
205 extern bool_t xdr_nfs_fh(XDR *, fhandle_t*);
206 extern bool_t xdr_nfstime(XDR *, nfstime*);
207 extern bool_t xdr_fattr(XDR *, nfsfattr*);
208 extern bool_t xdr_sattr(XDR *, nfssattr*);
209 extern bool_t xdr_filename(XDR *, filename*);
210 extern bool_t xdr_nfspath(XDR *, nfspath*);
211 extern bool_t xdr_attrstat(XDR *, nfsattrstat*);
212 extern bool_t xdr_sattrargs(XDR *, nfssattrargs*);
213 extern bool_t xdr_diropargs(XDR *, nfsdiropargs*);
214 extern bool_t xdr_diropokres(XDR *, nfsdiropokres*);
215 extern bool_t xdr_diropres(XDR *, nfsdiropres*);
216 extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*);
217 extern bool_t xdr_readargs(XDR *, nfsreadargs*);
218 extern bool_t xdr_readokres(XDR *, nfsreadokres*);
219 extern bool_t xdr_readres(XDR *, nfsreadres*);
220 extern bool_t xdr_writeargs(XDR *, nfswriteargs*);
221 extern bool_t xdr_createargs(XDR *, nfscreateargs*);
222 extern bool_t xdr_renameargs(XDR *, nfsrenameargs*);
223 extern bool_t xdr_linkargs(XDR *, nfslinkargs*);
224 extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*);
225 extern bool_t xdr_nfscookie(XDR *, nfscookie);
226 extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*);
227 extern bool_t xdr_entry(XDR *, nfsentry*);
228 extern bool_t xdr_dirlist(XDR *, nfsdirlist*);
229 extern bool_t xdr_readdirres(XDR *, nfsreaddirres*);
230 extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*);
231 extern bool_t xdr_statfsres(XDR *, nfsstatfsres*);
232 
233 
234 /*
235  * STRUCTURES:
236  */
237 
238 struct nfsreadlinkres {
239   nfsstat rlr_status;
240   union {
241     nfspath rlr_data_u;
242   } rlr_u;
243 };
244 
245 struct nfsreadokres {
246   nfsfattr raok_attributes;
247   struct {
248     u_int raok_len_u;
249     char *raok_val_u;
250   } raok_u;
251 };
252 
253 struct nfsreadres {
254   nfsstat rr_status;
255   union {
256     nfsreadokres rr_reply_u;
257   } rr_u;
258 };
259 
260 struct writeargs {
261   fhandle_t wra_fhandle;
262   u_int wra_beginoffset;
263   u_int wra_offset;
264   u_int wra_totalcount;
265   struct {
266     u_int wra_len_u;
267     char *wra_val_u;
268   } wra_u;
269 };
270 
271 struct nfsreaddirargs {
272   fhandle_t rda_fhandle;
273   nfscookie rda_cookie;
274   u_int rda_count;
275 };
276 
277 struct nfsentry {
278   u_int ne_fileid;
279   filename ne_name;
280   nfscookie ne_cookie;
281   nfsentry *ne_nextentry;
282 };
283 
284 struct nfsdirlist {
285   nfsentry *dl_entries;
286   bool_t dl_eof;
287 };
288 
289 struct nfsreaddirres {
290   nfsstat rdr_status;
291   union {
292     nfsdirlist rdr_reply_u;
293   } rdr_u;
294 };
295 
296 struct nfsstatfsokres {
297   u_int sfrok_tsize;
298   u_int sfrok_bsize;
299   u_int sfrok_blocks;
300   u_int sfrok_bfree;
301   u_int sfrok_bavail;
302 };
303 
304 struct nfsstatfsres {
305   nfsstat sfr_status;
306   union {
307     nfsstatfsokres sfr_reply_u;
308   } sfr_u;
309 };
310 #endif /* not _AMU_NFS_PROT_H */
311