1 /*	$NetBSD: am_xdr_func.h,v 1.1.1.2 2009/03/20 20:26:55 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/include/am_xdr_func.h
43  *
44  */
45 
46 #ifdef HAVE_FS_NFS3
47 
48 #define AM_FHSIZE3 64		/* size in bytes of a file handle (v3) */
49 #define	AM_MOUNTVERS3 ((unsigned long)(3))
50 
51 /* NFSv3 handle */
52 struct am_nfs_fh3 {
53   u_int am_fh3_length;
54   char am_fh3_data[AM_FHSIZE3];
55 };
56 typedef struct am_nfs_fh3 am_nfs_fh3;
57 
58 #define AM_NFSPROC3_LOOKUP ((u_long) 3)
59 enum am_nfsstat3 {
60 	AM_NFS3_OK = 0,
61 	AM_NFS3ERR_PERM = 1,
62 	AM_NFS3ERR_NOENT = 2,
63 	AM_NFS3ERR_IO = 5,
64 	AM_NFS3ERR_NXIO = 6,
65 	AM_NFS3ERR_ACCES = 13,
66 	AM_NFS3ERR_EXIST = 17,
67 	AM_NFS3ERR_XDEV = 18,
68 	AM_NFS3ERR_NODEV = 19,
69 	AM_NFS3ERR_NOTDIR = 20,
70 	AM_NFS3ERR_ISDIR = 21,
71 	AM_NFS3ERR_INVAL = 22,
72 	AM_NFS3ERR_FBIG = 27,
73 	AM_NFS3ERR_NOSPC = 28,
74 	AM_NFS3ERR_ROFS = 30,
75 	AM_NFS3ERR_MLINK = 31,
76 	AM_NFS3ERR_NAMETOOLONG = 63,
77 	AM_NFS3ERR_NOTEMPTY = 66,
78 	AM_NFS3ERR_DQUOT = 69,
79 	AM_NFS3ERR_STALE = 70,
80 	AM_NFS3ERR_REMOTE = 71,
81 	AM_NFS3ERR_BADHANDLE = 10001,
82 	AM_NFS3ERR_NOT_SYNC = 10002,
83 	AM_NFS3ERR_BAD_COOKIE = 10003,
84 	AM_NFS3ERR_NOTSUPP = 10004,
85 	AM_NFS3ERR_TOOSMALL = 10005,
86 	AM_NFS3ERR_SERVERFAULT = 10006,
87 	AM_NFS3ERR_BADTYPE = 10007,
88 	AM_NFS3ERR_JUKEBOX = 10008
89 };
90 typedef enum am_nfsstat3 am_nfsstat3;
91 
92 typedef struct {
93   u_int fhandle3_len;
94   char *fhandle3_val;
95 } am_fhandle3;
96 
97 enum am_mountstat3 {
98        AM_MNT3_OK = 0,
99        AM_MNT3ERR_PERM = 1,
100        AM_MNT3ERR_NOENT = 2,
101        AM_MNT3ERR_IO = 5,
102        AM_MNT3ERR_ACCES = 13,
103        AM_MNT3ERR_NOTDIR = 20,
104        AM_MNT3ERR_INVAL = 22,
105        AM_MNT3ERR_NAMETOOLONG = 63,
106        AM_MNT3ERR_NOTSUPP = 10004,
107        AM_MNT3ERR_SERVERFAULT = 10006
108 };
109 typedef enum am_mountstat3 am_mountstat3;
110 
111 struct am_mountres3_ok {
112        am_fhandle3 fhandle;
113        struct {
114                u_int auth_flavors_len;
115                int *auth_flavors_val;
116        } auth_flavors;
117 };
118 typedef struct am_mountres3_ok am_mountres3_ok;
119 
120 struct am_mountres3 {
121        am_mountstat3 fhs_status;
122        union {
123                am_mountres3_ok mountinfo;
124        } mountres3_u;
125 };
126 typedef struct am_mountres3 am_mountres3;
127 
128 typedef char *am_filename3;
129 
130 struct am_diropargs3 {
131 	am_nfs_fh3 dir;
132 	am_filename3 name;
133 };
134 typedef struct am_diropargs3 am_diropargs3;
135 
136 struct am_LOOKUP3args {
137 	am_diropargs3 what;
138 };
139 typedef struct am_LOOKUP3args am_LOOKUP3args;
140 
141 struct am_LOOKUP3resok {
142 	am_nfs_fh3 object;
143 #if 0
144 	post_op_attr obj_attributes;
145 	post_op_attr dir_attributes;
146 #endif /* 0 */
147 };
148 typedef struct am_LOOKUP3resok am_LOOKUP3resok;
149 
150 struct am_LOOKUP3resfail {
151 #if 0
152 	post_op_attr dir_attributes;
153 #else /* !0 */
154 	char dummy;		/* cannot have an empty declaration */
155 #endif /* !0 */
156 };
157 typedef struct am_LOOKUP3resfail am_LOOKUP3resfail;
158 
159 struct am_LOOKUP3res {
160 	am_nfsstat3 status;
161 	union {
162 		am_LOOKUP3resok ok;
163 		am_LOOKUP3resfail fail;
164 	} res_u;
165 };
166 typedef struct am_LOOKUP3res am_LOOKUP3res;
167 #endif /* HAVE_FS_NFS3 */
168 
169 /*
170  * Multi-protocol NFS file handle
171  */
172 union am_nfs_handle {
173 				/* placeholder for V4 file handle */
174 #ifdef HAVE_FS_NFS3
175   am_nfs_fh3		v3;	/* NFS version 3 handle */
176 #endif /* HAVE_FS_NFS3 */
177   am_nfs_fh		v2;	/* NFS version 2 handle */
178 };
179 typedef union am_nfs_handle am_nfs_handle_t;
180 
181 
182 /*
183  * Definitions of all possible xdr functions that are otherwise
184  * not defined elsewhere.
185  */
186 
187 #ifndef _AM_XDR_FUNC_H
188 #define _AM_XDR_FUNC_H
189 
190 #ifndef HAVE_XDR_ATTRSTAT
191 bool_t xdr_attrstat(XDR *xdrs, nfsattrstat *objp);
192 #endif /* not HAVE_XDR_ATTRSTAT */
193 #ifndef HAVE_XDR_CREATEARGS
194 bool_t xdr_createargs(XDR *xdrs, nfscreateargs *objp);
195 #endif /* not HAVE_XDR_CREATEARGS */
196 #ifndef HAVE_XDR_DIRLIST
197 bool_t xdr_dirlist(XDR *xdrs, nfsdirlist *objp);
198 #endif /* not HAVE_XDR_DIRLIST */
199 #ifndef HAVE_XDR_DIROPARGS
200 bool_t xdr_diropargs(XDR *xdrs, nfsdiropargs *objp);
201 #endif /* not HAVE_XDR_DIROPARGS */
202 #ifndef HAVE_XDR_DIROPOKRES
203 bool_t xdr_diropokres(XDR *xdrs, nfsdiropokres *objp);
204 #endif /* not HAVE_XDR_DIROPOKRES */
205 #ifndef HAVE_XDR_DIROPRES
206 bool_t xdr_diropres(XDR *xdrs, nfsdiropres *objp);
207 #endif /* not HAVE_XDR_DIROPRES */
208 #ifndef HAVE_XDR_DIRPATH
209 bool_t xdr_dirpath(XDR *xdrs, dirpath *objp);
210 #endif /* not HAVE_XDR_DIRPATH */
211 #ifndef HAVE_XDR_ENTRY
212 bool_t xdr_entry(XDR *xdrs, nfsentry *objp);
213 #endif /* not HAVE_XDR_ENTRY */
214 #ifndef HAVE_XDR_EXPORTNODE
215 bool_t xdr_exportnode(XDR *xdrs, exportnode *objp);
216 #endif /* not HAVE_XDR_EXPORTNODE */
217 #ifndef HAVE_XDR_EXPORTS
218 bool_t xdr_exports(XDR *xdrs, exports *objp);
219 #endif /* not HAVE_XDR_EXPORTS */
220 #ifndef HAVE_XDR_FATTR
221 bool_t xdr_fattr(XDR *xdrs, nfsfattr *objp);
222 #endif /* not HAVE_XDR_FATTR */
223 #ifndef HAVE_XDR_FHANDLE
224 bool_t xdr_fhandle(XDR *xdrs, fhandle objp);
225 #endif /* not HAVE_XDR_FHANDLE */
226 #ifndef HAVE_XDR_FHSTATUS
227 bool_t xdr_fhstatus(XDR *xdrs, fhstatus *objp);
228 #endif /* not HAVE_XDR_FHSTATUS */
229 #ifndef HAVE_XDR_FILENAME
230 bool_t xdr_filename(XDR *xdrs, filename *objp);
231 #endif /* not HAVE_XDR_FILENAME */
232 #ifndef HAVE_XDR_FTYPE
233 bool_t xdr_ftype(XDR *xdrs, nfsftype *objp);
234 #endif /* not HAVE_XDR_FTYPE */
235 #ifndef HAVE_XDR_GROUPNODE
236 bool_t xdr_groupnode(XDR *xdrs, groupnode *objp);
237 #endif /* not HAVE_XDR_GROUPNODE */
238 #ifndef HAVE_XDR_GROUPS
239 bool_t xdr_groups(XDR *xdrs, groups *objp);
240 #endif /* not HAVE_XDR_GROUPS */
241 #ifndef HAVE_XDR_LINKARGS
242 bool_t xdr_linkargs(XDR *xdrs, nfslinkargs *objp);
243 #endif /* not HAVE_XDR_LINKARGS */
244 #ifndef HAVE_XDR_MOUNTBODY
245 bool_t xdr_mountbody(XDR *xdrs, mountbody *objp);
246 #endif /* not HAVE_XDR_MOUNTBODY */
247 #ifndef HAVE_XDR_MOUNTLIST
248 bool_t xdr_mountlist(XDR *xdrs, mountlist *objp);
249 #endif /* not HAVE_XDR_MOUNTLIST */
250 #ifndef HAVE_XDR_NAME
251 bool_t xdr_name(XDR *xdrs, name *objp);
252 #endif /* not HAVE_XDR_NAME */
253 #ifndef HAVE_XDR_NFS_FH
254 bool_t xdr_nfs_fh(XDR *xdrs, am_nfs_fh *objp);
255 #endif /* not HAVE_XDR_NFS_FH */
256 #ifndef HAVE_XDR_NFSCOOKIE
257 bool_t xdr_nfscookie(XDR *xdrs, nfscookie objp);
258 #endif /* not HAVE_XDR_NFSCOOKIE */
259 #ifndef HAVE_XDR_NFSPATH
260 bool_t xdr_nfspath(XDR *xdrs, nfspath *objp);
261 #endif /* not HAVE_XDR_NFSPATH */
262 #ifndef HAVE_XDR_NFSSTAT
263 bool_t xdr_nfsstat(XDR *xdrs, nfsstat *objp);
264 #endif /* not HAVE_XDR_NFSSTAT */
265 #ifndef HAVE_XDR_NFSTIME
266 bool_t xdr_nfstime(XDR *xdrs, nfstime *objp);
267 #endif /* not HAVE_XDR_NFSTIME */
268 #ifndef HAVE_XDR_POINTER
269 bool_t xdr_pointer(register XDR *xdrs, char **objpp, u_int obj_size, XDRPROC_T_TYPE xdr_obj);
270 #endif /* not HAVE_XDR_POINTER */
271 #ifndef HAVE_XDR_READARGS
272 bool_t xdr_readargs(XDR *xdrs, nfsreadargs *objp);
273 #endif /* not HAVE_XDR_READARGS */
274 #ifndef HAVE_XDR_READDIRARGS
275 bool_t xdr_readdirargs(XDR *xdrs, nfsreaddirargs *objp);
276 #endif /* not HAVE_XDR_READDIRARGS */
277 #ifndef HAVE_XDR_READDIRRES
278 bool_t xdr_readdirres(XDR *xdrs, nfsreaddirres *objp);
279 #endif /* not HAVE_XDR_READDIRRES */
280 #ifndef HAVE_XDR_READLINKRES
281 bool_t xdr_readlinkres(XDR *xdrs, nfsreadlinkres *objp);
282 #endif /* not HAVE_XDR_READLINKRES */
283 #ifndef HAVE_XDR_READOKRES
284 bool_t xdr_readokres(XDR *xdrs, nfsreadokres *objp);
285 #endif /* not HAVE_XDR_READOKRES */
286 #ifndef HAVE_XDR_READRES
287 bool_t xdr_readres(XDR *xdrs, nfsreadres *objp);
288 #endif /* not HAVE_XDR_READRES */
289 #ifndef HAVE_XDR_RENAMEARGS
290 bool_t xdr_renameargs(XDR *xdrs, nfsrenameargs *objp);
291 #endif /* not HAVE_XDR_RENAMEARGS */
292 #ifndef HAVE_XDR_SATTR
293 bool_t xdr_sattr(XDR *xdrs, nfssattr *objp);
294 #endif /* not HAVE_XDR_SATTR */
295 #ifndef HAVE_XDR_SATTRARGS
296 bool_t xdr_sattrargs(XDR *xdrs, nfssattrargs *objp);
297 #endif /* not HAVE_XDR_SATTRARGS */
298 #ifndef HAVE_XDR_STATFSOKRES
299 bool_t xdr_statfsokres(XDR *xdrs, nfsstatfsokres *objp);
300 #endif /* not HAVE_XDR_STATFSOKRES */
301 #ifndef HAVE_XDR_STATFSRES
302 bool_t xdr_statfsres(XDR *xdrs, nfsstatfsres *objp);
303 #endif /* not HAVE_XDR_STATFSRES */
304 #ifndef HAVE_XDR_SYMLINKARGS
305 bool_t xdr_symlinkargs(XDR *xdrs, nfssymlinkargs *objp);
306 #endif /* not HAVE_XDR_SYMLINKARGS */
307 #ifndef HAVE_XDR_WRITEARGS
308 bool_t xdr_writeargs(XDR *xdrs, nfswriteargs *objp);
309 #endif /* not HAVE_XDR_WRITEARGS */
310 
311 /*
312  * NFS3 XDR FUNCTIONS:
313  */
314 #ifdef HAVE_FS_NFS3
315 bool_t xdr_am_fhandle3(XDR *xdrs, am_fhandle3 *objp);
316 bool_t xdr_am_mountstat3(XDR *xdrs, am_mountstat3 *objp);
317 bool_t xdr_am_mountres3_ok(XDR *xdrs, am_mountres3_ok *objp);
318 bool_t xdr_am_mountres3(XDR *xdrs, am_mountres3 *objp);
319 bool_t xdr_am_diropargs3(XDR *xdrs, am_diropargs3 *objp);
320 bool_t xdr_am_filename3(XDR *xdrs, am_filename3 *objp);
321 bool_t xdr_am_LOOKUP3args(XDR *xdrs, am_LOOKUP3args *objp);
322 bool_t xdr_am_LOOKUP3res(XDR *xdrs, am_LOOKUP3res *objp);
323 bool_t xdr_am_LOOKUP3resfail(XDR *xdrs, am_LOOKUP3resfail *objp);
324 bool_t xdr_am_LOOKUP3resok(XDR *xdrs, am_LOOKUP3resok *objp);
325 bool_t xdr_am_nfsstat3(XDR *xdrs, am_nfsstat3 *objp);
326 bool_t xdr_am_nfs_fh3(XDR *xdrs, am_nfs_fh3 *objp);
327 #endif /* HAVE_FS_NFS3 */
328 
329 #endif /* not _AM_XDR_FUNC_H */
330