]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/amd/include/am_compat.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / amd / include / am_compat.h
1 /*
2  * Copyright (c) 1997-2006 Erez Zadok
3  * Copyright (c) 1990 Jan-Simon Pendry
4  * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
5  * Copyright (c) 1990 The Regents of the University of California.
6  * All rights reserved.
7  *
8  * This code is derived from software contributed to Berkeley by
9  * Jan-Simon Pendry at Imperial College, London.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  * 3. All advertising materials mentioning features or use of this software
20  *    must display the following acknowledgment:
21  *      This product includes software developed by the University of
22  *      California, Berkeley and its contributors.
23  * 4. Neither the name of the University nor the names of its contributors
24  *    may be used to endorse or promote products derived from this software
25  *    without specific prior written permission.
26  *
27  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37  * SUCH DAMAGE.
38  *
39  *
40  * File: am-utils/include/am_compat.h
41  *
42  */
43
44 /*
45  *
46  * This file contains compatibility functions and macros, all of which
47  * should be auto-discovered, but for one reason or another (mostly
48  * brain-damage on the part of system designers and header files) they cannot.
49  *
50  * Each compatibility macro/function must include instructions on how/when
51  * it can be removed the am-utils code.
52  *
53  */
54
55 #ifndef _AM_COMPAT_H
56 # define _AM_COMPAT_H
57
58 /*
59  * incomplete mount options definitions (sunos4, irix6, linux, etc.)
60  */
61
62
63 /*
64  * Complete MNTTAB_OPT_* options based on MNT2_NFS_OPT_* mount options.
65  */
66 #if defined(MNT2_NFS_OPT_ACDIRMAX) && !defined(MNTTAB_OPT_ACDIRMAX)
67 # define MNTTAB_OPT_ACDIRMAX "acdirmax"
68 #endif /* defined(MNT2_NFS_OPT_ACDIRMAX) && !defined(MNTTAB_OPT_ACDIRMAX) */
69
70 #if defined(MNT2_NFS_OPT_ACDIRMIN) && !defined(MNTTAB_OPT_ACDIRMIN)
71 # define MNTTAB_OPT_ACDIRMIN "acdirmin"
72 #endif /* defined(MNT2_NFS_OPT_ACDIRMIN) && !defined(MNTTAB_OPT_ACDIRMIN) */
73
74 #if defined(MNT2_NFS_OPT_ACREGMAX) && !defined(MNTTAB_OPT_ACREGMAX)
75 # define MNTTAB_OPT_ACREGMAX "acregmax"
76 #endif /* defined(MNT2_NFS_OPT_ACREGMAX) && !defined(MNTTAB_OPT_ACREGMAX) */
77
78 #if defined(MNT2_NFS_OPT_ACREGMIN) && !defined(MNTTAB_OPT_ACREGMIN)
79 # define MNTTAB_OPT_ACREGMIN "acregmin"
80 #endif /* defined(MNT2_NFS_OPT_ACREGMIN) && !defined(MNTTAB_OPT_ACREGMIN) */
81
82 #if !defined(MNTTAB_OPT_IGNORE)
83 /* SunOS 4.1.x and others define "noauto" option, but not "auto" */
84 # if defined(MNTTAB_OPT_NOAUTO) && !defined(MNTTAB_OPT_AUTO)
85 #  define MNTTAB_OPT_AUTO "auto"
86 # endif /* defined(MNTTAB_OPT_NOAUTO) && !defined(MNTTAB_OPT_AUTO) */
87 #endif /* !defined(MNTTAB_OPT_IGNORE) */
88
89 #if defined(MNT2_NFS_OPT_NOAC) && !defined(MNTTAB_OPT_NOAC)
90 # define MNTTAB_OPT_NOAC "noac"
91 #endif /* defined(MNT2_NFS_OPT_NOAC) && !defined(MNTTAB_OPT_NOAC) */
92
93 #if defined(MNT2_NFS_OPT_NOCONN) && !defined(MNTTAB_OPT_NOCONN)
94 # define MNTTAB_OPT_NOCONN "noconn"
95 # ifndef MNTTAB_OPT_CONN
96 #  define MNTTAB_OPT_CONN "conn"
97 # endif /* MNTTAB_OPT_CONN */
98 #endif /* defined(MNT2_NFS_OPT_NOCONN) && !defined(MNTTAB_OPT_NOCONN) */
99
100 #if defined(MNT2_NFS_OPT_PGTHRESH) && !defined(MNTTAB_OPT_PGTHRESH)
101 # define MNTTAB_OPT_PGTHRESH "pgthresh"
102 #endif /* defined(MNT2_NFS_OPT_PGTHRESH) && !defined(MNTTAB_OPT_PGTHRESH) */
103
104 #if defined(MNT2_NFS_OPT_PRIVATE) && !defined(MNTTAB_OPT_PRIVATE)
105 # define MNTTAB_OPT_PRIVATE "private"
106 #endif /* defined(MNT2_NFS_OPT_PRIVATE) && !defined(MNTTAB_OPT_PRIVATE) */
107
108 #if defined(MNT2_NFS_OPT_RETRANS) && !defined(MNTTAB_OPT_RETRANS)
109 # define MNTTAB_OPT_RETRANS "retrans"
110 #endif /* defined(MNT2_NFS_OPT_RETRANS) && !defined(MNTTAB_OPT_RETRANS) */
111
112 #if defined(MNT2_NFS_OPT_RSIZE) && !defined(MNTTAB_OPT_RSIZE)
113 # define MNTTAB_OPT_RSIZE "rsize"
114 #endif /* defined(MNT2_NFS_OPT_RSIZE) && !defined(MNTTAB_OPT_RSIZE) */
115
116 #if defined(MNT2_NFS_OPT_SOFT) && !defined(MNTTAB_OPT_SOFT)
117 # define MNTTAB_OPT_SOFT "soft"
118 # ifndef MNTTAB_OPT_HARD
119 #  define MNTTAB_OPT_HARD "hard"
120 # endif /* not MNTTAB_OPT_HARD */
121 #endif /* defined(MNT2_NFS_OPT_SOFT) && !defined(MNTTAB_OPT_SOFT) */
122
123 #if defined(MNT2_NFS_OPT_TIMEO) && !defined(MNTTAB_OPT_TIMEO)
124 # define MNTTAB_OPT_TIMEO "timeo"
125 #endif /* defined(MNT2_NFS_OPT_TIMEO) && !defined(MNTTAB_OPT_TIMEO) */
126
127 #if defined(MNT2_NFS_OPT_WSIZE) && !defined(MNTTAB_OPT_WSIZE)
128 # define MNTTAB_OPT_WSIZE "wsize"
129 #endif /* defined(MNT2_NFS_OPT_WSIZE) && !defined(MNTTAB_OPT_WSIZE) */
130
131 #if defined(MNT2_NFS_OPT_MAXGRPS) && !defined(MNTTAB_OPT_MAXGROUPS)
132 # define MNTTAB_OPT_MAXGROUPS "maxgroups"
133 #endif /* defined(MNT2_NFS_OPT_MAXGRPS) && !defined(MNTTAB_OPT_MAXGROUPS) */
134
135 #if defined(MNT2_NFS_OPT_PROPLIST) && !defined(MNTTAB_OPT_PROPLIST)
136 # define MNTTAB_OPT_PROPLIST "proplist"
137 #endif /* defined(MNT2_NFS_OPT_PROPLIST) && !defined(MNTTAB_OPT_PROPLIST) */
138
139 #if defined(MNT2_NFS_OPT_NONLM) && !defined(MNTTAB_OPT_NOLOCK)
140 # define MNTTAB_OPT_NOLOCK "nolock"
141 #endif /* defined(MNT2_NFS_OPT_NONLM) && !defined(MNTTAB_OPT_NOLOCK) */
142
143 #if defined(MNT2_NFS_OPT_XLATECOOKIE) && !defined(MNTTAB_OPT_XLATECOOKIE)
144 # define MNTTAB_OPT_XLATECOOKIE "xlatecookie"
145 #endif /* defined(MNT2_NFS_OPT_XLATECOOKIE) && !defined(MNTTAB_OPT_XLATECOOKIE) */
146
147 /*
148  * Complete MNTTAB_OPT_* options based on MNT2_CDFS_OPT_* mount options.
149  */
150 #if defined(MNT2_CDFS_OPT_DEFPERM) && !defined(MNTTAB_OPT_DEFPERM)
151 # define MNTTAB_OPT_DEFPERM "defperm"
152 #endif /* defined(MNT2_CDFS_OPT_DEFPERM) && !defined(MNTTAB_OPT_DEFPERM) */
153
154 #if defined(MNT2_CDFS_OPT_NODEFPERM) && !defined(MNTTAB_OPT_NODEFPERM)
155 # define MNTTAB_OPT_NODEFPERM "nodefperm"
156 /*
157  * DEC OSF/1 V3.x/Digital UNIX V4.0 have M_NODEFPERM only, but
158  * both mnttab ops.
159  */
160 # ifndef MNTTAB_OPT_DEFPERM
161 #  define MNTTAB_OPT_DEFPERM "defperm"
162 # endif /* not MNTTAB_OPT_DEFPERM */
163 #endif /* defined(MNT2_CDFS_OPT_NODEFPERM) && !defined(MNTTAB_OPT_NODEFPERM) */
164
165 #if defined(MNT2_CDFS_OPT_NOVERSION) && !defined(MNTTAB_OPT_NOVERSION)
166 # define MNTTAB_OPT_NOVERSION "noversion"
167 #endif /* defined(MNT2_CDFS_OPT_NOVERSION) && !defined(MNTTAB_OPT_NOVERSION) */
168
169 #if defined(MNT2_CDFS_OPT_RRIP) && !defined(MNTTAB_OPT_RRIP)
170 # define MNTTAB_OPT_RRIP "rrip"
171 #endif /* defined(MNT2_CDFS_OPT_RRIP) && !defined(MNTTAB_OPT_RRIP) */
172 #if defined(MNT2_CDFS_OPT_NORRIP) && !defined(MNTTAB_OPT_NORRIP)
173 # define MNTTAB_OPT_NORRIP "norrip"
174 #endif /* defined(MNT2_CDFS_OPT_NORRIP) && !defined(MNTTAB_OPT_NORRIP) */
175
176 #if defined(MNT2_CDFS_OPT_GENS) && !defined(MNTTAB_OPT_GENS)
177 # define MNTTAB_OPT_GENS "gens"
178 #endif /* defined(MNT2_CDFS_OPT_GENS) && !defined(MNTTAB_OPT_GENS) */
179 #if defined(MNT2_CDFS_OPT_EXTATT) && !defined(MNTTAB_OPT_EXTATT)
180 # define MNTTAB_OPT_EXTATT "extatt"
181 #endif /* defined(MNT2_CDFS_OPT_EXTATT) && !defined(MNTTAB_OPT_EXTATT) */
182
183 /*
184  * Complete MNTTAB_OPT_* options based on MNT2_PCFS_OPT_* mount options.
185  */
186 #if defined(MNT2_PCFS_OPT_LONGNAME) && !defined(MNTTAB_OPT_LONGNAME)
187 # define MNTTAB_OPT_LONGNAME "longnames"
188 #endif /* defined(MNT2_PCFS_OPT_LONGNAME) && !defined(MNTTAB_OPT_LONGNAME) */
189 #if defined(MNT2_PCFS_OPT_NOWIN95) && !defined(MNTTAB_OPT_NOWIN95)
190 # define MNTTAB_OPT_NOWIN95 "nowin95"
191 #endif /* defined(MNT2_PCFS_OPT_NOWIN95) && !defined(MNTTAB_OPT_NOWIN95) */
192 #if defined(MNT2_PCFS_OPT_SHORTNAME) && !defined(MNTTAB_OPT_SHORTNAME)
193 # define MNTTAB_OPT_SHORTNAME "shortnames"
194 #endif /* defined(MNT2_PCFS_OPT_SHORTNAME) && !defined(MNTTAB_OPT_SHORTNAME) */
195
196 /*
197  * Complete MNTTAB_OPT_* options based on MNT2_GEN_OPT_* mount options.
198  */
199 #if defined(MNT2_GEN_OPT_GRPID) && !defined(MNTTAB_OPT_GRPID)
200 # define MNTTAB_OPT_GRPID "grpid"
201 #endif /* defined(MNT2_GEN_OPT_GRPID) && !defined(MNTTAB_OPT_GRPID) */
202
203 #if defined(MNT2_GEN_OPT_NOCACHE) && !defined(MNTTAB_OPT_NOCACHE)
204 # define MNTTAB_OPT_NOCACHE "nocache"
205 #endif /* defined(MNT2_GEN_OPT_NOCACHE) && !defined(MNTTAB_OPT_NOCACHE) */
206
207 #if defined(MNT2_GEN_OPT_NOSUID) && !defined(MNTTAB_OPT_NOSUID)
208 # define MNTTAB_OPT_NOSUID "nosuid"
209 #endif /* defined(MNT2_GEN_OPT_NOSUID) && !defined(MNTTAB_OPT_NOSUID) */
210
211 #if defined(MNT2_GEN_OPT_OVERLAY) && !defined(MNTTAB_OPT_OVERLAY)
212 # define MNTTAB_OPT_OVERLAY "overlay"
213 #endif /* defined(MNT2_GEN_OPT_OVERLAY) && !defined(MNTTAB_OPT_OVERLAY) */
214
215 /*
216  * Complete MNTTAB_OPT_* options and their inverse based on MNT2_GEN_OPT_*
217  * options.
218  */
219 #if defined(MNT2_GEN_OPT_NODEV) && !defined(MNTTAB_OPT_NODEV)
220 # define MNTTAB_OPT_NODEV "nodev"
221 #endif /* defined(MNT2_GEN_OPT_NODEV) && !defined(MNTTAB_OPT_NODEV) */
222
223 #if defined(MNT2_GEN_OPT_NOEXEC) && !defined(MNTTAB_OPT_NOEXEC)
224 # define MNTTAB_OPT_NOEXEC "noexec"
225 /* this is missing under some versions of Linux */
226 # ifndef MNTTAB_OPT_EXEC
227 #  define MNTTAB_OPT_EXEC "exec"
228 # endif /* not MNTTAB_OPT_EXEC */
229 #endif /* defined(MNT2_GEN_OPT_NOEXEC) && !defined(MNTTAB_OPT_NOEXEC) */
230
231 #if defined(MNT2_GEN_OPT_QUOTA) && !defined(MNTTAB_OPT_QUOTA)
232 # define MNTTAB_OPT_QUOTA "quota"
233 #endif /* defined(MNT2_GEN_OPT_QUOTA) && !defined(MNTTAB_OPT_QUOTA) */
234
235 #if defined(MNT2_GEN_OPT_SYNC) && !defined(MNTTAB_OPT_SYNC)
236 # define MNTTAB_OPT_SYNC "sync"
237 #endif /* defined(MNT2_GEN_OPT_SYNC) && !defined(MNTTAB_OPT_SYNC) */
238
239
240 /*
241  * Add missing MNTTAB_OPT_* options.
242  */
243 #ifndef MNTTAB_OPT_ACTIMEO
244 # define MNTTAB_OPT_ACTIMEO "actimeo"
245 #endif /* not MNTTAB_OPT_ACTIMEO */
246
247 #ifndef MNTTAB_OPT_INTR
248 # define MNTTAB_OPT_INTR "intr"
249 #endif /* not MNTTAB_OPT_INTR */
250
251 #ifndef MNTTAB_OPT_PORT
252 # define MNTTAB_OPT_PORT "port"
253 #endif /* not MNTTAB_OPT_PORT */
254
255 #ifndef MNTTAB_OPT_PUBLIC
256 # define MNTTAB_OPT_PUBLIC "public"
257 #endif /* not MNTTAB_OPT_PUBLIC */
258
259 #ifndef MNTTAB_OPT_RETRANS
260 # define MNTTAB_OPT_RETRANS "retrans"
261 #endif /* not MNTTAB_OPT_RETRANS */
262
263 #ifndef MNTTAB_OPT_RETRY
264 # define MNTTAB_OPT_RETRY "retry"
265 #endif /* not MNTTAB_OPT_RETRY */
266
267 #ifndef MNTTAB_OPT_RO
268 # define MNTTAB_OPT_RO "ro"
269 #endif /* not MNTTAB_OPT_RO */
270
271 #ifndef MNTTAB_OPT_RSIZE
272 # define MNTTAB_OPT_RSIZE "rsize"
273 #endif /* not MNTTAB_OPT_RSIZE */
274
275 #ifndef MNTTAB_OPT_RW
276 # define MNTTAB_OPT_RW "rw"
277 #endif /* not MNTTAB_OPT_RW */
278
279 #ifndef MNTTAB_OPT_TIMEO
280 # define MNTTAB_OPT_TIMEO "timeo"
281 #endif /* not MNTTAB_OPT_TIMEO */
282
283 #ifndef MNTTAB_OPT_WSIZE
284 # define MNTTAB_OPT_WSIZE "wsize"
285 #endif /* not MNTTAB_OPT_WSIZE */
286
287 /* next four are useful for pcfs mounts */
288 #ifndef MNTTAB_OPT_USER
289 # define MNTTAB_OPT_USER "user"
290 #endif /* not MNTTAB_OPT_USER */
291 #ifndef MNTTAB_OPT_GROUP
292 # define MNTTAB_OPT_GROUP "group"
293 #endif /* not MNTTAB_OPT_GROUP */
294 #ifndef MNTTAB_OPT_MASK
295 # define MNTTAB_OPT_MASK "mask"
296 #endif /* not MNTTAB_OPT_MASK */
297 #ifndef MNTTAB_OPT_DIRMASK
298 # define MNTTAB_OPT_DIRMASK "dirmask"
299 #endif /* not MNTTAB_OPT_DIRMASK */
300
301 /*
302  * Incomplete filesystem definitions (sunos4, irix6, solaris2)
303  */
304 #if defined(HAVE_FS_CDFS) && defined(MOUNT_TYPE_CDFS) && !defined(MNTTYPE_CDFS)
305 # define MNTTYPE_CDFS "hsfs"
306 #endif /* defined(HAVE_FS_CDFS) && defined(MOUNT_TYPE_CDFS) && !defined(MNTTYPE_CDFS) */
307
308 #ifndef cdfs_args_t
309 /*
310  * Solaris has an HSFS filesystem, but does not define hsfs_args.
311  * XXX: the definition here for solaris is wrong, since under solaris,
312  * hsfs_args should be a single integer used as a bit-field for options.
313  * so this code has to be fixed later.  -Erez.
314  */
315 struct hsfs_args {
316         char *fspec;    /* name of filesystem to mount */
317         int norrip;
318 };
319 # define cdfs_args_t struct hsfs_args
320 # define HAVE_CDFS_ARGS_T_NORRIP
321 #endif /* not cdfs_args_t */
322
323 /*
324  * if does not define struct pc_args, assume integer bit-field (irix6)
325  */
326 #if defined(HAVE_FS_PCFS) && !defined(pcfs_args_t)
327 # define pcfs_args_t u_int
328 #endif /* defined(HAVE_FS_PCFS) && !defined(pcfs_args_t) */
329
330 /*
331  * if does not define struct ufs_args, assume integer bit-field (linux)
332  */
333 #if defined(HAVE_FS_UFS) && !defined(ufs_args_t)
334 # define ufs_args_t u_int
335 #endif /* defined(HAVE_FS_UFS) && !defined(ufs_args_t) */
336
337 /*
338  * if does not define struct efs_args, assume integer bit-field (linux)
339  */
340 #if defined(HAVE_FS_EFS) && !defined(efs_args_t)
341 # define efs_args_t u_int
342 #endif /* defined(HAVE_FS_EFS) && !defined(efs_args_t) */
343
344 /*
345  * if does not define struct xfs_args, assume integer bit-field (linux)
346  */
347 #if defined(HAVE_FS_XFS) && !defined(xfs_args_t)
348 # define xfs_args_t u_int
349 #endif /* defined(HAVE_FS_XFS) && !defined(xfs_args_t) */
350
351 #if defined(HAVE_FS_AUTOFS) && defined(MOUNT_TYPE_AUTOFS) && !defined(MNTTYPE_AUTOFS)
352 # define MNTTYPE_AUTOFS "autofs"
353 #endif /* defined(HAVE_FS_AUTOFS) && defined(MOUNT_TYPE_AUTOFS) && !defined(MNTTYPE_AUTOFS) */
354
355 /*
356  * If NFS3, then make sure that "proto" and "vers" mnttab options
357  * are available.
358  */
359 #ifdef HAVE_FS_NFS3
360 # ifndef MNTTAB_OPT_VERS
361 #  define MNTTAB_OPT_VERS "vers"
362 # endif /* not MNTTAB_OPT_VERS */
363 # ifndef MNTTAB_OPT_PROTO
364 #  define MNTTAB_OPT_PROTO "proto"
365 # endif /* not MNTTAB_OPT_PROTO */
366 #endif /* not HAVE_FS_NFS3 */
367
368 /*
369  * If loop device (header file) exists, define mount table option
370  */
371 #if defined(HAVE_LOOP_DEVICE) && !defined(MNTTAB_OPT_LOOP)
372 # define MNTTAB_OPT_LOOP "loop"
373 #endif /* defined(HAVE_LOOP_DEVICE) && !defined(MNTTAB_OPT_LOOP) */
374
375 /*
376  * Define a dummy struct netconfig for non-TLI systems
377  */
378 #if !defined(HAVE_NETCONFIG_H) && !defined(HAVE_SYS_NETCONFIG_H)
379 struct netconfig {
380   int dummy;
381 };
382 #endif /* not HAVE_NETCONFIG_H and not HAVE_SYS_NETCONFIG_H */
383
384 /* some OSs don't define INADDR_NONE and assume it's unsigned -1 */
385 #ifndef INADDR_NONE
386 # define INADDR_NONE    0xffffffffU
387 #endif /* INADDR_NONE */
388 /* some OSs don't define INADDR_LOOPBACK */
389 #ifndef INADDR_LOOPBACK
390 # define INADDR_LOOPBACK        0x7f000001
391 #endif /* not INADDR_LOOPBACK */
392
393 #endif /* not _AM_COMPAT_H */