2 * Copyright (c) 1997-2004 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
41 * $Id: am_defs.h,v 1.15.2.16 2004/05/12 15:54:31 ezk Exp $
47 * Definitions that are not specific to the am-utils package, but
48 * are rather generic, and can be used elsewhere.
55 * Actions to take if ANSI C.
59 /* for function prototypes */
62 #else /* not STDC_HEADERS */
63 /* empty function prototypes */
68 # define strrchr rindex
69 # endif /* not HAVE_STRCHR */
70 char *strchr(), *strrchr(), *strdup();
71 #endif /* not STDC_HEADERS */
73 /* AIX requires this to be the first thing in the file. */
77 # else /* not HAVE_ALLOCA_H */
80 * This pragma directive is indented so that pre-ANSI C compilers will
81 * ignore it, rather than choke on it.
86 /* predefined by HP cc +Olibcalls */
88 # endif /* not alloca */
89 # endif /* not _AIX */
90 # endif /* not HAVE_ALLOCA_H */
91 #endif /* not __GNUC__ */
94 * Handle gcc __attribute__ if available.
97 /* This feature is available in gcc versions 2.5 and later. */
98 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
99 # define __attribute__(Spec) /* empty */
100 # endif /* __GNUC__ < 2 ... */
102 * The __-protected variants of `format' and `printf' attributes
103 * are accepted by gcc versions 2.6.4 (effectively 2.7) and later.
105 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
106 # define __format__ format
107 # define __printf__ printf
108 # endif /* __GNUC__ < 2 ... */
109 #endif /* not __attribute__ */
112 * How to handle signals of any type
114 #ifdef HAVE_SYS_WAIT_H
115 # include <sys/wait.h>
116 #endif /* HAVE_SYS_WAIT_H */
118 # define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
119 #endif /* not WEXITSTATUS */
121 # define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
122 #endif /* not WIFEXITED */
125 * Actions to take regarding <time.h> and <sys/time.h>.
127 #if TIME_WITH_SYS_TIME
128 # include <sys/time.h>
130 #else /* not TIME_WITH_SYS_TIME */
132 # include <sys/time.h>
133 # else /* not HAVE_SYS_TIME_H */
135 # endif /* not HAVE_SYS_TIME_H */
136 #endif /* not TIME_WITH_SYS_TIME */
139 * Actions to take if <machine/endian.h> exists.
141 #ifdef HAVE_MACHINE_ENDIAN_H
142 # include <machine/endian.h>
143 #endif /* HAVE_MACHINE_ENDIAN_H */
146 * Big-endian or little-endian?
148 #ifdef WORDS_BIGENDIAN
149 # define ARCH_ENDIAN "big"
150 #else /* not WORDS_BIGENDIAN */
151 # define ARCH_ENDIAN "little"
152 #endif /* not WORDS_BIGENDIAN */
155 * Actions to take if HAVE_SYS_TYPES_H is defined.
158 # include <sys/types.h>
159 #endif /* HAVE_SYS_TYPES_H */
162 * Actions to take if HAVE_UNISTD_H is defined.
166 #endif /* HAVE_UNISTD_H */
168 /* after <unistd.h>, check if this is a POSIX.1 system */
169 #ifdef _POSIX_VERSION
170 /* Code for POSIX.1 systems. */
171 #endif /* _POSIX_VERSION */
174 * Variable length argument lists.
175 * Must use only one of the two!
180 * On Solaris 2.6, <sys/varargs.h> is included in <sys/fs/autofs.h>
181 * So this ensures that only one is included.
183 # ifndef _SYS_VARARGS_H
184 # define _SYS_VARARGS_H
185 # endif /* not _SYS_VARARGS_H */
186 #else /* not HAVE_STDARG_H */
187 # ifdef HAVE_VARARGS_H
188 # include <varargs.h>
189 # endif /* HAVE_VARARGS_H */
190 #endif /* not HAVE_STDARG_H */
193 * Pick the right header file and macros for directory processing functions.
197 # define NAMLEN(dirent) strlen((dirent)->d_name)
198 #else /* not HAVE_DIRENT_H */
199 # define dirent direct
200 # define NAMLEN(dirent) (dirent)->d_namlen
202 # include <sys/ndir.h>
203 # endif /* HAVE_SYS_NDIR_H */
205 # include <sys/dir.h>
206 # endif /* HAVE_SYS_DIR_H */
209 # endif /* HAVE_NDIR_H */
210 #endif /* not HAVE_DIRENT_H */
213 * Actions to take if HAVE_FCNTL_H is defined.
217 #endif /* HAVE_FCNTL_H */
220 * Actions to take if HAVE_MEMORY_H is defined.
224 #endif /* HAVE_MEMORY_H */
227 * Actions to take if HAVE_SYS_FILE_H is defined.
230 # include <sys/file.h>
231 #endif /* HAVE_SYS_FILE_H */
234 * Actions to take if HAVE_SYS_IOCTL_H is defined.
237 # include <sys/ioctl.h>
238 #endif /* HAVE_SYS_IOCTL_H */
241 * Actions to take if HAVE_SYSLOG_H or HAVE_SYS_SYSLOG_H is defined.
245 #else /* not HAVE_SYSLOG_H */
246 # if HAVE_SYS_SYSLOG_H
247 # include <sys/syslog.h>
248 # endif /* HAVE_SYS_SYSLOG_H */
249 #endif /* HAVE_SYSLOG_H */
252 * Actions to take if <sys/param.h> exists.
254 #ifdef HAVE_SYS_PARAM_H
255 # include <sys/param.h>
256 #endif /* HAVE_SYS_PARAM_H */
259 * Actions to take if <sys/socket.h> exists.
261 #ifdef HAVE_SYS_SOCKET_H
262 # include <sys/socket.h>
263 #endif /* HAVE_SYS_SOCKET_H */
266 * Actions to take if <rpc/rpc.h> exists.
268 #ifdef HAVE_RPC_RPC_H
270 * Turn on PORTMAP, so that additional header files would get included
271 * and the important definition for UDPMSGSIZE is included too.
275 # endif /* not PORTMAP */
276 # include <rpc/rpc.h>
277 # ifndef XDRPROC_T_TYPE
278 typedef bool_t (*xdrproc_t) __P ((XDR *, __ptr_t, ...));
279 # endif /* not XDRPROC_T_TYPE */
280 #endif /* HAVE_RPC_RPC_H */
283 * Actions to take if <rpc/types.h> exists.
285 #ifdef HAVE_RPC_TYPES_H
286 # include <rpc/types.h>
287 #endif /* HAVE_RPC_TYPES_H */
290 * Actions to take if <rpc/xdr.h> exists.
292 /* Prevent multiple inclusion on Ultrix 4 */
293 #if defined(HAVE_RPC_XDR_H) && !defined(__XDR_HEADER__)
294 # include <rpc/xdr.h>
295 #endif /* defined(HAVE_RPC_XDR_H) && !defined(__XDR_HEADER__) */
298 * Actions to take if <malloc.h> exists.
299 * Don't include malloc.h if stdlib.h exists, because modern
300 * systems complain if you use malloc.h instead of stdlib.h.
301 * XXX: let's hope there are no systems out there that need both.
303 #if defined(HAVE_MALLOC_H) && !defined(HAVE_STDLIB_H)
305 #endif /* defined(HAVE_MALLOC_H) && !defined(HAVE_STDLIB_H) */
308 * Actions to take if <mntent.h> exists.
311 /* some systems need <stdio.h> before <mntent.h> is included */
314 # endif /* HAVE_STDIO_H */
316 #endif /* HAVE_MNTENT_H */
319 * Actions to take if <sys/errno.h> exists.
321 #ifdef HAVE_SYS_ERRNO_H
322 # include <sys/errno.h>
324 #endif /* HAVE_SYS_ERRNO_H */
327 * Actions to take if <sys/fsid.h> exists.
329 #ifdef HAVE_SYS_FSID_H
330 # include <sys/fsid.h>
331 #endif /* HAVE_SYS_FSID_H */
334 * Actions to take if <sys/utsname.h> exists.
336 #ifdef HAVE_SYS_UTSNAME_H
337 # include <sys/utsname.h>
338 #endif /* HAVE_SYS_UTSNAME_H */
341 * Actions to take if <sys/mntent.h> exists.
343 #ifdef HAVE_SYS_MNTENT_H
344 # include <sys/mntent.h>
345 #endif /* HAVE_SYS_MNTENT_H */
348 * Actions to take if <ndbm.h> or <db1/ndbm.h> exist.
349 * Should be included before <rpcsvc/yp_prot.h> because on some systems
350 * like Linux, it also defines "struct datum".
355 /* ensure that struct datum is not included again from <rpcsvc/yp_prot.h> */
357 # endif /* not DATUM */
358 #endif /* HAVE_MAP_NDBM */
361 * Actions to take if <net/errno.h> exists.
363 #ifdef HAVE_NET_ERRNO_H
364 # include <net/errno.h>
365 #endif /* HAVE_NET_ERRNO_H */
368 * Actions to take if <net/route.h> exists.
370 #ifdef HAVE_NET_ROUTE_H
371 # include <net/route.h>
372 #endif /* HAVE_NET_ROUTE_H */
375 * Actions to take if <sys/mbuf.h> exists.
377 #ifdef HAVE_SYS_MBUF_H
378 # include <sys/mbuf.h>
380 * OSF4 (DU-4.0) defines m_next and m_data also in <sys/mount.h> so I must
381 # undefine them here to avoid conflicts.
390 * AIX 3 defines MFREE and m_flags also in <sys/mount.h>.
394 # endif /* m_flags */
398 #endif /* HAVE_SYS_MBUF_H */
401 * Actions to take if <net/if.h> exists.
405 #endif /* HAVE_NET_IF_H */
408 * Actions to take if <netdb.h> exists.
412 #endif /* HAVE_NETDB_H */
415 * Actions to take if <netdir.h> exists.
419 #endif /* HAVE_NETDIR_H */
422 * Actions to take if <net/if_var.h> exists.
424 #ifdef HAVE_NET_IF_VAR_H
425 # include <net/if_var.h>
426 #endif /* HAVE_NET_IF_VAR_H */
429 * Actions to take if <netinet/if_ether.h> exists.
431 #ifdef HAVE_NETINET_IF_ETHER_H
432 # include <netinet/if_ether.h>
433 #endif /* HAVE_NETINET_IF_ETHER_H */
436 * Actions to take if <netinet/in.h> exists.
438 #ifdef HAVE_NETINET_IN_H
439 # include <netinet/in.h>
440 #endif /* HAVE_NETINET_IN_H */
443 * Actions to take if <rpcsvc/yp_prot.h> exists.
445 #ifdef HAVE_RPCSVC_YP_PROT_H
446 # ifdef HAVE_BAD_HEADERS
447 /* avoid circular dependency in aix 4.3 with <rpcsvc/ypclnt.h> */
448 struct ypall_callback;
449 # endif /* HAVE_BAD_HEADERS */
450 # include <rpcsvc/yp_prot.h>
451 #endif /* HAVE_RPCSVC_YP_PROT_H */
454 * Actions to take if <rpcsvc/ypclnt.h> exists.
456 #ifdef HAVE_RPCSVC_YPCLNT_H
457 # include <rpcsvc/ypclnt.h>
458 #endif /* HAVE_RPCSVC_YPCLNT_H */
461 * Actions to take if <sys/ucred.h> exists.
463 #ifdef HAVE_SYS_UCRED_H
464 # include <sys/ucred.h>
465 #endif /* HAVE_SYS_UCRED_H */
469 * Actions to take if <sys/mount.h> exists.
471 #ifdef HAVE_SYS_MOUNT_H
473 * Some operating systems must define these variables to get
474 * NFS and other definitions included.
478 # endif /* not NFSCLIENT */
481 # endif /* not NFS */
484 # endif /* not PCFS */
487 # endif /* not LOFS */
490 # endif /* not RFS */
493 # endif /* not MSDOSFS */
496 # endif /* not MFS */
499 # endif /* not CD9660 */
500 # include <sys/mount.h>
501 #endif /* HAVE_SYS_MOUNT_H */
503 #ifdef HAVE_SYS_VMOUNT_H
504 # include <sys/vmount.h>
505 #endif /* HAVE_SYS_VMOUNT_H */
508 * Actions to take if <linux/fs.h> exists.
509 * There is no point in including this on a glibc2 system,
510 * we're only asking for trouble
512 #if defined HAVE_LINUX_FS_H && (!defined __GLIBC__ || __GLIBC__ < 2)
514 * There are various conflicts in definitions between RedHat Linux, newer
515 * 2.2 kernels, and <netinet/in.h> and <linux/fs.h>.
517 # ifdef HAVE_SOCKETBITS_H
518 /* conflicts with <socketbits.h> */
519 # define _LINUX_SOCKET_H
529 # if defined(__GLIBC__) && __GLIBC__ >= 2
530 /* conflicts with <waitflags.h> */
533 # endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */
534 /* conflicts with <statfsbuf.h> */
535 # define _SYS_STATFS_H
536 # endif /* HAVE_SOCKETBITS_H */
539 # if defined(__GLIBC__) && __GLIBC__ >= 2
540 /* conflicts with <bits/waitflags.h> (RedHat/Linux 6.0 and kernels 2.2 */
543 # endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */
544 # endif /* _SYS_WAIT_H */
546 # ifdef HAVE_LINUX_POSIX_TYPES_H
547 # include <linux/posix_types.h>
548 # endif /* HAVE_LINUX_POSIX_TYPES_H */
549 # ifndef _LINUX_BYTEORDER_GENERIC_H
550 # define _LINUX_BYTEORDER_GENERIC_H
551 # endif /* _LINUX_BYTEORDER_GENERIC_H */
552 /* conflicts with <sys/mount.h> in 2.[12] kernels */
566 # undef MS_NODIRATIME
572 # undef MS_SYNCHRONOUS
575 /* conflicts with <statfsbuf.h> */
576 # define _SYS_STATFS_H
577 # endif /* _SYS_MOUNT_H */
578 # ifndef _LINUX_STRING_H_
579 # define _LINUX_STRING_H_
580 # endif /* not _LINUX_STRING_H_ */
581 # ifdef HAVE_LINUX_KDEV_T_H
583 # include <linux/kdev_t.h>
585 # endif /* HAVE_LINUX_KDEV_T_H */
586 # ifdef HAVE_LINUX_LIST_H
588 # include <linux/list.h>
590 # endif /* HAVE_LINUX_LIST_H */
591 # include <linux/fs.h>
592 #endif /* HAVE_LINUX_FS_H && (!__GLIBC__ || __GLIBC__ < 2) */
594 #ifdef HAVE_CDFS_CDFS_MOUNT_H
595 # include <cdfs/cdfs_mount.h>
596 #endif /* HAVE_CDFS_CDFS_MOUNT_H */
598 #ifdef HAVE_CDFS_CDFSMOUNT_H
599 # include <cdfs/cdfsmount.h>
600 #endif /* HAVE_CDFS_CDFSMOUNT_H */
603 * Actions to take if <linux/auto_fs.h> exists.
604 * We really don't want <linux/fs.h> pulled in here
608 #endif /* _LINUX_FS_H */
609 #ifdef HAVE_LINUX_AUTO_FS_H
610 # include <linux/auto_fs.h>
611 #endif /* HAVE_LINUX_AUTO_FS_H */
614 * NFS PROTOCOL HEADER FILES:
618 * Actions to take if <nfs/export.h> exists.
620 #ifdef HAVE_NFS_EXPORT_H
621 # include <nfs/export.h>
622 #endif /* HAVE_NFS_EXPORT_H */
624 /****************************************************************************
626 ** We always include am-util's amu_nfs_prot.h. **
627 ** That is actually defined in "conf/nfs_prot/nfs_prot_${host_os_name}.h" **
628 ****************************************************************************/
629 #include <amu_nfs_prot.h>
632 * DO NOT INCLUDE THESE FILES:
633 * They conflicts with other NFS headers and are generally not needed.
635 #ifdef DO_NOT_INCLUDE
636 # ifdef HAVE_NFS_NFS_CLNT_H
637 # include <nfs/nfs_clnt.h>
638 # endif /* HAVE_NFS_NFS_CLNT_H */
639 # ifdef HAVE_LINUX_NFS_H
640 # include <linux/nfs.h>
641 # endif /* HAVE_LINUX_NFS_H */
642 #endif /* DO NOT INCLUDE */
645 * Actions to take if one of the nfs headers exists.
647 #ifdef HAVE_NFS_NFS_GFS_H
648 # include <nfs/nfs_gfs.h>
649 #endif /* HAVE_NFS_NFS_GFS_H */
650 #ifdef HAVE_NFS_MOUNT_H
651 # include <nfs/mount.h>
652 #endif /* HAVE_NFS_MOUNT_H */
653 #ifdef HAVE_NFS_NFS_MOUNT_H_off
654 /* broken on nextstep3 (includes non-existing headers) */
655 # include <nfs/nfs_mount.h>
656 #endif /* HAVE_NFS_NFS_MOUNT_H */
657 #ifdef HAVE_NFS_PATHCONF_H
658 # include <nfs/pathconf.h>
659 #endif /* HAVE_NFS_PATHCONF_H */
660 #ifdef HAVE_SYS_FS_NFS_MOUNT_H
661 # include <sys/fs/nfs/mount.h>
662 #endif /* HAVE_SYS_FS_NFS_MOUNT_H */
663 #ifdef HAVE_SYS_FS_NFS_NFS_CLNT_H
664 # include <sys/fs/nfs/nfs_clnt.h>
665 #endif /* HAVE_SYS_FS_NFS_NFS_CLNT_H */
666 #ifdef HAVE_SYS_FS_NFS_CLNT_H
667 # include <sys/fs/nfs_clnt.h>
668 #endif /* HAVE_SYS_FS_NFS_CLNT_H */
669 #ifdef HAVE_LINUX_NFS_MOUNT_H
670 # define _LINUX_NFS_H
671 # define _LINUX_NFS2_H
672 # define _LINUX_NFS3_H
673 # define _LINUX_NFS_FS_H
675 # include <linux/nfs_mount.h>
676 #endif /* HAVE_LINUX_NFS_MOUNT_H */
679 * Actions to take if <pwd.h> exists.
683 #endif /* HAVE_PWD_H */
686 * Actions to take if <hesiod.h> exists.
690 #endif /* HAVE_HESIOD_H */
693 * Actions to take if <lber.h> exists.
694 * This header file is required before <ldap.h> can be included.
698 #endif /* HAVE_LBER_H */
701 * Actions to take if <ldap.h> exists.
705 #endif /* HAVE_LDAP_H */
708 * Actions to take if <arpa/nameser.h> exists.
709 * Should be included before <resolv.h>.
711 #ifdef HAVE_ARPA_NAMESER_H
714 # endif /* NOERROR */
716 * Conflicts with <sys/tpicommon.h> which is included from <sys/tiuser.h>
717 * on Solaris 2.6 systems. So undefine it first.
721 # endif /* T_UNSPEC */
722 # include <arpa/nameser.h>
723 #endif /* HAVE_ARPA_NAMESER_H */
726 * Actions to take if <arpa/inet.h> exists.
728 #ifdef HAVE_ARPA_INET_H
729 # ifdef HAVE_BAD_HEADERS
730 /* aix 4.3: avoid including <net/if_dl.h> */
732 # endif /* HAVE_BAD_HEADERS */
733 # include <arpa/inet.h>
734 #endif /* HAVE_ARPA_INET_H */
737 * Actions to take if <resolv.h> exists.
741 #endif /* HAVE_RESOLV_H */
744 * Actions to take if <sys/uio.h> exists.
746 #ifdef HAVE_SYS_UIO_H
747 # include <sys/uio.h>
748 #endif /* HAVE_SYS_UIO_H */
751 * Actions to take if <sys/fs/cachefs_fs.h> exists.
753 #ifdef HAVE_SYS_FS_CACHEFS_FS_H
754 # include <sys/fs/cachefs_fs.h>
755 #endif /* HAVE_SYS_FS_CACHEFS_FS_H */
758 * Actions to take if <sys/fs/pc_fs.h> exists.
760 #ifdef HAVE_SYS_FS_PC_FS_H
761 # include <sys/fs/pc_fs.h>
762 #endif /* HAVE_SYS_FS_PC_FS_H */
765 * Actions to take if <msdosfs/msdosfsmount.h> exists.
767 #ifdef HAVE_MSDOSFS_MSDOSFSMOUNT_H
768 # include <msdosfs/msdosfsmount.h>
769 #endif /* HAVE_MSDOSFS_MSDOSFSMOUNT_H */
770 #ifdef HAVE_FS_MSDOSFS_MSDOSFSMOUNT_H
771 # include <fs/msdosfs/msdosfsmount.h>
772 #endif /* HAVE_FS_MSDOSFS_MSDOSFSMOUNT_H */
775 * Actions to take if <sys/fs/tmp.h> exists.
777 #ifdef HAVE_SYS_FS_TMP_H
778 # include <sys/fs/tmp.h>
779 #endif /* HAVE_SYS_FS_TMP_H */
782 * Actions to take if <sys/fs/ufs_mount.h> exists.
784 #ifdef HAVE_SYS_FS_UFS_MOUNT_H
785 # include <sys/fs/ufs_mount.h>
786 #endif /* HAVE_SYS_FS_UFS_MOUNT_H */
788 * HAVE_UFS_UFS_UFSMOUNT_H should NOT be defined on netbsd/openbsd because it
789 * causes errors with other header files. Instead, add it to the specific
790 * conf/nfs_prot_*.h file.
792 #ifdef HAVE_UFS_UFS_UFSMOUNT_H
793 # include <ufs/ufs/ufsmount.h>
794 #endif /* HAVE_UFS_UFS_UFSMOUNT_H */
797 * Actions to take if <sys/fs/efs_clnt.h> exists.
799 #ifdef HAVE_SYS_FS_EFS_CLNT_H
800 # include <sys/fs/efs_clnt.h>
801 #endif /* HAVE_SYS_FS_EFS_CLNT_H */
804 * Actions to take if <sys/fs/xfs_clnt.h> exists.
806 #ifdef HAVE_SYS_FS_XFS_CLNT_H
807 # include <sys/fs/xfs_clnt.h>
808 #endif /* HAVE_SYS_FS_XFS_CLNT_H */
811 * Actions to take if <assert.h> exists.
815 #endif /* HAVE_ASSERT_H */
818 * Actions to take if <cfs.h> exists.
822 #endif /* HAVE_CFS_H */
825 * Actions to take if <cluster.h> exists.
827 #ifdef HAVE_CLUSTER_H
828 # include <cluster.h>
829 #endif /* HAVE_CLUSTER_H */
832 * Actions to take if <ctype.h> exists.
836 #endif /* HAVE_CTYPE_H */
839 * Actions to take if <errno.h> exists.
843 #endif /* HAVE_ERRNO_H */
846 * Actions to take if <grp.h> exists.
850 #endif /* HAVE_GRP_H */
853 * Actions to take if <hsfs/hsfs.h> exists.
855 #ifdef HAVE_HSFS_HSFS_H
856 # include <hsfs/hsfs.h>
857 #endif /* HAVE_HSFS_HSFS_H */
860 * Actions to take if <cdfs/cdfsmount.h> exists.
862 #ifdef HAVE_CDFS_CDFSMOUNT_H
863 # include <cdfs/cdfsmount.h>
864 #endif /* HAVE_CDFS_CDFSMOUNT_H */
867 * Actions to take if <isofs/cd9660/cd9660_mount.h> exists.
869 #ifdef HAVE_ISOFS_CD9660_CD9660_MOUNT_H
870 # include <isofs/cd9660/cd9660_mount.h>
871 #endif /* HAVE_ISOFS_CD9660_CD9660_MOUNT_H */
874 * Actions to take if <mount.h> exists.
878 #endif /* HAVE_MOUNT_H */
881 * Actions to take if <nsswitch.h> exists.
883 #ifdef HAVE_NSSWITCH_H
884 # include <nsswitch.h>
885 #endif /* HAVE_NSSWITCH_H */
888 * Actions to take if <rpc/auth_des.h> exists.
890 #ifdef HAVE_RPC_AUTH_DES_H
891 # include <rpc/auth_des.h>
892 #endif /* HAVE_RPC_AUTH_DES_H */
895 * Actions to take if <rpc/pmap_clnt.h> exists.
897 #ifdef HAVE_RPC_PMAP_CLNT_H
898 # include <rpc/pmap_clnt.h>
899 #endif /* HAVE_RPC_PMAP_CLNT_H */
902 * Actions to take if <rpc/pmap_prot.h> exists.
904 #ifdef HAVE_RPC_PMAP_PROT_H
905 # include <rpc/pmap_prot.h>
906 #endif /* HAVE_RPC_PMAP_PROT_H */
910 * Actions to take if <rpcsvc/mount.h> exists.
911 * AIX does not protect against this file doubly included,
912 * so I have to do my own protection here.
914 #ifdef HAVE_RPCSVC_MOUNT_H
915 # ifndef _RPCSVC_MOUNT_H
916 # include <rpcsvc/mount.h>
917 # endif /* not _RPCSVC_MOUNT_H */
918 #endif /* HAVE_RPCSVC_MOUNT_H */
921 * Actions to take if <rpcsvc/nis.h> exists.
923 #ifdef HAVE_RPCSVC_NIS_H
924 # include <rpcsvc/nis.h>
925 #endif /* HAVE_RPCSVC_NIS_H */
928 * Actions to take if <setjmp.h> exists.
932 #endif /* HAVE_SETJMP_H */
935 * Actions to take if <signal.h> exists.
939 #endif /* HAVE_SIGNAL_H */
942 * Actions to take if <string.h> exists.
946 #endif /* HAVE_STRING_H */
949 * Actions to take if <strings.h> exists.
951 #ifdef HAVE_STRINGS_H
952 # include <strings.h>
953 #endif /* HAVE_STRINGS_H */
956 * Actions to take if <sys/config.h> exists.
958 #ifdef HAVE_SYS_CONFIG_H
959 # include <sys/config.h>
960 #endif /* HAVE_SYS_CONFIG_H */
963 * Actions to take if <sys/dg_mount.h> exists.
965 #ifdef HAVE_SYS_DG_MOUNT_H
966 # include <sys/dg_mount.h>
967 #endif /* HAVE_SYS_DG_MOUNT_H */
970 * Actions to take if <sys/fs_types.h> exists.
972 #ifdef HAVE_SYS_FS_TYPES_H
974 * Define KERNEL here to avoid multiple definitions of gt_names[] on
978 # include <sys/fs_types.h>
980 #endif /* HAVE_SYS_FS_TYPES_H */
983 * Actions to take if <sys/fstyp.h> exists.
985 #ifdef HAVE_SYS_FSTYP_H
986 # include <sys/fstyp.h>
987 #endif /* HAVE_SYS_FSTYP_H */
990 * Actions to take if <sys/lock.h> exists.
992 #ifdef HAVE_SYS_LOCK_H
993 # include <sys/lock.h>
994 #endif /* HAVE_SYS_LOCK_H */
997 * Actions to take if <sys/machine.h> exists.
999 #ifdef HAVE_SYS_MACHINE_H
1000 # include <sys/machine.h>
1001 #endif /* HAVE_SYS_MACHINE_H */
1004 * Actions to take if <sys/mntctl.h> exists.
1006 #ifdef HAVE_SYS_MNTCTL_H
1007 # include <sys/mntctl.h>
1008 #endif /* HAVE_SYS_MNTCTL_H */
1011 * Actions to take if <sys/mnttab.h> exists.
1013 #ifdef HAVE_SYS_MNTTAB_H
1014 # include <sys/mnttab.h>
1015 #endif /* HAVE_SYS_MNTTAB_H */
1018 * Actions to take if <mnttab.h> exists.
1019 * Do not include it if MNTTAB is already defined because it probably
1020 * came from <sys/mnttab.h> and we do not want conflicting definitions.
1022 #if defined(HAVE_MNTTAB_H) && !defined(MNTTAB)
1023 # include <mnttab.h>
1024 #endif /* defined(HAVE_MNTTAB_H) && !defined(MNTTAB) */
1027 * Actions to take if <netconfig.h> exists.
1029 #ifdef HAVE_NETCONFIG_H
1030 # include <netconfig.h>
1031 /* Some systems (Solaris 2.5.1) don't declare this external */
1032 extern char *nc_sperror(void);
1033 #endif /* HAVE_NETCONFIG_H */
1036 * Actions to take if <sys/netconfig.h> exists.
1038 #ifdef HAVE_SYS_NETCONFIG_H
1039 # include <sys/netconfig.h>
1040 #endif /* HAVE_SYS_NETCONFIG_H */
1043 * Actions to take if <sys/pathconf.h> exists.
1045 #ifdef HAVE_SYS_PATHCONF_H
1046 # include <sys/pathconf.h>
1047 #endif /* HAVE_SYS_PATHCONF_H */
1050 * Actions to take if <sys/resource.h> exists.
1052 #ifdef HAVE_SYS_RESOURCE_H
1053 # include <sys/resource.h>
1054 #endif /* HAVE_SYS_RESOURCE_H */
1057 * Actions to take if <sys/sema.h> exists.
1059 #ifdef HAVE_SYS_SEMA_H
1060 # include <sys/sema.h>
1061 #endif /* HAVE_SYS_SEMA_H */
1064 * Actions to take if <sys/signal.h> exists.
1066 #ifdef HAVE_SYS_SIGNAL_H
1067 # include <sys/signal.h>
1068 #endif /* HAVE_SYS_SIGNAL_H */
1071 * Actions to take if <sys/sockio.h> exists.
1073 #ifdef HAVE_SYS_SOCKIO_H
1074 # include <sys/sockio.h>
1075 #endif /* HAVE_SYS_SOCKIO_H */
1078 * Actions to take if <sys/syscall.h> exists.
1080 #ifdef HAVE_SYS_SYSCALL_H
1081 # include <sys/syscall.h>
1082 #endif /* HAVE_SYS_SYSCALL_H */
1085 * Actions to take if <sys/syslimits.h> exists.
1087 #ifdef HAVE_SYS_SYSLIMITS_H
1088 # include <sys/syslimits.h>
1089 #endif /* HAVE_SYS_SYSLIMITS_H */
1092 * Actions to take if <tiuser.h> exists.
1094 #ifdef HAVE_TIUSER_H
1096 * Some systems like AIX have multiple definitions for T_NULL and others
1097 * that are defined first in <arpa/nameser.h>.
1099 # ifdef HAVE_ARPA_NAMESER_H
1102 # endif /* T_NULL */
1105 # endif /* T_UNSPEC */
1108 # endif /* T_IDLE */
1109 # endif /* HAVE_ARPA_NAMESER_H */
1110 # include <tiuser.h>
1111 #endif /* HAVE_TIUSER_H */
1114 * Actions to take if <sys/tiuser.h> exists.
1116 #ifdef HAVE_SYS_TIUSER_H
1117 # include <sys/tiuser.h>
1118 #endif /* HAVE_SYS_TIUSER_H */
1121 * Actions to take if <sys/statfs.h> exists.
1123 #ifdef HAVE_SYS_STATFS_H
1124 # include <sys/statfs.h>
1125 #endif /* HAVE_SYS_STATFS_H */
1128 * Actions to take if <sys/vfs.h> exists.
1130 #ifdef HAVE_SYS_VFS_H
1131 # include <sys/vfs.h>
1132 #endif /* HAVE_SYS_VFS_H */
1135 * Actions to take if <sys/vmount.h> exists.
1137 #ifdef HAVE_SYS_VMOUNT_H
1138 # include <sys/vmount.h>
1139 #endif /* HAVE_SYS_VMOUNT_H */
1142 * Actions to take if <ufs/ufs_mount.h> exists.
1144 #ifdef HAVE_UFS_UFS_MOUNT_H
1145 # include <ufs/ufs_mount.h>
1146 #endif /* HAVE_UFS_UFS_MOUNT_H */
1149 * Are S_ISDIR, S_ISREG, et al broken? If not, include <sys/stat.h>.
1150 * Turned off the not using sys/stat.h based on if the macros are
1151 * "broken", because they incorrectly get reported as broken on
1154 #ifndef STAT_MACROS_BROKEN_notused
1156 * RedHat Linux 4.2 (alpha) has a problem in the headers that causes
1157 * duplicate definitions, and also some other nasty bugs. Upgrade to Redhat
1160 # ifdef HAVE_SYS_STAT_H
1161 /* avoid duplicates or conflicts with <linux/stat.h> (RedHat alpha linux) */
1162 # if defined(S_IFREG) && defined(HAVE_STATBUF_H)
1163 # include <statbuf.h>
1194 # endif /* defined(S_IFREG) && defined(HAVE_STATBUF_H) */
1195 # include <sys/stat.h>
1196 # endif /* HAVE_SYS_STAT_H */
1197 #endif /* not STAT_MACROS_BROKEN_notused */
1200 * Actions to take if <stdio.h> exists.
1204 #endif /* HAVE_STDIO_H */
1207 * Actions to take if <stdlib.h> exists.
1209 #ifdef HAVE_STDLIB_H
1210 # include <stdlib.h>
1211 #endif /* HAVE_STDLIB_H */
1214 * Actions to take if <regex.h> exists.
1218 #endif /* HAVE_REGEX_H */
1221 /****************************************************************************/
1223 * Specific macros we're looking for.
1227 # define memset(ptr, val, len) bzero((ptr), (len))
1228 # else /* not HAVE_BZERO */
1229 # error Cannot find either memset or bzero!
1230 # endif /* not HAVE_BZERO */
1231 #endif /* not HAVE_MEMSET */
1233 #ifndef HAVE_MEMMOVE
1235 # define memmove(to, from, len) bcopy((from), (to), (len))
1236 # else /* not HAVE_BCOPY */
1237 # error Cannot find either memmove or bcopy!
1238 # endif /* not HAVE_BCOPY */
1239 #endif /* not HAVE_MEMMOVE */
1242 * memcmp() is more problematic:
1243 * Systems that don't have it, but have bcmp(), will use bcmp() instead.
1244 * Those that have it, but it is bad (SunOS 4 doesn't handle
1245 * 8 bit comparisons correctly), will get to use am_memcmp().
1246 * Otherwise if you have memcmp() and it is good, use it.
1249 # ifdef HAVE_BAD_MEMCMP
1250 # define memcmp am_memcmp
1251 extern int am_memcmp(const voidp s1, const voidp s2, size_t len);
1252 # endif /* HAVE_BAD_MEMCMP */
1253 #else /* not HAVE_MEMCMP */
1255 # define memcmp(a, b, len) bcmp((a), (b), (len))
1256 # endif /* HAVE_BCMP */
1257 #endif /* not HAVE_MEMCMP */
1259 #ifndef HAVE_SETEUID
1260 # ifdef HAVE_SETRESUID
1261 # define seteuid(x) setresuid(-1,(x),-1)
1262 # else /* not HAVE_SETRESUID */
1263 # error Cannot find either seteuid or setresuid!
1264 # endif /* not HAVE_SETRESUID */
1265 #endif /* not HAVE_SETEUID */
1268 * Define type of mntent_t.
1269 * Defaults to struct mntent, else struct mnttab. If neither is found, and
1270 * the operating system does keep not mount tables in the kernel, then flag
1271 * it as an error. If neither is found and the OS keeps mount tables in the
1272 * kernel, then define our own version of mntent; it will be needed for amd
1273 * to keep its own internal version of the mount tables.
1275 #ifdef HAVE_STRUCT_MNTENT
1276 typedef struct mntent mntent_t;
1277 #else /* not HAVE_STRUCT_MNTENT */
1278 # ifdef HAVE_STRUCT_MNTTAB
1279 typedef struct mnttab mntent_t;
1280 /* map struct mnttab field names to struct mntent field names */
1281 # define mnt_fsname mnt_special
1282 # define mnt_dir mnt_mountp
1283 # define mnt_opts mnt_mntopts
1284 # define mnt_type mnt_fstype
1285 # else /* not HAVE_STRUCT_MNTTAB */
1286 # ifdef MOUNT_TABLE_ON_FILE
1287 # error Could not find definition for struct mntent or struct mnttab!
1288 # else /* not MOUNT_TABLE_ON_FILE */
1289 typedef struct _am_mntent {
1290 char *mnt_fsname; /* name of mounted file system */
1291 char *mnt_dir; /* file system path prefix */
1292 char *mnt_type; /* MNTTAB_TYPE_* */
1293 char *mnt_opts; /* MNTTAB_OPT_* */
1294 int mnt_freq; /* dump frequency, in days */
1295 int mnt_passno; /* pass number on parallel fsck */
1297 # endif /* not MOUNT_TABLE_ON_FILE */
1298 # endif /* not HAVE_STRUCT_MNTTAB */
1299 #endif /* not HAVE_STRUCT_MNTENT */
1303 * Complete external definitions missing from some systems.
1306 #ifndef HAVE_EXTERN_SYS_ERRLIST
1307 extern const char *const sys_errlist[];
1308 #endif /* not HAVE_EXTERN_SYS_ERRLIST */
1310 #ifndef HAVE_EXTERN_OPTARG
1311 extern char *optarg;
1313 #endif /* not HAVE_EXTERN_OPTARG */
1315 #if defined(HAVE_CLNT_SPCREATEERROR) && !defined(HAVE_EXTERN_CLNT_SPCREATEERROR)
1316 extern char *clnt_spcreateerror(const char *s);
1317 #endif /* defined(HAVE_CLNT_SPCREATEERROR) && !defined(HAVE_EXTERN_CLNT_SPCREATEERROR) */
1319 #if defined(HAVE_CLNT_SPERRNO) && !defined(HAVE_EXTERN_CLNT_SPERRNO)
1320 extern char *clnt_sperrno(const enum clnt_stat num);
1321 #endif /* defined(HAVE_CLNT_SPERRNO) && !defined(HAVE_EXTERN_CLNT_SPERRNO) */
1323 #ifndef HAVE_EXTERN_FREE
1324 extern void free(voidp);
1325 #endif /* not HAVE_EXTERN_FREE */
1327 #if defined(HAVE_GET_MYADDRESS) && !defined(HAVE_EXTERN_GET_MYADDRESS)
1328 extern void get_myaddress(struct sockaddr_in *addr);
1329 #endif /* defined(HAVE_GET_MYADDRESS) && !defined(HAVE_EXTERN_GET_MYADDRESS) */
1331 #if defined(HAVE_GETDOMAINNAME) && !defined(HAVE_EXTERN_GETDOMAINNAME)
1332 # if defined(HAVE_MAP_NIS) || defined(HAVE_MAP_NISPLUS)
1333 extern int getdomainname(char *name, int namelen);
1334 # endif /* defined(HAVE_MAP_NIS) || defined(HAVE_MAP_NISPLUS) */
1335 #endif /* defined(HAVE_GETDOMAINNAME) && !defined(HAVE_EXTERN_GETDOMAINNAME) */
1337 #if defined(HAVE_GETDTABLESIZE) && !defined(HAVE_EXTERN_GETDTABLESIZE)
1338 extern int getdtablesize(void);
1339 #endif /* defined(HAVE_GETDTABLESIZE) && !defined(HAVE_EXTERN_GETDTABLESIZE) */
1341 #if defined(HAVE_GETHOSTNAME) && !defined(HAVE_EXTERN_GETHOSTNAME)
1342 extern int gethostname(char *name, int namelen);
1343 #endif /* defined(HAVE_GETHOSTNAME) && !defined(HAVE_EXTERN_GETHOSTNAME) */
1345 #ifndef HAVE_EXTERN_GETLOGIN
1346 extern char *getlogin(void);
1347 #endif /* not HAVE_EXTERN_GETLOGIN */
1349 #if defined(HAVE_GETPAGESIZE) && !defined(HAVE_EXTERN_GETPAGESIZE)
1350 extern int getpagesize(void);
1351 #endif /* defined(HAVE_GETPAGESIZE) && !defined(HAVE_EXTERN_GETPAGESIZE) */
1353 #ifndef HAVE_EXTERN_GETWD
1354 extern char *getwd(char *s);
1355 #endif /* not HAVE_EXTERN_GETWD */
1357 #ifndef HAVE_EXTERN_INNETGR
1358 extern int innetgr(char *, char *, char *, char *);
1359 #endif /* not HAVE_EXTERN_INNETGR */
1361 #if defined(HAVE_MKSTEMP) && !defined(HAVE_EXTERN_MKSTEMP)
1362 extern int mkstemp(char *);
1363 #endif /* defined(HAVE_MKSTEMP) && !defined(HAVE_EXTERN_MKSTEMP) */
1365 #ifndef HAVE_EXTERN_SBRK
1366 extern caddr_t sbrk(int incr);
1367 #endif /* not HAVE_EXTERN_SBRK */
1369 #if defined(HAVE_SETEUID) && !defined(HAVE_EXTERN_SETEUID)
1370 extern int seteuid(uid_t euid);
1371 #endif /* not defined(HAVE_SETEUID) && !defined(HAVE_EXTERN_SETEUID) */
1373 #if defined(HAVE_SETITIMER) && !defined(HAVE_EXTERN_SETITIMER)
1374 extern int setitimer(int, struct itimerval *, struct itimerval *);
1375 #endif /* defined(HAVE_SETITIMER) && !defined(HAVE_EXTERN_SETITIMER) */
1377 #ifndef HAVE_EXTERN_STRCASECMP
1379 * define this extern even if function does not exist, for it will
1380 * be filled in by libamu/strcasecmp.c
1382 extern int strcasecmp(const char *s1, const char *s2);
1383 #endif /* not HAVE_EXTERN_STRCASECMP */
1385 #ifndef HAVE_EXTERN_STRDUP
1387 * define this extern even if function does not exist, for it will
1388 * be filled in by libamu/strdup.c
1390 extern char *strdup(const char *s);
1391 #endif /* not HAVE_EXTERN_STRDUP */
1393 #if defined(HAVE_STRSTR) && !defined(HAVE_EXTERN_STRSTR)
1394 extern char *strstr(const char *s1, const char *s2);
1395 #endif /* defined(HAVE_STRSTR) && !defined(HAVE_EXTERN_STRSTR) */
1397 #if defined(HAVE_USLEEP) && !defined(HAVE_EXTERN_USLEEP)
1398 extern int usleep(u_int useconds);
1399 #endif /* defined(HAVE_USLEEP) && !defined(HAVE_EXTERN_USLEEP) */
1401 #ifndef HAVE_EXTERN_UALARM
1402 extern u_int ualarm(u_int usecs, u_int interval);
1403 #endif /* not HAVE_EXTERN_UALARM */
1405 #if defined(HAVE_WAIT3) && !defined(HAVE_EXTERN_WAIT3)
1406 extern int wait3(int *statusp, int options, struct rusage *rusage);
1407 #endif /* defined(HAVE_WAIT3) && !defined(HAVE_EXTERN_WAIT3) */
1409 #if defined(HAVE_VSNPRINTF) && !defined(HAVE_EXTERN_VSNPRINTF)
1410 extern int vsnprintf(char *, int, const char *, ...);
1411 #endif /* defined(HAVE_VSNPRINTF) && !defined(HAVE_EXTERN_VSNPRINTF) */
1413 #ifndef HAVE_EXTERN_XDR_CALLMSG
1414 extern bool_t xdr_callmsg(XDR *xdrs, struct rpc_msg *msg);
1415 #endif /* not HAVE_EXTERN_XDR_CALLMSG */
1417 #ifndef HAVE_EXTERN_XDR_OPAQUE_AUTH
1418 extern bool_t xdr_opaque_auth(XDR *xdrs, struct opaque_auth *auth);
1419 #endif /* not HAVE_EXTERN_XDR_OPAQUE_AUTH */
1421 /****************************************************************************/
1423 * amd-specific header files.
1425 #ifdef THIS_HEADER_FILE_IS_INCLUDED_ABOVE
1426 # include <amu_nfs_prot.h>
1427 #endif /* THIS_HEADER_FILE_IS_INCLUDED_ABOVE */
1428 #include <am_utils.h>
1429 #include <amq_defs.h>
1430 #include <aux_conf.h>
1431 /* compatibility with old amd, while autoconfiscating it */
1432 #include <am_compat.h>
1435 /****************************************************************************/
1437 * External definitions that depend on other macros available (or not)
1438 * and those are probably declared in any of the above headers.
1441 #ifndef HAVE_HASMNTOPT
1442 extern char *hasmntopt(mntent_t *mnt, char *opt);
1443 #endif /* not HAVE_HASMNTOPT */
1446 * include definitions of all possible xdr functions that are otherwise
1447 * not defined elsewhere.
1449 #include <am_xdr_func.h>
1451 #endif /* not _AM_DEFS_H */