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.
8 * This code is derived from software contributed to Berkeley by
9 * Jan-Simon Pendry at Imperial College, London.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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
40 * File: am-utils/include/am_compat.h
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.
50 * Each compatibility macro/function must include instructions on how/when
51 * it can be removed the am-utils code.
59 * incomplete mount options definitions (sunos4, irix6, linux, etc.)
64 * Complete MNTTAB_OPT_* options based on MNT2_NFS_OPT_* mount options.
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) */
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) */
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) */
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) */
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) */
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) */
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) */
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) */
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) */
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) */
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) */
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) */
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) */
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) */
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) */
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) */
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) */
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) */
148 * Complete MNTTAB_OPT_* options based on MNT2_CDFS_OPT_* mount options.
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) */
154 #if defined(MNT2_CDFS_OPT_NODEFPERM) && !defined(MNTTAB_OPT_NODEFPERM)
155 # define MNTTAB_OPT_NODEFPERM "nodefperm"
157 * DEC OSF/1 V3.x/Digital UNIX V4.0 have M_NODEFPERM only, but
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) */
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) */
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) */
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) */
184 * Complete MNTTAB_OPT_* options based on MNT2_PCFS_OPT_* mount options.
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) */
197 * Complete MNTTAB_OPT_* options based on MNT2_GEN_OPT_* mount options.
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) */
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) */
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) */
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) */
216 * Complete MNTTAB_OPT_* options and their inverse based on MNT2_GEN_OPT_*
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) */
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) */
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) */
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) */
241 * Add missing MNTTAB_OPT_* options.
243 #ifndef MNTTAB_OPT_ACTIMEO
244 # define MNTTAB_OPT_ACTIMEO "actimeo"
245 #endif /* not MNTTAB_OPT_ACTIMEO */
247 #ifndef MNTTAB_OPT_INTR
248 # define MNTTAB_OPT_INTR "intr"
249 #endif /* not MNTTAB_OPT_INTR */
251 #ifndef MNTTAB_OPT_PORT
252 # define MNTTAB_OPT_PORT "port"
253 #endif /* not MNTTAB_OPT_PORT */
255 #ifndef MNTTAB_OPT_PUBLIC
256 # define MNTTAB_OPT_PUBLIC "public"
257 #endif /* not MNTTAB_OPT_PUBLIC */
259 #ifndef MNTTAB_OPT_RETRANS
260 # define MNTTAB_OPT_RETRANS "retrans"
261 #endif /* not MNTTAB_OPT_RETRANS */
263 #ifndef MNTTAB_OPT_RETRY
264 # define MNTTAB_OPT_RETRY "retry"
265 #endif /* not MNTTAB_OPT_RETRY */
267 #ifndef MNTTAB_OPT_RO
268 # define MNTTAB_OPT_RO "ro"
269 #endif /* not MNTTAB_OPT_RO */
271 #ifndef MNTTAB_OPT_RSIZE
272 # define MNTTAB_OPT_RSIZE "rsize"
273 #endif /* not MNTTAB_OPT_RSIZE */
275 #ifndef MNTTAB_OPT_RW
276 # define MNTTAB_OPT_RW "rw"
277 #endif /* not MNTTAB_OPT_RW */
279 #ifndef MNTTAB_OPT_TIMEO
280 # define MNTTAB_OPT_TIMEO "timeo"
281 #endif /* not MNTTAB_OPT_TIMEO */
283 #ifndef MNTTAB_OPT_WSIZE
284 # define MNTTAB_OPT_WSIZE "wsize"
285 #endif /* not MNTTAB_OPT_WSIZE */
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 */
302 * Incomplete filesystem definitions (sunos4, irix6, solaris2)
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) */
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.
316 char *fspec; /* name of filesystem to mount */
319 # define cdfs_args_t struct hsfs_args
320 # define HAVE_CDFS_ARGS_T_NORRIP
321 #endif /* not cdfs_args_t */
324 * if does not define struct pc_args, assume integer bit-field (irix6)
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) */
331 * if does not define struct ufs_args, assume integer bit-field (linux)
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) */
338 * if does not define struct efs_args, assume integer bit-field (linux)
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) */
345 * if does not define struct xfs_args, assume integer bit-field (linux)
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) */
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) */
356 * If NFS3, then make sure that "proto" and "vers" mnttab options
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 */
369 * If loop device (header file) exists, define mount table option
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) */
376 * Define a dummy struct netconfig for non-TLI systems
378 #if !defined(HAVE_NETCONFIG_H) && !defined(HAVE_SYS_NETCONFIG_H)
382 #endif /* not HAVE_NETCONFIG_H and not HAVE_SYS_NETCONFIG_H */
384 /* some OSs don't define INADDR_NONE and assume it's unsigned -1 */
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 */
393 #endif /* not _AM_COMPAT_H */