aboutsummaryrefslogtreecommitdiffstats
path: root/conf
diff options
context:
space:
mode:
authorCy Schubert <cy@FreeBSD.org>2016-08-31 00:08:49 +0000
committerCy Schubert <cy@FreeBSD.org>2016-08-31 00:08:49 +0000
commitca57057f598bfc7119f79f71bf38ec88244ab396 (patch)
tree051f78ef258707b493cc7cb21569b6949915f6c7 /conf
parente66b16bf080ead1c51f321eaf56710c771778706 (diff)
downloadsrc-ca57057f598bfc7119f79f71bf38ec88244ab396.tar.gz
src-ca57057f598bfc7119f79f71bf38ec88244ab396.zip
Import am-utils 6.2,vendor/amd/6.2vendor/amd
Suggested by: pfg@ Obtained from: ftp://ftp.am-utils.org/pub/am-utils/
Notes
Notes: svn path=/vendor/amd/dist/; revision=305100 svn path=/vendor/amd/6.2/; revision=305101; tag=vendor/amd/6.2
Diffstat (limited to 'conf')
-rw-r--r--conf/autofs/autofs_default.c43
-rw-r--r--conf/autofs/autofs_default.h58
-rw-r--r--conf/autofs/autofs_linux.c909
-rw-r--r--conf/autofs/autofs_linux.h109
-rw-r--r--conf/autofs/autofs_solaris_v1.c719
-rw-r--r--conf/autofs/autofs_solaris_v1.h83
-rw-r--r--conf/autofs/autofs_solaris_v2_v3.c1292
-rw-r--r--conf/autofs/autofs_solaris_v2_v3.h69
-rw-r--r--conf/checkmount/checkmount_aix.c93
-rw-r--r--conf/checkmount/checkmount_bsd44.c11
-rw-r--r--conf/checkmount/checkmount_default.c105
-rw-r--r--conf/checkmount/checkmount_osf.c85
-rw-r--r--conf/checkmount/checkmount_svr4.c96
-rw-r--r--conf/checkmount/checkmount_ultrix.c75
-rw-r--r--conf/fh_dref/fh_dref_aix3.h2
-rw-r--r--conf/fh_dref/fh_dref_aix42.h2
-rw-r--r--conf/fh_dref/fh_dref_bsd44.h2
-rw-r--r--conf/fh_dref/fh_dref_default.h2
-rw-r--r--conf/fh_dref/fh_dref_hpux.h2
-rw-r--r--conf/fh_dref/fh_dref_irix.h2
-rw-r--r--conf/fh_dref/fh_dref_isc3.h2
-rw-r--r--conf/fh_dref/fh_dref_linux.h2
-rw-r--r--conf/fh_dref/fh_dref_nextstep.h2
-rw-r--r--conf/fh_dref/fh_dref_osf2.h2
-rw-r--r--conf/fh_dref/fh_dref_osf4.h2
-rw-r--r--conf/fh_dref/fh_dref_sunos3.h2
-rw-r--r--conf/fh_dref/fh_dref_sunos4.h2
-rw-r--r--conf/fh_dref/fh_dref_svr4.h2
-rw-r--r--conf/hn_dref/hn_dref_isc3.h2
-rw-r--r--conf/hn_dref/hn_dref_linux.h2
-rw-r--r--conf/mount/mount_aix.c182
-rw-r--r--conf/mount/mount_aix3.c225
-rw-r--r--conf/mount/mount_bsdi3.c48
-rw-r--r--conf/mount/mount_default.c11
-rw-r--r--conf/mount/mount_hpux.c86
-rw-r--r--conf/mount/mount_irix5.c98
-rw-r--r--conf/mount/mount_irix6.c106
-rw-r--r--conf/mount/mount_isc3.c72
-rw-r--r--conf/mount/mount_linux.c1153
-rw-r--r--conf/mount/mount_mach3.c82
-rw-r--r--conf/mount/mount_stellix.c (renamed from conf/mount/mount_freebsd3.c)35
-rw-r--r--conf/mount/mount_svr4.c158
-rw-r--r--conf/mtab/mtab_aix.c178
-rw-r--r--conf/mtab/mtab_bsd.c21
-rw-r--r--conf/mtab/mtab_file.c454
-rw-r--r--conf/mtab/mtab_isc3.c269
-rw-r--r--conf/mtab/mtab_linux.c565
-rw-r--r--conf/mtab/mtab_mach3.c501
-rw-r--r--conf/mtab/mtab_osf.c146
-rw-r--r--conf/mtab/mtab_svr4.c302
-rw-r--r--conf/mtab/mtab_ultrix.c119
-rw-r--r--conf/nfs_prot/nfs_prot_aix3.h212
-rw-r--r--conf/nfs_prot/nfs_prot_aix4.h210
-rw-r--r--conf/nfs_prot/nfs_prot_aix4_2.h249
-rw-r--r--conf/nfs_prot/nfs_prot_aix4_3.h317
-rw-r--r--conf/nfs_prot/nfs_prot_aix5_1.h107
-rw-r--r--conf/nfs_prot/nfs_prot_aix5_2.h365
-rw-r--r--conf/nfs_prot/nfs_prot_bsdi2.h496
-rw-r--r--conf/nfs_prot/nfs_prot_bsdi3.h181
-rw-r--r--conf/nfs_prot/nfs_prot_darwin.h85
-rw-r--r--conf/nfs_prot/nfs_prot_default.h166
-rw-r--r--conf/nfs_prot/nfs_prot_freebsd2.h10
-rw-r--r--conf/nfs_prot/nfs_prot_freebsd3.h8
-rw-r--r--conf/nfs_prot/nfs_prot_hpux.h398
-rw-r--r--conf/nfs_prot/nfs_prot_hpux11.h595
-rw-r--r--conf/nfs_prot/nfs_prot_irix5.h450
-rw-r--r--conf/nfs_prot/nfs_prot_irix6.h496
-rw-r--r--conf/nfs_prot/nfs_prot_linux.h334
-rw-r--r--conf/nfs_prot/nfs_prot_ncr2.h476
-rw-r--r--conf/nfs_prot/nfs_prot_netbsd.h165
-rw-r--r--conf/nfs_prot/nfs_prot_netbsd1_3.h154
-rw-r--r--conf/nfs_prot/nfs_prot_netbsd1_4.h180
-rw-r--r--conf/nfs_prot/nfs_prot_nextstep.h595
-rw-r--r--conf/nfs_prot/nfs_prot_openbsd.h183
-rw-r--r--conf/nfs_prot/nfs_prot_osf2.h307
-rw-r--r--conf/nfs_prot/nfs_prot_osf4.h417
-rw-r--r--conf/nfs_prot/nfs_prot_osf5.h29
-rw-r--r--conf/nfs_prot/nfs_prot_sunos3.h401
-rw-r--r--conf/nfs_prot/nfs_prot_sunos4.h401
-rw-r--r--conf/nfs_prot/nfs_prot_sunos5_3.h264
-rw-r--r--conf/nfs_prot/nfs_prot_sunos5_4.h266
-rw-r--r--conf/nfs_prot/nfs_prot_sunos5_5.h381
-rw-r--r--conf/nfs_prot/nfs_prot_sunos5_6.h385
-rw-r--r--conf/nfs_prot/nfs_prot_sunos5_7.h396
-rw-r--r--conf/nfs_prot/nfs_prot_sunos5_8.h12
-rw-r--r--conf/nfs_prot/nfs_prot_svr4.h401
-rw-r--r--conf/nfs_prot/nfs_prot_ultrix.h304
-rw-r--r--conf/sa_dref/sa_dref_386bsd.h5
-rw-r--r--conf/sa_dref/sa_dref_aix3.h3
-rw-r--r--conf/sa_dref/sa_dref_aoi.h7
-rw-r--r--conf/sa_dref/sa_dref_default.h3
-rw-r--r--conf/sa_dref/sa_dref_isc3.h7
-rw-r--r--conf/sa_dref/sa_dref_linux.h3
-rw-r--r--conf/sa_dref/sa_dref_svr4.h7
-rw-r--r--conf/transp/transp_sockets.c137
-rw-r--r--conf/transp/transp_tli.c924
-rw-r--r--conf/trap/trap_aix3.h5
-rw-r--r--conf/trap/trap_aux.h2
-rw-r--r--conf/trap/trap_dgux.h2
-rw-r--r--conf/trap/trap_freebsd3.h3
-rw-r--r--conf/trap/trap_hcx.h2
-rw-r--r--conf/trap/trap_hpux.h15
-rw-r--r--conf/trap/trap_irix.h3
-rw-r--r--conf/trap/trap_isc3.h3
-rw-r--r--conf/trap/trap_linux.h3
-rw-r--r--conf/trap/trap_mach3.h3
-rw-r--r--conf/trap/trap_netbsd.h6
-rw-r--r--conf/trap/trap_news4.h2
-rw-r--r--conf/trap/trap_rtu6.h2
-rw-r--r--conf/trap/trap_stellix.h3
-rw-r--r--conf/trap/trap_svr4.h3
-rw-r--r--conf/trap/trap_ultrix.h3
-rw-r--r--conf/umount/umount_aix.c197
-rw-r--r--conf/umount/umount_bsd44.c9
-rw-r--r--conf/umount/umount_default.c188
-rw-r--r--conf/umount/umount_linux.c264
-rw-r--r--conf/umount/umount_osf.c120
117 files changed, 20625 insertions, 295 deletions
diff --git a/conf/autofs/autofs_default.c b/conf/autofs/autofs_default.c
new file mode 100644
index 000000000000..ae75f4de5532
--- /dev/null
+++ b/conf/autofs/autofs_default.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 1999-2003 Ion Badulescu
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/autofs/autofs_default.c
+ *
+ */
+
+/*
+ * Default Automounter filesystem (empty)
+ */
diff --git a/conf/autofs/autofs_default.h b/conf/autofs/autofs_default.h
new file mode 100644
index 000000000000..6668eb640255
--- /dev/null
+++ b/conf/autofs/autofs_default.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 1999-2003 Ion Badulescu
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/autofs/autofs_default.h
+ *
+ */
+
+/*
+ * Default automounter filesystem
+ */
+
+/*
+ * Autofs is not supported on this platform,
+ * so disable it if it gets detected.
+ */
+
+#ifdef MNTTYPE_AUTOFS
+# undef MNTTYPE_AUTOFS
+#endif /* MNTTYPE_AUTOFS */
+#ifdef MNTTAB_TYPE_AUTOFS
+# undef MNTTAB_TYPE_AUTOFS
+#endif /* MNTTAB_TYPE_AUTOFS */
+#ifdef HAVE_FS_AUTOFS
+# undef HAVE_FS_AUTOFS
+#endif /* HAVE_FS_AUTOFS */
diff --git a/conf/autofs/autofs_linux.c b/conf/autofs/autofs_linux.c
new file mode 100644
index 000000000000..d543979d3e41
--- /dev/null
+++ b/conf/autofs/autofs_linux.c
@@ -0,0 +1,909 @@
+/*
+ * Copyright (c) 1999-2003 Ion Badulescu
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/autofs/autofs_linux.c
+ *
+ */
+
+/*
+ * Automounter filesystem for Linux
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <am_defs.h>
+#include <amd.h>
+
+#ifdef HAVE_FS_AUTOFS
+
+/*
+ * MACROS:
+ */
+
+#define AUTOFS_MIN_VERSION 3
+#if AUTOFS_MAX_PROTO_VERSION >= 5
+/*
+ * Autofs version 5 support is experimental; change this to 5 you want
+ * to play with, it. There are reports it does not work.
+ */
+#define AUTOFS_MAX_VERSION 4 /* we only know up to version 5 */
+#else
+#define AUTOFS_MAX_VERSION AUTOFS_MAX_PROTO_VERSION
+#endif
+
+/*
+ * STRUCTURES:
+ */
+
+/*
+ * VARIABLES:
+ */
+
+static int autofs_max_fds;
+static am_node **hash;
+static int *list;
+static int numfds = 0;
+static int bind_works = 1;
+
+
+static void
+hash_init(void)
+{
+ int i;
+ struct rlimit rlim;
+
+ if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) {
+ plog(XLOG_ERROR, "getrlimit failed, defaulting to 256 fd's");
+ autofs_max_fds = 256;
+ } else {
+ autofs_max_fds = (rlim.rlim_cur > 1024) ? 1024 : rlim.rlim_cur;
+ plog(XLOG_INFO, "%d fd's available for autofs", autofs_max_fds);
+ }
+
+ list = malloc(autofs_max_fds * sizeof(*list));
+ hash = malloc(autofs_max_fds * sizeof(*hash));
+
+ for (i = 0 ; i < autofs_max_fds; i++) {
+ hash[i] = NULL;
+ list[i] = -1;
+ }
+}
+
+
+static void
+hash_insert(int fd, am_node *mp)
+{
+ if (hash[fd] != 0)
+ plog(XLOG_ERROR, "file descriptor %d already in the hash", fd);
+
+ hash[fd] = mp;
+ list[numfds] = fd;
+ numfds++;
+}
+
+
+static void
+hash_delete(int fd)
+{
+ int i;
+
+ if (hash[fd] == 0)
+ plog(XLOG_WARNING, "file descriptor %d not in the hash", fd);
+
+ hash[fd] = NULL;
+ numfds--;
+ for (i = 0; i < numfds; i++)
+ if (list[i] == fd) {
+ list[i] = list[numfds];
+ break;
+ }
+}
+
+
+int
+autofs_get_fh(am_node *mp)
+{
+ int fds[2];
+ autofs_fh_t *fh;
+
+ plog(XLOG_DEBUG, "autofs_get_fh for %s", mp->am_path);
+ if (pipe(fds) < 0)
+ return errno;
+
+ /* sanity check */
+ if (fds[0] > autofs_max_fds) {
+ close(fds[0]);
+ close(fds[1]);
+ return EMFILE;
+ }
+
+ fh = ALLOC(autofs_fh_t);
+ fh->fd = fds[0];
+ fh->kernelfd = fds[1];
+ fh->ioctlfd = -1;
+ fh->pending_mounts = NULL;
+ fh->pending_umounts = NULL;
+
+ mp->am_autofs_fh = fh;
+
+ return 0;
+}
+
+
+void
+autofs_mounted(am_node *mp)
+{
+ autofs_fh_t *fh = mp->am_autofs_fh;
+ unsigned long timeout = gopt.am_timeo;
+
+ close(fh->kernelfd);
+ fh->kernelfd = -1;
+
+ autofs_get_mp(mp);
+
+ /* Get autofs protocol version */
+ if (ioctl(fh->ioctlfd, AUTOFS_IOC_PROTOVER, &fh->version) < 0) {
+ plog(XLOG_ERROR, "AUTOFS_IOC_PROTOVER: %s", strerror(errno));
+ fh->version = AUTOFS_MIN_VERSION;
+ plog(XLOG_ERROR, "autofs: assuming protocol version %d", fh->version);
+ } else
+ plog(XLOG_INFO, "autofs: using protocol version %d", fh->version);
+
+ /* set expiration timeout */
+ if (ioctl(fh->ioctlfd, AUTOFS_IOC_SETTIMEOUT, &timeout) < 0)
+ plog(XLOG_ERROR, "AUTOFS_IOC_SETTIMEOUT: %s", strerror(errno));
+
+ /* tell the daemon to call us for expirations */
+ mp->am_autofs_ttl = clocktime(NULL) + gopt.am_timeo_w;
+}
+
+
+void
+autofs_get_mp(am_node *mp)
+{
+ autofs_fh_t *fh = mp->am_autofs_fh;
+ dlog("autofs: getting mount point");
+ if (fh->ioctlfd < 0)
+ fh->ioctlfd = open(mp->am_path, O_RDONLY);
+ hash_insert(fh->fd, mp);
+}
+
+
+void
+autofs_release_mp(am_node *mp)
+{
+ autofs_fh_t *fh = mp->am_autofs_fh;
+ dlog("autofs: releasing mount point");
+ if (fh->ioctlfd >= 0) {
+ close(fh->ioctlfd);
+ fh->ioctlfd = -1;
+ }
+ /*
+ * take the kernel fd out of the hash/fdset
+ * so select() doesn't go crazy if the umount succeeds
+ */
+ if (fh->fd >= 0)
+ hash_delete(fh->fd);
+}
+
+
+void
+autofs_release_fh(am_node *mp)
+{
+ autofs_fh_t *fh = mp->am_autofs_fh;
+ struct autofs_pending_mount **pp, *p;
+ struct autofs_pending_umount **upp, *up;
+
+ dlog("autofs: releasing file handle");
+ if (fh) {
+ /*
+ * if a mount succeeded, the kernel fd was closed on
+ * the amd side, so it might have been reused.
+ * we set it to -1 after closing it, to avoid the problem.
+ */
+ if (fh->kernelfd >= 0)
+ close(fh->kernelfd);
+
+ if (fh->ioctlfd >= 0)
+ close(fh->ioctlfd);
+
+ if (fh->fd >= 0)
+ close(fh->fd);
+
+ pp = &fh->pending_mounts;
+ while (*pp) {
+ p = *pp;
+ XFREE(p->name);
+ *pp = p->next;
+ XFREE(p);
+ }
+
+ upp = &fh->pending_umounts;
+ while (*upp) {
+ up = *upp;
+ XFREE(up->name);
+ *upp = up->next;
+ XFREE(up);
+ }
+
+ XFREE(fh);
+ mp->am_autofs_fh = NULL;
+ }
+}
+
+
+void
+autofs_add_fdset(fd_set *readfds)
+{
+ int i;
+ for (i = 0; i < numfds; i++)
+ FD_SET(list[i], readfds);
+}
+
+
+static ssize_t
+autofs_get_pkt(int fd, void *buf, size_t bytes)
+{
+ ssize_t i;
+
+ do {
+ i = read(fd, buf, bytes);
+
+ if (i <= 0)
+ break;
+
+ buf = (char *)buf + i;
+ bytes -= i;
+ } while (bytes);
+
+ return bytes;
+}
+
+
+static void
+send_fail(int fd, autofs_wqt_t token)
+{
+ if (token == 0)
+ return;
+ if (ioctl(fd, AUTOFS_IOC_FAIL, token) < 0)
+ plog(XLOG_ERROR, "AUTOFS_IOC_FAIL: %s", strerror(errno));
+}
+
+
+static void
+send_ready(int fd, autofs_wqt_t token)
+{
+ if (token == 0)
+ return;
+ if (ioctl(fd, AUTOFS_IOC_READY, token) < 0)
+ plog(XLOG_ERROR, "AUTOFS_IOC_READY: %s", strerror(errno));
+}
+
+
+static void
+autofs_lookup_failed(am_node *mp, char *name)
+{
+ autofs_fh_t *fh = mp->am_autofs_fh;
+ struct autofs_pending_mount **pp, *p;
+
+ pp = &fh->pending_mounts;
+ while (*pp && !STREQ((*pp)->name, name))
+ pp = &(*pp)->next;
+
+ /* sanity check */
+ if (*pp == NULL)
+ return;
+
+ p = *pp;
+ plog(XLOG_INFO, "autofs: lookup of %s failed", name);
+ send_fail(fh->ioctlfd, p->wait_queue_token);
+
+ XFREE(p->name);
+ *pp = p->next;
+ XFREE(p);
+}
+
+
+static void
+autofs_expire_one(am_node *mp, char *name, autofs_wqt_t token)
+{
+ autofs_fh_t *fh;
+ am_node *ap;
+ struct autofs_pending_umount *p;
+ char *ap_path;
+
+ fh = mp->am_autofs_fh;
+
+ ap_path = str3cat(NULL, mp->am_path, "/", name);
+ if (amuDebug(D_TRACE))
+ plog(XLOG_DEBUG, "\tumount(%s)", ap_path);
+
+ p = fh->pending_umounts;
+ while (p && p->wait_queue_token != token)
+ p = p->next;
+
+ if (p) {
+ /* already pending */
+ dlog("Umounting of %s already pending", ap_path);
+ amd_stats.d_drops++;
+ goto out;
+ }
+
+ ap = find_ap(ap_path);
+ if (ap == NULL) {
+ /* not found??? not sure what to do here... */
+ send_fail(fh->ioctlfd, token);
+ goto out;
+ }
+
+ p = ALLOC(struct autofs_pending_umount);
+ p->wait_queue_token = token;
+ p->name = xstrdup(name);
+ p->next = fh->pending_umounts;
+ fh->pending_umounts = p;
+
+ unmount_mp(ap);
+
+out:
+ XFREE(ap_path);
+}
+
+
+static void
+autofs_missing_one(am_node *mp, autofs_wqt_t wait_queue_token, char *name)
+{
+ autofs_fh_t *fh;
+ mntfs *mf;
+ am_node *ap;
+ struct autofs_pending_mount *p;
+ int error;
+
+ mf = mp->am_al->al_mnt;
+ fh = mp->am_autofs_fh;
+
+ p = fh->pending_mounts;
+ while (p && p->wait_queue_token != wait_queue_token)
+ p = p->next;
+
+ if (p) {
+ /* already pending */
+ dlog("Mounting of %s/%s already pending",
+ mp->am_path, name);
+ amd_stats.d_drops++;
+ return;
+ }
+
+ p = ALLOC(struct autofs_pending_mount);
+ p->wait_queue_token = wait_queue_token;
+ p->name = xstrdup(name);
+ p->next = fh->pending_mounts;
+ fh->pending_mounts = p;
+
+ if (amuDebug(D_TRACE))
+ plog(XLOG_DEBUG, "\tlookup(%s, %s)", mp->am_path, name);
+ ap = mf->mf_ops->lookup_child(mp, name, &error, VLOOK_CREATE);
+ if (ap && error < 0)
+ ap = mf->mf_ops->mount_child(ap, &error);
+
+ /* some of the rest can be done in amfs_auto_cont */
+
+ if (ap == 0) {
+ if (error < 0) {
+ dlog("Mount still pending, not sending autofs reply yet");
+ return;
+ }
+ autofs_lookup_failed(mp, name);
+ }
+ mp->am_stats.s_lookup++;
+}
+
+
+static void
+autofs_handle_expire(am_node *mp, struct autofs_packet_expire *pkt)
+{
+ autofs_expire_one(mp, pkt->name, 0);
+}
+
+
+static void
+autofs_handle_missing(am_node *mp, struct autofs_packet_missing *pkt)
+{
+ autofs_missing_one(mp, pkt->wait_queue_token, pkt->name);
+}
+
+
+#if AUTOFS_MAX_PROTO_VERSION >= 4
+static void
+autofs_handle_expire_multi(am_node *mp, struct autofs_packet_expire_multi *pkt)
+{
+ autofs_expire_one(mp, pkt->name, pkt->wait_queue_token);
+}
+#endif /* AUTOFS_MAX_PROTO_VERSION >= 4 */
+
+
+#if AUTOFS_MAX_PROTO_VERSION >= 5
+static void
+autofs_handle_expire_direct(am_node *mp,
+ autofs_packet_expire_direct_t *pkt)
+{
+ autofs_expire_one(mp, pkt->name, 0);
+}
+
+static void
+autofs_handle_expire_indirect(am_node *mp,
+ autofs_packet_expire_indirect_t *pkt)
+{
+ autofs_expire_one(mp, pkt->name, 0);
+}
+
+
+static void
+autofs_handle_missing_direct(am_node *mp,
+ autofs_packet_missing_direct_t *pkt)
+{
+ autofs_missing_one(mp, pkt->wait_queue_token, pkt->name);
+}
+
+
+static void
+autofs_handle_missing_indirect(am_node *mp,
+ autofs_packet_missing_indirect_t *pkt)
+{
+ autofs_missing_one(mp, pkt->wait_queue_token, pkt->name);
+}
+#endif /* AUTOFS_MAX_PROTO_VERSION >= 5 */
+
+
+int
+autofs_handle_fdset(fd_set *readfds, int nsel)
+{
+ int i;
+ union {
+#if AUTOFS_MAX_PROTO_VERSION >= 5
+ union autofs_v5_packet_union pkt5;
+#endif
+ union autofs_packet_union pkt;
+ } p;
+ autofs_fh_t *fh;
+ am_node *mp;
+ size_t len;
+
+ for (i = 0; nsel && i < numfds; i++) {
+ if (!FD_ISSET(list[i], readfds))
+ continue;
+
+ nsel--;
+ FD_CLR(list[i], readfds);
+ mp = hash[list[i]];
+ fh = mp->am_autofs_fh;
+
+#if AUTOFS_MAX_PROTO_VERSION >= 5
+ if (fh->version < 5) {
+ len = sizeof(p.pkt);
+ } else {
+ len = sizeof(p.pkt5);
+ }
+#else
+ len = sizeof(p.pkt);
+#endif /* AUTOFS_MAX_PROTO_VERSION >= 5 */
+
+ if (autofs_get_pkt(fh->fd, &p, len))
+ continue;
+
+ switch (p.pkt.hdr.type) {
+ case autofs_ptype_missing:
+ autofs_handle_missing(mp, &p.pkt.missing);
+ break;
+ case autofs_ptype_expire:
+ autofs_handle_expire(mp, &p.pkt.expire);
+ break;
+#if AUTOFS_MAX_PROTO_VERSION >= 4
+ case autofs_ptype_expire_multi:
+ autofs_handle_expire_multi(mp, &p.pkt.expire_multi);
+ break;
+#endif /* AUTOFS_MAX_PROTO_VERSION >= 4 */
+#if AUTOFS_MAX_PROTO_VERSION >= 5
+ case autofs_ptype_expire_indirect:
+ autofs_handle_expire_indirect(mp, &p.pkt5.expire_direct);
+ break;
+ case autofs_ptype_expire_direct:
+ autofs_handle_expire_direct(mp, &p.pkt5.expire_direct);
+ break;
+ case autofs_ptype_missing_indirect:
+ autofs_handle_missing_indirect(mp, &p.pkt5.missing_direct);
+ break;
+ case autofs_ptype_missing_direct:
+ autofs_handle_missing_direct(mp, &p.pkt5.missing_direct);
+ break;
+#endif /* AUTOFS_MAX_PROTO_VERSION >= 5 */
+ default:
+ plog(XLOG_ERROR, "Unknown autofs packet type %d",
+ p.pkt.hdr.type);
+ }
+ }
+ return nsel;
+}
+
+
+int
+create_autofs_service(void)
+{
+ hash_init();
+
+ /* not the best place, but... */
+ if (linux_version_code() < KERNEL_VERSION(2,4,0))
+ bind_works = 0;
+
+ return 0;
+}
+
+
+int
+destroy_autofs_service(void)
+{
+ /* Nothing to do */
+ return 0;
+}
+
+
+static int
+autofs_bind_umount(char *mountpoint)
+{
+ int err = 1;
+#ifdef MNT2_GEN_OPT_BIND
+ if (bind_works && gopt.flags & CFM_AUTOFS_USE_LOFS) {
+ struct stat buf;
+
+ if ((err = lstat(mountpoint, &buf)))
+ return errno;
+ if (S_ISLNK(buf.st_mode))
+ goto use_symlink;
+
+ plog(XLOG_INFO, "autofs: un-bind-mounting %s", mountpoint);
+ err = umount_fs(mountpoint, mnttab_file_name, 1);
+ if (err)
+ plog(XLOG_INFO, "autofs: unmounting %s failed: %m", mountpoint);
+ else
+ err = rmdir(mountpoint);
+ goto out;
+ }
+#endif /* MNT2_GEN_OPT_BIND */
+ use_symlink:
+ plog(XLOG_INFO, "autofs: deleting symlink %s", mountpoint);
+ err = unlink(mountpoint);
+
+ out:
+ if (err)
+ return errno;
+ return 0;
+}
+
+
+int
+autofs_mount_fs(am_node *mp, mntfs *mf)
+{
+ char *target, *target2 = NULL;
+ int err = 0;
+
+ if (mf->mf_flags & MFF_ON_AUTOFS) {
+ if ((err = mkdir(mp->am_path, 0555)))
+ return errno;
+ }
+
+ /*
+ * For sublinks, we could end up here with an already mounted f/s.
+ * Don't do anything in that case.
+ */
+ if (!(mf->mf_flags & MFF_MOUNTED))
+ err = mf->mf_ops->mount_fs(mp, mf);
+
+ if (err) {
+ if (mf->mf_flags & MFF_ON_AUTOFS)
+ rmdir(mp->am_path);
+ return err;
+ }
+
+ if (mf->mf_flags & MFF_ON_AUTOFS)
+ /* Nothing else to do */
+ return 0;
+
+ if (mp->am_link)
+ target = mp->am_link;
+ else
+ target = mf->mf_fo->opt_fs;
+
+#ifdef MNT2_GEN_OPT_BIND
+ if (bind_works && gopt.flags & CFM_AUTOFS_USE_LOFS) {
+ struct stat buf;
+
+ /*
+ * HACK ALERT!
+ *
+ * Since the bind mount mechanism doesn't allow mountpoint crossing,
+ * we _must_ use symlinks for the host mount case. Otherwise we end up
+ * with a bunch of empty mountpoints...
+ */
+ if (mf->mf_ops == &amfs_host_ops)
+ goto use_symlink;
+
+ if (target[0] != '/')
+ target2 = str3cat(NULL, mp->am_parent->am_path, "/", target);
+ else
+ target2 = xstrdup(target);
+
+ /*
+ * We need to stat() the destination, because the bind mount does not
+ * follow symlinks and/or allow for non-existent destinations.
+ * We fall back to symlinks if there are problems.
+ *
+ * We also need to temporarily change pgrp, otherwise our stat() won't
+ * trigger whatever cascading mounts are needed.
+ *
+ * WARNING: we will deadlock if this function is called from the master
+ * amd process and it happens to trigger another auto mount. Therefore,
+ * this function should be called only from a child amd process, or
+ * at the very least it should not be called from the parent unless we
+ * know for sure that it won't cause a recursive mount. We refuse to
+ * cause the recursive mount anyway if called from the parent amd.
+ */
+ if (!foreground) {
+ pid_t pgrp = getpgrp();
+ setpgrp();
+ err = stat(target2, &buf);
+ if ((err = setpgid(0, pgrp))) {
+ plog(XLOG_ERROR, "autofs: cannot restore pgrp: %s", strerror(errno));
+ plog(XLOG_ERROR, "autofs: aborting the mount");
+ goto out;
+ }
+ if (err)
+ goto use_symlink;
+ }
+ if ((err = lstat(target2, &buf)))
+ goto use_symlink;
+ if (S_ISLNK(buf.st_mode))
+ goto use_symlink;
+
+ plog(XLOG_INFO, "autofs: bind-mounting %s -> %s", mp->am_path, target2);
+ mkdir(mp->am_path, 0555);
+ err = mount_lofs(mp->am_path, target2, mf->mf_mopts, 1);
+ if (err) {
+ rmdir(mp->am_path);
+ plog(XLOG_INFO, "autofs: bind-mounting %s -> %s failed", mp->am_path, target2);
+ goto use_symlink;
+ }
+ goto out;
+ }
+#endif /* MNT2_GEN_OPT_BIND */
+ use_symlink:
+ plog(XLOG_INFO, "autofs: symlinking %s -> %s", mp->am_path, target);
+ err = symlink(target, mp->am_path);
+
+ out:
+ if (target2)
+ XFREE(target2);
+
+ if (err)
+ return errno;
+ return 0;
+}
+
+
+int
+autofs_umount_fs(am_node *mp, mntfs *mf)
+{
+ int err = 0;
+ if (!(mf->mf_flags & MFF_ON_AUTOFS)) {
+ err = autofs_bind_umount(mp->am_path);
+ if (err)
+ return err;
+ }
+
+ /*
+ * Multiple sublinks could reference this f/s.
+ * Don't actually unmount it unless we're holding the last reference.
+ */
+ if (mf->mf_refc == 1) {
+ err = mf->mf_ops->umount_fs(mp, mf);
+ if (err)
+ return err;
+ if (mf->mf_flags & MFF_ON_AUTOFS)
+ rmdir(mp->am_path);
+ }
+ return 0;
+}
+
+
+int
+autofs_umount_succeeded(am_node *mp)
+{
+ autofs_fh_t *fh = mp->am_parent->am_autofs_fh;
+ struct autofs_pending_umount **pp, *p;
+
+ /* Already gone? */
+ if (fh == NULL)
+ return 0;
+
+ pp = &fh->pending_umounts;
+ while (*pp && !STREQ((*pp)->name, mp->am_name))
+ pp = &(*pp)->next;
+
+ /* sanity check */
+ if (*pp == NULL)
+ return -1;
+
+ p = *pp;
+ plog(XLOG_INFO, "autofs: unmounting %s succeeded", mp->am_path);
+ send_ready(fh->ioctlfd, p->wait_queue_token);
+
+ XFREE(p->name);
+ *pp = p->next;
+ XFREE(p);
+ return 0;
+}
+
+
+int
+autofs_umount_failed(am_node *mp)
+{
+ autofs_fh_t *fh = mp->am_parent->am_autofs_fh;
+ struct autofs_pending_umount **pp, *p;
+
+ pp = &fh->pending_umounts;
+ while (*pp && !STREQ((*pp)->name, mp->am_name))
+ pp = &(*pp)->next;
+
+ /* sanity check */
+ if (*pp == NULL)
+ return -1;
+
+ p = *pp;
+ plog(XLOG_INFO, "autofs: unmounting %s failed", mp->am_path);
+ send_fail(fh->ioctlfd, p->wait_queue_token);
+
+ XFREE(p->name);
+ *pp = p->next;
+ XFREE(p);
+ return 0;
+}
+
+
+void
+autofs_mount_succeeded(am_node *mp)
+{
+ autofs_fh_t *fh = mp->am_parent->am_autofs_fh;
+ struct autofs_pending_mount **pp, *p;
+
+ /*
+ * don't expire the entries -- the kernel will do it for us.
+ *
+ * but it won't do autofs filesystems, so we expire them the old
+ * fashioned way instead.
+ */
+ if (!(mp->am_al->al_mnt->mf_flags & MFF_IS_AUTOFS))
+ mp->am_flags |= AMF_NOTIMEOUT;
+
+ pp = &fh->pending_mounts;
+ while (*pp && !STREQ((*pp)->name, mp->am_name))
+ pp = &(*pp)->next;
+
+ /* sanity check */
+ if (*pp == NULL)
+ return;
+
+ p = *pp;
+ plog(XLOG_INFO, "autofs: mounting %s succeeded", mp->am_path);
+ send_ready(fh->ioctlfd, p->wait_queue_token);
+
+ XFREE(p->name);
+ *pp = p->next;
+ XFREE(p);
+}
+
+
+void
+autofs_mount_failed(am_node *mp)
+{
+ autofs_fh_t *fh = mp->am_parent->am_autofs_fh;
+ struct autofs_pending_mount **pp, *p;
+
+ pp = &fh->pending_mounts;
+ while (*pp && !STREQ((*pp)->name, mp->am_name))
+ pp = &(*pp)->next;
+
+ /* sanity check */
+ if (*pp == NULL)
+ return;
+
+ p = *pp;
+ plog(XLOG_INFO, "autofs: mounting %s failed", mp->am_path);
+ send_fail(fh->ioctlfd, p->wait_queue_token);
+
+ XFREE(p->name);
+ *pp = p->next;
+ XFREE(p);
+}
+
+
+void
+autofs_get_opts(char *opts, size_t l, autofs_fh_t *fh)
+{
+ xsnprintf(opts, l, "fd=%d,minproto=%d,maxproto=%d",
+ fh->kernelfd, AUTOFS_MIN_VERSION, AUTOFS_MAX_VERSION);
+}
+
+
+int
+autofs_compute_mount_flags(mntent_t *mnt)
+{
+ return 0;
+}
+
+
+#if AUTOFS_MAX_PROTO_VERSION >= 4
+static int autofs_timeout_mp_task(void *arg)
+{
+ am_node *mp = (am_node *)arg;
+ autofs_fh_t *fh = mp->am_autofs_fh;
+ int now = 0;
+
+ while (ioctl(fh->ioctlfd, AUTOFS_IOC_EXPIRE_MULTI, &now) == 0);
+ return 0;
+}
+#endif /* AUTOFS_MAX_PROTO_VERSION >= 4 */
+
+
+void autofs_timeout_mp(am_node *mp)
+{
+ autofs_fh_t *fh = mp->am_autofs_fh;
+ time_t now = clocktime(NULL);
+
+ /* update the ttl */
+ mp->am_autofs_ttl = now + gopt.am_timeo_w;
+
+ if (fh->version < 4) {
+ struct autofs_packet_expire pkt;
+ while (ioctl(fh->ioctlfd, AUTOFS_IOC_EXPIRE, &pkt) == 0)
+ autofs_handle_expire(mp, &pkt);
+ return;
+ }
+
+#if AUTOFS_MAX_PROTO_VERSION >= 4
+ run_task(autofs_timeout_mp_task, mp, NULL, NULL);
+#endif /* AUTOFS_MAX_PROTO_VERSION >= 4 */
+}
+
+#endif /* HAVE_FS_AUTOFS */
diff --git a/conf/autofs/autofs_linux.h b/conf/autofs/autofs_linux.h
new file mode 100644
index 000000000000..885bfc07133a
--- /dev/null
+++ b/conf/autofs/autofs_linux.h
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 1999-2003 Ion Badulescu
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/autofs/autofs_linux.h
+ *
+ */
+
+/*
+ * Automounter filesystem headers for Linux
+ */
+
+#if !defined(HAVE_LINUX_AUTO_FS_H) && !defined(HAVE_LINUX_AUTO_FS4_H)
+/* We didn't find the headers, so we can't compile in the autofs support */
+# undef HAVE_FS_AUTOFS
+# undef MNTTAB_TYPE_AUTOFS
+#endif /* !HAVE_LINUX_AUTO_FS_H && !HAVE_LINUX_AUTO_FS4_H */
+
+#ifdef HAVE_FS_AUTOFS
+
+struct autofs_pending_mount {
+ unsigned long wait_queue_token; /* Associated kernel wait token */
+ char *name;
+ struct autofs_pending_mount *next;
+};
+
+struct autofs_pending_umount {
+ unsigned long wait_queue_token; /* Associated kernel wait token */
+ char *name;
+ struct autofs_pending_umount *next;
+};
+
+typedef struct {
+ int fd;
+ int kernelfd;
+ int ioctlfd;
+ int version;
+ struct autofs_pending_mount *pending_mounts;
+ struct autofs_pending_umount *pending_umounts;
+} autofs_fh_t;
+
+#ifndef HAVE_LINUX_AUTO_FS4_H
+union autofs_packet_union {
+ struct autofs_packet_hdr hdr;
+ struct autofs_packet_missing missing;
+ struct autofs_packet_expire expire;
+};
+
+/* typedef unsigned long autofs_wqt_t; */
+#endif /* not HAVE_LINUX_AUTO_FS4_H */
+
+#define AUTOFS_AUTO_FS_FLAGS (FS_AMQINFO | FS_DIRECTORY | FS_AUTOFS | FS_ON_AUTOFS)
+#define AUTOFS_DIRECT_FS_FLAGS (FS_DIRECT | FS_MKMNT | FS_NOTIMEOUT | FS_BACKGROUND | FS_AMQINFO)
+#define AUTOFS_ERROR_FS_FLAGS (FS_DISCARD)
+#define AUTOFS_HOST_FS_FLAGS (FS_MKMNT | FS_BACKGROUND | FS_AMQINFO)
+#define AUTOFS_LINK_FS_FLAGS (FS_MBACKGROUND)
+#define AUTOFS_LINKX_FS_FLAGS (FS_MBACKGROUND)
+#define AUTOFS_NFSL_FS_FLAGS (FS_BACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#define AUTOFS_NFSX_FS_FLAGS (/* FS_UBACKGROUND| */ FS_AMQINFO )
+#define AUTOFS_PROGRAM_FS_FLAGS (FS_BACKGROUND | FS_AMQINFO)
+#define AUTOFS_ROOT_FS_FLAGS (FS_NOTIMEOUT | FS_AMQINFO | FS_DIRECTORY)
+#define AUTOFS_TOPLVL_FS_FLAGS (FS_MKMNT | FS_NOTIMEOUT | FS_BACKGROUND | FS_AMQINFO | FS_DIRECTORY | FS_AUTOFS)
+#define AUTOFS_UNION_FS_FLAGS (FS_NOTIMEOUT | FS_BACKGROUND | FS_AMQINFO | FS_DIRECTORY | FS_ON_AUTOFS)
+
+#define AUTOFS_CACHEFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#define AUTOFS_CDFS_FS_FLAGS (FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#define AUTOFS_UDF_FS_FLAGS (FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#define AUTOFS_LUSTRE_FS_FLAGS (FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#define AUTOFS_EFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#define AUTOFS_LOFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#define AUTOFS_NFS_FS_FLAGS (FS_BACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#define AUTOFS_PCFS_FS_FLAGS (FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#define AUTOFS_UFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#define AUTOFS_XFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#define AUTOFS_EXT_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#define AUTOFS_TMPFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#endif /* HAVE_FS_AUTOFS */
diff --git a/conf/autofs/autofs_solaris_v1.c b/conf/autofs/autofs_solaris_v1.c
new file mode 100644
index 000000000000..fcce6e3de006
--- /dev/null
+++ b/conf/autofs/autofs_solaris_v1.c
@@ -0,0 +1,719 @@
+/*
+ * Copyright (c) 1999-2003 Ion Badulescu
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/autofs/autofs_solaris_v1.c
+ *
+ */
+
+/*
+ * Automounter filesystem
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <am_defs.h>
+#include <amd.h>
+
+#ifdef HAVE_FS_AUTOFS
+
+/*
+ * MACROS:
+ */
+#ifndef AUTOFS_NULL
+# define AUTOFS_NULL NULLPROC
+#endif /* not AUTOFS_NULL */
+
+/*
+ * STRUCTURES:
+ */
+
+/*
+ * VARIABLES:
+ */
+
+/* forward declarations */
+# ifndef HAVE_XDR_MNTREQUEST
+bool_t xdr_mntrequest(XDR *xdrs, mntrequest *objp);
+# endif /* not HAVE_XDR_MNTREQUEST */
+# ifndef HAVE_XDR_MNTRES
+bool_t xdr_mntres(XDR *xdrs, mntres *objp);
+# endif /* not HAVE_XDR_MNTRES */
+# ifndef HAVE_XDR_UMNTREQUEST
+bool_t xdr_umntrequest(XDR *xdrs, umntrequest *objp);
+# endif /* not HAVE_XDR_UMNTREQUEST */
+# ifndef HAVE_XDR_UMNTRES
+bool_t xdr_umntres(XDR *xdrs, umntres *objp);
+# endif /* not HAVE_XDR_UMNTRES */
+static int autofs_mount_1_req(struct mntrequest *mr, struct mntres *result, struct authunix_parms *cred, SVCXPRT *transp);
+static int autofs_unmount_1_req(struct umntrequest *ur, struct umntres *result, struct authunix_parms *cred, SVCXPRT *transp);
+
+/****************************************************************************
+ *** VARIABLES ***
+ ****************************************************************************/
+
+/****************************************************************************
+ *** FUNCTIONS ***
+ ****************************************************************************/
+
+/*
+ * AUTOFS XDR FUNCTIONS:
+ */
+
+#ifndef HAVE_XDR_MNTREQUEST
+bool_t
+xdr_mntrequest(XDR *xdrs, mntrequest *objp)
+{
+ if (amuDebug(D_XDRTRACE))
+ plog(XLOG_DEBUG, "xdr_mntrequest:");
+
+ if (!xdr_string(xdrs, &objp->name, A_MAXNAME))
+ return (FALSE);
+
+ if (!xdr_string(xdrs, &objp->map, A_MAXNAME))
+ return (FALSE);
+
+ if (!xdr_string(xdrs, &objp->opts, A_MAXOPTS))
+ return (FALSE);
+
+ if (!xdr_string(xdrs, &objp->path, A_MAXPATH))
+ return (FALSE);
+
+ return (TRUE);
+}
+#endif /* not HAVE_XDR_MNTREQUEST */
+
+
+#ifndef HAVE_XDR_MNTRES
+bool_t
+xdr_mntres(XDR *xdrs, mntres *objp)
+{
+ if (amuDebug(D_XDRTRACE))
+ plog(XLOG_DEBUG, "xdr_mntres:");
+
+ if (!xdr_int(xdrs, &objp->status))
+ return (FALSE);
+
+ return (TRUE);
+}
+# endif /* not HAVE_XDR_MNTRES */
+
+
+#ifndef HAVE_XDR_UMNTREQUEST
+bool_t
+xdr_umntrequest(XDR *xdrs, umntrequest *objp)
+{
+ if (amuDebug(D_XDRTRACE))
+ plog(XLOG_DEBUG, "xdr_umntrequest:");
+
+ if (!xdr_int(xdrs, (int *) &objp->isdirect))
+ return (FALSE);
+
+ if (!xdr_u_int(xdrs, (u_int *) &objp->devid))
+ return (FALSE);
+
+#ifdef HAVE_UMNTREQUEST_RDEVID
+ if (!xdr_u_long(xdrs, &objp->rdevid))
+ return (FALSE);
+#endif /* HAVE_UMNTREQUEST_RDEVID */
+
+ if (!xdr_pointer(xdrs, (char **) &objp->next, sizeof(umntrequest), (XDRPROC_T_TYPE) xdr_umntrequest))
+ return (FALSE);
+
+ return (TRUE);
+}
+#endif /* not HAVE_XDR_UMNTREQUEST */
+
+
+#ifndef HAVE_XDR_UMNTRES
+bool_t
+xdr_umntres(XDR *xdrs, umntres *objp)
+{
+ if (amuDebug(D_XDRTRACE))
+ plog(XLOG_DEBUG, "xdr_mntres:");
+
+ if (!xdr_int(xdrs, &objp->status))
+ return (FALSE);
+
+ return (TRUE);
+}
+#endif /* not HAVE_XDR_UMNTRES */
+
+
+/*
+ * AUTOFS RPC methods
+ */
+
+static int
+autofs_mount_1_req(struct mntrequest *m,
+ struct mntres *res,
+ struct authunix_parms *cred,
+ SVCXPRT *transp)
+{
+ int err = 0;
+ int isdirect = 0;
+ am_node *mp, *ap;
+ mntfs *mf;
+
+ dlog("MOUNT REQUEST: name=%s map=%s opts=%s path=%s",
+ m->name, m->map, m->opts, m->path);
+
+ /* find the effective uid/gid from RPC request */
+ xsnprintf(opt_uid, sizeof(uid_str), "%d", (int) cred->aup_uid);
+ xsnprintf(opt_gid, sizeof(gid_str), "%d", (int) cred->aup_gid);
+
+ mp = find_ap(m->path);
+ if (!mp) {
+ plog(XLOG_ERROR, "map %s not found", m->path);
+ err = ENOENT;
+ goto out;
+ }
+
+ mf = mp->am_al->al_mnt;
+ isdirect = (mf->mf_fsflags & FS_DIRECT) ? 1 : 0;
+ ap = mf->mf_ops->lookup_child(mp, m->name + isdirect, &err, VLOOK_CREATE);
+ if (ap && err < 0)
+ ap = mf->mf_ops->mount_child(ap, &err);
+ if (ap == NULL) {
+ if (err < 0) {
+ /* we're working on it */
+ amd_stats.d_drops++;
+ return 1;
+ }
+ err = ENOENT;
+ goto out;
+ }
+
+out:
+ if (err) {
+ if (isdirect) {
+ /* direct mount */
+ plog(XLOG_ERROR, "mount of %s failed", m->path);
+ } else {
+ /* indirect mount */
+ plog(XLOG_ERROR, "mount of %s/%s failed", m->path, m->name);
+ }
+ }
+
+ dlog("MOUNT REPLY: status=%d (%s)", err, strerror(err));
+
+ res->status = err;
+ return 0;
+}
+
+
+static int
+autofs_unmount_1_req(struct umntrequest *ul,
+ struct umntres *res,
+ struct authunix_parms *cred,
+ SVCXPRT *transp)
+{
+ int mapno, err;
+ am_node *mp = NULL;
+
+ dlog("UNMOUNT REQUEST: dev=%lx rdev=%lx %s",
+ (u_long) ul->devid,
+ (u_long) ul->rdevid,
+ ul->isdirect ? "direct" : "indirect");
+
+ /* by default, and if not found, succeed */
+ res->status = 0;
+
+ for (mapno = 0; ; mapno++) {
+ mp = get_exported_ap(mapno);
+ if (!mp)
+ break;
+ if (mp->am_dev == ul->devid &&
+ (ul->rdevid == 0 || mp->am_rdev == ul->rdevid))
+ break;
+ }
+
+ if (mp) {
+ /* save RPC context */
+ if (!mp->am_transp && transp) {
+ mp->am_transp = (SVCXPRT *) xmalloc(sizeof(SVCXPRT));
+ *(mp->am_transp) = *transp;
+ }
+
+ mapno = mp->am_mapno;
+ err = unmount_mp(mp);
+
+ if (err)
+ /* backgrounded, don't reply yet */
+ return 1;
+
+ if (get_exported_ap(mapno))
+ /* unmounting failed, tell the kernel */
+ res->status = 1;
+ }
+
+ dlog("UNMOUNT REPLY: status=%d", res->status);
+ return 0;
+}
+
+
+/****************************************************************************/
+/* autofs program dispatcher */
+static void
+autofs_program_1(struct svc_req *rqstp, SVCXPRT *transp)
+{
+ union {
+ mntrequest autofs_mount_1_arg;
+ umntrequest autofs_umount_1_arg;
+ } argument;
+ union {
+ mntres mount_res;
+ umntres umount_res;
+ } result;
+ int ret;
+
+ bool_t (*xdr_argument)();
+ bool_t (*xdr_result)();
+ int (*local)();
+
+ current_transp = transp;
+
+ switch (rqstp->rq_proc) {
+
+ case AUTOFS_NULL:
+ svc_sendreply(transp,
+ (XDRPROC_T_TYPE) xdr_void,
+ (SVC_IN_ARG_TYPE) NULL);
+ return;
+
+ case AUTOFS_MOUNT:
+ xdr_argument = xdr_mntrequest;
+ xdr_result = xdr_mntres;
+ local = autofs_mount_1_req;
+ break;
+
+ case AUTOFS_UNMOUNT:
+ xdr_argument = xdr_umntrequest;
+ xdr_result = xdr_umntres;
+ local = autofs_unmount_1_req;
+ break;
+
+ default:
+ svcerr_noproc(transp);
+ return;
+ }
+
+ memset((char *) &argument, 0, sizeof(argument));
+ if (!svc_getargs(transp,
+ (XDRPROC_T_TYPE) xdr_argument,
+ (SVC_IN_ARG_TYPE) &argument)) {
+ plog(XLOG_ERROR,
+ "AUTOFS xdr decode failed for %d %d %d",
+ (int) rqstp->rq_prog, (int) rqstp->rq_vers, (int) rqstp->rq_proc);
+ svcerr_decode(transp);
+ return;
+ }
+
+ memset((char *)&result, 0, sizeof(result));
+ ret = (*local) (&argument, &result, rqstp, transp);
+
+ current_transp = NULL;
+
+ /* send reply only if the RPC method returned 0 */
+ if (!ret) {
+ if (!svc_sendreply(transp,
+ (XDRPROC_T_TYPE) xdr_result,
+ (SVC_IN_ARG_TYPE) &result)) {
+ svcerr_systemerr(transp);
+ }
+ }
+
+ if (!svc_freeargs(transp,
+ (XDRPROC_T_TYPE) xdr_argument,
+ (SVC_IN_ARG_TYPE) &argument)) {
+ plog(XLOG_FATAL, "unable to free rpc arguments in autofs_program_1");
+ }
+}
+
+
+int
+autofs_get_fh(am_node *mp)
+{
+ autofs_fh_t *fh;
+ char buf[MAXHOSTNAMELEN];
+ mntfs *mf = mp->am_al->al_mnt;
+ struct utsname utsname;
+
+ plog(XLOG_DEBUG, "autofs_get_fh for %s", mp->am_path);
+ fh = ALLOC(autofs_fh_t);
+ memset((voidp) fh, 0, sizeof(autofs_fh_t)); /* Paranoid */
+
+ /*
+ * SET MOUNT ARGS
+ */
+ if (uname(&utsname) < 0) {
+ xstrlcpy(buf, "localhost.autofs", sizeof(buf));
+ } else {
+ xstrlcpy(buf, utsname.nodename, sizeof(buf));
+ xstrlcat(buf, ".autofs", sizeof(buf));
+ }
+#ifdef HAVE_AUTOFS_ARGS_T_ADDR
+ fh->addr.buf = xstrdup(buf);
+ fh->addr.len = fh->addr.maxlen = strlen(buf);
+#endif /* HAVE_AUTOFS_ARGS_T_ADDR */
+
+ fh->direct = (mf->mf_fsflags & FS_DIRECT) ? 1 : 0;
+ fh->rpc_to = 1; /* XXX: arbitrary */
+ fh->mount_to = mp->am_timeo;
+ fh->path = mp->am_path;
+ fh->opts = ""; /* XXX: arbitrary */
+ fh->map = mp->am_path; /* this is what we get back in readdir */
+
+ mp->am_autofs_fh = fh;
+ return 0;
+}
+
+
+void
+autofs_mounted(am_node *mp)
+{
+ /* We don't want any timeouts on autofs nodes */
+ mp->am_autofs_ttl = NEVER;
+}
+
+
+void
+autofs_release_fh(am_node *mp)
+{
+ autofs_fh_t *fh = mp->am_autofs_fh;
+#ifdef HAVE_AUTOFS_ARGS_T_ADDR
+ XFREE(fh->addr.buf);
+#endif /* HAVE_AUTOFS_ARGS_T_ADDR */
+ XFREE(fh);
+ mp->am_autofs_fh = NULL;
+}
+
+
+void
+autofs_get_mp(am_node *mp)
+{
+ /* nothing to do */
+}
+
+
+void
+autofs_release_mp(am_node *mp)
+{
+ /* nothing to do */
+}
+
+
+void
+autofs_add_fdset(fd_set *readfds)
+{
+ /* nothing to do */
+}
+
+
+int
+autofs_handle_fdset(fd_set *readfds, int nsel)
+{
+ /* nothing to do */
+ return nsel;
+}
+
+
+/*
+ * Create the autofs service for amd
+ */
+int
+create_autofs_service(void)
+{
+ dlog("creating autofs service listener");
+ return register_autofs_service(AUTOFS_CONFTYPE, autofs_program_1);
+}
+
+
+int
+destroy_autofs_service(void)
+{
+ dlog("destroying autofs service listener");
+ return unregister_autofs_service(AUTOFS_CONFTYPE);
+}
+
+
+int
+autofs_mount_fs(am_node *mp, mntfs *mf)
+{
+ int err = 0;
+ char *target, *target2 = NULL;
+ char *space_hack = autofs_strdup_space_hack(mp->am_path);
+ struct stat buf;
+
+ if (mf->mf_flags & MFF_ON_AUTOFS) {
+ if ((err = mkdir(space_hack, 0555)))
+ goto out;
+ }
+
+ /*
+ * For sublinks, we could end up here with an already mounted f/s.
+ * Don't do anything in that case.
+ */
+ if (!(mf->mf_flags & MFF_MOUNTED))
+ err = mf->mf_ops->mount_fs(mp, mf);
+
+ if (err) {
+ if (mf->mf_flags & MFF_ON_AUTOFS)
+ rmdir(space_hack);
+ errno = err;
+ goto out;
+ }
+
+ /*
+ * Autofs v1 doesn't support symlinks,
+ * so we ignore the CFM_AUTOFS_USE_LOFS flag
+ */
+ if (mf->mf_flags & MFF_ON_AUTOFS)
+ /* Nothing to do */
+ goto out;
+
+ if (mp->am_link)
+ target = mp->am_link;
+ else
+ target = mf->mf_mount;
+
+ if (target[0] != '/')
+ target2 = str3cat(NULL, mp->am_parent->am_path, "/", target);
+ else
+ target2 = xstrdup(target);
+
+ plog(XLOG_INFO, "autofs: converting from link to lofs (%s -> %s)", mp->am_path, target2);
+ /*
+ * we need to stat() the destination, because the bind mount does not
+ * follow symlinks and/or allow for non-existent destinations.
+ *
+ * WARNING: we will deadlock if this function is called from the master
+ * amd process and it happens to trigger another auto mount. Therefore,
+ * this function should be called only from a child amd process, or
+ * at the very least it should not be called from the parent unless we
+ * know for sure that it won't cause a recursive mount. We refuse to
+ * cause the recursive mount anyway if called from the parent amd.
+ */
+ if (!foreground) {
+ if ((err = stat(target2, &buf)))
+ goto out;
+ }
+ if ((err = lstat(target2, &buf)))
+ goto out;
+
+ if ((err = mkdir(space_hack, 0555)))
+ goto out;
+
+ if ((err = mount_lofs(mp->am_path, target2, mf->mf_mopts, 1))) {
+ errno = err;
+ goto out;
+ }
+
+ out:
+ XFREE(space_hack);
+ if (target2)
+ XFREE(target2);
+
+ if (err)
+ return errno;
+ return 0;
+}
+
+
+int
+autofs_umount_fs(am_node *mp, mntfs *mf)
+{
+ int err = 0;
+ char *space_hack = autofs_strdup_space_hack(mp->am_path);
+
+ /*
+ * Autofs v1 doesn't support symlinks,
+ * so we ignore the CFM_AUTOFS_USE_LOFS flag
+ */
+ if (!(mf->mf_flags & MFF_ON_AUTOFS)) {
+ err = UMOUNT_FS(mp->am_path, mnttab_file_name, 1);
+ if (err)
+ goto out;
+ rmdir(space_hack);
+ }
+
+ /*
+ * Multiple sublinks could reference this f/s.
+ * Don't actually unmount it unless we're holding the last reference.
+ */
+ if (mf->mf_refc == 1) {
+ if ((err = mf->mf_ops->umount_fs(mp, mf)))
+ goto out;
+
+ if (mf->mf_flags & MFF_ON_AUTOFS)
+ rmdir(space_hack);
+ }
+
+ out:
+ XFREE(space_hack);
+ return err;
+}
+
+
+int
+autofs_umount_succeeded(am_node *mp)
+{
+ umntres res;
+ SVCXPRT *transp = mp->am_transp;
+
+ if (transp) {
+ res.status = 0;
+
+ if (!svc_sendreply(transp,
+ (XDRPROC_T_TYPE) xdr_umntres,
+ (SVC_IN_ARG_TYPE) &res))
+ svcerr_systemerr(transp);
+
+ dlog("Quick reply sent for %s", mp->am_al->al_mnt->mf_mount);
+ XFREE(transp);
+ mp->am_transp = NULL;
+ }
+
+ plog(XLOG_INFO, "autofs: unmounting %s succeeded", mp->am_path);
+ return 0;
+}
+
+
+int
+autofs_umount_failed(am_node *mp)
+{
+ umntres res;
+ SVCXPRT *transp = mp->am_transp;
+
+ if (transp) {
+ res.status = 1;
+
+ if (!svc_sendreply(transp,
+ (XDRPROC_T_TYPE) xdr_umntres,
+ (SVC_IN_ARG_TYPE) &res))
+ svcerr_systemerr(transp);
+
+ dlog("Quick reply sent for %s", mp->am_al->al_mnt->mf_mount);
+ XFREE(transp);
+ mp->am_transp = NULL;
+ }
+
+ plog(XLOG_INFO, "autofs: unmounting %s failed", mp->am_path);
+ return 0;
+}
+
+
+void
+autofs_mount_succeeded(am_node *mp)
+{
+ SVCXPRT *transp = mp->am_transp;
+ struct stat stb;
+ char *space_hack;
+
+ if (transp) {
+ /* this was a mount request */
+ mntres res;
+ res.status = 0;
+
+ if (!svc_sendreply(transp,
+ (XDRPROC_T_TYPE) xdr_mntres,
+ (SVC_IN_ARG_TYPE) &res))
+ svcerr_systemerr(transp);
+
+ dlog("Quick reply sent for %s", mp->am_al->al_mnt->mf_mount);
+ XFREE(transp);
+ mp->am_transp = NULL;
+ }
+
+ space_hack = autofs_strdup_space_hack(mp->am_path);
+ if (!lstat(space_hack, &stb)) {
+ mp->am_dev = stb.st_dev;
+ mp->am_rdev = stb.st_rdev;
+ }
+ XFREE(space_hack);
+ /* don't expire the entries -- the kernel will do it for us */
+ mp->am_flags |= AMF_NOTIMEOUT;
+
+ plog(XLOG_INFO, "autofs: mounting %s succeeded", mp->am_path);
+}
+
+
+void
+autofs_mount_failed(am_node *mp)
+{
+ SVCXPRT *transp = mp->am_transp;
+
+ if (transp) {
+ /* this was a mount request */
+ mntres res;
+ res.status = ENOENT;
+
+ if (!svc_sendreply(transp,
+ (XDRPROC_T_TYPE) xdr_mntres,
+ (SVC_IN_ARG_TYPE) &res))
+ svcerr_systemerr(transp);
+
+ dlog("Quick reply sent for %s", mp->am_al->al_mnt->mf_mount);
+ XFREE(transp);
+ mp->am_transp = NULL;
+ }
+
+ plog(XLOG_INFO, "autofs: mounting %s failed", mp->am_path);
+}
+
+
+void
+autofs_get_opts(char *opts, size_t l, autofs_fh_t *fh)
+{
+ xsnprintf(opts, l, "%sdirect",
+ fh->direct ? "" : "in");
+}
+
+
+int
+autofs_compute_mount_flags(mntent_t *mntp)
+{
+ /* Must use overlay mounts */
+ return MNT2_GEN_OPT_OVERLAY;
+}
+
+
+void autofs_timeout_mp(am_node *mp)
+{
+ /* We don't want any timeouts on autofs nodes */
+ mp->am_autofs_ttl = NEVER;
+}
+#endif /* HAVE_FS_AUTOFS */
diff --git a/conf/autofs/autofs_solaris_v1.h b/conf/autofs/autofs_solaris_v1.h
new file mode 100644
index 000000000000..1c11c998743e
--- /dev/null
+++ b/conf/autofs/autofs_solaris_v1.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 1999-2003 Ion Badulescu
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/autofs/autofs_solaris_v1.h
+ *
+ */
+
+/*
+ * Automounter filesystem header for Solaris v1
+ */
+
+#ifndef autofs_args_t
+# undef HAVE_FS_AUTOFS
+# undef MNTTAB_TYPE_AUTOFS
+#endif /* !autofs_args_t */
+
+#ifdef HAVE_FS_AUTOFS
+typedef autofs_args_t autofs_fh_t;
+
+#define NEED_AUTOFS_SPACE_HACK
+/*
+ * autofs hack: append a space to the directory name
+ * to stop the kernel->daemon recursion.
+ *
+ * Returns malloc'ed space which needs to be freed by the caller.
+ */
+#define autofs_strdup_space_hack(s) str3cat(NULL, (s), " ", "")
+
+#define AUTOFS_AUTO_FS_FLAGS (FS_AMQINFO | FS_DIRECTORY | FS_AUTOFS | FS_ON_AUTOFS)
+#define AUTOFS_DIRECT_FS_FLAGS (FS_DIRECT | FS_NOTIMEOUT | FS_BACKGROUND | FS_AMQINFO | FS_DIRECTORY | FS_AUTOFS)
+#define AUTOFS_ERROR_FS_FLAGS (FS_DISCARD)
+#define AUTOFS_HOST_FS_FLAGS (FS_MKMNT | FS_BACKGROUND | FS_AMQINFO)
+#define AUTOFS_LINK_FS_FLAGS (FS_MBACKGROUND)
+#define AUTOFS_LINKX_FS_FLAGS (FS_MBACKGROUND)
+#define AUTOFS_NFSL_FS_FLAGS (FS_BACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#define AUTOFS_NFSX_FS_FLAGS (/* FS_UBACKGROUND| */ FS_AMQINFO )
+#define AUTOFS_PROGRAM_FS_FLAGS (FS_MKMNT | FS_BACKGROUND | FS_AMQINFO)
+#define AUTOFS_ROOT_FS_FLAGS (FS_NOTIMEOUT | FS_AMQINFO | FS_DIRECTORY)
+#define AUTOFS_TOPLVL_FS_FLAGS (FS_NOTIMEOUT | FS_BACKGROUND | FS_AMQINFO | FS_DIRECTORY | FS_AUTOFS)
+#define AUTOFS_UNION_FS_FLAGS (FS_NOTIMEOUT | FS_BACKGROUND | FS_AMQINFO | FS_DIRECTORY | FS_ON_AUTOFS)
+
+#define AUTOFS_CACHEFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#define AUTOFS_CDFS_FS_FLAGS (FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#define AUTOFS_EFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#define AUTOFS_LOFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#define AUTOFS_NFS_FS_FLAGS (FS_BACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#define AUTOFS_PCFS_FS_FLAGS (FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#define AUTOFS_UFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#define AUTOFS_XFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#endif /* HAVE_FS_AUTOFS */
diff --git a/conf/autofs/autofs_solaris_v2_v3.c b/conf/autofs/autofs_solaris_v2_v3.c
new file mode 100644
index 000000000000..f3b653e7ea90
--- /dev/null
+++ b/conf/autofs/autofs_solaris_v2_v3.c
@@ -0,0 +1,1292 @@
+/*
+ * Copyright (c) 1999-2003 Ion Badulescu
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/autofs/autofs_solaris_v2_v3.c
+ *
+ */
+
+/*
+ * Automounter filesystem
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <am_defs.h>
+#include <amd.h>
+
+/*
+ * MACROS:
+ */
+#ifndef AUTOFS_NULL
+# define AUTOFS_NULL NULLPROC
+#endif /* not AUTOFS_NULL */
+
+/*
+ * STRUCTURES:
+ */
+
+struct amd_rddirres {
+ enum autofs_res rd_status;
+ u_long rd_bufsize;
+ nfsdirlist rd_dl;
+};
+typedef struct amd_rddirres amd_rddirres;
+
+/*
+ * VARIABLES:
+ */
+
+SVCXPRT *autofs_xprt = NULL;
+
+/* forward declarations */
+bool_t xdr_umntrequest(XDR *xdrs, umntrequest *objp);
+bool_t xdr_umntres(XDR *xdrs, umntres *objp);
+bool_t xdr_autofs_lookupargs(XDR *xdrs, autofs_lookupargs *objp);
+bool_t xdr_autofs_mountres(XDR *xdrs, autofs_mountres *objp);
+bool_t xdr_autofs_lookupres(XDR *xdrs, autofs_lookupres *objp);
+bool_t xdr_autofs_rddirargs(XDR *xdrs, autofs_rddirargs *objp);
+static bool_t xdr_amd_rddirres(XDR *xdrs, amd_rddirres *objp);
+
+/*
+ * These exist only in the AutoFS V2 protocol.
+ */
+#ifdef AUTOFS_POSTUNMOUNT
+bool_t xdr_postumntreq(XDR *xdrs, postumntreq *objp);
+bool_t xdr_postumntres(XDR *xdrs, postumntres *objp);
+bool_t xdr_postmountreq(XDR *xdrs, postmountreq *objp);
+bool_t xdr_postmountres(XDR *xdrs, postmountres *objp);
+#endif /* AUTOFS_POSTUMOUNT */
+
+/*
+ * AUTOFS XDR FUNCTIONS:
+ */
+
+bool_t
+xdr_autofs_stat(XDR *xdrs, autofs_stat *objp)
+{
+ if (!xdr_enum(xdrs, (enum_t *)objp))
+ return (FALSE);
+ return (TRUE);
+}
+
+
+bool_t
+xdr_autofs_action(XDR *xdrs, autofs_action *objp)
+{
+ if (!xdr_enum(xdrs, (enum_t *)objp))
+ return (FALSE);
+ return (TRUE);
+}
+
+
+bool_t
+xdr_linka(XDR *xdrs, linka *objp)
+{
+ if (!xdr_string(xdrs, &objp->dir, AUTOFS_MAXPATHLEN))
+ return (FALSE);
+ if (!xdr_string(xdrs, &objp->link, AUTOFS_MAXPATHLEN))
+ return (FALSE);
+ return (TRUE);
+}
+
+
+bool_t
+xdr_autofs_netbuf(XDR *xdrs, struct netbuf *objp)
+{
+ bool_t dummy;
+
+ if (!xdr_u_long(xdrs, (u_long *) &objp->maxlen))
+ return (FALSE);
+ dummy = xdr_bytes(xdrs, (char **)&(objp->buf),
+ (u_int *)&(objp->len), objp->maxlen);
+ return (dummy);
+}
+
+
+bool_t
+xdr_autofs_args(XDR *xdrs, autofs_args *objp)
+{
+ if (!xdr_autofs_netbuf(xdrs, &objp->addr))
+ return (FALSE);
+ if (!xdr_string(xdrs, &objp->path, AUTOFS_MAXPATHLEN))
+ return (FALSE);
+ if (!xdr_string(xdrs, &objp->opts, AUTOFS_MAXOPTSLEN))
+ return (FALSE);
+ if (!xdr_string(xdrs, &objp->map, AUTOFS_MAXPATHLEN))
+ return (FALSE);
+ if (!xdr_string(xdrs, &objp->subdir, AUTOFS_MAXPATHLEN))
+ return (FALSE);
+ if (!xdr_string(xdrs, &objp->key, AUTOFS_MAXCOMPONENTLEN))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->mount_to))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->rpc_to))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->direct))
+ return (FALSE);
+ return (TRUE);
+}
+
+
+bool_t
+xdr_mounta(XDR *xdrs, struct mounta *objp)
+{
+ if (!xdr_string(xdrs, &objp->spec, AUTOFS_MAXPATHLEN))
+ return (FALSE);
+ if (!xdr_string(xdrs, &objp->dir, AUTOFS_MAXPATHLEN))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->flags))
+ return (FALSE);
+ if (!xdr_string(xdrs, &objp->fstype, AUTOFS_MAXCOMPONENTLEN))
+ return (FALSE);
+ if (!xdr_pointer(xdrs, (char **)&objp->dataptr, sizeof(autofs_args),
+ (XDRPROC_T_TYPE) xdr_autofs_args))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->datalen))
+ return (FALSE);
+ return (TRUE);
+}
+
+
+bool_t
+xdr_action_list_entry(XDR *xdrs, action_list_entry *objp)
+{
+ if (!xdr_autofs_action(xdrs, &objp->action))
+ return (FALSE);
+ switch (objp->action) {
+ case AUTOFS_MOUNT_RQ:
+ if (!xdr_mounta(xdrs, &objp->action_list_entry_u.mounta))
+ return (FALSE);
+ break;
+ case AUTOFS_LINK_RQ:
+ if (!xdr_linka(xdrs, &objp->action_list_entry_u.linka))
+ return (FALSE);
+ break;
+ default:
+ break;
+ }
+ return (TRUE);
+}
+
+
+bool_t
+xdr_action_list(XDR *xdrs, action_list *objp)
+{
+ if (!xdr_action_list_entry(xdrs, &objp->action))
+ return (FALSE);
+ if (!xdr_pointer(xdrs, (char **)&objp->next, sizeof(action_list),
+ (XDRPROC_T_TYPE) xdr_action_list))
+ return (FALSE);
+ return (TRUE);
+}
+
+
+bool_t
+xdr_umntrequest(XDR *xdrs, umntrequest *objp)
+{
+ if (amuDebug(D_XDRTRACE))
+ plog(XLOG_DEBUG, "xdr_umntrequest:");
+
+ if (!xdr_bool_t(xdrs, &objp->isdirect))
+ return (FALSE);
+#ifdef HAVE_STRUCT_UMNTREQUEST_DEVID
+ if (!xdr_dev_t(xdrs, &objp->devid))
+ return (FALSE);
+ if (!xdr_dev_t(xdrs, &objp->rdevid))
+ return (FALSE);
+#else /* not HAVE_STRUCT_UMNTREQUEST_DEVID */
+ if (!xdr_string(xdrs, &objp->mntresource, AUTOFS_MAXPATHLEN))
+ return (FALSE);
+ if (!xdr_string(xdrs, &objp->mntpnt, AUTOFS_MAXPATHLEN))
+ return (FALSE);
+ if (!xdr_string(xdrs, &objp->fstype, AUTOFS_MAXCOMPONENTLEN))
+ return (FALSE);
+ if (!xdr_string(xdrs, &objp->mntopts, AUTOFS_MAXOPTSLEN))
+ return (FALSE);
+#endif /* not HAVE_STRUCT_UMNTREQUEST_DEVID */
+ if (!xdr_pointer(xdrs, (char **) &objp->next, sizeof(umntrequest),
+ (XDRPROC_T_TYPE) xdr_umntrequest))
+ return (FALSE);
+
+ return (TRUE);
+}
+
+
+bool_t
+xdr_umntres(XDR *xdrs, umntres *objp)
+{
+ if (amuDebug(D_XDRTRACE))
+ plog(XLOG_DEBUG, "xdr_mntres:");
+
+ if (!xdr_int(xdrs, &objp->status))
+ return (FALSE);
+ return (TRUE);
+}
+
+
+/*
+ * These exist only in the AutoFS V2 protocol.
+ */
+#ifdef AUTOFS_POSTUNMOUNT
+bool_t
+xdr_postumntreq(XDR *xdrs, postumntreq *objp)
+{
+ if (!xdr_dev_t(xdrs, &objp->devid))
+ return (FALSE);
+ if (!xdr_dev_t(xdrs, &objp->rdevid))
+ return (FALSE);
+ if (!xdr_pointer(xdrs, (char **)&objp->next,
+ sizeof(struct postumntreq),
+ (XDRPROC_T_TYPE) xdr_postumntreq))
+ return (FALSE);
+ return (TRUE);
+}
+
+
+bool_t
+xdr_postumntres(XDR *xdrs, postumntres *objp)
+{
+ if (!xdr_int(xdrs, &objp->status))
+ return (FALSE);
+ return (TRUE);
+}
+
+
+bool_t
+xdr_postmountreq(XDR *xdrs, postmountreq *objp)
+{
+ if (!xdr_string(xdrs, &objp->special, AUTOFS_MAXPATHLEN))
+ return (FALSE);
+ if (!xdr_string(xdrs, &objp->mountp, AUTOFS_MAXPATHLEN))
+ return (FALSE);
+ if (!xdr_string(xdrs, &objp->fstype, AUTOFS_MAXCOMPONENTLEN))
+ return (FALSE);
+ if (!xdr_string(xdrs, &objp->mntopts, AUTOFS_MAXOPTSLEN))
+ return (FALSE);
+ if (!xdr_dev_t(xdrs, &objp->devid))
+ return (FALSE);
+ return (TRUE);
+}
+
+
+bool_t
+xdr_postmountres(XDR *xdrs, postmountres *objp)
+{
+ if (!xdr_int(xdrs, &objp->status))
+ return (FALSE);
+ return (TRUE);
+}
+#endif /* AUTOFS_POSTUNMOUNT */
+
+
+bool_t
+xdr_autofs_res(XDR *xdrs, autofs_res *objp)
+{
+ if (!xdr_enum(xdrs, (enum_t *)objp))
+ return (FALSE);
+ return (TRUE);
+}
+
+
+bool_t
+xdr_autofs_lookupargs(XDR *xdrs, autofs_lookupargs *objp)
+{
+ if (amuDebug(D_XDRTRACE))
+ plog(XLOG_DEBUG, "xdr_autofs_lookupargs:");
+
+ if (!xdr_string(xdrs, &objp->map, AUTOFS_MAXPATHLEN))
+ return (FALSE);
+ if (!xdr_string(xdrs, &objp->path, AUTOFS_MAXPATHLEN))
+ return (FALSE);
+ if (!xdr_string(xdrs, &objp->name, AUTOFS_MAXCOMPONENTLEN))
+ return (FALSE);
+ if (!xdr_string(xdrs, &objp->subdir, AUTOFS_MAXPATHLEN))
+ return (FALSE);
+ if (!xdr_string(xdrs, &objp->opts, AUTOFS_MAXOPTSLEN))
+ return (FALSE);
+ if (!xdr_bool_t(xdrs, &objp->isdirect))
+ return (FALSE);
+ return (TRUE);
+}
+
+
+bool_t
+xdr_mount_result_type(XDR *xdrs, mount_result_type *objp)
+{
+ if (!xdr_autofs_stat(xdrs, &objp->status))
+ return (FALSE);
+ switch (objp->status) {
+ case AUTOFS_ACTION:
+ if (!xdr_pointer(xdrs,
+ (char **)&objp->mount_result_type_u.list,
+ sizeof(action_list), (XDRPROC_T_TYPE) xdr_action_list))
+ return (FALSE);
+ break;
+ case AUTOFS_DONE:
+ if (!xdr_int(xdrs, &objp->mount_result_type_u.error))
+ return (FALSE);
+ break;
+ }
+ return (TRUE);
+}
+
+
+bool_t
+xdr_autofs_mountres(XDR *xdrs, autofs_mountres *objp)
+{
+ if (amuDebug(D_XDRTRACE))
+ plog(XLOG_DEBUG, "xdr_mntres:");
+
+ if (!xdr_mount_result_type(xdrs, &objp->mr_type))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->mr_verbose))
+ return (FALSE);
+
+ return (TRUE);
+}
+
+
+bool_t
+xdr_lookup_result_type(XDR *xdrs, lookup_result_type *objp)
+{
+ if (!xdr_autofs_action(xdrs, &objp->action))
+ return (FALSE);
+ switch (objp->action) {
+ case AUTOFS_LINK_RQ:
+ if (!xdr_linka(xdrs, &objp->lookup_result_type_u.lt_linka))
+ return (FALSE);
+ break;
+ default:
+ break;
+ }
+ return (TRUE);
+}
+
+
+bool_t
+xdr_autofs_lookupres(XDR *xdrs, autofs_lookupres *objp)
+{
+ if (!xdr_autofs_res(xdrs, &objp->lu_res))
+ return (FALSE);
+ if (!xdr_lookup_result_type(xdrs, &objp->lu_type))
+ return (FALSE);
+ if (!xdr_int(xdrs, &objp->lu_verbose))
+ return (FALSE);
+ return (TRUE);
+}
+
+
+bool_t
+xdr_autofs_rddirargs(XDR *xdrs, autofs_rddirargs *objp)
+{
+ if (!xdr_string(xdrs, &objp->rda_map, AUTOFS_MAXPATHLEN))
+ return (FALSE);
+ if (!xdr_u_int(xdrs, (u_int *) &objp->rda_offset))
+ return (FALSE);
+ if (!xdr_u_int(xdrs, (u_int *) &objp->rda_count))
+ return (FALSE);
+ return (TRUE);
+}
+
+
+/*
+ * ENCODE ONLY
+ *
+ * Solaris automountd uses struct autofsrddir to pass the results.
+ * We use the traditional nfsreaddirres and do the conversion ourselves.
+ */
+static bool_t
+xdr_amd_putrddirres(XDR *xdrs, nfsdirlist *dp, ulong reqsize)
+{
+ nfsentry *ep;
+ char *name;
+ u_int namlen;
+ bool_t true = TRUE;
+ bool_t false = FALSE;
+ int entrysz;
+ int tofit;
+ int bufsize;
+ u_long ino, off;
+
+ bufsize = 1 * BYTES_PER_XDR_UNIT;
+ for (ep = dp->dl_entries; ep; ep = ep->ne_nextentry) {
+ name = ep->ne_name;
+ namlen = strlen(name);
+ ino = (u_long) ep->ne_fileid;
+ off = (u_long) ep->ne_cookie + AUTOFS_DAEMONCOOKIE;
+ entrysz = (1 + 1 + 1 + 1) * BYTES_PER_XDR_UNIT +
+ roundup(namlen, BYTES_PER_XDR_UNIT);
+ tofit = entrysz + 2 * BYTES_PER_XDR_UNIT;
+ if (bufsize + tofit > reqsize) {
+ dp->dl_eof = FALSE;
+ break;
+ }
+ if (!xdr_bool(xdrs, &true) ||
+ !xdr_u_long(xdrs, &ino) ||
+ !xdr_bytes(xdrs, &name, &namlen, AUTOFS_MAXPATHLEN) ||
+ !xdr_u_long(xdrs, &off)) {
+ return (FALSE);
+ }
+ bufsize += entrysz;
+ }
+ if (!xdr_bool(xdrs, &false)) {
+ return (FALSE);
+ }
+ if (!xdr_bool(xdrs, &dp->dl_eof)) {
+ return (FALSE);
+ }
+ return (TRUE);
+}
+
+
+static bool_t
+xdr_amd_rddirres(XDR *xdrs, amd_rddirres *objp)
+{
+ if (!xdr_enum(xdrs, (enum_t *)&objp->rd_status))
+ return (FALSE);
+ if (objp->rd_status != AUTOFS_OK)
+ return (TRUE);
+ return (xdr_amd_putrddirres(xdrs, &objp->rd_dl, objp->rd_bufsize));
+}
+
+
+/*
+ * AUTOFS RPC methods
+ */
+
+static int
+autofs_lookup_2_req(autofs_lookupargs *m,
+ autofs_lookupres *res,
+ struct authunix_parms *cred,
+ SVCXPRT *transp)
+{
+ int err;
+ am_node *mp, *new_mp;
+ mntfs *mf;
+
+ dlog("LOOKUP REQUEST: name=%s[%s] map=%s opts=%s path=%s direct=%d",
+ m->name, m->subdir, m->map, m->opts,
+ m->path, m->isdirect);
+
+ /* find the effective uid/gid from RPC request */
+ xsnprintf(opt_uid, sizeof(uid_str), "%d", (int) cred->aup_uid);
+ xsnprintf(opt_gid, sizeof(gid_str), "%d", (int) cred->aup_gid);
+
+ mp = find_ap(m->path);
+ if (!mp) {
+ plog(XLOG_ERROR, "map %s not found", m->path);
+ err = AUTOFS_NOENT;
+ goto out;
+ }
+
+ mf = mp->am_al->al_mnt;
+ new_mp = mf->mf_ops->lookup_child(mp, m->name, &err, VLOOK_LOOKUP);
+ if (!new_mp) {
+ err = AUTOFS_NOENT;
+ goto out;
+ }
+
+ if (err == 0) {
+ plog(XLOG_ERROR, "autofs requests to mount an already mounted node???");
+ } else {
+ free_map(new_mp);
+ }
+ err = AUTOFS_OK;
+ res->lu_type.action = AUTOFS_NONE;
+
+ out:
+ res->lu_res = err;
+ res->lu_verbose = 1;
+
+ dlog("LOOKUP REPLY: status=%d", res->lu_res);
+ return 0;
+}
+
+
+static void
+autofs_lookup_2_free(autofs_lookupres *res)
+{
+ struct linka link;
+
+ if ((res->lu_res == AUTOFS_OK) &&
+ (res->lu_type.action == AUTOFS_LINK_RQ)) {
+ /*
+ * Free link information
+ */
+ link = res->lu_type.lookup_result_type_u.lt_linka;
+ if (link.dir)
+ XFREE(link.dir);
+ if (link.link)
+ XFREE(link.link);
+ }
+}
+
+
+static int
+autofs_mount_2_req(autofs_lookupargs *m,
+ autofs_mountres *res,
+ struct authunix_parms *cred,
+ SVCXPRT *transp)
+{
+ int err = AUTOFS_OK;
+ am_node *mp, *new_mp;
+ mntfs *mf;
+
+ dlog("MOUNT REQUEST: name=%s[%s] map=%s opts=%s path=%s direct=%d",
+ m->name, m->subdir, m->map, m->opts,
+ m->path, m->isdirect);
+
+ /* find the effective uid/gid from RPC request */
+ xsnprintf(opt_uid, sizeof(uid_str), "%d", (int) cred->aup_uid);
+ xsnprintf(opt_gid, sizeof(gid_str), "%d", (int) cred->aup_gid);
+
+ mp = find_ap(m->path);
+ if (!mp) {
+ plog(XLOG_ERROR, "map %s not found", m->path);
+ res->mr_type.status = AUTOFS_DONE;
+ res->mr_type.mount_result_type_u.error = AUTOFS_NOENT;
+ goto out;
+ }
+
+ mf = mp->am_al->al_mnt;
+ new_mp = mf->mf_ops->lookup_child(mp, m->name + m->isdirect, &err, VLOOK_CREATE);
+ if (new_mp && err < 0) {
+ /* new_mp->am_transp = transp; */
+ new_mp = mf->mf_ops->mount_child(new_mp, &err);
+ }
+ if (new_mp == NULL) {
+ if (err < 0) {
+ /* we're working on it */
+ amd_stats.d_drops++;
+ return 1;
+ }
+ res->mr_type.status = AUTOFS_DONE;
+ res->mr_type.mount_result_type_u.error = AUTOFS_NOENT;
+ goto out;
+ }
+
+ if (gopt.flags & CFM_AUTOFS_USE_LOFS ||
+ new_mp->am_al->al_mnt->mf_flags & MFF_ON_AUTOFS) {
+ res->mr_type.status = AUTOFS_DONE;
+ res->mr_type.mount_result_type_u.error = AUTOFS_OK;
+ } else {
+ struct action_list *list = malloc(sizeof(struct action_list));
+ char *target;
+ if (new_mp->am_link)
+ target = new_mp->am_link;
+ else
+ target = new_mp->am_al->al_mnt->mf_mount;
+ list->action.action = AUTOFS_LINK_RQ;
+ list->action.action_list_entry_u.linka.dir = xstrdup(new_mp->am_name);
+ list->action.action_list_entry_u.linka.link = xstrdup(target);
+ list->next = NULL;
+ res->mr_type.status = AUTOFS_ACTION;
+ res->mr_type.mount_result_type_u.list = list;
+ }
+
+out:
+ res->mr_verbose = 1;
+
+ switch (res->mr_type.status) {
+ case AUTOFS_ACTION:
+ dlog("MOUNT REPLY: status=%d, AUTOFS_ACTION", err);
+ break;
+ case AUTOFS_DONE:
+ dlog("MOUNT REPLY: status=%d, AUTOFS_DONE", err);
+ break;
+ default:
+ dlog("MOUNT REPLY: status=%d, UNKNOWN(%d)", err, res->mr_type.status);
+ }
+
+ if (err) {
+ if (m->isdirect) {
+ /* direct mount */
+ plog(XLOG_ERROR, "mount of %s failed", m->path);
+ } else {
+ /* indirect mount */
+ plog(XLOG_ERROR, "mount of %s/%s failed", m->path, m->name);
+ }
+ }
+ return 0;
+}
+
+
+static void
+autofs_mount_2_free(struct autofs_mountres *res)
+{
+ if (res->mr_type.status == AUTOFS_ACTION &&
+ res->mr_type.mount_result_type_u.list != NULL) {
+ autofs_action action;
+ dlog("freeing action list");
+ action = res->mr_type.mount_result_type_u.list->action.action;
+ if (action == AUTOFS_LINK_RQ) {
+ /*
+ * Free link information
+ */
+ struct linka *link;
+ link = &(res->mr_type.mount_result_type_u.list->action.action_list_entry_u.linka);
+ if (link->dir)
+ XFREE(link->dir);
+ if (link->link)
+ XFREE(link->link);
+ } else if (action == AUTOFS_MOUNT_RQ) {
+ struct mounta *mnt;
+ mnt = &(res->mr_type.mount_result_type_u.list->action.action_list_entry_u.mounta);
+ if (mnt->spec)
+ XFREE(mnt->spec);
+ if (mnt->dir)
+ XFREE(mnt->dir);
+ if (mnt->fstype)
+ XFREE(mnt->fstype);
+ if (mnt->dataptr)
+ XFREE(mnt->dataptr);
+#ifdef HAVE_MOUNTA_OPTPTR
+ if (mnt->optptr)
+ XFREE(mnt->optptr);
+#endif /* HAVE_MOUNTA_OPTPTR */
+ }
+ XFREE(res->mr_type.mount_result_type_u.list);
+ }
+}
+
+
+static int
+autofs_unmount_2_req(umntrequest *ul,
+ umntres *res,
+ struct authunix_parms *cred,
+ SVCXPRT *transp)
+{
+ int mapno, err;
+ am_node *mp = NULL;
+
+#ifdef HAVE_STRUCT_UMNTREQUEST_DEVID
+ dlog("UNMOUNT REQUEST: dev=%lx rdev=%lx %s",
+ (u_long) ul->devid,
+ (u_long) ul->rdevid,
+ ul->isdirect ? "direct" : "indirect");
+#else /* not HAVE_STRUCT_UMNTREQUEST_DEVID */
+ dlog("UNMOUNT REQUEST: mntresource='%s' mntpnt='%s' fstype='%s' mntopts='%s' %s",
+ ul->mntresource,
+ ul->mntpnt,
+ ul->fstype,
+ ul->mntopts,
+ ul->isdirect ? "direct" : "indirect");
+#endif /* not HAVE_STRUCT_UMNTREQUEST_DEVID */
+
+ /* by default, and if not found, succeed */
+ res->status = 0;
+
+#ifdef HAVE_STRUCT_UMNTREQUEST_DEVID
+ for (mp = get_first_exported_ap(&mapno);
+ mp;
+ mp = get_next_exported_ap(&mapno)) {
+ if (mp->am_dev == ul->devid &&
+ mp->am_rdev == ul->rdevid)
+ break;
+ }
+#else /* not HAVE_STRUCT_UMNTREQUEST_DEVID */
+ mp = find_ap(ul->mntpnt);
+#endif /* not HAVE_STRUCT_UMNTREQUEST_DEVID */
+
+ if (mp) {
+ /* save RPC context */
+ if (!mp->am_transp && transp) {
+ mp->am_transp = (SVCXPRT *) xmalloc(sizeof(SVCXPRT));
+ *(mp->am_transp) = *transp;
+ }
+
+ mapno = mp->am_mapno;
+ err = unmount_mp(mp);
+
+ if (err)
+ /* backgrounded, don't reply yet */
+ return 1;
+
+ if (get_exported_ap(mapno))
+ /* unmounting failed, tell the kernel */
+ res->status = 1;
+ }
+
+ dlog("UNMOUNT REPLY: status=%d", res->status);
+ return 0;
+}
+
+
+/*
+ * These exist only in the AutoFS V2 protocol.
+ */
+#ifdef AUTOFS_POSTUNMOUNT
+/* XXX not implemented */
+static int
+autofs_postunmount_2_req(postumntreq *req,
+ postumntres *res,
+ struct authunix_parms *cred,
+ SVCXPRT *transp)
+{
+ postumntreq *ul = req;
+
+ dlog("POSTUNMOUNT REQUEST: dev=%lx rdev=%lx",
+ (u_long) ul->devid,
+ (u_long) ul->rdevid);
+
+ /* succeed unconditionally */
+ res->status = 0;
+
+ dlog("POSTUNMOUNT REPLY: status=%d", res->status);
+ return 0;
+}
+
+
+/* XXX not implemented */
+static int
+autofs_postmount_2_req(postmountreq *req,
+ postmountres *res,
+ struct authunix_parms *cred,
+ SVCXPRT *transp)
+{
+ dlog("POSTMOUNT REQUEST: %s\tdev=%lx\tspecial=%s %s",
+ req->mountp, (u_long) req->devid, req->special, req->mntopts);
+
+ /* succeed unconditionally */
+ res->status = 0;
+
+ dlog("POSTMOUNT REPLY: status=%d", res->status);
+ return 0;
+}
+#endif /* AUTOFS_POSTUNMOUNT */
+
+
+static int
+autofs_readdir_2_req(struct autofs_rddirargs *req,
+ struct amd_rddirres *res,
+ struct authunix_parms *cred,
+ SVCXPRT *transp)
+{
+ am_node *mp;
+ int err;
+ static nfsentry e_res[MAX_READDIR_ENTRIES];
+
+ dlog("READDIR REQUEST: %s @ %d",
+ req->rda_map, (int) req->rda_offset);
+
+ mp = find_ap(req->rda_map);
+ if (!mp) {
+ plog(XLOG_ERROR, "map %s not found", req->rda_map);
+ res->rd_status = AUTOFS_NOENT;
+ goto out;
+ }
+
+ mp->am_stats.s_readdir++;
+ req->rda_offset -= AUTOFS_DAEMONCOOKIE;
+ err = mp->am_al->al_mnt->mf_ops->readdir(mp, (char *)&req->rda_offset,
+ &res->rd_dl, e_res, req->rda_count);
+ if (err) {
+ res->rd_status = AUTOFS_ECOMM;
+ goto out;
+ }
+
+ res->rd_status = AUTOFS_OK;
+ res->rd_bufsize = req->rda_count;
+
+out:
+ dlog("READDIR REPLY: status=%d", res->rd_status);
+ return 0;
+}
+
+
+/****************************************************************************/
+/* autofs program dispatcher */
+static void
+autofs_program_2(struct svc_req *rqstp, SVCXPRT *transp)
+{
+ union {
+ autofs_lookupargs autofs_mount_2_arg;
+ autofs_lookupargs autofs_lookup_2_arg;
+ umntrequest autofs_umount_2_arg;
+ autofs_rddirargs autofs_readdir_2_arg;
+#ifdef AUTOFS_POSTUNMOUNT
+ postmountreq autofs_postmount_2_arg;
+ postumntreq autofs_postumnt_2_arg;
+#endif /* AUTOFS_POSTUNMOUNT */
+ } argument;
+
+ union {
+ autofs_mountres mount_res;
+ autofs_lookupres lookup_res;
+ umntres umount_res;
+ amd_rddirres readdir_res;
+#ifdef AUTOFS_POSTUNMOUNT
+ postumntres postumnt_res;
+ postmountres postmnt_res;
+#endif /* AUTOFS_POSTUNMOUNT */
+ } result;
+ int ret;
+
+ bool_t (*xdr_argument)();
+ bool_t (*xdr_result)();
+ int (*local)();
+ void (*local_free)() = NULL;
+
+ current_transp = transp;
+
+ switch (rqstp->rq_proc) {
+
+ case AUTOFS_NULL:
+ svc_sendreply(transp,
+ (XDRPROC_T_TYPE) xdr_void,
+ (SVC_IN_ARG_TYPE) NULL);
+ return;
+
+ case AUTOFS_LOOKUP:
+ xdr_argument = xdr_autofs_lookupargs;
+ xdr_result = xdr_autofs_lookupres;
+ local = autofs_lookup_2_req;
+ local_free = autofs_lookup_2_free;
+ break;
+
+ case AUTOFS_MOUNT:
+ xdr_argument = xdr_autofs_lookupargs;
+ xdr_result = xdr_autofs_mountres;
+ local = autofs_mount_2_req;
+ local_free = autofs_mount_2_free;
+ break;
+
+ case AUTOFS_UNMOUNT:
+ xdr_argument = xdr_umntrequest;
+ xdr_result = xdr_umntres;
+ local = autofs_unmount_2_req;
+ break;
+
+/*
+ * These exist only in the AutoFS V2 protocol.
+ */
+#ifdef AUTOFS_POSTUNMOUNT
+ case AUTOFS_POSTUNMOUNT:
+ xdr_argument = xdr_postumntreq;
+ xdr_result = xdr_postumntres;
+ local = autofs_postunmount_2_req;
+ break;
+
+ case AUTOFS_POSTMOUNT:
+ xdr_argument = xdr_postmountreq;
+ xdr_result = xdr_postmountres;
+ local = autofs_postmount_2_req;
+ break;
+#endif /* AUTOFS_POSTUNMOUNT */
+
+ case AUTOFS_READDIR:
+ xdr_argument = xdr_autofs_rddirargs;
+ xdr_result = xdr_amd_rddirres;
+ local = autofs_readdir_2_req;
+ break;
+
+ default:
+ svcerr_noproc(transp);
+ return;
+ }
+
+ memset((char *) &argument, 0, sizeof(argument));
+ if (!svc_getargs(transp,
+ (XDRPROC_T_TYPE) xdr_argument,
+ (SVC_IN_ARG_TYPE) &argument)) {
+ plog(XLOG_ERROR, "AUTOFS xdr decode failed for %d %d %d",
+ (int) rqstp->rq_prog, (int) rqstp->rq_vers, (int) rqstp->rq_proc);
+ svcerr_decode(transp);
+ return;
+ }
+
+ memset((char *)&result, 0, sizeof(result));
+ ret = (*local) (&argument, &result, rqstp->rq_clntcred, transp);
+
+ current_transp = NULL;
+
+ /* send reply only if the RPC method returned 0 */
+ if (!ret) {
+ if (!svc_sendreply(transp,
+ (XDRPROC_T_TYPE) xdr_result,
+ (SVC_IN_ARG_TYPE) &result)) {
+ svcerr_systemerr(transp);
+ }
+ }
+
+ if (!svc_freeargs(transp,
+ (XDRPROC_T_TYPE) xdr_argument,
+ (SVC_IN_ARG_TYPE) &argument)) {
+ plog(XLOG_FATAL, "unable to free rpc arguments in autofs_program_2");
+ }
+
+ if (local_free)
+ (*local_free)(&result);
+}
+
+
+int
+autofs_get_fh(am_node *mp)
+{
+ autofs_fh_t *fh;
+ char buf[MAXHOSTNAMELEN];
+ mntfs *mf = mp->am_al->al_mnt;
+ struct utsname utsname;
+
+ plog(XLOG_DEBUG, "autofs_get_fh for %s", mp->am_path);
+ fh = ALLOC(autofs_fh_t);
+ memset((voidp) fh, 0, sizeof(autofs_fh_t)); /* Paranoid */
+
+ /*
+ * SET MOUNT ARGS
+ */
+ if (uname(&utsname) < 0) {
+ xstrlcpy(buf, "localhost.autofs", sizeof(buf));
+ } else {
+ xstrlcpy(buf, utsname.nodename, sizeof(buf));
+ xstrlcat(buf, ".autofs", sizeof(buf));
+ }
+#ifdef HAVE_AUTOFS_ARGS_T_ADDR
+ fh->addr.buf = xstrdup(buf);
+ fh->addr.len = fh->addr.maxlen = strlen(buf);
+#endif /* HAVE_AUTOFS_ARGS_T_ADDR */
+
+ fh->direct = ((mf->mf_ops->autofs_fs_flags & FS_DIRECT) == FS_DIRECT);
+ fh->rpc_to = 1; /* XXX: arbitrary */
+ fh->mount_to = mp->am_timeo;
+ fh->path = mp->am_path;
+ fh->opts = ""; /* XXX: arbitrary */
+ fh->map = mp->am_path; /* this is what we get back in readdir */
+ fh->subdir = "";
+ if (fh->direct)
+ fh->key = mp->am_name;
+ else
+ fh->key = "";
+
+ mp->am_autofs_fh = fh;
+ return 0;
+}
+
+
+void
+autofs_mounted(am_node *mp)
+{
+ /* We don't want any timeouts on autofs nodes */
+ mp->am_autofs_ttl = NEVER;
+}
+
+
+void
+autofs_release_fh(am_node *mp)
+{
+ autofs_fh_t *fh = mp->am_autofs_fh;
+#ifdef HAVE_AUTOFS_ARGS_T_ADDR
+ XFREE(fh->addr.buf);
+#endif /* HAVE_AUTOFS_ARGS_T_ADDR */
+ XFREE(fh);
+ mp->am_autofs_fh = NULL;
+}
+
+
+void
+autofs_get_mp(am_node *mp)
+{
+ /* nothing to do */
+}
+
+
+void
+autofs_release_mp(am_node *mp)
+{
+ /* nothing to do */
+}
+
+
+void
+autofs_add_fdset(fd_set *readfds)
+{
+ /* nothing to do */
+}
+
+
+int
+autofs_handle_fdset(fd_set *readfds, int nsel)
+{
+ /* nothing to do */
+ return nsel;
+}
+
+
+/*
+ * Create the autofs service for amd
+ */
+int
+create_autofs_service(void)
+{
+ dlog("creating autofs service listener");
+ return register_autofs_service(AUTOFS_CONFTYPE, autofs_program_2);
+}
+
+
+int
+destroy_autofs_service(void)
+{
+ dlog("destroying autofs service listener");
+ return unregister_autofs_service(AUTOFS_CONFTYPE);
+}
+
+
+int
+autofs_mount_fs(am_node *mp, mntfs *mf)
+{
+ int err = 0;
+ char *target, *target2 = NULL;
+ struct stat buf;
+
+ /*
+ * For sublinks, we could end up here with an already mounted f/s.
+ * Don't do anything in that case.
+ */
+ if (!(mf->mf_flags & MFF_MOUNTED))
+ err = mf->mf_ops->mount_fs(mp, mf);
+
+ if (err || mf->mf_flags & MFF_ON_AUTOFS)
+ /* Nothing else to do */
+ return err;
+
+ if (!(gopt.flags & CFM_AUTOFS_USE_LOFS))
+ /* Symlinks will be requested in autofs_mount_succeeded */
+ return 0;
+
+ if (mp->am_link)
+ target = mp->am_link;
+ else
+ target = mf->mf_mount;
+
+ if (target[0] != '/')
+ target2 = str3cat(NULL, mp->am_parent->am_path, "/", target);
+ else
+ target2 = xstrdup(target);
+
+ plog(XLOG_INFO, "autofs: converting from link to lofs (%s -> %s)", mp->am_path, target2);
+
+ /*
+ * we need to stat() the destination, because the bind mount does not
+ * follow symlinks and/or allow for non-existent destinations.
+ * we fall back to symlinks if there are problems.
+ *
+ * we need to temporarily change pgrp, otherwise our stat() won't
+ * trigger whatever cascading mounts are needed.
+ *
+ * WARNING: we will deadlock if this function is called from the master
+ * amd process and it happens to trigger another auto mount. Therefore,
+ * this function should be called only from a child amd process, or
+ * at the very least it should not be called from the parent unless we
+ * know for sure that it won't cause a recursive mount. We refuse to
+ * cause the recursive mount anyway if called from the parent amd.
+ */
+ if (!foreground) {
+ if ((err = stat(target2, &buf)))
+ goto out;
+ }
+ if ((err = lstat(target2, &buf)))
+ goto out;
+
+ if ((err = mount_lofs(mp->am_path, target2, mf->mf_mopts, 1))) {
+ errno = err;
+ goto out;
+ }
+
+ out:
+ if (target2)
+ XFREE(target2);
+
+ if (err)
+ return errno;
+ return 0;
+}
+
+
+int
+autofs_umount_fs(am_node *mp, mntfs *mf)
+{
+ int err = 0;
+ if (!(mf->mf_flags & MFF_ON_AUTOFS) &&
+ gopt.flags & CFM_AUTOFS_USE_LOFS) {
+ err = UMOUNT_FS(mp->am_path, mnttab_file_name, 1);
+ if (err)
+ return err;
+ }
+
+ /*
+ * Multiple sublinks could reference this f/s.
+ * Don't actually unmount it unless we're holding the last reference.
+ */
+ if (mf->mf_refc == 1)
+ err = mf->mf_ops->umount_fs(mp, mf);
+ return err;
+}
+
+
+int
+autofs_umount_succeeded(am_node *mp)
+{
+ umntres res;
+ SVCXPRT *transp = mp->am_transp;
+
+ if (transp) {
+ res.status = 0;
+
+ if (!svc_sendreply(transp,
+ (XDRPROC_T_TYPE) xdr_umntres,
+ (SVC_IN_ARG_TYPE) &res))
+ svcerr_systemerr(transp);
+
+ dlog("Quick reply sent for %s", mp->am_al->al_mnt->mf_mount);
+ XFREE(transp);
+ mp->am_transp = NULL;
+ }
+
+ plog(XLOG_INFO, "autofs: unmounting %s succeeded", mp->am_path);
+ return 0;
+}
+
+
+int
+autofs_umount_failed(am_node *mp)
+{
+ umntres res;
+ SVCXPRT *transp = mp->am_transp;
+
+ if (transp) {
+ res.status = 1;
+
+ if (!svc_sendreply(transp,
+ (XDRPROC_T_TYPE) xdr_umntres,
+ (SVC_IN_ARG_TYPE) &res))
+ svcerr_systemerr(transp);
+
+ dlog("Quick reply sent for %s", mp->am_al->al_mnt->mf_mount);
+ XFREE(transp);
+ mp->am_transp = NULL;
+ }
+
+ plog(XLOG_INFO, "autofs: unmounting %s failed", mp->am_path);
+ return 0;
+}
+
+
+void
+autofs_mount_succeeded(am_node *mp)
+{
+ SVCXPRT *transp = mp->am_transp;
+ struct stat stb;
+
+ /*
+ * Store dev and rdev -- but not for symlinks
+ */
+ if (gopt.flags & CFM_AUTOFS_USE_LOFS ||
+ mp->am_al->al_mnt->mf_flags & MFF_ON_AUTOFS) {
+ if (!lstat(mp->am_path, &stb)) {
+ mp->am_dev = stb.st_dev;
+ mp->am_rdev = stb.st_rdev;
+ }
+ /* don't expire the entries -- the kernel will do it for us */
+ mp->am_flags |= AMF_NOTIMEOUT;
+ }
+
+ if (transp) {
+ autofs_mountres res;
+ res.mr_type.status = AUTOFS_DONE;
+ res.mr_type.mount_result_type_u.error = AUTOFS_OK;
+ res.mr_verbose = 1;
+
+ if (!svc_sendreply(transp,
+ (XDRPROC_T_TYPE) xdr_autofs_mountres,
+ (SVC_IN_ARG_TYPE) &res))
+ svcerr_systemerr(transp);
+
+ dlog("Quick reply sent for %s", mp->am_al->al_mnt->mf_mount);
+ XFREE(transp);
+ mp->am_transp = NULL;
+ }
+
+ plog(XLOG_INFO, "autofs: mounting %s succeeded", mp->am_path);
+}
+
+
+void
+autofs_mount_failed(am_node *mp)
+{
+ SVCXPRT *transp = mp->am_transp;
+
+ if (transp) {
+ autofs_mountres res;
+ res.mr_type.status = AUTOFS_DONE;
+ res.mr_type.mount_result_type_u.error = AUTOFS_NOENT;
+ res.mr_verbose = 1;
+
+ if (!svc_sendreply(transp,
+ (XDRPROC_T_TYPE) xdr_autofs_mountres,
+ (SVC_IN_ARG_TYPE) &res))
+ svcerr_systemerr(transp);
+
+ dlog("Quick reply sent for %s", mp->am_al->al_mnt->mf_mount);
+ XFREE(transp);
+ mp->am_transp = NULL;
+ }
+
+ plog(XLOG_INFO, "autofs: mounting %s failed", mp->am_path);
+}
+
+
+void
+autofs_get_opts(char *opts, size_t l, autofs_fh_t *fh)
+{
+ xsnprintf(opts, l, "%sdirect",
+ fh->direct ? "" : "in");
+}
+
+
+int
+autofs_compute_mount_flags(mntent_t *mntp)
+{
+ /* Must use overlay mounts */
+ return MNT2_GEN_OPT_OVERLAY;
+}
+
+
+void autofs_timeout_mp(am_node *mp)
+{
+ /* We don't want any timeouts on autofs nodes */
+ mp->am_autofs_ttl = NEVER;
+}
diff --git a/conf/autofs/autofs_solaris_v2_v3.h b/conf/autofs/autofs_solaris_v2_v3.h
new file mode 100644
index 000000000000..5d6ec54509c2
--- /dev/null
+++ b/conf/autofs/autofs_solaris_v2_v3.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 1999-2003 Ion Badulescu
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/autofs/autofs_solaris_v2_v3.h
+ *
+ */
+
+/*
+ * Automounter filesystem headers for Solaris v2-v3
+ */
+
+#ifdef HAVE_FS_AUTOFS
+typedef struct autofs_args autofs_fh_t;
+
+#define AUTOFS_AUTO_FS_FLAGS (FS_AMQINFO | FS_DIRECTORY | FS_AUTOFS | FS_ON_AUTOFS)
+#define AUTOFS_DIRECT_FS_FLAGS (FS_DIRECT | FS_NOTIMEOUT | FS_BACKGROUND | FS_AMQINFO | FS_DIRECTORY | FS_AUTOFS)
+#define AUTOFS_ERROR_FS_FLAGS (FS_DISCARD)
+#define AUTOFS_HOST_FS_FLAGS (FS_MKMNT | FS_BACKGROUND | FS_AMQINFO)
+#define AUTOFS_LINK_FS_FLAGS (FS_MBACKGROUND)
+#define AUTOFS_LINKX_FS_FLAGS (FS_MBACKGROUND)
+#define AUTOFS_NFSL_FS_FLAGS (FS_BACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#define AUTOFS_NFSX_FS_FLAGS (/* FS_UBACKGROUND| */ FS_AMQINFO )
+#define AUTOFS_PROGRAM_FS_FLAGS (FS_BACKGROUND | FS_AMQINFO)
+#define AUTOFS_ROOT_FS_FLAGS (FS_NOTIMEOUT | FS_AMQINFO | FS_DIRECTORY)
+#define AUTOFS_TOPLVL_FS_FLAGS (FS_MKMNT | FS_NOTIMEOUT | FS_BACKGROUND | FS_AMQINFO | FS_DIRECTORY | FS_AUTOFS)
+#define AUTOFS_UNION_FS_FLAGS (FS_NOTIMEOUT | FS_BACKGROUND | FS_AMQINFO | FS_DIRECTORY | FS_ON_AUTOFS)
+
+#define AUTOFS_CACHEFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#define AUTOFS_CDFS_FS_FLAGS (FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#define AUTOFS_EFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#define AUTOFS_LOFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#define AUTOFS_NFS_FS_FLAGS (FS_BACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#define AUTOFS_PCFS_FS_FLAGS (FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#define AUTOFS_UFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#define AUTOFS_XFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS)
+#endif /* HAVE_FS_AUTOFS */
diff --git a/conf/checkmount/checkmount_aix.c b/conf/checkmount/checkmount_aix.c
new file mode 100644
index 000000000000..599c136facfe
--- /dev/null
+++ b/conf/checkmount/checkmount_aix.c
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/checkmount/checkmount_aix.c
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <am_defs.h>
+
+
+/*
+ * These were missing external definitions from old AIX's headers. They
+ * appear to be available in <sys/vmount.h> on AIX 5.3, and possibly
+ * earlier. Hence I commented this out.
+ */
+#ifndef HAVE_EXTERN_MNTCTL
+extern int mntctl(int cmd, int size, voidp buf);
+#endif /* not HAVE_EXTERN_MNTCTL */
+extern int is_same_host(char *name1, char *name2, struct in_addr addr2);
+
+
+int
+fixmount_check_mount(char *host, struct in_addr hostaddr, char *path)
+{
+ int ret, i;
+ char *mntinfo = NULL, *cp;
+ char *short_hostname, *long_hostname, *mount_point;
+ struct vmount *vp;
+
+ /*
+ * First figure out size of mount table and allocate space for a copy...
+ * Then get mount table for real.
+ */
+ ret = mntctl(MCTL_QUERY, sizeof(i), (char *) &i);
+ if (ret == 0) {
+ mntinfo = xmalloc(i);
+ ret = mntctl(MCTL_QUERY, i, mntinfo);
+ }
+ if (ret <= 0) {
+ fprintf(stderr, "mntctl: %m");
+ XFREE(mntinfo);
+ exit(1);
+ }
+
+ /* iterate over each vmount structure */
+ for (i = 0, cp = mntinfo; i < ret; i++, cp += vp->vmt_length) {
+ vp = (struct vmount *) cp;
+ mount_point = vmt2dataptr(vp, VMT_STUB);
+ long_hostname = vmt2dataptr(vp, VMT_HOSTNAME);
+ short_hostname = vmt2dataptr(vp, VMT_HOST);
+ if (STREQ(path, mount_point) &&
+ (is_same_host(long_hostname, host, hostaddr) ||
+ is_same_host(short_hostname, host, hostaddr)))
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/conf/checkmount/checkmount_bsd44.c b/conf/checkmount/checkmount_bsd44.c
index a6ec2438da88..6c6b21dcb4a2 100644
--- a/conf/checkmount/checkmount_bsd44.c
+++ b/conf/checkmount/checkmount_bsd44.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2006 Erez Zadok
+ * Copyright (c) 1997-2014 Erez Zadok
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
@@ -16,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgment:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -45,6 +41,9 @@
# include <config.h>
#endif /* HAVE_CONFIG_H */
#include <am_defs.h>
+#if __NetBSD_Version__ > 200030000
+#define statfs statvfs
+#endif
extern int is_same_host(char *name1, char *name2, struct in_addr addr2);
int fixmount_check_mount(char *host, struct in_addr hostaddr, char *path);
diff --git a/conf/checkmount/checkmount_default.c b/conf/checkmount/checkmount_default.c
new file mode 100644
index 000000000000..18d8fe335fec
--- /dev/null
+++ b/conf/checkmount/checkmount_default.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/checkmount/checkmount_default.c
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <am_defs.h>
+
+#ifndef _PATH_MTAB
+#define _PATH_MTAB "/etc/mtab"
+#endif /* not _PATH_MTAB */
+
+extern int is_same_host(char *name1, char *name2, struct in_addr addr2);
+
+
+int
+fixmount_check_mount(char *host, struct in_addr hostaddr, char *path)
+{
+ FILE *mtab;
+ mntent_t *ment;
+ int found = 0;
+
+ /* scan mtab for path */
+ if (!(mtab = setmntent(_PATH_MTAB, "r"))) {
+ perror(_PATH_MTAB);
+ exit(1);
+ }
+
+ /*
+ * setmntent() doesn't do locking in read-only mode. Too bad -- it seems to
+ * rely on mount() and friends to do atomic updates by renaming the file.
+ * Well, our patched amd rewrites mtab in place to avoid NFS lossage, so
+ * better do the locking ourselves.
+ */
+#ifdef HAVE_FLOCK
+ if (flock(fileno(mtab), LOCK_SH) < 0) {
+#else /* not HAVE_FLOCK */
+ if (lockf(fileno(mtab), F_LOCK, 0) < 0) {
+#endif /* not HAVE_FLOCK */
+ perror(_PATH_MTAB);
+ exit(1);
+ }
+
+ while (!found && (ment = getmntent(mtab))) {
+ char *colon;
+
+ if ((colon = strchr(ment->mnt_fsname, ':'))) {
+ *colon = '\0';
+ if ((STREQ(colon + 1, path) ||
+ STREQ(ment->mnt_dir, path)) &&
+ is_same_host(ment->mnt_fsname, host, hostaddr))
+ found = 1;
+ }
+ }
+
+ (void) endmntent(mtab);
+
+ if (!found) {
+ char *swap;
+
+ /* swap files never show up in mtab, only root fs */
+ if ((swap = strstr(path, "swap"))) {
+ strncpy(swap, "root", 4); /* this should NOT use xstrlcpy */
+ found = fixmount_check_mount(host, hostaddr, path);
+ strncpy(swap, "swap", 4); /* this should NOT use xstrlcpy */
+ }
+ }
+ return found;
+}
diff --git a/conf/checkmount/checkmount_osf.c b/conf/checkmount/checkmount_osf.c
new file mode 100644
index 000000000000..530433ce232f
--- /dev/null
+++ b/conf/checkmount/checkmount_osf.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/checkmount/checkmount_osf.c
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <am_defs.h>
+
+extern int is_same_host(char *name1, char *name2, struct in_addr addr2);
+
+
+int
+fixmount_check_mount(char *host, struct in_addr hostaddr, char *path)
+{
+ int nentries, i;
+ struct statfs *fslist;
+ int found = 0;
+
+ nentries = getmntinfo(&fslist, MNT_NOWAIT);
+ if (nentries <= 0) {
+ perror("getmntinfo");
+ exit(1);
+ }
+
+ for (i = 0; !found && (i < nentries); i++) {
+ char *delim;
+
+ /*
+ * Apparently two forms of nfs mount syntax are
+ * accepted: host:/path or /path@host
+ */
+ if ((delim = strchr(fslist[i].f_mntfromname, ':'))) {
+ *delim = '\0';
+ if ((STREQ(delim + 1, path) ||
+ STREQ(fslist[i].f_mntonname, path)) &&
+ is_same_host(fslist[i].f_mntfromname,
+ host, hostaddr))
+ found = 1;
+ } else if ((delim = strchr(fslist[i].f_mntfromname, '@'))) {
+ *delim = '\0';
+ if ((STREQ(fslist[i].f_mntfromname, path) ||
+ STREQ(fslist[i].f_mntonname, path)) &&
+ is_same_host(delim + 1, host, hostaddr))
+ found = 1;
+ }
+ }
+
+ return found;
+}
diff --git a/conf/checkmount/checkmount_svr4.c b/conf/checkmount/checkmount_svr4.c
new file mode 100644
index 000000000000..4294c2cd42a7
--- /dev/null
+++ b/conf/checkmount/checkmount_svr4.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/checkmount/checkmount_svr4.c
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <am_defs.h>
+
+extern int is_same_host(char *name1, char *name2, struct in_addr addr2);
+
+
+int
+fixmount_check_mount(char *host, struct in_addr hostaddr, char *path)
+{
+ FILE *mtab;
+ struct mnttab ment;
+ int err = 0;
+ int found = 0;
+
+ /* scan mtab for path */
+ if (!(mtab = fopen(MNTTAB, "r"))) {
+ perror(MNTTAB);
+ exit(1);
+ }
+
+ while (!found && (err = getmntent(mtab, &ment)) == 0) {
+ char *colon;
+
+ if ((colon = strchr(ment.mnt_fsname, ':'))) {
+ *colon = '\0';
+ if ((STREQ(colon + 1, path) ||
+ STREQ(ment.mnt_dir, path)) &&
+ is_same_host(ment.mnt_fsname, host, hostaddr))
+ found = 1;
+ }
+ }
+
+ if (err > 0) {
+ fprintf(stderr, "getmntent: %s: %s\n", MNTTAB,
+ err == MNT_TOOLONG ? "entry exceeds MNT_LINE_MAX" :
+ err == MNT_TOOMANY ? "too many fields in line" :
+ err == MNT_TOOFEW ? "too few fields in line" :
+ "unknown error code");
+ exit(1);
+ }
+ (void) fclose(mtab);
+
+ /* XXX: Is this still valid in SunOS 5.x ? */
+ if (!found) {
+ char *swap;
+
+ /* swap files never show up in mtab, only root fs */
+ if ((swap = strstr(path, "swap"))) {
+ strncpy(swap, "root", 4); /* this should NOT use xstrlcpy */
+ found = fixmount_check_mount(host, hostaddr, path);
+ strncpy(swap, "swap", 4); /* this should NOT use xstrlcpy */
+ }
+ }
+ return found;
+}
diff --git a/conf/checkmount/checkmount_ultrix.c b/conf/checkmount/checkmount_ultrix.c
new file mode 100644
index 000000000000..fd67ff453a3e
--- /dev/null
+++ b/conf/checkmount/checkmount_ultrix.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/checkmount/checkmount_ultrix.c
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <am_defs.h>
+
+extern int is_same_host(char *name1, char *name2, struct in_addr addr2);
+
+
+int
+fixmount_check_mount(char *host, struct in_addr hostaddr, char *path)
+{
+ int start = 0;
+ int err = 0;
+ struct fs_data ment;
+ int found = 0;
+
+ /* scan mtab for path */
+ while (!found && (err = getmnt(&start, &ment, sizeof(ment),
+ NOSTAT_MANY, NULL)) > 0) {
+ char *colon;
+
+ if (colon = strchr(ment.fd_devname, ':')) {
+ *colon = '\0';
+ if ((STREQ(colon + 1, path) ||
+ STREQ(ment.fd_path, path)) &&
+ is_same_host(ment.fd_devname, host, hostaddr))
+ found = 1;
+ }
+ }
+
+ if (!found && err < 0) {
+ perror("getmnt");
+ exit(1);
+ }
+ return found;
+}
diff --git a/conf/fh_dref/fh_dref_aix3.h b/conf/fh_dref/fh_dref_aix3.h
new file mode 100644
index 000000000000..c7abaa03b1b1
--- /dev/null
+++ b/conf/fh_dref/fh_dref_aix3.h
@@ -0,0 +1,2 @@
+/* $srcdir/conf/fh_dref/fh_dref_aix3.h */
+#define NFS_FH_DREF(dst, src) memcpy((char *) &(dst.x), (char *) src, sizeof(struct nfs_fh))
diff --git a/conf/fh_dref/fh_dref_aix42.h b/conf/fh_dref/fh_dref_aix42.h
new file mode 100644
index 000000000000..02ba30502274
--- /dev/null
+++ b/conf/fh_dref/fh_dref_aix42.h
@@ -0,0 +1,2 @@
+/* $srcdir/conf/fh_dref/fh_dref_aix42.h */
+#define NFS_FH_DREF(dst, src) (dst) = (caddr_t)(src)
diff --git a/conf/fh_dref/fh_dref_bsd44.h b/conf/fh_dref/fh_dref_bsd44.h
new file mode 100644
index 000000000000..72ec8cfa6202
--- /dev/null
+++ b/conf/fh_dref/fh_dref_bsd44.h
@@ -0,0 +1,2 @@
+/* $srcdir/conf/fh_dref/fh_dref_bsd44.h */
+#define NFS_FH_DREF(dst, src) (dst) = (nfsv2fh_t *) (src)
diff --git a/conf/fh_dref/fh_dref_default.h b/conf/fh_dref/fh_dref_default.h
new file mode 100644
index 000000000000..9a074760fae2
--- /dev/null
+++ b/conf/fh_dref/fh_dref_default.h
@@ -0,0 +1,2 @@
+/* $srcdir/conf/fh_dref/fh_dref_default.h */
+#define NFS_FH_DREF(dst, src) (dst) = (src)
diff --git a/conf/fh_dref/fh_dref_hpux.h b/conf/fh_dref/fh_dref_hpux.h
new file mode 100644
index 000000000000..b3a75708f8df
--- /dev/null
+++ b/conf/fh_dref/fh_dref_hpux.h
@@ -0,0 +1,2 @@
+/* $srcdir/conf/fh_dref/fh_dref_hpux.h */
+#define NFS_FH_DREF(dst, src) (dst) = (fhandle_t *) (src)
diff --git a/conf/fh_dref/fh_dref_irix.h b/conf/fh_dref/fh_dref_irix.h
new file mode 100644
index 000000000000..1a5de2026bd3
--- /dev/null
+++ b/conf/fh_dref/fh_dref_irix.h
@@ -0,0 +1,2 @@
+/* $srcdir/conf/fh_dref/fh_dref_irix.h */
+#define NFS_FH_DREF(dst, src) (dst) = (fhandle_t *) (src)
diff --git a/conf/fh_dref/fh_dref_isc3.h b/conf/fh_dref/fh_dref_isc3.h
new file mode 100644
index 000000000000..0ff1ad4b9158
--- /dev/null
+++ b/conf/fh_dref/fh_dref_isc3.h
@@ -0,0 +1,2 @@
+/* $srcdir/conf/fh_dref/fh_dref_isc3.h */
+#define NFS_FH_DREF(dst, src) (dst) = *(src)
diff --git a/conf/fh_dref/fh_dref_linux.h b/conf/fh_dref/fh_dref_linux.h
new file mode 100644
index 000000000000..7ffa5b506952
--- /dev/null
+++ b/conf/fh_dref/fh_dref_linux.h
@@ -0,0 +1,2 @@
+/* $srcdir/conf/fh_dref/fh_dref_linux.h */
+#define NFS_FH_DREF(dst, src) memcpy((char *) &(dst.data), (char *) src, sizeof(struct nfs_fh))
diff --git a/conf/fh_dref/fh_dref_nextstep.h b/conf/fh_dref/fh_dref_nextstep.h
new file mode 100644
index 000000000000..819035443ea7
--- /dev/null
+++ b/conf/fh_dref/fh_dref_nextstep.h
@@ -0,0 +1,2 @@
+/* $srcdir/conf/fh_dref/fh_dref_nextstep.h */
+#define NFS_FH_DREF(dst, src) (dst) = (caddr_t) (src)
diff --git a/conf/fh_dref/fh_dref_osf2.h b/conf/fh_dref/fh_dref_osf2.h
new file mode 100644
index 000000000000..74669a76b7dd
--- /dev/null
+++ b/conf/fh_dref/fh_dref_osf2.h
@@ -0,0 +1,2 @@
+/* $srcdir/conf/fh_dref/fh_dref_osf2.h */
+#define NFS_FH_DREF(dst, src) (dst) = (nfsv2fh_t *) (src)
diff --git a/conf/fh_dref/fh_dref_osf4.h b/conf/fh_dref/fh_dref_osf4.h
new file mode 100644
index 000000000000..5bb073c27634
--- /dev/null
+++ b/conf/fh_dref/fh_dref_osf4.h
@@ -0,0 +1,2 @@
+/* $srcdir/conf/fh_dref/fh_dref_osf4.h */
+#define NFS_FH_DREF(dst, src) (dst) = (caddr_t) (src)
diff --git a/conf/fh_dref/fh_dref_sunos3.h b/conf/fh_dref/fh_dref_sunos3.h
new file mode 100644
index 000000000000..c3dd0b60441f
--- /dev/null
+++ b/conf/fh_dref/fh_dref_sunos3.h
@@ -0,0 +1,2 @@
+/* $srcdir/conf/fh_dref/fh_dref_sunos3.h */
+#define NFS_FH_DREF(dst, src) (dst) = (caddr_t) (src)
diff --git a/conf/fh_dref/fh_dref_sunos4.h b/conf/fh_dref/fh_dref_sunos4.h
new file mode 100644
index 000000000000..f13c6bef3d44
--- /dev/null
+++ b/conf/fh_dref/fh_dref_sunos4.h
@@ -0,0 +1,2 @@
+/* $srcdir/conf/fh_dref/fh_dref_sunos4.h */
+#define NFS_FH_DREF(dst, src) (dst) = (caddr_t) (src)
diff --git a/conf/fh_dref/fh_dref_svr4.h b/conf/fh_dref/fh_dref_svr4.h
new file mode 100644
index 000000000000..2b9b686b88f2
--- /dev/null
+++ b/conf/fh_dref/fh_dref_svr4.h
@@ -0,0 +1,2 @@
+/* $srcdir/conf/fh_dref/fh_dref_svr4.h */
+#define NFS_FH_DREF(dst, src) (dst) = (caddr_t) (src)
diff --git a/conf/hn_dref/hn_dref_isc3.h b/conf/hn_dref/hn_dref_isc3.h
new file mode 100644
index 000000000000..82291c19fcf8
--- /dev/null
+++ b/conf/hn_dref/hn_dref_isc3.h
@@ -0,0 +1,2 @@
+/* $srcdir/conf/hn_dref/hn_dref_isc3.h */
+#define NFS_HN_DREF(dst, src) xstrlcpy((dst), (src), MAXHOSTNAMELEN)
diff --git a/conf/hn_dref/hn_dref_linux.h b/conf/hn_dref/hn_dref_linux.h
new file mode 100644
index 000000000000..cf01d300a8a6
--- /dev/null
+++ b/conf/hn_dref/hn_dref_linux.h
@@ -0,0 +1,2 @@
+/* $srcdir/conf/hn_dref/hn_dref_linux.h */
+#define NFS_HN_DREF(dst, src) xstrlcpy((dst), (src), MAXHOSTNAMELEN)
diff --git a/conf/mount/mount_aix.c b/conf/mount/mount_aix.c
new file mode 100644
index 000000000000..6cb832611148
--- /dev/null
+++ b/conf/mount/mount_aix.c
@@ -0,0 +1,182 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/mount/mount_aix.c
+ *
+ */
+
+/*
+ * AIX 5.x Mount helper
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <am_defs.h>
+#include <amu.h>
+
+#define VMT_ROUNDUP(len) (4 * ((len + 3) / 4))
+#define VMT_ASSIGN(vp, idx, data, size) \
+ vp->vmt_data[idx].vmt_off = p - (char *) vp; \
+ vp->vmt_data[idx].vmt_size = size; \
+ memmove(p, data, size); \
+ p += VMT_ROUNDUP(size);
+
+/* missing external definitions from AIX's headers */
+extern int vmount(struct vmount *vmount, int size);
+
+
+static int
+aix5_mkvp(char *p, int gfstype, int flags, char *object, char *stub, char *host, char *info, int info_size, char *args)
+{
+ struct vmount *vp = (struct vmount *) p;
+
+ memset((voidp) vp, 0, sizeof(*vp));
+ /*
+ * Fill in standard fields
+ */
+ vp->vmt_revision = VMT_REVISION;
+ vp->vmt_flags = flags;
+ vp->vmt_gfstype = gfstype;
+
+ /*
+ * Fill in all variable length data
+ */
+ p += sizeof(*vp);
+
+ VMT_ASSIGN(vp, VMT_OBJECT, object, strlen(object) + 1);
+ VMT_ASSIGN(vp, VMT_STUB, stub, strlen(stub) + 1);
+ VMT_ASSIGN(vp, VMT_HOST, host, strlen(host) + 1);
+ VMT_ASSIGN(vp, VMT_HOSTNAME, host, strlen(host) + 1);
+ VMT_ASSIGN(vp, VMT_INFO, info, info_size);
+ VMT_ASSIGN(vp, VMT_ARGS, args, strlen(args) + 1);
+
+ /*
+ * Return length
+ */
+ return vp->vmt_length = p - (char *) vp;
+}
+
+
+/*
+ * Map from conventional mount arguments to AIX 3,x style arguments.
+ * But we avoid all the messy BIS stuff for AIX 5.x
+ */
+int
+mount_aix3(char *fsname, char *dir, int flags, int type, void *data, char *mnt_opts)
+{
+ char buf[4096];
+ int size, ret;
+ int real_size = sizeof(nfs_args_t); /* size passed to aix5_mkvp() */
+ char *real_args = data; /* args passed to aix5_mkvp() */
+ char *host, *rfs, *idx;
+ int aix_type = type;
+#ifdef HAVE_FS_NFS3
+ struct nfs_args v2args;
+ nfs_args_t *v3args = (nfs_args_t *) data;
+#endif /* HAVE_FS_NFS3 */
+
+#ifdef DEBUG
+ dlog("mount_aix3: fsname %s, dir %s, type %d", fsname, dir, type);
+#endif /* DEBUG */
+
+ switch (aix_type) {
+
+ case MOUNT_TYPE_NFS:
+
+#ifdef HAVE_FS_NFS3
+ /*
+ * This is tricky. If we have v3 support, but this nfs mount is v2,
+ * then I must copy the arguments from the v3 nfs_args to the v2 one.
+ */
+ memmove((voidp) &v2args.addr, (voidp) &v3args->addr, sizeof(struct sockaddr_in));
+ v2args.hostname = v3args->hostname;
+ v2args.netname = v3args->netname;
+ memmove((voidp) v2args.fh.x, v3args->fh, FHSIZE);
+ v2args.flags = v3args->flags;
+ v2args.wsize = v3args->wsize;
+ v2args.rsize = v3args->rsize;
+ v2args.timeo = v3args->timeo;
+ v2args.retrans = v3args->retrans;
+ v2args.acregmin = v3args->acregmin;
+ v2args.acregmax = v3args->acregmax;
+ v2args.acdirmin = v3args->acdirmin;
+ v2args.acdirmax = v3args->acdirmax;
+ v2args.pathconf = v3args->pathconf;
+
+ /* now set real_* stuff */
+ real_size = sizeof(v2args);
+ real_args = (char *) &v2args;
+
+ case MOUNT_TYPE_NFS3:
+#endif /* HAVE_FS_NFS3 */
+
+ idx = strchr(fsname, ':');
+ if (idx) {
+ *idx = '\0';
+ rfs = xstrdup(idx + 1);
+ host = xstrdup(fsname);
+ *idx = ':';
+ } else {
+ rfs = xstrdup(fsname);
+ host = xstrdup(am_get_hostname());
+ }
+
+ size = aix5_mkvp(buf, type, flags, rfs, dir, host,
+ real_args, real_size, mnt_opts);
+ XFREE(rfs);
+ XFREE(host);
+ break;
+
+ case MOUNT_TYPE_UFS:
+ /* Need to open block device and extract log device info from sblk. */
+ return EINVAL;
+
+ default:
+ return EINVAL;
+ }
+
+ /*
+ * XXX: Warning, if vmount() hangs your amd in AIX 5.1, it
+ * is because of a kernel bug in the NFS code. Get a patch from IBM
+ * or upgrade to 5.2.
+ */
+ ret = vmount((struct vmount *)buf, size);
+ if (ret < 0) {
+ plog(XLOG_ERROR, "mount_aix3: vmount failed with errno %d", errno);
+ perror ("vmount");
+ }
+ return ret;
+}
diff --git a/conf/mount/mount_aix3.c b/conf/mount/mount_aix3.c
new file mode 100644
index 000000000000..5e66791b270f
--- /dev/null
+++ b/conf/mount/mount_aix3.c
@@ -0,0 +1,225 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/mount/mount_aix3.c
+ *
+ */
+
+/*
+ * AIX 3.x/4.x Mount helper
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <am_defs.h>
+#include <amu.h>
+
+#define VMT_ROUNDUP(len) (4 * ((len + 3) / 4))
+#define VMT_ASSIGN(vp, idx, data, size) \
+ vp->vmt_data[idx].vmt_off = p - (char *) vp; \
+ vp->vmt_data[idx].vmt_size = size; \
+ memmove(p, data, size); \
+ p += VMT_ROUNDUP(size);
+
+/* missing external definitions from AIX's headers */
+extern int vmount(struct vmount *vmount, int size);
+
+
+static int
+aix3_mkvp(char *p, int gfstype, int flags, char *object, char *stub, char *host, char *info, int info_size, char *args)
+{
+ struct vmount *vp = (struct vmount *) p;
+
+ memset((voidp) vp, 0, sizeof(*vp));
+ /*
+ * Fill in standard fields
+ */
+ vp->vmt_revision = VMT_REVISION;
+ vp->vmt_flags = flags;
+ vp->vmt_gfstype = gfstype;
+
+ /*
+ * Fill in all variable length data
+ */
+ p += sizeof(*vp);
+
+ VMT_ASSIGN(vp, VMT_OBJECT, object, strlen(object) + 1);
+ VMT_ASSIGN(vp, VMT_STUB, stub, strlen(stub) + 1);
+ VMT_ASSIGN(vp, VMT_HOST, host, strlen(host) + 1);
+ VMT_ASSIGN(vp, VMT_HOSTNAME, host, strlen(host) + 1);
+ VMT_ASSIGN(vp, VMT_INFO, info, info_size);
+ VMT_ASSIGN(vp, VMT_ARGS, args, strlen(args) + 1);
+
+ /*
+ * Return length
+ */
+ return vp->vmt_length = p - (char *) vp;
+}
+
+
+/*
+ * Map from conventional mount arguments
+ * to AIX 3-style arguments.
+ */
+int
+mount_aix3(char *fsname, char *dir, int flags, int type, void *data, char *mnt_opts)
+{
+ char buf[4096];
+ int size, ret;
+ int real_size = sizeof(nfs_args_t); /* size passed to aix3_mkvp() */
+ char *real_args = data; /* args passed to aix3_mkvp() */
+ char *host, *rfs, *idx;
+ int aix_type = type;
+#ifdef HAVE_FS_NFS3
+ struct nfs_args v2args;
+ nfs_args_t *v3args = (nfs_args_t *) data;
+#ifdef MOUNT_TYPE_NFS3_BIS
+ struct aix4_nfs_args_bis v3args_bis;
+#endif /* MOUNT_TYPE_NFS3_BIS */
+#endif /* HAVE_FS_NFS3 */
+
+#ifdef DEBUG
+ dlog("mount_aix3: fsname %s, dir %s, type %d", fsname, dir, type);
+#endif /* DEBUG */
+
+#ifdef MOUNT_TYPE_NFS3_BIS
+ retry_ibm_buggy_service_pack:
+#endif /* MOUNT_TYPE_NFS3_BIS */
+ switch (aix_type) {
+
+ case MOUNT_TYPE_NFS:
+
+#ifdef HAVE_FS_NFS3
+ /*
+ * This is tricky. If we have v3 support, but this nfs mount is v2,
+ * then I must copy the arguments from the v3 nfs_args to the v2 one.
+ */
+ memmove((voidp) &v2args.addr, (voidp) &v3args->addr, sizeof(struct sockaddr_in));
+ v2args.hostname = v3args->hostname;
+ v2args.netname = v3args->netname;
+ memmove((voidp) v2args.fh, v3args->fh, FHSIZE);
+ v2args.flags = v3args->flags;
+ v2args.wsize = v3args->wsize;
+ v2args.rsize = v3args->rsize;
+ v2args.timeo = v3args->timeo;
+ v2args.retrans = v3args->retrans;
+ v2args.acregmin = v3args->acregmin;
+ v2args.acregmax = v3args->acregmax;
+ v2args.acdirmin = v3args->acdirmin;
+ v2args.acdirmax = v3args->acdirmax;
+ v2args.pathconf = v3args->pathconf;
+
+ /* now set real_* stuff */
+ real_size = sizeof(v2args);
+ real_args = (char *) &v2args;
+
+ case MOUNT_TYPE_NFS3:
+#ifdef MOUNT_TYPE_NFS3_BIS
+ case MOUNT_TYPE_NFS3_BIS:
+ /* just fall through */
+ if (aix_type == MOUNT_TYPE_NFS3_BIS) {
+ dlog("mount_aix3: creating alternate nfs3_args structure");
+ memmove((voidp) &v3args_bis.addr, (voidp) &v3args->addr, sizeof(struct sockaddr_in));
+ v3args_bis.syncaddr = v3args->syncaddr;
+ v3args_bis.proto = v3args->proto;
+ v3args_bis.hostname = v3args->hostname;
+ v3args_bis.netname = v3args->netname;
+ v3args_bis.fh = v3args->fh;
+ v3args_bis.flags = v3args->flags;
+ v3args_bis.wsize = v3args->wsize;
+ v3args_bis.rsize = v3args->rsize;
+ v3args_bis.timeo = v3args->timeo;
+ v3args_bis.retrans = v3args->retrans;
+ v3args_bis.acregmin = v3args->acregmin;
+ v3args_bis.acregmax = v3args->acregmax;
+ v3args_bis.acdirmin = v3args->acdirmin;
+ v3args_bis.acdirmax = v3args->acdirmax;
+ v3args_bis.pathconf = v3args->pathconf;
+ v3args_bis.biods = v3args->biods;
+ v3args_bis.numclust = v3args->numclust;
+ /* now set real_* stuff */
+ real_size = sizeof(v3args_bis);
+ real_args = (char *) &v3args_bis;
+ }
+#endif /* MOUNT_TYPE_NFS3_BIS */
+#endif /* HAVE_FS_NFS3 */
+
+ idx = strchr(fsname, ':');
+ if (idx) {
+ *idx = '\0';
+ rfs = xstrdup(idx + 1);
+ host = xstrdup(fsname);
+ *idx = ':';
+ } else {
+ rfs = xstrdup(fsname);
+ host = xstrdup(am_get_hostname());
+ }
+
+ size = aix3_mkvp(buf, type, flags, rfs, dir, host,
+ real_args, real_size, mnt_opts);
+ XFREE(rfs);
+ XFREE(host);
+ break;
+
+ case MOUNT_TYPE_UFS:
+ /* Need to open block device and extract log device info from sblk. */
+ return EINVAL;
+
+ default:
+ return EINVAL;
+ }
+
+ /*
+ * XXX: Warning, if vmount() hangs your amd in AIX 5.1, it
+ * is because of a kernel bug in the NFS code. Get a patch from IBM
+ * or upgrade to 5.2.
+ */
+ ret = vmount((struct vmount *)buf, size);
+ if (ret < 0) {
+ plog(XLOG_ERROR, "mount_aix3: vmount failed with errno %d", errno);
+ perror ("vmount");
+#ifdef MOUNT_TYPE_NFS3_BIS
+ if (aix_type == MOUNT_TYPE_NFS3 && errno == EINVAL) {
+ aix_type = MOUNT_TYPE_NFS3_BIS;
+#ifdef DEBUG
+ dlog("mount_aix3: retrying with alternate nfs3_args structure");
+#endif /* DEBUG */
+ goto retry_ibm_buggy_service_pack;
+ }
+#endif /* MOUNT_TYPE_NFS3_BIS */
+ }
+ return ret;
+}
diff --git a/conf/mount/mount_bsdi3.c b/conf/mount/mount_bsdi3.c
new file mode 100644
index 000000000000..bb39f99a6ce1
--- /dev/null
+++ b/conf/mount/mount_bsdi3.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/mount/mount_bsdi3.c
+ *
+ */
+
+/*
+ * BSD/OS 3 Mount helper
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <am_defs.h>
+#include <amu.h>
diff --git a/conf/mount/mount_default.c b/conf/mount/mount_default.c
index 1bdf52293cfe..9e85e1601719 100644
--- a/conf/mount/mount_default.c
+++ b/conf/mount/mount_default.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2003 Erez Zadok
+ * Copyright (c) 1997-2014 Erez Zadok
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
@@ -16,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgment:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -36,9 +32,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * %W% (Berkeley) %G%
*
- * $Id: mount_default.c,v 1.1.2.3 2002/12/27 22:44:48 ezk Exp $
+ * File: am-utils/conf/mount/mount_default.c
*/
/*
diff --git a/conf/mount/mount_hpux.c b/conf/mount/mount_hpux.c
new file mode 100644
index 000000000000..5a0e02046695
--- /dev/null
+++ b/conf/mount/mount_hpux.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/mount/mount_hpux.c
+ *
+ */
+
+/*
+ * HPUX:
+ * HPUX 9.0 and 10.0 Mount helper.
+ * -Erez Zadok <ezk@cs.columbia.edu>
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <am_defs.h>
+#include <amu.h>
+
+
+/*
+ * Map from conventional mount arguments
+ * to HPUX style arguments.
+ */
+int
+mount_hpux(MTYPE_TYPE type, const char *dir, int flags, caddr_t data)
+{
+
+#if defined(MOUNT_TYPE_NFS) && defined(MOUNT_NFS)
+ if (STREQ(type, MOUNT_TYPE_NFS))
+ return vfsmount(MOUNT_NFS, dir, flags, data);
+#endif /* defined(MOUNT_TYPE_NFS) && defined(MOUNT_NFS) */
+
+#if defined(MOUNT_TYPE_UFS) && defined(MOUNT_UFS)
+ if (STREQ(type, MOUNT_TYPE_UFS))
+ return vfsmount(MOUNT_UFS, dir, flags, data);
+#endif /* defined(MOUNT_TYPE_UFS) && defined(MOUNT_UFS) */
+
+#if defined(MOUNT_TYPE_PCFS) && defined(MOUNT_PC)
+ /*
+ * MOUNT_TYPE_PCFS gets redefined in conf/trap/trap_hpux.h because of
+ * stupidities in HPUX 9.0's headers.
+ */
+ if (STREQ(type, MOUNT_TYPE_PCFS))
+ return vfsmount(MOUNT_PC, dir, flags, data);
+#endif /* defined(MOUNT_TYPE_PCFS) && defined(MOUNT_PC) */
+
+#if defined(MOUNT_TYPE_CDFS) && defined(MOUNT_CDFS)
+ if (STREQ(type, MOUNT_TYPE_CDFS))
+ return vfsmount(MOUNT_CDFS, dir, flags, data);
+#endif /* defined(MOUNT_TYPE_CDFS) && defined(MOUNT_CDFS) */
+
+ return EINVAL;
+}
diff --git a/conf/mount/mount_irix5.c b/conf/mount/mount_irix5.c
new file mode 100644
index 000000000000..359e55a8333e
--- /dev/null
+++ b/conf/mount/mount_irix5.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/mount/mount_irix5.c
+ *
+ */
+
+/*
+ * IRIX Mount helper
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <am_defs.h>
+#include <amu.h>
+
+
+/*
+ * Map from conventional mount arguments
+ * to IRIX style arguments.
+ *
+ * NOTE: We have to use struct nfs_args (not nfs_args_t) below because
+ * while IRIX5.3 needs the fh_len field added to struct nfs_args for NFS3
+ * mounts to succeed, the the mount syscall fails if the argument size
+ * includes fh_len! Talk about a broken interface ... -- stolcke 7/4/97
+ */
+int
+mount_irix(char *fsname, char *dir, int flags, MTYPE_TYPE type, voidp data)
+{
+
+#ifdef DEBUG
+ dlog("mount_irix: fsname %s, dir %s, type %d", fsname, dir, type);
+#endif /* DEBUG */
+
+#ifdef HAVE_FS_NFS3
+ if (STREQ(type, MOUNT_TYPE_NFS3))
+ return mount(fsname, dir, (MNT2_GEN_OPT_FSS | MNT2_GEN_OPT_DATA | flags),
+ type, (struct nfs_args *) data, sizeof(struct nfs_args));
+#endif /* HAVE_FS_NFS3 */
+
+#ifdef HAVE_FS_NFS
+ if (STREQ(type, MOUNT_TYPE_NFS))
+ return mount(fsname, dir, (MNT2_GEN_OPT_FSS | MNT2_GEN_OPT_DATA | flags),
+ type, (struct nfs_args *) data, sizeof(struct nfs_args));
+#endif /* HAVE_FS_NFS */
+
+ /* XXX: do I need to pass {u,x,e}fs_args ? */
+
+#ifdef HAVE_FS_UFS
+ if (STREQ(type, MOUNT_TYPE_UFS))
+ return mount(fsname, dir, (MNT2_GEN_OPT_FSS | flags), type);
+#endif /* HAVE_FS_UFS */
+
+#ifdef HAVE_FS_EFS
+ if (STREQ(type, MOUNT_TYPE_EFS))
+ return mount(fsname, dir, (MNT2_GEN_OPT_FSS | flags), type);
+#endif /* HAVE_FS_EFS */
+
+#ifdef HAVE_FS_XFS
+ if (STREQ(type, MOUNT_TYPE_XFS))
+ return mount(fsname, dir, (MNT2_GEN_OPT_FSS | flags), type);
+#endif /* HAVE_FS_XFS */
+
+ return EINVAL;
+}
diff --git a/conf/mount/mount_irix6.c b/conf/mount/mount_irix6.c
new file mode 100644
index 000000000000..b0eb55bd6333
--- /dev/null
+++ b/conf/mount/mount_irix6.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/mount/mount_irix6.c
+ *
+ */
+
+/*
+ * IRIX Mount helper
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <am_defs.h>
+#include <amu.h>
+
+
+/*
+ * Map from conventional mount arguments
+ * to IRIX style arguments.
+ */
+int
+mount_irix(char *fsname, char *dir, int flags, MTYPE_TYPE type, voidp data)
+{
+
+#ifdef DEBUG
+ dlog("mount_irix: fsname %s, dir %s, type %s", fsname, dir, type);
+#endif /* DEBUG */
+
+#ifdef HAVE_FS_NFS3
+ if (STREQ(type, MOUNT_TYPE_NFS3))
+ return mount(fsname, dir, (MNT2_GEN_OPT_FSS | MNT2_GEN_OPT_DATA | flags),
+ type, (nfs_args_t *) data, sizeof(nfs_args_t));
+#endif /* HAVE_FS_NFS3 */
+
+#ifdef HAVE_FS_NFS
+ if (STREQ(type, MOUNT_TYPE_NFS))
+ return mount(fsname, dir, (MNT2_GEN_OPT_FSS | MNT2_GEN_OPT_DATA | flags),
+ type, (nfs_args_t *) data, sizeof(nfs_args_t));
+#endif /* HAVE_FS_NFS */
+
+#ifdef HAVE_FS_UFS
+ if (STREQ(type, MOUNT_TYPE_UFS))
+ return mount(fsname, dir, (MNT2_GEN_OPT_FSS | MNT2_GEN_OPT_DATA | flags),
+ type, (ufs_args_t *) data, sizeof(ufs_args_t));
+#endif /* HAVE_FS_UFS */
+
+#ifdef HAVE_FS_XFS
+ if (STREQ(type, MOUNT_TYPE_XFS))
+ return mount(fsname, dir, (MNT2_GEN_OPT_FSS | MNT2_GEN_OPT_DATA | flags),
+ type, (xfs_args_t *) data, sizeof(xfs_args_t));
+#endif /* HAVE_FS_XFS */
+
+#ifdef HAVE_FS_EFS
+ if (STREQ(type, MOUNT_TYPE_EFS))
+ return mount(fsname, dir, (MNT2_GEN_OPT_FSS | MNT2_GEN_OPT_DATA | flags),
+ type, (efs_args_t *) data, sizeof(efs_args_t));
+#endif /* HAVE_FS_EFS */
+
+#ifdef HAVE_FS_AUTOFS
+ if (STREQ(type, MOUNT_TYPE_AUTOFS))
+ return mount(fsname, dir, (MNT2_GEN_OPT_FSS | MNT2_GEN_OPT_DATA | flags),
+ type, (autofs_args_t *) data, sizeof(autofs_args_t));
+#endif /* HAVE_FS_AUTOFS */
+
+#ifdef HAVE_FS_LOFS
+ if (STREQ(type, MOUNT_TYPE_LOFS))
+ return mount(fsname, dir, (MNT2_GEN_OPT_FSS | MNT2_GEN_OPT_DATA | flags),
+ type, (char *) NULL, 0);
+#endif /* HAVE_FS_LOFS */
+
+ return EINVAL;
+}
diff --git a/conf/mount/mount_isc3.c b/conf/mount/mount_isc3.c
new file mode 100644
index 000000000000..0896a31b5b40
--- /dev/null
+++ b/conf/mount/mount_isc3.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/mount/mount_isc3.c
+ */
+
+/*
+ * IX/386 Mount helper
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <am_defs.h>
+#include <amu.h>
+
+
+/*
+ * Map from conventional mount arguments
+ * to IX/386 style arguments.
+ */
+int
+mount_isc3(char *fsname, char *dir, int flags, int type, void *data)
+{
+
+#ifdef DEBUG
+ dlog("mount_isc3: fsname %s, dir %s, type %d", fsname, dir, type);
+#endif /* DEBUG */
+
+ if (type == MOUNT_TYPE_NFS)
+ return mount("/dev/nfsd", dir,
+ (MNT2_GEN_OPT_FSS | MNT2_GEN_OPT_DATA | flags),
+ type, (struct nfs_args *) data,
+ sizeof(struct nfs_args));
+
+ if (type == MOUNT_TYPE_UFS)
+ return mount(fsname, dir, (MNT2_GEN_OPT_FSS | flags), type);
+
+ return EINVAL;
+}
diff --git a/conf/mount/mount_linux.c b/conf/mount/mount_linux.c
new file mode 100644
index 000000000000..d3841cedc5f7
--- /dev/null
+++ b/conf/mount/mount_linux.c
@@ -0,0 +1,1153 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/mount/mount_linux.c
+ */
+
+/*
+ * Linux mount helper.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <am_defs.h>
+#include <amu.h>
+#include <nfs_common.h>
+
+#ifdef HAVE_RPC_AUTH_H
+# include <rpc/auth.h>
+#endif
+
+#ifndef MOUNT_TYPE_UFS
+/*
+ * Autoconf didn't find any disk-based f/s on this system,
+ * So provide some default definition for this file to compile.
+ */
+# define MOUNT_TYPE_UFS "no_disk_fs"
+#endif /* not MOUNT_TYPE_UFS */
+
+struct opt_map {
+ const char *opt; /* option name */
+ int inv; /* true if flag value should be inverted */
+ int mask; /* flag mask value */
+};
+
+const struct opt_map opt_map[] =
+{
+ {"defaults", 0, 0},
+ {MNTTAB_OPT_RO, 0, MNT2_GEN_OPT_RDONLY},
+ {MNTTAB_OPT_RW, 1, MNT2_GEN_OPT_RDONLY},
+ {MNTTAB_OPT_EXEC, 1, MNT2_GEN_OPT_NOEXEC},
+ {MNTTAB_OPT_NOEXEC, 0, MNT2_GEN_OPT_NOEXEC},
+ {MNTTAB_OPT_SUID, 1, MNT2_GEN_OPT_NOSUID},
+ {MNTTAB_OPT_NOSUID, 0, MNT2_GEN_OPT_NOSUID},
+#ifdef MNT2_GEN_OPT_NODEV
+ {MNTTAB_OPT_NODEV, 0, MNT2_GEN_OPT_NODEV},
+#endif /* MNT2_GEN_OPT_NODEV */
+#ifdef MNT2_GEN_OPT_SYNC
+ {MNTTAB_OPT_SYNC, 0, MNT2_GEN_OPT_SYNC},
+ {MNTTAB_OPT_ASYNC, 1, MNT2_GEN_OPT_SYNC},
+#endif /* MNT2_GEN_OPT_SYNC */
+#ifdef MNT2_GEN_OPT_NOSUB
+ {MNTTAB_OPT_SUB, 1, MNT2_GEN_OPT_NOSUB},
+ {MNTTAB_OPT_NOSUB, 0, MNT2_GEN_OPT_NOSUB},
+#endif /* MNT2_GEN_OPT_NOSUB */
+#ifdef MNT2_GEN_OPT_SYNCHRONOUS
+ {"synchronous", 0, MNT2_GEN_OPT_SYNCHRONOUS},
+#endif /* MNT2_GEN_OPT_SYNCHRONOUS */
+#ifdef MNT2_GEN_OPT_MANDLOCK
+ {"mandlock", 0, MNT2_GEN_OPT_MANDLOCK},
+#endif /* MNT2_GEN_OPT_MANDLOCK */
+#ifdef MNT2_GEN_OPT_NOATIME
+ {"noatime", 0, MNT2_GEN_OPT_NOATIME},
+#endif /* MNT2_GEN_OPT_NOATIME */
+#ifdef MNT2_GEN_OPT_NODIRATIME
+ {"nodiratime", 0, MNT2_GEN_OPT_NODIRATIME},
+#endif /* MNT2_GEN_OPT_NODIRATIME */
+ {NULL, 0, 0}
+};
+
+struct fs_opts {
+ const char *opt;
+ int type; /* XXX: Ion, what is this for? */
+};
+
+const struct fs_opts iso_opts[] = {
+ { "map", 0 },
+ { "norock", 0 },
+ { "cruft", 0 },
+ { "unhide", 0 },
+ { "conv", 1 },
+ { "block", 1 },
+ { "mode", 1 },
+ { "gid", 1 },
+ { "uid", 1 },
+ { NULL, 0 }
+};
+
+const struct fs_opts dos_opts[] = {
+ { "check", 1 },
+ { "conv", 1 },
+ { "uid", 1 },
+ { "gid", 1 },
+ { "umask", 1 },
+ { "debug", 0 },
+ { "fat", 1 },
+ { "quiet", 0 },
+ { "blocksize",1 },
+ { NULL, 0 }
+};
+
+const struct fs_opts autofs_opts[] = {
+ { "fd", 1 },
+ { "pgrp", 1 },
+ { "minproto", 1 },
+ { "maxproto", 1 },
+ { NULL, 0 }
+};
+
+const struct fs_opts lustre_opts[] = {
+ { "flock", 0 },
+ { "localflock", 0 },
+ { NULL, 0 }
+};
+
+const struct fs_opts null_opts[] = {
+ { NULL, 0 }
+};
+
+const struct fs_opts ext2_opts[] = {
+ { "check", 1 },
+ { "nocheck", 0 },
+ { "debug", 0 },
+ { "errors", 1 },
+ { "grpid", 0 },
+ { "nogrpid", 0 },
+ { "bsdgroups", 0 },
+ { "sysvgroups", 0 },
+ { "grpquota", 0 },
+ { "usrquota", 0 },
+ { "noquota", 0 },
+ { "quota", 0 },
+ { "nouid32", 0 },
+ { "oldalloc", 0 },
+ { "orlov", 0 },
+ { "resgid", 1 },
+ { "resuid", 1 },
+ { "sb", 1 },
+ { "user_xattr", 1 },
+ { "nouser_xattr", 1 },
+ { "journal_dev", 0 },
+ { "norecovery", 0 },
+ { "noload", 0 },
+ { "data", 1 },
+ { "barrier", 1 },
+ { "commit", 1 },
+ { "user_xattr", 0 },
+ { "nouser_xattr", 0 },
+ { "acl", 0 },
+ { "noacl", 0 },
+ { "bsddf", 0 },
+ { "minixdf", 0 },
+ { "usrjquota", 1 },
+ { "grpjquota", 1 },
+ { "jqfmt", 1 },
+ { NULL, 0 }
+};
+
+const struct fs_opts ext3_opts[] = {
+ { "check", 1 },
+ { "nocheck", 0 },
+ { "debug", 0 },
+ { "errors", 1 },
+ { "grpid", 0 },
+ { "nogrpid", 0 },
+ { "bsdgroups", 0 },
+ { "sysvgroups", 0 },
+ { "grpquota", 0 },
+ { "usrquota", 0 },
+ { "noquota", 0 },
+ { "quota", 0 },
+ { "nouid32", 0 },
+ { "oldalloc", 0 },
+ { "orlov", 0 },
+ { "resgid", 1 },
+ { "resuid", 1 },
+ { "sb", 1 },
+ { "user_xattr", 1 },
+ { "nouser_xattr", 1 },
+ { "journal", 1 },
+ { "journal_dev", 1 },
+ { "norecovery", 0 },
+ { "noload", 0 },
+ { "data", 1 },
+ { "barrier", 1 },
+ { "commit", 1 },
+ { "user_xattr", 0 },
+ { "nouser_xattr", 0 },
+ { "acl", 0 },
+ { "noacl", 0 },
+ { "bsddf", 0 },
+ { "minixdf", 0 },
+ { "usrjquota", 1 },
+ { "grpjquota", 1 },
+ { "jqfmt", 1 },
+ { NULL, 0 }
+};
+
+const struct fs_opts ext4_opts[] = {
+ { "debug", 0 },
+ { "errors", 1 },
+ { "grpid", 0 },
+ { "nogrpid", 0 },
+ { "bsdgroups", 0 },
+ { "sysvgroups", 0 },
+ { "grpquota", 0 },
+ { "usrquota", 0 },
+ { "noquota", 0 },
+ { "quota", 0 },
+ { "oldalloc", 0 },
+ { "orlov", 0 },
+ { "resgid", 1 },
+ { "resuid", 1 },
+ { "sb", 1 },
+ { "user_xattr", 1 },
+ { "nouser_xattr", 1 },
+ { "journal", 1 },
+ { "journal_dev", 1 },
+ { "noload", 0 },
+ { "data", 1 },
+ { "commit", 1 },
+ { "user_xattr", 0 },
+ { "nouser_xattr", 0 },
+ { "acl", 0 },
+ { "noacl", 0 },
+ { "bsddf", 0 },
+ { "minixdf", 0 },
+ { "usrjquota", 1 },
+ { "grpjquota", 1 },
+ { "jqfmt", 1 },
+ { "journal_checksum", 0 },
+ { "journal_async_commit", 0 },
+ { "journal", 1 },
+ { "barrier", 1 },
+ { "nobarrier", 0 },
+ { "inode_readahead_blks", 1 },
+ { "stripe", 1 },
+ { "delalloc", 0 },
+ { "nodelalloc", 0 },
+ { "min_batch_time", 1 },
+ { "mxn_batch_time", 1 },
+ { "journal_ioprio", 1 },
+ { "abort", 0 },
+ { "auto_da_alloc", 0 },
+ { "noauto_da_alloc", 0 },
+ { "discard", 0 },
+ { "nodiscard", 0 },
+ { "nouid32", 0 },
+ { "resize", 0 },
+ { "block_validity", 0 },
+ { "noblock_validity", 0 },
+ { "dioread_lock", 0 },
+ { "dioread_nolock", 0 },
+ { NULL, 0 }
+};
+
+
+/*
+ * New parser for linux-specific mounts.
+ * Should now handle fs-type specific mount-options correctly.
+ * Currently implemented: msdos, iso9660.
+ */
+static char *
+parse_opts(char *type, const char *optstr, int *flags, char **xopts, int *noauto)
+{
+ const struct opt_map *std_opts;
+ const struct fs_opts *dev_opts;
+ char *opt, *topts, *xoptstr;
+ size_t l;
+
+ if (optstr == NULL)
+ return NULL;
+
+ xoptstr = xstrdup(optstr); /* because strtok is destructive below */
+
+ *noauto = 0;
+ l = strlen(optstr) + 2;
+ *xopts = (char *) xmalloc(l);
+ topts = (char *) xmalloc(l);
+ *topts = '\0';
+ **xopts = '\0';
+
+ for (opt = strtok(xoptstr, ","); opt; opt = strtok(NULL, ",")) {
+ /*
+ * First, parse standard options
+ */
+ std_opts = opt_map;
+ while (std_opts->opt &&
+ !NSTREQ(std_opts->opt, opt, strlen(std_opts->opt)))
+ ++std_opts;
+ if (!(*noauto = STREQ(opt, MNTTAB_OPT_NOAUTO)) || std_opts->opt) {
+ xstrlcat(topts, opt, l);
+ xstrlcat(topts, ",", l);
+ if (std_opts->inv)
+ *flags &= ~std_opts->mask;
+ else
+ *flags |= std_opts->mask;
+ }
+ /*
+ * Next, select which fs-type is to be used
+ * and parse the fs-specific options
+ */
+#ifdef MOUNT_TYPE_AUTOFS
+ if (STREQ(type, MOUNT_TYPE_AUTOFS)) {
+ dev_opts = autofs_opts;
+ goto do_opts;
+ }
+#endif /* MOUNT_TYPE_AUTOFS */
+#ifdef MOUNT_TYPE_PCFS
+ if (STREQ(type, MOUNT_TYPE_PCFS)) {
+ dev_opts = dos_opts;
+ goto do_opts;
+ }
+#endif /* MOUNT_TYPE_PCFS */
+#ifdef MOUNT_TYPE_CDFS
+ if (STREQ(type, MOUNT_TYPE_CDFS)) {
+ dev_opts = iso_opts;
+ goto do_opts;
+ }
+#endif /* MOUNT_TYPE_CDFS */
+#ifdef MOUNT_TYPE_LOFS
+ if (STREQ(type, MOUNT_TYPE_LOFS)) {
+ dev_opts = null_opts;
+ goto do_opts;
+ }
+#endif /* MOUNT_TYPE_LOFS */
+#ifdef MOUNT_TYPE_LUSTRE
+ if (STREQ(type, MOUNT_TYPE_LUSTRE)) {
+ dev_opts = lustre_opts;
+ goto do_opts;
+ }
+#endif /* MOUNT_TYPE_LUSTRE */
+#ifdef MOUNT_TYPE_EXT2
+ if (STREQ(type, MOUNT_TYPE_EXT2)) {
+ dev_opts = ext2_opts;
+ goto do_opts;
+ }
+#endif /* MOUNT_TYPE_EXT2 */
+#ifdef MOUNT_TYPE_EXT3
+ if (STREQ(type, MOUNT_TYPE_EXT3)) {
+ dev_opts = ext3_opts;
+ goto do_opts;
+ }
+#endif /* MOUNT_TYPE_EXT3 */
+#ifdef MOUNT_TYPE_EXT4
+ if (STREQ(type, MOUNT_TYPE_EXT4)) {
+ dev_opts = ext4_opts;
+ goto do_opts;
+ }
+#endif /* MOUNT_TYPE_EXT4 */
+ plog(XLOG_FATAL, "linux mount: unknown fs-type: %s\n", type);
+ XFREE(xoptstr);
+ XFREE(*xopts);
+ XFREE(topts);
+ return NULL;
+
+do_opts:
+ while (dev_opts->opt &&
+ (!NSTREQ(dev_opts->opt, opt, strlen(dev_opts->opt)))) {
+ ++dev_opts;
+ }
+ if (dev_opts->opt) {
+ xstrlcat(*xopts, opt, l);
+ xstrlcat(*xopts, ",", l);
+ }
+ }
+ /*
+ * All other options are discarded
+ */
+ if (strlen(*xopts))
+ *(*xopts + strlen(*xopts)-1) = '\0';
+ if (strlen(topts))
+ topts[strlen(topts)-1] = '\0';
+ XFREE(xoptstr);
+ return topts;
+}
+
+
+/*
+ * Returns combined linux kernel version number. For a kernel numbered
+ * x.y.z, returns x*65535+y*256+z.
+ */
+int
+linux_version_code(void)
+{
+ char *token;
+ int shift = 16;
+ struct utsname my_utsname;
+ static int release = 0;
+
+ if ( release || uname(&my_utsname))
+ return release;
+
+ for (token = strtok(my_utsname.release, "."); token && (shift > -1); token = strtok(NULL, "."))
+ {
+ release |= (atoi(token) << shift);
+ shift -= 8;
+ }
+
+ return release;
+}
+
+
+int
+do_mount_linux(MTYPE_TYPE type, mntent_t *mnt, int flags, caddr_t data)
+{
+ if (amuDebug(D_FULL)) {
+ plog(XLOG_DEBUG, "do_mount_linux: fsname %s\n", mnt->mnt_fsname);
+ plog(XLOG_DEBUG, "do_mount_linux: type (mntent) %s\n", mnt->mnt_type);
+ plog(XLOG_DEBUG, "do_mount_linux: opts %s\n", mnt->mnt_opts);
+ plog(XLOG_DEBUG, "do_mount_linux: dir %s\n", mnt->mnt_dir);
+ }
+
+ /*
+ * If we have an nfs mount, the 5th argument to system mount() must be the
+ * nfs_mount_data structure, otherwise it is the return from parse_opts()
+ */
+ return mount(mnt->mnt_fsname,
+ mnt->mnt_dir,
+ type,
+ MS_MGC_VAL | flags,
+ data);
+}
+
+static void
+setup_nfs_args(struct nfs_common_args *ca)
+{
+ if (!ca->timeo) {
+#ifdef MNT2_NFS_OPT_TCP
+ if (ca->flags & MNT2_NFS_OPT_TCP)
+ ca->timeo = 600;
+ else
+#endif /* MNT2_NFS_OPT_TCP */
+ ca->timeo = 7;
+ }
+ if (!ca->retrans)
+ ca->retrans = 3;
+
+#ifdef MNT2_NFS_OPT_NOAC
+ if (!(ca->flags & MNT2_NFS_OPT_NOAC)) {
+ if (!(ca->flags & MNT2_NFS_OPT_ACREGMIN))
+ ca->acregmin = 3;
+ if (!(ca->flags & MNT2_NFS_OPT_ACREGMAX))
+ ca->acregmax = 60;
+ if (!(ca->flags & MNT2_NFS_OPT_ACDIRMIN))
+ ca->acdirmin = 30;
+ if (!(ca->flags & MNT2_NFS_OPT_ACDIRMAX))
+ ca->acdirmax = 60;
+ }
+#endif /* MNT2_NFS_OPT_NOAC */
+}
+
+
+int
+mount_linux_nfs(MTYPE_TYPE type, mntent_t *mnt, int flags, caddr_t data)
+{
+ nfs_args_t *mnt_data = (nfs_args_t *) data;
+ int errorcode;
+ struct nfs_common_args a;
+
+ /* Fake some values for linux */
+ mnt_data->version = NFS_MOUNT_VERSION;
+
+ put_nfs_common_args(mnt_data, a);
+ setup_nfs_args(&a);
+ get_nfs_common_args(mnt_data, a);
+
+ /*
+ * in nfs structure implementation version 4, the old
+ * filehandle field was renamed "old_root" and left as 3rd field,
+ * while a new field called "root" was added to the end of the
+ * structure. Both of them however need a copy of the file handle
+ * for NFSv2 mounts.
+ */
+#ifdef MNT2_NFS_OPT_VER3
+ if (mnt_data->flags & MNT2_NFS_OPT_VER3)
+ memset(mnt_data->old_root.data, 0, FHSIZE);
+ else
+#endif /* MNT2_NFS_OPT_VER3 */
+ memcpy(mnt_data->old_root.data, mnt_data->root.data, FHSIZE);
+
+#ifdef HAVE_NFS_ARGS_T_BSIZE
+ /* linux mount version 3 */
+ mnt_data->bsize = 0; /* let the kernel decide */
+#endif /* HAVE_NFS_ARGS_T_BSIZE */
+
+#ifdef HAVE_NFS_ARGS_T_NAMLEN
+ /* linux mount version 2 */
+ mnt_data->namlen = NAME_MAX; /* 256 bytes */
+#endif /* HAVE_NFS_ARGS_T_NAMELEN */
+
+#ifdef HAVE_NFS_ARGS_T_PSEUDOFLAVOR
+# ifdef HAVE_RPC_AUTH_H
+ mnt_data->pseudoflavor = AUTH_UNIX;
+# else
+ mnt_data->pseudoflavor = 0;
+# endif
+#endif /* HAVE_NFS_ARGS_T_PSEUDOFLAVOR */
+
+#ifdef HAVE_NFS_ARGS_T_CONTEXT
+ memset(mnt_data->context, 0, sizeof(mnt_data->context));
+#endif /* HAVE_NFS_ARGS_T_CONTEXT */
+
+ mnt_data->fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ if (mnt_data->fd < 0) {
+ plog(XLOG_ERROR, "Can't create socket for kernel");
+ return 1;
+ }
+ if (bindresvport(mnt_data->fd, NULL) < 0) {
+ plog(XLOG_ERROR, "Can't bind to reserved port");
+ errorcode = 1;
+ goto out;
+ }
+ /*
+ * connect() the socket for kernels 1.3.10 and below
+ * only to avoid problems with multihomed hosts.
+ */
+ if (linux_version_code() <= 0x01030a) {
+ int ret = connect(mnt_data->fd,
+ (struct sockaddr *) &mnt_data->addr,
+ sizeof(mnt_data->addr));
+ if (ret < 0) {
+ plog(XLOG_ERROR, "Can't connect socket for kernel");
+ errorcode = 1;
+ goto out;
+ }
+ }
+ if (amuDebug(D_FULL)) {
+ plog(XLOG_DEBUG, "%s: type %s\n", __func__, type);
+ plog(XLOG_DEBUG, "%s: version %d\n", __func__, mnt_data->version);
+ plog(XLOG_DEBUG, "%s: fd %d\n", __func__, mnt_data->fd);
+ plog(XLOG_DEBUG, "%s: hostname %s\n", __func__,
+ inet_ntoa(mnt_data->addr.sin_addr));
+ plog(XLOG_DEBUG, "%s: port %d\n", __func__,
+ htons(mnt_data->addr.sin_port));
+ }
+ if (amuDebug(D_TRACE)) {
+ plog(XLOG_DEBUG, "%s: Generic mount flags 0x%x", __func__,
+ MS_MGC_VAL | flags);
+ plog(XLOG_DEBUG, "%s: updated nfs_args...", __func__);
+ print_nfs_args(mnt_data, 0);
+ }
+
+ mnt_data->flags &= MNT2_NFS_OPT_FLAGMASK;
+
+ errorcode = do_mount_linux(type, mnt, flags, data);
+
+ out:
+ /*
+ * If we failed, (i.e. errorcode != 0), then close the socket
+ * if it is open.
+ */
+ if (errorcode && mnt_data->fd != -1) {
+ /* save errno, may be clobbered by close() call! */
+ int save_errno = errno;
+ close(mnt_data->fd);
+ errno = save_errno;
+ }
+ return errorcode;
+}
+
+#ifdef HAVE_FS_NFS4
+int
+mount_linux_nfs4(MTYPE_TYPE type, mntent_t *mnt, int flags, caddr_t data)
+{
+ nfs4_args_t *mnt_data = (nfs4_args_t *) data;
+ int errorcode;
+ struct nfs_common_args a;
+
+ /* Fake some values for linux */
+ mnt_data->version = NFS4_MOUNT_VERSION;
+
+ put_nfs_common_args(mnt_data, a);
+ setup_nfs_args(&a);
+ get_nfs_common_args(mnt_data, a);
+
+ if (amuDebug(D_FULL)) {
+ plog(XLOG_DEBUG, "%s: type %s\n", __func__, type);
+ plog(XLOG_DEBUG, "%s: version %d\n", __func__, mnt_data->version);
+ }
+ if (amuDebug(D_TRACE)) {
+ plog(XLOG_DEBUG, "%s: Generic mount flags 0x%x", __func__,
+ MS_MGC_VAL | flags);
+ plog(XLOG_DEBUG, "%s: updated nfs_args...", __func__);
+ print_nfs_args(mnt_data, NFS_VERSION4);
+ }
+
+ errorcode = do_mount_linux(type, mnt, flags, data);
+
+ return errorcode;
+}
+#endif
+
+int
+mount_linux_nonfs(MTYPE_TYPE type, mntent_t *mnt, int flags, caddr_t data)
+{
+ char *extra_opts = NULL;
+ char *tmp_opts = NULL;
+ char *sub_type = NULL;
+ char *loopdev = NULL;
+ int noauto = 0;
+ int errorcode;
+
+ sub_type = hasmnteq(mnt, "type");
+ if (sub_type) {
+ sub_type = xstrdup(sub_type);
+ type = strpbrk(sub_type, ",:;\n\t");
+ if (type == NULL)
+ type = MOUNT_TYPE_UFS;
+ else {
+ *type = '\0';
+ type = sub_type;
+ }
+ }
+
+ if (!hasmntopt(mnt, "type"))
+ mnt->mnt_type = type;
+
+ tmp_opts = parse_opts(type, mnt->mnt_opts, &flags, &extra_opts, &noauto);
+
+#ifdef MOUNT_TYPE_LOFS
+ if (STREQ(type, MOUNT_TYPE_LOFS)) {
+# ifndef MNT2_GEN_OPT_BIND
+ size_t l;
+ /* this is basically a hack to support fist lofs */
+ XFREE(extra_opts);
+ l = strlen(mnt->mnt_fsname) + sizeof("dir=") + 1;
+ extra_opts = (char *) xmalloc(l);
+ xsnprintf(extra_opts, l, sizeof(extra_opts), "dir=%s", mnt->mnt_fsname);
+# else /* MNT2_GEN_OPT_BIND */
+ /* use bind mounts for lofs */
+ flags |= MNT2_GEN_OPT_BIND;
+# endif /* MNT2_GEN_OPT_BIND */
+ errorcode = do_mount_linux(type, mnt, flags, extra_opts);
+ } else /* end of "if type is LOFS" */
+#endif /* MOUNT_TYPE_LOFS */
+
+#ifdef MOUNT_TYPE_LUSTRE
+ if (STREQ(type, MOUNT_TYPE_LUSTRE)) {
+ char *topts;
+ if (*extra_opts)
+ topts = strvcat(extra_opts, ",device=", mnt->mnt_fsname, NULL);
+ else
+ topts = strvcat("device=", mnt->mnt_fsname, NULL);
+ free(extra_opts);
+ extra_opts = topts;
+ }
+#endif /* MOUNT_TYPE_LOFS */
+
+ {
+#ifdef HAVE_LOOP_DEVICE
+ /*
+ * If the mounted "device" is actually a regular file,
+ # try to attach a loop device to it.
+ */
+ struct stat buf;
+ char *old_fsname = NULL;
+ if (stat(mnt->mnt_fsname, &buf) == 0 &&
+ S_ISREG(buf.st_mode)) {
+ if ((loopdev = setup_loop_device(mnt->mnt_fsname)) != NULL) {
+ char *str;
+ size_t l;
+
+ plog(XLOG_INFO, "setup loop device %s over %s OK", loopdev, mnt->mnt_fsname);
+ old_fsname = mnt->mnt_fsname;
+ mnt->mnt_fsname = loopdev;
+ /* XXX: hack, append loop=/dev/loopX to mnttab opts */
+ l = strlen(mnt->mnt_opts) + 7 + strlen(loopdev);
+ str = (char *) xmalloc(l);
+ if (str) {
+ xsnprintf(str, l, "%s,loop=%s", mnt->mnt_opts, loopdev);
+ XFREE(mnt->mnt_opts);
+ mnt->mnt_opts = str;
+ }
+ } else {
+ plog(XLOG_ERROR, "failed to set up a loop device: %m");
+ errorcode = 1;
+ goto out;
+ }
+ }
+#endif /* HAVE_LOOP_DEVICE */
+
+ errorcode = do_mount_linux(type, mnt, flags, extra_opts);
+
+#ifdef HAVE_LOOP_DEVICE
+ /* if mount failed and we used a loop device, then undo it */
+ if (errorcode != 0 && loopdev != NULL) {
+ if (delete_loop_device(loopdev) < 0)
+ plog(XLOG_WARNING, "mount() failed to release loop device %s: %m", loopdev);
+ else
+ plog(XLOG_INFO, "mount() released loop device %s OK", loopdev);
+ }
+ if (old_fsname)
+ mnt->mnt_fsname = old_fsname;
+#endif /* HAVE_LOOP_DEVICE */
+ }
+
+ /*
+ * Free all allocated space and return errorcode.
+ */
+out:
+if (loopdev)
+ XFREE(loopdev);
+ if (extra_opts != NULL)
+ XFREE(extra_opts);
+ if (tmp_opts != NULL)
+ XFREE(tmp_opts);
+ if (sub_type != NULL)
+ XFREE(sub_type);
+ return errorcode;
+}
+
+
+int
+mount_linux(MTYPE_TYPE type, mntent_t *mnt, int flags, caddr_t data)
+{
+ int errorcode;
+
+ if (mnt->mnt_opts && STREQ(mnt->mnt_opts, "defaults"))
+ mnt->mnt_opts = NULL;
+
+ if (type == NULL)
+ type = index(mnt->mnt_fsname, ':') ? MOUNT_TYPE_NFS : MOUNT_TYPE_UFS;
+
+#ifdef HAVE_FS_NFS4
+ if (STREQ(type, MOUNT_TYPE_NFS4))
+ errorcode = mount_linux_nfs4(type, mnt, flags, data);
+ else
+#endif
+ if (STREQ(type, MOUNT_TYPE_NFS))
+ errorcode = mount_linux_nfs(type, mnt, flags, data);
+ else /* non-NFS mounts */
+ errorcode = mount_linux_nonfs(type, mnt, flags, data);
+
+ return errorcode;
+}
+
+
+/****************************************************************************/
+/*
+ * NFS error numbers and Linux errno's are two different things! Linux is
+ * `worse' than other OSes in the respect that it loudly complains about
+ * undefined NFS return value ("bad NFS return value.."). So we should
+ * translate ANY possible Linux errno to their NFS equivalent. Just, there
+ * aren't much NFS numbers, so most go to EINVAL or EIO. The mapping below
+ * should fit at least for Linux/i386 and Linux/68k. I haven't checked
+ * other architectures yet.
+ */
+
+#define NE_PERM 1
+#define NE_NOENT 2
+#define NE_IO 5
+#define NE_NXIO 6
+#define NE_AGAIN 11
+#define NE_ACCES 13
+#define NE_EXIST 17
+#define NE_NODEV 19
+#define NE_NOTDIR 20
+#define NE_ISDIR 21
+#define NE_INVAL 22
+#define NE_FBIG 27
+#define NE_NOSPC 28
+#define NE_ROFS 30
+#define NE_OPNOTSUPP 45
+#define NE_NAMETOOLONG 63
+#define NE_NOTEMPTY 66
+#define NE_DQUOT 69
+#define NE_STALE 70
+#define NE_REMOTE 71
+
+#define NFS_LOMAP 0
+#define NFS_HIMAP 122
+
+/*
+ * The errno's below are correct for Linux/i386. One day, somebody
+ * with lots of energy ought to verify them against the other ports...
+ */
+static int nfs_errormap[] = {
+ 0, /* success(0) */
+ NE_PERM, /* EPERM (1) */
+ NE_NOENT, /* ENOENT (2) */
+ NE_INVAL, /* ESRCH (3) */
+ NE_IO, /* EINTR (4) */
+ NE_IO, /* EIO (5) */
+ NE_NXIO, /* ENXIO (6) */
+ NE_INVAL, /* E2BIG (7) */
+ NE_INVAL, /* ENOEXEC (8) */
+ NE_INVAL, /* EBADF (9) */
+ NE_IO, /* ECHILD (10) */
+ NE_AGAIN, /* EAGAIN (11) */
+ NE_IO, /* ENOMEM (12) */
+ NE_ACCES, /* EACCES (13) */
+ NE_INVAL, /* EFAULT (14) */
+ NE_INVAL, /* ENOTBLK (15) */
+ NE_IO, /* EBUSY (16) */
+ NE_EXIST, /* EEXIST (17) */
+ NE_INVAL, /* EXDEV (18) */
+ NE_NODEV, /* ENODEV (19) */
+ NE_NOTDIR, /* ENOTDIR (20) */
+ NE_ISDIR, /* EISDIR (21) */
+ NE_INVAL, /* EINVAL (22) */
+ NE_IO, /* ENFILE (23) */
+ NE_IO, /* EMFILE (24) */
+ NE_INVAL, /* ENOTTY (25) */
+ NE_ACCES, /* ETXTBSY (26) */
+ NE_FBIG, /* EFBIG (27) */
+ NE_NOSPC, /* ENOSPC (28) */
+ NE_INVAL, /* ESPIPE (29) */
+ NE_ROFS, /* EROFS (30) */
+ NE_INVAL, /* EMLINK (31) */
+ NE_INVAL, /* EPIPE (32) */
+ NE_INVAL, /* EDOM (33) */
+ NE_INVAL, /* ERANGE (34) */
+ NE_INVAL, /* EDEADLK (35) */
+ NE_NAMETOOLONG, /* ENAMETOOLONG (36) */
+ NE_INVAL, /* ENOLCK (37) */
+ NE_INVAL, /* ENOSYS (38) */
+ NE_NOTEMPTY, /* ENOTEMPTY (39) */
+ NE_INVAL, /* ELOOP (40) */
+ NE_INVAL, /* unused (41) */
+ NE_INVAL, /* ENOMSG (42) */
+ NE_INVAL, /* EIDRM (43) */
+ NE_INVAL, /* ECHRNG (44) */
+ NE_INVAL, /* EL2NSYNC (45) */
+ NE_INVAL, /* EL3HLT (46) */
+ NE_INVAL, /* EL3RST (47) */
+ NE_INVAL, /* ELNRNG (48) */
+ NE_INVAL, /* EUNATCH (49) */
+ NE_INVAL, /* ENOCSI (50) */
+ NE_INVAL, /* EL2HLT (51) */
+ NE_INVAL, /* EBADE (52) */
+ NE_INVAL, /* EBADR (53) */
+ NE_INVAL, /* EXFULL (54) */
+ NE_INVAL, /* ENOANO (55) */
+ NE_INVAL, /* EBADRQC (56) */
+ NE_INVAL, /* EBADSLT (57) */
+ NE_INVAL, /* unused (58) */
+ NE_INVAL, /* EBFONT (59) */
+ NE_INVAL, /* ENOSTR (60) */
+ NE_INVAL, /* ENODATA (61) */
+ NE_INVAL, /* ETIME (62) */
+ NE_INVAL, /* ENOSR (63) */
+ NE_INVAL, /* ENONET (64) */
+ NE_INVAL, /* ENOPKG (65) */
+ NE_INVAL, /* EREMOTE (66) */
+ NE_INVAL, /* ENOLINK (67) */
+ NE_INVAL, /* EADV (68) */
+ NE_INVAL, /* ESRMNT (69) */
+ NE_IO, /* ECOMM (70) */
+ NE_IO, /* EPROTO (71) */
+ NE_IO, /* EMULTIHOP (72) */
+ NE_IO, /* EDOTDOT (73) */
+ NE_INVAL, /* EBADMSG (74) */
+ NE_INVAL, /* EOVERFLOW (75) */
+ NE_INVAL, /* ENOTUNIQ (76) */
+ NE_INVAL, /* EBADFD (77) */
+ NE_IO, /* EREMCHG (78) */
+ NE_IO, /* ELIBACC (79) */
+ NE_IO, /* ELIBBAD (80) */
+ NE_IO, /* ELIBSCN (81) */
+ NE_IO, /* ELIBMAX (82) */
+ NE_IO, /* ELIBEXEC (83) */
+ NE_INVAL, /* EILSEQ (84) */
+ NE_INVAL, /* ERESTART (85) */
+ NE_INVAL, /* ESTRPIPE (86) */
+ NE_INVAL, /* EUSERS (87) */
+ NE_INVAL, /* ENOTSOCK (88) */
+ NE_INVAL, /* EDESTADDRREQ (89) */
+ NE_INVAL, /* EMSGSIZE (90) */
+ NE_INVAL, /* EPROTOTYPE (91) */
+ NE_INVAL, /* ENOPROTOOPT (92) */
+ NE_INVAL, /* EPROTONOSUPPORT (93) */
+ NE_INVAL, /* ESOCKTNOSUPPORT (94) */
+ NE_INVAL, /* EOPNOTSUPP (95) */
+ NE_INVAL, /* EPFNOSUPPORT (96) */
+ NE_INVAL, /* EAFNOSUPPORT (97) */
+ NE_INVAL, /* EADDRINUSE (98) */
+ NE_INVAL, /* EADDRNOTAVAIL (99) */
+ NE_IO, /* ENETDOWN (100) */
+ NE_IO, /* ENETUNREACH (101) */
+ NE_IO, /* ENETRESET (102) */
+ NE_IO, /* ECONNABORTED (103) */
+ NE_IO, /* ECONNRESET (104) */
+ NE_IO, /* ENOBUFS (105) */
+ NE_IO, /* EISCONN (106) */
+ NE_IO, /* ENOTCONN (107) */
+ NE_IO, /* ESHUTDOWN (108) */
+ NE_IO, /* ETOOMANYREFS (109) */
+ NE_IO, /* ETIMEDOUT (110) */
+ NE_IO, /* ECONNREFUSED (111) */
+ NE_IO, /* EHOSTDOWN (112) */
+ NE_IO, /* EHOSTUNREACH (113) */
+ NE_IO, /* EALREADY (114) */
+ NE_IO, /* EINPROGRESS (115) */
+ NE_STALE, /* ESTALE (116) */
+ NE_IO, /* EUCLEAN (117) */
+ NE_INVAL, /* ENOTNAM (118) */
+ NE_INVAL, /* ENAVAIL (119) */
+ NE_INVAL, /* EISNAM (120) */
+ NE_IO, /* EREMOTEIO (121) */
+ NE_DQUOT, /* EDQUOT (122) */
+};
+
+
+int
+linux_nfs_error(int e)
+{
+ int ret = (nfsstat) NE_IO;
+
+ if (e < NFS_LOMAP || e > NFS_HIMAP)
+ ret = (nfsstat) NE_IO;
+ else
+ ret = nfs_errormap[e - NFS_LOMAP];
+ dlog("linux_nfs_error: map error %d to NFS error %d", e, ret);
+ return (nfsstat) ret;
+}
+
+
+#ifdef HAVE_LOOP_DEVICE
+/****************************************************************************/
+/*** LOOP DEVICE SUPPORT ***/
+/*** Loop Device setup code taken from mount-2.11g-5.src.rpm, which was ***/
+/*** originally written bt Ted T'so and others. ***/
+/****************************************************************************/
+
+#define PROC_DEVICES "/proc/devices"
+
+#if not_used_yet
+static int
+show_loop(char *device)
+{
+ struct loop_info loopinfo;
+ int fd;
+
+ if ((fd = open(device, O_RDONLY)) < 0) {
+ dlog("loop: can't open device %s: %m", device);
+ return -2;
+ }
+ if (ioctl(fd, LOOP_GET_STATUS, &loopinfo) < 0) {
+ dlog("loop: can't get info on device %s: %m", device);
+ close(fd);
+ return -1;
+ }
+ dlog("show_loop: %s: [%04x]:%ld (%s)",
+ device, loopinfo.lo_device, loopinfo.lo_inode,
+ loopinfo.lo_name);
+
+ close(fd);
+
+ return 0;
+}
+
+
+static int
+is_loop_device(const char *device)
+{
+ struct stat statbuf;
+ int loopmajor = 7;
+
+ return (loopmajor && stat(device, &statbuf) == 0 &&
+ S_ISBLK(statbuf.st_mode) &&
+ (statbuf.st_rdev>>8) == loopmajor);
+}
+#endif /* not_used_yet */
+
+
+/*
+ * Just creating a device, say in /tmp, is probably a bad idea - people
+ * might have problems with backup or so. So, we just try /dev/loop[0-7].
+ */
+static char *
+find_unused_loop_device(void)
+{
+ char dev[20];
+ char *loop_formats[] = { "/dev/loop%d", "/dev/loop/%d" };
+ int i, j, fd, somedev = 0, someloop = 0, loop_known = 0;
+ struct stat statbuf;
+ struct loop_info loopinfo;
+ FILE *procdev;
+
+#define LOOP_FMT_SIZE(a) (sizeof(a)/sizeof(a[0]))
+ for (j = 0; j < (int) LOOP_FMT_SIZE(loop_formats); j++) {
+ for (i = 0; i < 256; i++) {
+ xsnprintf(dev, sizeof(dev), loop_formats[j], i);
+ if (stat(dev, &statbuf) == 0 && S_ISBLK(statbuf.st_mode)) {
+ somedev++;
+ fd = open(dev, O_RDONLY);
+ if (fd >= 0) {
+ if (ioctl(fd, LOOP_GET_STATUS, &loopinfo) == 0)
+ someloop++; /* in use */
+ else if (errno == ENXIO) {
+ close(fd);
+ return xstrdup(dev); /* probably free */
+ }
+ close(fd);
+ }
+ continue; /* continue trying as long as devices exist */
+ }
+ break;
+ }
+ }
+
+ /* Nothing found. Why not? */
+ if ((procdev = fopen(PROC_DEVICES, "r")) != NULL) {
+ char line[100];
+ while (fgets(line, sizeof(line), procdev))
+ if (strstr(line, " loop\n")) {
+ loop_known = 1;
+ break;
+ }
+ fclose(procdev);
+ if (!loop_known)
+ loop_known = -1;
+ }
+
+ if (!somedev) {
+ dlog("Could not find any device /dev/loop#");
+ } else if (!someloop) {
+ if (loop_known == 1) {
+ dlog("Could not find any loop device.");
+ dlog("...Maybe /dev/loop# has a wrong major number?");
+ }
+ else if (loop_known == -1) {
+ dlog("Could not find any loop device, and, according to %s,", PROC_DEVICES);
+ dlog("...this kernel does not know about the loop device.");
+ dlog("... (If so, then recompile or `insmod loop.o'.)");
+ } else {
+ dlog("Could not find any loop device. Maybe this kernel does not know,");
+ dlog("...about the loop device (then recompile or `insmod loop.o'), or");
+ dlog("...maybe /dev/loop# has the wrong major number?");
+ }
+ } else {
+ dlog("Could not find any free loop device!");
+ }
+ return NULL;
+}
+
+
+/* returns 0 if OK, -1 otherwise */
+char *
+setup_loop_device(const char *file)
+{
+ struct loop_info loopinfo;
+ int fd, ffd, mode, err = -1;
+ char *device = find_unused_loop_device();
+
+ if (!device) {
+ dlog("no unused loop device");
+ goto out;
+ }
+
+ mode = O_RDWR | O_LARGEFILE;
+ if ((ffd = open(file, mode)) < 0) {
+ if (errno == EROFS) {
+ mode = O_RDONLY | O_LARGEFILE;
+ ffd = open(file, mode);
+ }
+ if (ffd < 0) {
+ dlog("%s: %m", file);
+ goto out;
+ }
+ }
+ if ((fd = open(device, mode)) < 0) {
+ dlog("%s: %m", device);
+ goto out_close;
+ }
+
+ memset(&loopinfo, 0, sizeof(loopinfo));
+ xstrlcpy(loopinfo.lo_name, file, LO_NAME_SIZE);
+ loopinfo.lo_offset = 0;
+
+ if (ioctl(fd, LOOP_SET_FD, ffd) < 0) {
+ dlog("ioctl: LOOP_SET_FD: %m");
+ goto out_close_all;
+ }
+ if (ioctl(fd, LOOP_SET_STATUS, &loopinfo) < 0) {
+ (void) ioctl(fd, LOOP_CLR_FD, 0);
+ dlog("ioctl: LOOP_SET_STATUS: %m");
+ goto out_close_all;
+ }
+
+ /* if gets here, all is OK */
+ err = 0;
+
+out_close_all:
+ close(fd);
+out_close:
+ close(ffd);
+out:
+
+ if (err) {
+ XFREE(device);
+ return NULL;
+ } else {
+ dlog("setup_loop_device(%s,%s): success", device, file);
+ return device;
+ }
+}
+
+
+int
+delete_loop_device(const char *device)
+{
+ int fd;
+
+ if ((fd = open(device, O_RDONLY)) < 0) {
+ dlog("delete_loop_device: can't delete device %s: %m", device);
+ return -1;
+ }
+ if (ioctl(fd, LOOP_CLR_FD, 0) < 0) {
+ dlog("ioctl: LOOP_CLR_FD: %m");
+ return -1;
+ }
+ close(fd);
+ dlog("delete_loop_device(%s): success", device);
+ return 0;
+}
+#endif /* HAVE_LOOP_DEVICE */
+
+
+/****************************************************************************/
diff --git a/conf/mount/mount_mach3.c b/conf/mount/mount_mach3.c
new file mode 100644
index 000000000000..5319a92e542f
--- /dev/null
+++ b/conf/mount/mount_mach3.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/mount/mount_mach3.c
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <am_defs.h>
+#include <amu.h>
+
+
+int
+mount_mach3(char *type, char *mnt, int flags, caddr_t mnt_data)
+{
+ int err = 0;
+ errno = 0;
+
+ if (syscall(SYS_vfsmount, type, mnt->mnt_dir, flags, mnt_data)) {
+ err = -1;
+ if (errno == ENODEV) {
+ /*
+ * might be an old kernel, need to try again
+ * with file type number instead of string
+ */
+ int typeno = 1;
+ plog(XLOG_ERROR, "%s: 1SYS_vfsmount: %m", mnt->mnt_dir);
+
+ if (STREQ(mnt->mnt_type, MOUNT_TYPE_UFS))
+ typeno = 0;
+ else if (STREQ(mnt->mnt_type, MOUNT_TYPE_NFS))
+ typeno = 1;
+ else
+ plog(XLOG_ERROR, "%s: type defaults to nfs...", mnt->mnt_dir);
+
+ plog(XLOG_ERROR, "%s: retry SYS_vfsmount %s %d", mnt->mnt_dir,
+ mnt->mnt_type, typeno);
+ if (typeno >= 0) {
+ if (syscall(SYS_vfsmount, typeno, mnt->mnt_dir, flags, mnt_data)) {
+ plog(XLOG_ERROR, "%s: 2SYS_vfsmount: %m", mnt->mnt_dir);
+ } else {
+ err = 0;
+ }
+ }
+ }
+ }
+ return err;
+}
diff --git a/conf/mount/mount_freebsd3.c b/conf/mount/mount_stellix.c
index 5888ed949d30..53615d3fce91 100644
--- a/conf/mount/mount_freebsd3.c
+++ b/conf/mount/mount_stellix.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-1998 Erez Zadok
+ * Copyright (c) 1997-2014 Erez Zadok
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
@@ -16,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -36,14 +32,13 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * %W% (Berkeley) %G%
*
- * $Id: mount_freebsd3.c,v 5.2.2.1 1992/02/09 15:10:08 jsp beta $
+ * File: am-utils/conf/mount/mount_stellix.c
*
*/
/*
- * FreeBSD 3.x (as of snapshot 3.0-980311-SNAP) Mount helper
+ * STELLIX Mount helper
*/
#ifdef HAVE_CONFIG_H
@@ -52,17 +47,25 @@
#include <am_defs.h>
#include <amu.h>
+
/*
* Map from conventional mount arguments
- * to FreeBSD 3.0 style arguments.
+ * to STELLIX style arguments.
*/
int
-mount_freebsd3(MTYPE_TYPE type, const char *dir, int flags, voidp data)
+mount_stellix(char *fsname, char *dir, int flags, int type, void *data)
{
- char const *namelist[] = INITMOUNTNAMES;
- return mount(namelist[type],
- dir,
- flags,
- data);
+#ifdef DEBUG
+ dlog("stellix_mount: fsname %s, dir %s, type %d", fsname, dir, type);
+#endif /* DEBUG */
+
+ if (type == MOUNT_TYPE_NFS)
+ return mount(dir, dir, (MNT2_GEN_OPT_FSS | MNT2_GEN_OPT_NFS | flags),
+ type, (caddr_t) data);
+
+ if (type == MOUNT_TYPE_UFS)
+ return mount(fsname, dir, (MNT2_GEN_OPT_FSS | flags), type);
+
+ return EINVAL;
}
diff --git a/conf/mount/mount_svr4.c b/conf/mount/mount_svr4.c
new file mode 100644
index 000000000000..e139567bfb98
--- /dev/null
+++ b/conf/mount/mount_svr4.c
@@ -0,0 +1,158 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/mount/mount_svr4.c
+ *
+ */
+
+/*
+ * SVR4:
+ * Solaris 2.x (SunOS 5.x) and HPUX-11 Mount helper.
+ * -Erez Zadok <ezk@cs.columbia.edu>
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <am_defs.h>
+#include <amu.h>
+
+
+/*
+ * On Solaris 8 with in-kernel mount table, pass mount options to kernel to
+ * have them evaluated. They will also show up in /etc/mnttab.
+ */
+#if defined(MNT2_GEN_OPT_OPTIONSTR) && defined(MAX_MNTOPT_STR)
+# define sys_mount(fsname, dir, flags, type, data, datasize) \
+ mount((fsname), (dir), (MNT2_GEN_OPT_OPTIONSTR | flags), (type), \
+ (data), (datasize), mountopts, sizeof(mountopts))
+#else /* not defined(MNT2_GEN_OPT_OPTIONSTR) && defined(MAX_MNTOPT_STR) */
+# define sys_mount(fsname, dir, flags, type, data, datasize) \
+ mount((fsname), (dir), (flags), (type), (data), (datasize))
+#endif /* not defined(MNT2_GEN_OPT_OPTIONSTR) && defined(MAX_MNTOPT_STR) */
+
+
+/*
+ * Map from conventional mount arguments
+ * to Solaris 2.x (SunOS 5.x) style arguments.
+ */
+int
+mount_svr4(char *fsname, char *dir, int flags, MTYPE_TYPE type, caddr_t data, const char *optstr)
+{
+#if defined(MNT2_GEN_OPT_OPTIONSTR) && defined(MAX_MNTOPT_STR)
+ char mountopts[MAX_MNTOPT_STR];
+
+ /*
+ * Save a copy of the mount options. The kernel will overwrite them with
+ * those it recognizes.
+ */
+ xstrlcpy(mountopts, optstr, MAX_MNTOPT_STR);
+#endif /* defined(MNT2_GEN_OPT_OPTIONSTR) && defined(MAX_MNTOPT_STR) */
+
+#if defined(MOUNT_TYPE_NFS3) && defined(MNTTAB_TYPE_NFS3)
+ if (STREQ(type, MOUNT_TYPE_NFS3)) {
+ return sys_mount(fsname, dir, (MNT2_GEN_OPT_DATA | flags),
+ type, (char *) data, sizeof(nfs_args_t));
+ }
+#endif /* defined(MOUNT_TYPE_NFS3) && defined(MNTTAB_TYPE_NFS3) */
+
+#if defined(MOUNT_TYPE_NFS) && defined(MNTTAB_TYPE_NFS)
+ if (STREQ(type, MOUNT_TYPE_NFS)) {
+ return sys_mount(fsname, dir, (MNT2_GEN_OPT_DATA | flags),
+ type, (char *) data, sizeof(nfs_args_t));
+ }
+#endif /* defined(MOUNT_TYPE_NFS) && defined(MNTTAB_TYPE_NFS) */
+
+#if defined(MOUNT_TYPE_AUTOFS) && defined(MNTTAB_TYPE_AUTOFS)
+ if (STREQ(type, MOUNT_TYPE_AUTOFS)) {
+ return sys_mount(fsname, dir, (MNT2_GEN_OPT_DATA | flags),
+ type, (char *) data, sizeof(autofs_args_t));
+ }
+#endif /* defined(MOUNT_TYPE_AUTOFS) && defined(MNTTAB_TYPE_AUTOFS) */
+
+#if defined(MOUNT_TYPE_UFS) && defined(MNTTAB_TYPE_UFS)
+ if (STREQ(type, MOUNT_TYPE_UFS))
+ return sys_mount(fsname, dir, (MNT2_GEN_OPT_DATA | flags),
+ type, (char *) data, sizeof(ufs_args_t));
+#endif /* defined(MOUNT_TYPE_UFS) && defined(MNTTAB_TYPE_UFS) */
+
+#if defined(MOUNT_TYPE_PCFS) && defined(MNTTAB_TYPE_PCFS)
+ if (STREQ(type, MOUNT_TYPE_PCFS))
+ return sys_mount(fsname, dir, (MNT2_GEN_OPT_DATA | flags),
+ type, (char *) data, sizeof(pcfs_args_t));
+#endif /* defined(MOUNT_TYPE_PCFS) && defined(MNTTAB_TYPE_PCFS) */
+
+#if defined(MOUNT_TYPE_CDFS) && defined(MNTTAB_TYPE_CDFS)
+ /*
+ * HSFS on Solaris allows for 3 HSFSMNT_* flags to be passed
+ * as arguments to the mount(). These flags are bit fields in an
+ * integer, and that integer is passed as the "data" of this system
+ * call. The flags are described in <sys/fs/hsfs_rrip.h>. However,
+ * Solaris does not have an interface to these. It does not define
+ * a structure hsfs_args or anything that one can figure out what
+ * arguments to pass to mount(2) for this type of filesystem.
+ * Therefore, until Sun does, no arguments are passed to this mount
+ * below.
+ * -Erez Zadok <ezk@cs.columbia.edu>.
+ */
+ if (STREQ(type, MOUNT_TYPE_CDFS))
+ return sys_mount(fsname, dir, (MNT2_GEN_OPT_FSS | flags),
+ type, (char *) NULL, 0);
+#endif /* defined(MOUNT_TYPE_CDFS) && defined(MNTTAB_TYPE_CDFS) */
+
+#if defined(MOUNT_TYPE_LOFS) && defined(MNTTAB_TYPE_LOFS)
+ if (STREQ(type, MOUNT_TYPE_LOFS))
+ return sys_mount(fsname, dir, (MNT2_GEN_OPT_FSS | flags),
+ type, (char *) NULL, 0);
+#endif /* defined(MOUNT_TYPE_LOFS) && defined(MNTTAB_TYPE_LOFS) */
+
+#ifdef HAVE_FS_CACHEFS
+# if defined(MOUNT_TYPE_CACHEFS) && defined(MNTTAB_TYPE_CACHEFS)
+ if (STREQ(type, MOUNT_TYPE_CACHEFS))
+ return sys_mount(fsname, dir, (MNT2_GEN_OPT_DATA | flags),
+ type, (char *) data, sizeof(cachefs_args_t));
+# endif /* defined(MOUNT_TYPE_CACHEFS) && defined(MNTTAB_TYPE_CACHEFS) */
+#endif /*HAVE_FS_CACHEFS */
+
+#ifdef HAVE_FS_AUTOFS
+# if defined(MOUNT_TYPE_AUTOFS) && defined(MNTTAB_TYPE_AUTOFS)
+ if (STREQ(type, MOUNT_TYPE_AUTOFS))
+ return sys_mount(fsname, dir, (MNT2_GEN_OPT_DATA | flags),
+ type, (char *) data, sizeof(autofs_args_t));
+# endif /* defined(MOUNT_TYPE_AUTOFS) && defined(MNTTAB_TYPE_AUTOFS) */
+#endif /* HAVE_FS_AUTOFS */
+
+ return EINVAL;
+}
diff --git a/conf/mtab/mtab_aix.c b/conf/mtab/mtab_aix.c
new file mode 100644
index 000000000000..072adc74151d
--- /dev/null
+++ b/conf/mtab/mtab_aix.c
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/mtab/mtab_aix.c
+ *
+ */
+
+/*
+ * AIX systems don't write their mount tables on a file. Instead, they
+ * use a (better) system where the kernel keeps this state, and you access
+ * the mount tables via a known interface.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <am_defs.h>
+#include <amu.h>
+
+/*
+ * These were missing external definitions from old AIX's headers. They
+ * appear to be available in <sys/vmount.h> on AIX 5.3, and possibly
+ * earlier. Hence I commented this out.
+ */
+#ifndef HAVE_EXTERN_MNTCTL
+extern int mntctl(int cmd, int size, voidp buf);
+#endif /* not HAVE_EXTERN_MNTCTL */
+
+
+static mntent_t *
+mnt_dup(struct vmount *mp)
+{
+ mntent_t *new_mp = ALLOC(mntent_t);
+ char *ty;
+ char *fsname = xstrdup(vmt2dataptr(mp, VMT_OBJECT));
+
+ new_mp->mnt_dir = strdup(vmt2dataptr(mp, VMT_STUB));
+ new_mp->mnt_opts = strdup(vmt2dataptr(mp, VMT_ARGS));
+
+ switch (mp->vmt_gfstype) {
+
+ case MOUNT_TYPE_UFS:
+ ty = MNTTAB_TYPE_UFS;
+ new_mp->mnt_fsname = xstrdup(fsname);
+ break;
+
+ case MOUNT_TYPE_NFS:
+ ty = MNTTAB_TYPE_NFS;
+ new_mp->mnt_fsname = str3cat((char *) NULL,
+ vmt2dataptr(mp, VMT_HOSTNAME), ":",
+ fsname);
+ break;
+
+#ifdef HAVE_FS_NFS3
+ case MOUNT_TYPE_NFS3:
+ ty = MNTTAB_TYPE_NFS3;
+ new_mp->mnt_fsname = str3cat((char *) NULL,
+ vmt2dataptr(mp, VMT_HOSTNAME), ":",
+ fsname);
+ break;
+#endif /* HAVE_FS_NFS3 */
+
+ default:
+ ty = "unknown";
+ new_mp->mnt_fsname = xstrdup(fsname);
+ break;
+
+ }
+
+ new_mp->mnt_type = xstrdup(ty);
+ /* store the VFS ID for uvmount() */
+ new_mp->mnt_passno = mp->vmt_vfsnumber;
+ new_mp->mnt_freq = 0;
+
+ XFREE(fsname);
+
+ return new_mp;
+}
+
+
+/*
+ * Read a mount table into memory
+ */
+mntlist *
+read_mtab(char *fs, const char *mnttabname)
+{
+ mntlist **mpp, *mhp;
+ int i;
+ char *mntinfo = NULL, *cp;
+ struct vmount *vp;
+ int ret;
+ int maxtry = 10; /* maximum number of times to try mntctl */
+
+ /*
+ * Figure out size of mount table and allocate space for a copy. Then get
+ * mount table for real. We repeat this loop at most 10 times to minimze
+ * the chance of a race condition (something gets un/mounted in between
+ * calls to mntctl()
+ */
+ i = sizeof(int);
+ do {
+ if (mntinfo)
+ XFREE(mntinfo);
+ mntinfo = xmalloc(i);
+ ret = mntctl(MCTL_QUERY, i, mntinfo);
+ if (ret == 0)
+ i = *(int*) mntinfo;
+ if (--maxtry <= 0) {
+ plog(XLOG_ERROR, "mntctl: could not get a stable result");
+ ret = -1;
+ errno = EINVAL;
+ break;
+ }
+ } while (ret == 0);
+ if (ret < 0) {
+ plog(XLOG_ERROR, "mntctl: %m");
+ goto out;
+ }
+
+ mpp = &mhp;
+ for (i = 0, cp = mntinfo; i < ret; i++, cp += vp->vmt_length) {
+ vp = (struct vmount *) cp;
+
+ /*
+ * Allocate a new slot
+ */
+ *mpp = ALLOC(struct mntlist);
+
+ /*
+ * Copy the data returned by mntctl
+ */
+ (*mpp)->mnt = mnt_dup(vp);
+
+ /*
+ * Move to next pointer
+ */
+ mpp = &(*mpp)->mnext;
+ }
+
+ *mpp = NULL;
+
+out:
+ if (mntinfo)
+ XFREE(mntinfo);
+ return mhp;
+}
diff --git a/conf/mtab/mtab_bsd.c b/conf/mtab/mtab_bsd.c
index fe3991aa575d..203a265e13af 100644
--- a/conf/mtab/mtab_bsd.c
+++ b/conf/mtab/mtab_bsd.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2006 Erez Zadok
+ * Copyright (c) 1997-2014 Erez Zadok
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
@@ -16,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgment:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -53,6 +49,9 @@
#include <am_defs.h>
#include <amu.h>
+#if __NetBSD_Version__ > 200030000
+#define statfs statvfs
+#endif
static mntent_t *
mnt_dup(struct statfs *mp)
@@ -60,8 +59,8 @@ mnt_dup(struct statfs *mp)
mntent_t *new_mp = ALLOC(mntent_t);
char *ty;
- new_mp->mnt_fsname = strdup(mp->f_mntfromname);
- new_mp->mnt_dir = strdup(mp->f_mntonname);
+ new_mp->mnt_fsname = xstrdup(mp->f_mntfromname);
+ new_mp->mnt_dir = xstrdup(mp->f_mntonname);
#ifdef HAVE_STRUCT_STATFS_F_FSTYPENAME
ty = mp->f_fstypename;
@@ -93,8 +92,8 @@ mnt_dup(struct statfs *mp)
}
#endif /* not HAVE_STRUCT_STATFS_F_FSTYPENAME */
- new_mp->mnt_type = strdup(ty);
- new_mp->mnt_opts = strdup("unset");
+ new_mp->mnt_type = xstrdup(ty);
+ new_mp->mnt_opts = xstrdup("unset");
new_mp->mnt_freq = 0;
new_mp->mnt_passno = 0;
@@ -138,7 +137,7 @@ read_mtab(char *fs, const char *mnttabname)
/*
* Terminate the list
*/
- *mpp = 0;
+ *mpp = NULL;
return mhp;
}
diff --git a/conf/mtab/mtab_file.c b/conf/mtab/mtab_file.c
new file mode 100644
index 000000000000..5004ef5f0e68
--- /dev/null
+++ b/conf/mtab/mtab_file.c
@@ -0,0 +1,454 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/mtab/mtab_file.c
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <am_defs.h>
+#include <amu.h>
+
+#define NFILE_RETRIES 10 /* number of retries (seconds) */
+
+#ifdef MOUNT_TABLE_ON_FILE
+
+static FILE *mnt_file;
+
+
+/*
+ * If the system is being trashed by something, then
+ * opening mtab may fail with ENFILE. So, go to sleep
+ * for a second and try again. (Yes - this has happened to me.)
+ *
+ * Note that this *may* block the automounter, oh well.
+ * If we get to this state then things are badly wrong anyway...
+ *
+ * Give the system 10 seconds to recover but then give up.
+ * Hopefully something else will exit and free up some file
+ * table slots in that time.
+ */
+# ifdef HAVE_FLOCK
+# define lock(fd) (flock((fd), LOCK_EX))
+# else /* not HAVE_FLOCK */
+static int
+lock(int fd)
+{
+ int rc;
+ struct flock lk;
+
+ lk.l_type = F_WRLCK;
+ lk.l_whence = 0;
+ lk.l_start = 0;
+ lk.l_len = 0;
+
+again:
+ rc = fcntl(fd, F_SETLKW, (caddr_t) & lk);
+ if (rc < 0 && (errno == EACCES || errno == EAGAIN)) {
+# ifdef DEBUG
+ dlog("Blocked, trying to obtain exclusive mtab lock");
+# endif /* DEBUG */
+ sleep(1);
+ goto again;
+ }
+ return rc;
+}
+# endif /* not HAVE_FLOCK */
+
+
+static FILE *
+open_locked_mtab(const char *mnttabname, char *mode, char *fs)
+{
+ FILE *mfp = NULL;
+
+ /*
+ * There is a possible race condition if two processes enter
+ * this routine at the same time. One will be blocked by the
+ * exclusive lock below (or by the shared lock in setmntent)
+ * and by the time the second process has the exclusive lock
+ * it will be on the wrong underlying object. To check for this
+ * the mtab file is stat'ed before and after all the locking
+ * sequence, and if it is a different file then we assume that
+ * it may be the wrong file (only "may", since there is another
+ * race between the initial stat and the setmntent).
+ *
+ * Simpler solutions to this problem are invited...
+ */
+ int racing = 2;
+ int rc;
+ int retries = 0;
+ struct stat st_before, st_after;
+
+ if (mnt_file) {
+# ifdef DEBUG
+ dlog("Forced close on %s in read_mtab", mnttabname);
+# endif /* DEBUG */
+ endmntent(mnt_file);
+ mnt_file = NULL;
+ }
+again:
+ if (mfp) {
+ endmntent(mfp);
+ mfp = NULL;
+ }
+ if (stat(mnttabname, &st_before) < 0) {
+ plog(XLOG_ERROR, "%s: stat: %m", mnttabname);
+ if (errno == ESTALE) {
+ /* happens occasionally */
+ sleep(1);
+ goto again;
+ }
+ /*
+ * If 'mnttabname' file does not exist give setmntent() a
+ * chance to create it (depending on the mode).
+ * Otherwise, bail out.
+ */
+ else if (errno != ENOENT) {
+ return 0;
+ }
+ }
+
+eacces:
+ mfp = setmntent((char *)mnttabname, mode);
+ if (!mfp) {
+ /*
+ * Since setmntent locks the descriptor, it
+ * is possible it can fail... so retry if
+ * needed.
+ */
+ if (errno == EACCES || errno == EAGAIN) {
+# ifdef DEBUG
+ dlog("Blocked, trying to obtain exclusive mtab lock");
+# endif /* DEBUG */
+ goto eacces;
+ } else if (errno == ENFILE && retries++ < NFILE_RETRIES) {
+ sleep(1);
+ goto eacces;
+ }
+ plog(XLOG_ERROR, "setmntent(\"%s\", \"%s\"): %m", mnttabname, mode);
+ return 0;
+ }
+ /*
+ * At this point we have an exclusive lock on the mount list,
+ * but it may be the wrong one so...
+ */
+
+ /*
+ * Need to get an exclusive lock on the current
+ * mount table until we have a new copy written
+ * out, when the lock is released in free_mntlist.
+ * flock is good enough since the mount table is
+ * not shared between machines.
+ */
+ do
+ rc = lock(fileno(mfp));
+ while (rc < 0 && errno == EINTR);
+ if (rc < 0) {
+ plog(XLOG_ERROR, "Couldn't lock %s: %m", mnttabname);
+ endmntent(mfp);
+ return 0;
+ }
+ /*
+ * Now check whether the mtab file has changed under our feet
+ */
+ if (stat(mnttabname, &st_after) < 0) {
+ plog(XLOG_ERROR, "%s: stat: %m", mnttabname);
+ goto again;
+ }
+ if (st_before.st_dev != st_after.st_dev ||
+ st_before.st_ino != st_after.st_ino) {
+ struct timeval tv;
+ if (racing == 0) {
+ /* Sometimes print a warning */
+ plog(XLOG_WARNING,
+ "Possible mount table race - retrying %s", fs);
+ }
+ racing = (racing + 1) & 3;
+ /*
+ * Take a nap. From: Doug Kingston <dpk@morgan.com>
+ */
+ tv.tv_sec = 0;
+ tv.tv_usec = (am_mypid & 0x07) << 17;
+ if (tv.tv_usec)
+ if (select(0, (voidp) 0, (voidp) 0, (voidp) 0, &tv) < 0)
+ plog(XLOG_WARNING, "mtab nap failed: %m");
+
+ goto again;
+ }
+
+ return mfp;
+}
+
+
+/*
+ * Unlock the mount table
+ */
+void
+unlock_mntlist(void)
+{
+ /*
+ * Release file lock, by closing the file
+ */
+ if (mnt_file) {
+ dlog("unlock_mntlist: releasing");
+ endmntent(mnt_file);
+ mnt_file = NULL;
+ }
+}
+
+
+/*
+ * Write out a mount list
+ */
+void
+rewrite_mtab(mntlist *mp, const char *mnttabname)
+{
+ FILE *mfp;
+ int error = 0;
+
+ /*
+ * Concoct a temporary name in the same directory as the target mount
+ * table so that rename() will work.
+ */
+ char tmpname[64];
+ int retries;
+ int tmpfd;
+ char *cp;
+ char mcp[128];
+
+ xstrlcpy(mcp, mnttabname, sizeof(mcp));
+ cp = strrchr(mcp, '/');
+ if (cp) {
+ memmove(tmpname, mcp, cp - mcp);
+ tmpname[cp - mcp] = '\0';
+ } else {
+ plog(XLOG_WARNING, "No '/' in mtab (%s), using \".\" as tmp directory", mnttabname);
+ tmpname[0] = '.';
+ tmpname[1] = '\0';
+ }
+ xstrlcat(tmpname, "/mtabXXXXXX", sizeof(tmpname));
+ retries = 0;
+enfile1:
+#ifdef HAVE_MKSTEMP
+ tmpfd = mkstemp(tmpname);
+ fchmod(tmpfd, 0644);
+#else /* not HAVE_MKSTEMP */
+ mktemp(tmpname);
+ tmpfd = open(tmpname, O_RDWR | O_CREAT | O_TRUNC, 0644);
+#endif /* not HAVE_MKSTEMP */
+ if (tmpfd < 0) {
+ if (errno == ENFILE && retries++ < NFILE_RETRIES) {
+ sleep(1);
+ goto enfile1;
+ }
+ plog(XLOG_ERROR, "%s: open: %m", tmpname);
+ return;
+ }
+ if (close(tmpfd) < 0)
+ plog(XLOG_ERROR, "Couldn't close tmp file descriptor: %m");
+
+ retries = 0;
+enfile2:
+ mfp = setmntent(tmpname, "w");
+ if (!mfp) {
+ if (errno == ENFILE && retries++ < NFILE_RETRIES) {
+ sleep(1);
+ goto enfile2;
+ }
+ plog(XLOG_ERROR, "setmntent(\"%s\", \"w\"): %m", tmpname);
+ error = 1;
+ goto out;
+ }
+ while (mp) {
+ if (mp->mnt) {
+ if (addmntent(mfp, mp->mnt)) {
+ plog(XLOG_ERROR, "Can't write entry to %s", tmpname);
+ error = 1;
+ goto out;
+ }
+ }
+ mp = mp->mnext;
+ }
+
+ /*
+ * SunOS 4.1 manuals say that the return code from entmntent()
+ * is always 1 and to treat as a void. That means we need to
+ * call fflush() to make sure the new mtab file got written.
+ */
+ if (fflush(mfp)) {
+ plog(XLOG_ERROR, "flush new mtab file: %m");
+ error = 1;
+ goto out;
+ }
+ (void) endmntent(mfp);
+
+ /*
+ * Rename temporary mtab to real mtab
+ */
+ if (rename(tmpname, mnttabname) < 0) {
+ plog(XLOG_ERROR, "rename %s to %s: %m", tmpname, mnttabname);
+ error = 1;
+ goto out;
+ }
+out:
+ if (error)
+ (void) unlink(tmpname);
+}
+
+
+static void
+mtab_stripnl(char *s)
+{
+ do {
+ s = strchr(s, '\n');
+ if (s)
+ *s++ = ' ';
+ } while (s);
+}
+
+
+/*
+ * Append a mntent structure to the
+ * current mount table.
+ */
+void
+write_mntent(mntent_t *mp, const char *mnttabname)
+{
+ int retries = 0;
+ FILE *mfp;
+enfile:
+ mfp = open_locked_mtab(mnttabname, "a", mp->mnt_dir);
+ if (mfp) {
+ mtab_stripnl(mp->mnt_opts);
+ if (addmntent(mfp, mp))
+ plog(XLOG_ERROR, "Couldn't write %s: %m", mnttabname);
+ if (fflush(mfp))
+ plog(XLOG_ERROR, "Couldn't flush %s: %m", mnttabname);
+ (void) endmntent(mfp);
+ } else {
+ if (errno == ENFILE && retries < NFILE_RETRIES) {
+ sleep(1);
+ goto enfile;
+ }
+ plog(XLOG_ERROR, "setmntent(\"%s\", \"a\"): %m", mnttabname);
+ }
+}
+
+#endif /* MOUNT_TABLE_ON_FILE */
+
+
+static mntent_t *
+mnt_dup(mntent_t *mp)
+{
+ mntent_t *new_mp = ALLOC(mntent_t);
+
+ new_mp->mnt_fsname = xstrdup(mp->mnt_fsname);
+ new_mp->mnt_dir = xstrdup(mp->mnt_dir);
+ new_mp->mnt_type = xstrdup(mp->mnt_type);
+ new_mp->mnt_opts = xstrdup(mp->mnt_opts);
+
+ new_mp->mnt_freq = mp->mnt_freq;
+ new_mp->mnt_passno = mp->mnt_passno;
+
+#ifdef HAVE_MNTENT_T_MNT_TIME
+# ifdef HAVE_MNTENT_T_MNT_TIME_STRING
+ new_mp->mnt_time = xstrdup(mp->mnt_time);
+# else /* not HAVE_MNTENT_T_MNT_TIME_STRING */
+ new_mp->mnt_time = mp->mnt_time;
+# endif /* not HAVE_MNTENT_T_MNT_TIME_STRING */
+#endif /* HAVE_MNTENT_T_MNT_TIME */
+
+#ifdef HAVE_MNTENT_T_MNT_CNODE
+ new_mp->mnt_cnode = mp->mnt_cnode;
+#endif /* HAVE_MNTENT_T_MNT_CNODE */
+
+ return new_mp;
+}
+
+
+/*
+ * Read a mount table into memory
+ */
+mntlist *
+read_mtab(char *fs, const char *mnttabname)
+{
+ mntlist **mpp, *mhp;
+
+ mntent_t *mep;
+ FILE *mfp = open_locked_mtab(mnttabname, "r+", fs);
+
+ if (!mfp)
+ return 0;
+
+ mpp = &mhp;
+
+/*
+ * XXX - In SunOS 4 there is (yet another) memory leak
+ * which loses 1K the first time getmntent is called.
+ * (jsp)
+ */
+ while ((mep = getmntent(mfp))) {
+ /*
+ * Allocate a new slot
+ */
+ *mpp = ALLOC(struct mntlist);
+
+ /*
+ * Copy the data returned by getmntent
+ */
+ (*mpp)->mnt = mnt_dup(mep);
+
+ /*
+ * Move to next pointer
+ */
+ mpp = &(*mpp)->mnext;
+ }
+ *mpp = NULL;
+
+#ifdef MOUNT_TABLE_ON_FILE
+ /*
+ * If we are not updating the mount table then we
+ * can free the resources held here, otherwise they
+ * must be held until the mount table update is complete
+ */
+ mnt_file = mfp;
+#else /* not MOUNT_TABLE_ON_FILE */
+ endmntent(mfp);
+#endif /* not MOUNT_TABLE_ON_FILE */
+
+ return mhp;
+}
diff --git a/conf/mtab/mtab_isc3.c b/conf/mtab/mtab_isc3.c
new file mode 100644
index 000000000000..9c8df1bae7d8
--- /dev/null
+++ b/conf/mtab/mtab_isc3.c
@@ -0,0 +1,269 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/mtab/mtab_isc3.c
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <am_defs.h>
+#include <amu.h>
+
+/* fd for /etc/.mnt.lock (also act as flag for: is_locked) */
+static int mtlckf = 0;
+static char mtlckname[] = "/etc/.mnt.lock";
+static char mnttabname[] = "/etc/mnttab";
+
+
+static void
+unlockmnttab(void)
+{
+ if (mtlckf) {
+ close(mtlckf);
+ mtlckf = 0;
+ }
+}
+
+
+static
+lockfile(int fd, int type)
+{
+ struct flock lk;
+
+ lk.l_type = type;
+ lk.l_whence = 0;
+ lk.l_start = 0;
+ lk.l_len = 0;
+
+ return fcntl(fd, F_SETLKW, &lk);
+}
+
+
+static
+lockmnttab(void)
+{
+ if (mtlckf == 0) { /* need lock on /etc/.mnt.lock */
+ mtlckf = open(mtlckname, O_RDWR);
+ if (mtlckf >= 0) {
+ if (lockfile(mtlckf, F_WRLCK) < 0) {
+ close(mtlckf);
+ mtlckf = 0;
+#ifdef DEBUG
+ dlog("lock failed %m");
+#endif /* DEBUG */
+ } else {
+ return 0;
+ }
+ }
+ }
+ plog(XLOG_ERROR, "Unable to lock %s: %m", mtlckname);
+ return -1;
+}
+
+
+void
+unlock_mntlist(void)
+{
+ dlog("unlock_mntlist: releasing");
+ unlockmnttab();
+}
+
+
+/* convert from ix386 mnttab to amd mntent */
+static mntent_t *
+mnt_dup(mntent_t *mp)
+{
+ /* note: may not be null terminated */
+ mntent_t *new_mp = ALLOC(mntent_t);
+ char nullcpy[128];
+
+ xstrlcpy(nullcpy, mp->mt_dev, 32);
+ new_mp->mnt_fsname = xstrdup(nullcpy);
+
+ xstrlcpy(nullcpy, mp->mt_filsys, 32);
+ new_mp->mnt_dir = xstrdup(nullcpy);
+
+ xstrlcpy(nullcpy, mp->mt_fstyp, 16);
+ new_mp->mnt_type = xstrdup(nullcpy);
+
+ xstrlcpy(nullcpy, mp->mt_mntopts, 64);
+ new_mp->mnt_opts = xstrdup(nullcpy);
+
+ new_mp->mnt_freq = 0;
+ new_mp->mnt_passno = 0;
+
+ new_mp->mnt_time = mp->mt_time;
+ new_mp->mnt_ro = mp->mt_ro_flg;
+
+ return new_mp;
+}
+
+
+/* convert back (static alloc) */
+static mntent_t *
+mtab_of(mntent_t *mnt)
+{
+ static mntent_t mt;
+
+ xstrlcpy(mt.mt_dev, mnt->mnt_fsname, 32);
+ xstrlcpy(mt.mt_filsys, mnt->mnt_dir, 32);
+
+ mt.mt_ro_flg = mnt->mnt_ro;
+ mt.mt_time = mnt->mnt_time;
+
+ xstrlcpy(mt.mt_fstyp, mnt->mnt_type, 16);
+ xstrlcpy(mt.mt_mntopts, mnt->mnt_opts, 64);
+
+ return &mt;
+}
+
+
+/*
+ * Read a mount table into memory
+ */
+mntlist *
+read_mtab(char *fs, const char *mnttabname)
+{
+ mntlist **mpp, *mhp;
+ /* From: Piete Brooks <pb@cl.cam.ac.uk> */
+ int fd;
+ mntent_t mountbuffer[NMOUNT], *fs_data;
+ int ret;
+ int nmts;
+
+ if (lockmnttab() != 0)
+ return (mntlist *) NULL;
+
+ fd = open(mnttabname, O_RDONLY);
+ if (fd < 0) {
+ plog(XLOG_ERROR, "Can't open %s: %m", mnttabname);
+ return (mntlist *) NULL;
+ }
+ mpp = &mhp;
+ while ((ret = read(fd, (char *) mountbuffer, NMOUNT * sizeof(mntent_t))) > 0) {
+ nmts = ret / sizeof(mntent_t);
+ for (fs_data = mountbuffer; fs_data < &mountbuffer[nmts]; fs_data++) {
+ /*
+ * Allocate a new slot
+ */
+ *mpp = ALLOC(struct mntlist);
+
+ /*
+ * Copy the data returned by getmntent
+ */
+ (*mpp)->mnt = mnt_dup(fs_data);
+
+ /*
+ * Move to next pointer
+ */
+ mpp = &(*mpp)->mnext;
+ }
+ }
+ if (ret < 0) {
+ plog(XLOG_ERROR, "read error on %s: %m", mnttabname);
+ unlockmnttab();
+ mhp = (mntlist *) NULL;
+ }
+ *mpp = NULL;
+
+ close(fd);
+ return mhp;
+}
+
+
+static
+write_mntent_to_mtab(int fd, mntent_t *mnt)
+{
+ int wr;
+
+eagain:
+ wr = write(fd, (char *) mtab_of(mnt), sizeof(mntent_t));
+ if (wr < 0) {
+ switch (wr) {
+ case EAGAIN:
+ goto eagain;
+ default:
+ return -1;
+ }
+ }
+ if (wr != sizeof(mntent_t))
+ plog(XLOG_ERROR, "Can't write entry to %s: %m", mnttabname);
+ return 0;
+}
+
+
+void
+rewrite_mtab(mntlist *mp, const char *mnttabname)
+{
+ int fd;
+
+ assert(mtlckf != 0);
+
+ fd = open(mnttabname, O_RDWR | O_TRUNC);
+ if (fd < 0) {
+ plog(XLOG_ERROR, "Can't open %s: %m", mnttabname);
+ unlockmnttab();
+ }
+ while (mp) {
+ if (mp->mnt)
+ write_mntent_to_mtab(fd, mp->mnt);
+ mp = mp->mnext;
+ }
+
+ close(fd);
+ unlockmnttab();
+}
+
+
+void
+write_mntent(mntent_t *mp, const char *mnttabname)
+{
+ int fd;
+
+ if (lockmnttab() == -1)
+ return;
+
+ fd = open(mnttabname, O_RDWR | O_APPEND);
+ if (fd < 0) {
+ plog(XLOG_ERROR, "Unable to append %s: %m", mnttabname);
+ return;
+ }
+ write_mntent_to_mtab(fd, mp);
+
+ close(fd);
+ unlockmnttab();
+}
diff --git a/conf/mtab/mtab_linux.c b/conf/mtab/mtab_linux.c
new file mode 100644
index 000000000000..829c97a57a35
--- /dev/null
+++ b/conf/mtab/mtab_linux.c
@@ -0,0 +1,565 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/mtab/mtab_linux.c
+ *
+ */
+
+/* This file was adapted by Red Hat for Linux from mtab_file.c */
+
+/*
+ * The locking code must be kept in sync with that used
+ * by the mount command in util-linux, otherwise you'll
+ * end with with race conditions leading to a corrupt
+ * /etc/mtab, particularly when AutoFS is used on same
+ * machine as AMD.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <am_defs.h>
+#include <amu.h>
+
+#define NFILE_RETRIES 10 /* number of retries (seconds) */
+#define LOCK_TIMEOUT 10
+
+#ifdef MOUNT_TABLE_ON_FILE
+
+# define PROC_MOUNTS "/proc/mounts"
+
+static FILE *mnt_file = NULL;
+/* Information about mtab. ------------------------------------*/
+static int have_mtab_info = 0;
+static int var_mtab_does_not_exist = 0;
+static int var_mtab_is_a_symlink = 0;
+/* Flag for already existing lock file. */
+static int we_created_lockfile = 0;
+static int lockfile_fd = -1;
+
+
+static void
+get_mtab_info(void)
+{
+ struct stat mtab_stat;
+
+ if (!have_mtab_info) {
+ if (lstat(MOUNTED, &mtab_stat))
+ var_mtab_does_not_exist = 1;
+ else if (S_ISLNK(mtab_stat.st_mode))
+ var_mtab_is_a_symlink = 1;
+ have_mtab_info = 1;
+ }
+}
+
+
+static int
+mtab_is_a_symlink(void)
+{
+ get_mtab_info();
+ return var_mtab_is_a_symlink;
+}
+
+
+static int
+mtab_is_writable()
+{
+ static int ret = -1;
+
+ /*
+ * Should we write to /etc/mtab upon an update? Probably not if it is a
+ * symlink to /proc/mounts, since that would create a file /proc/mounts in
+ * case the proc filesystem is not mounted.
+ */
+ if (mtab_is_a_symlink())
+ return 0;
+
+ if (ret == -1) {
+ int fd = open(MOUNTED, O_RDWR | O_CREAT, 0644);
+ if (fd >= 0) {
+ close(fd);
+ ret = 1;
+ } else
+ ret = 0;
+ }
+ return ret;
+}
+
+
+static void
+setlkw_timeout(int sig)
+{
+ /* nothing, fcntl will fail anyway */
+}
+
+
+/*
+ * Create the lock file.
+ * The lock file will be removed if we catch a signal or when we exit.
+ *
+ * The old code here used flock on a lock file /etc/mtab~ and deleted
+ * this lock file afterwards. However, as rgooch remarks, that has a
+ * race: a second mount may be waiting on the lock and proceed as
+ * soon as the lock file is deleted by the first mount, and immediately
+ * afterwards a third mount comes, creates a new /etc/mtab~, applies
+ * flock to that, and also proceeds, so that the second and third mount
+ * now both are scribbling in /etc/mtab.
+ * The new code uses a link() instead of a creat(), where we proceed
+ * only if it was us that created the lock, and hence we always have
+ * to delete the lock afterwards. Now the use of flock() is in principle
+ * superfluous, but avoids an arbitrary sleep().
+ */
+
+/*
+ * Where does the link point to? Obvious choices are mtab and mtab~~.
+ * HJLu points out that the latter leads to races. Right now we use
+ * mtab~.<pid> instead.
+ */
+#define MOUNTED_LOCK "/etc/mtab~"
+#define MOUNTLOCK_LINKTARGET MOUNTED_LOCK "%d"
+
+int
+lock_mtab(void)
+{
+ int tries = 100000, i;
+ char *linktargetfile;
+ size_t l;
+ int rc = 1;
+
+ /*
+ * Redhat's original code set a signal handler called "handler()" for all
+ * non-ALRM signals. The handler called unlock_mntlist(), plog'ed the
+ * signal name, and then exit(1)! Never, ever, exit() from inside a
+ * utility function. This messed up Amd's careful signal-handling code,
+ * and caused Amd to abort uncleanly only any other "innocent" signal
+ * (even simple SIGUSR1), leaving behind a hung Amd mnt point. That code
+ * should have at least restored the signal handlers' states upon a
+ * successful mtab unlocking. Anyway, that handler was unnecessary,
+ * because will call unlock_mntlist() properly anyway on exit.
+ */
+ setup_sighandler(SIGALRM, setlkw_timeout);
+
+ /* somewhat clumsy, but some ancient systems do not have snprintf() */
+ /* use 20 as upper bound for the length of %d output */
+ l = strlen(MOUNTLOCK_LINKTARGET) + 20;
+ linktargetfile = xmalloc(l);
+ xsnprintf(linktargetfile, l, MOUNTLOCK_LINKTARGET, getpid());
+
+ i = open(linktargetfile, O_WRONLY|O_CREAT, 0);
+ if (i < 0) {
+ int errsv = errno;
+ /*
+ * linktargetfile does not exist (as a file) and we cannot create
+ * it. Read-only filesystem? Too many files open in the system?
+ * Filesystem full?
+ */
+ plog(XLOG_ERROR, "%s: can't create lock file %s: %s "
+ "(use -n flag to override)", __func__,
+ linktargetfile, strerror(errsv));
+ goto error;
+ }
+ close(i);
+
+
+ /* Repeat until it was us who made the link */
+ while (!we_created_lockfile) {
+ struct flock flock;
+ int errsv, j;
+
+ j = link(linktargetfile, MOUNTED_LOCK);
+ errsv = errno;
+
+ if (j < 0 && errsv != EEXIST) {
+ (void) unlink(linktargetfile);
+ plog(XLOG_ERROR, "can't link lock file %s: %s ",
+ MOUNTED_LOCK, strerror(errsv));
+ rc = 0;
+ goto error;
+ }
+
+ lockfile_fd = open(MOUNTED_LOCK, O_WRONLY);
+ if (lockfile_fd < 0) {
+ int errsv = errno;
+ /* Strange... Maybe the file was just deleted? */
+ if (errno == ENOENT && tries-- > 0) {
+ if (tries % 200 == 0)
+ usleep(30);
+ continue;
+ }
+ (void) unlink(linktargetfile);
+ plog(XLOG_ERROR,"%s: can't open lock file %s: %s ", __func__,
+ MOUNTED_LOCK, strerror(errsv));
+ rc = 0;
+ goto error;
+ }
+
+ flock.l_type = F_WRLCK;
+ flock.l_whence = SEEK_SET;
+ flock.l_start = 0;
+ flock.l_len = 0;
+
+ if (j == 0) {
+ /* We made the link. Now claim the lock. */
+ if (fcntl(lockfile_fd, F_SETLK, &flock) == -1) {
+ int errsv = errno;
+ plog(XLOG_ERROR, "%s: Can't lock lock file %s: %s", __func__,
+ MOUNTED_LOCK, strerror(errsv));
+ /* proceed, since it was us who created the lockfile anyway */
+ }
+ we_created_lockfile = 1;
+ (void) unlink(linktargetfile);
+ } else {
+ static int tries = 0;
+
+ /* Someone else made the link. Wait. */
+ alarm(LOCK_TIMEOUT);
+
+ if (fcntl(lockfile_fd, F_SETLKW, &flock) == -1) {
+ int errsv = errno;
+ (void) unlink(linktargetfile);
+ plog(XLOG_ERROR, "%s: can't lock lock file %s: %s", __func__,
+ MOUNTED_LOCK, (errno == EINTR) ?
+ "timed out" : strerror(errsv));
+ rc = 0;
+ goto error;
+ }
+ alarm(0);
+ /*
+ * Limit the number of iterations - maybe there
+ * still is some old /etc/mtab~
+ */
+ ++tries;
+ if (tries % 200 == 0)
+ usleep(30);
+ if (tries > 100000) {
+ (void) unlink(linktargetfile);
+ close(lockfile_fd);
+ plog(XLOG_ERROR,
+ "%s: Cannot create link %s; Perhaps there is a stale lock file?",
+ __func__, MOUNTED_LOCK);
+ rc = 0;
+ goto error;
+ }
+ close(lockfile_fd);
+ }
+ }
+
+error:
+ XFREE(linktargetfile);
+
+ return rc;
+}
+
+
+static FILE *
+open_locked_mtab(const char *mnttabname, char *mode, char *fs)
+{
+ FILE *mfp = NULL;
+
+ if (mnt_file) {
+ dlog("Forced close on %s in read_mtab", mnttabname);
+ endmntent(mnt_file);
+ mnt_file = NULL;
+ }
+
+ if (!mtab_is_a_symlink() &&
+ !lock_mtab()) {
+ plog(XLOG_ERROR, "%s: Couldn't lock mtab", __func__);
+ return 0;
+ }
+
+ mfp = setmntent((char *)mnttabname, mode);
+ if (!mfp) {
+ plog(XLOG_ERROR, "%s: setmntent(\"%s\", \"%s\"): %m", __func__, mnttabname,
+ mode);
+ return 0;
+ }
+ return mfp;
+}
+
+
+/*
+ * Unlock the mount table
+ */
+void
+unlock_mntlist(void)
+{
+ if (mnt_file || we_created_lockfile)
+ dlog("unlock_mntlist: releasing");
+ if (mnt_file) {
+ endmntent(mnt_file);
+ mnt_file = NULL;
+ }
+ if (we_created_lockfile) {
+ close(lockfile_fd);
+ lockfile_fd = -1;
+ unlink(MOUNTED_LOCK);
+ we_created_lockfile = 0;
+ }
+}
+
+
+/*
+ * Write out a mount list
+ */
+void
+rewrite_mtab(mntlist *mp, const char *mnttabname)
+{
+ FILE *mfp;
+ int error = 0;
+ char tmpname[64];
+ int retries;
+ int tmpfd;
+ char *cp;
+ char mcp[128];
+
+ if (!mtab_is_writable()) {
+ return;
+ }
+
+ /*
+ * Concoct a temporary name in the same directory as the target mount
+ * table so that rename() will work.
+ */
+ xstrlcpy(mcp, mnttabname, sizeof(mcp));
+ cp = strrchr(mcp, '/');
+ if (cp) {
+ memmove(tmpname, mcp, cp - mcp);
+ tmpname[cp - mcp] = '\0';
+ } else {
+ plog(XLOG_WARNING, "No '/' in mtab (%s), using \".\" as tmp directory", mnttabname);
+ tmpname[0] = '.';
+ tmpname[1] = '\0';
+ }
+ xstrlcat(tmpname, "/mtabXXXXXX", sizeof(tmpname));
+ retries = 0;
+ enfile1:
+#ifdef HAVE_MKSTEMP
+ tmpfd = mkstemp(tmpname);
+ fchmod(tmpfd, 0644);
+#else /* not HAVE_MKSTEMP */
+ mktemp(tmpname);
+ tmpfd = open(tmpname, O_RDWR | O_CREAT | O_TRUNC, 0644);
+#endif /* not HAVE_MKSTEMP */
+ if (tmpfd < 0) {
+ if (errno == ENFILE && retries++ < NFILE_RETRIES) {
+ sleep(1);
+ goto enfile1;
+ }
+ plog(XLOG_ERROR, "%s: open: %m", tmpname);
+ return;
+ }
+ if (close(tmpfd) < 0)
+ plog(XLOG_ERROR, "%s: Couldn't close tmp file descriptor: %m", __func__);
+
+ retries = 0;
+ enfile2:
+ mfp = setmntent(tmpname, "w");
+ if (!mfp) {
+ if (errno == ENFILE && retries++ < NFILE_RETRIES) {
+ sleep(1);
+ goto enfile2;
+ }
+ plog(XLOG_ERROR, "%s: setmntent(\"%s\", \"w\"): %m", __func__, tmpname);
+ error = 1;
+ goto out;
+ }
+ while (mp) {
+ if (mp->mnt) {
+ if (addmntent(mfp, mp->mnt)) {
+ plog(XLOG_ERROR, "%s: Can't write entry to %s", __func__, tmpname);
+ error = 1;
+ goto out;
+ }
+ }
+ mp = mp->mnext;
+ }
+
+ /*
+ * SunOS 4.1 manuals say that the return code from entmntent()
+ * is always 1 and to treat as a void. That means we need to
+ * call fflush() to make sure the new mtab file got written.
+ */
+ if (fflush(mfp)) {
+ plog(XLOG_ERROR, "flush new mtab file: %m");
+ error = 1;
+ goto out;
+ }
+ (void) endmntent(mfp);
+
+ /*
+ * Rename temporary mtab to real mtab
+ */
+ if (rename(tmpname, mnttabname) < 0) {
+ plog(XLOG_ERROR, "rename %s to %s: %m", tmpname, mnttabname);
+ error = 1;
+ goto out;
+ }
+ out:
+ if (error)
+ (void) unlink(tmpname);
+}
+
+
+static void
+mtab_stripnl(char *s)
+{
+ do {
+ s = strchr(s, '\n');
+ if (s)
+ *s++ = ' ';
+ } while (s);
+}
+
+
+/*
+ * Append a mntent structure to the
+ * current mount table.
+ */
+void
+write_mntent(mntent_t *mp, const char *mnttabname)
+{
+ int retries = 0;
+ FILE *mfp;
+
+ if (!mtab_is_writable()) {
+ return;
+ }
+
+ enfile:
+ mfp = open_locked_mtab(mnttabname, "a", mp->mnt_dir);
+ if (mfp) {
+ mtab_stripnl(mp->mnt_opts);
+ if (addmntent(mfp, mp))
+ plog(XLOG_ERROR, "%s: Couldn't write %s: %m", __func__, mnttabname);
+ if (fflush(mfp))
+ plog(XLOG_ERROR, "%s: Couldn't flush %s: %m", __func__, mnttabname);
+ (void) endmntent(mfp);
+ } else {
+ if (errno == ENFILE && retries < NFILE_RETRIES) {
+ sleep(1);
+ goto enfile;
+ }
+ plog(XLOG_ERROR, "%s: setmntent(\"%s\", \"a\"): %m", __func__, mnttabname);
+ }
+
+ unlock_mntlist();
+}
+
+#endif /* MOUNT_TABLE_ON_FILE */
+
+
+static mntent_t *
+mnt_dup(mntent_t *mp)
+{
+ mntent_t *new_mp = ALLOC(mntent_t);
+
+ new_mp->mnt_fsname = xstrdup(mp->mnt_fsname);
+ new_mp->mnt_dir = xstrdup(mp->mnt_dir);
+ new_mp->mnt_type = xstrdup(mp->mnt_type);
+ new_mp->mnt_opts = xstrdup(mp->mnt_opts);
+
+ new_mp->mnt_freq = mp->mnt_freq;
+ new_mp->mnt_passno = mp->mnt_passno;
+
+#ifdef HAVE_MNTENT_T_MNT_TIME
+# ifdef HAVE_MNTENT_T_MNT_TIME_STRING
+ new_mp->mnt_time = xstrdup(mp->mnt_time);
+# else /* not HAVE_MNTENT_T_MNT_TIME_STRING */
+ new_mp->mnt_time = mp->mnt_time;
+# endif /* not HAVE_MNTENT_T_MNT_TIME_STRING */
+#endif /* HAVE_MNTENT_T_MNT_TIME */
+
+#ifdef HAVE_MNTENT_T_MNT_CNODE
+ new_mp->mnt_cnode = mp->mnt_cnode;
+#endif /* HAVE_MNTENT_T_MNT_CNODE */
+
+ return new_mp;
+}
+
+
+/*
+ * Read a mount table into memory
+ */
+mntlist *
+read_mtab(char *fs, const char *mnttabname)
+{
+ mntlist **mpp, *mhp;
+
+ mntent_t *mep;
+
+ FILE *mfp = open_locked_mtab(mnttabname, "r+", fs);
+
+ if (!mfp)
+ return 0;
+
+ mpp = &mhp;
+
+ /*
+ * XXX - In SunOS 4 there is (yet another) memory leak
+ * which loses 1K the first time getmntent is called.
+ * (jsp)
+ */
+ while ((mep = getmntent(mfp))) {
+ /*
+ * Allocate a new slot
+ */
+ *mpp = ALLOC(struct mntlist);
+
+ /*
+ * Copy the data returned by getmntent
+ */
+ (*mpp)->mnt = mnt_dup(mep);
+
+ /*
+ * Move to next pointer
+ */
+ mpp = &(*mpp)->mnext;
+ }
+ *mpp = NULL;
+
+#ifdef MOUNT_TABLE_ON_FILE
+ /*
+ * If we are not updating the mount table then we
+ * can free the resources held here, otherwise they
+ * must be held until the mount table update is complete
+ */
+ mnt_file = mfp;
+#else /* not MOUNT_TABLE_ON_FILE */
+ endmntent(mfp);
+#endif /* not MOUNT_TABLE_ON_FILE */
+
+ return mhp;
+}
diff --git a/conf/mtab/mtab_mach3.c b/conf/mtab/mtab_mach3.c
new file mode 100644
index 000000000000..af1313d3d8da
--- /dev/null
+++ b/conf/mtab/mtab_mach3.c
@@ -0,0 +1,501 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/mtab/mtab_mach3.c
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <am_defs.h>
+#include <amu.h>
+
+#define NFILE_RETRIES 10 /* number of retries (seconds) */
+
+static FILE *mnt_file;
+
+
+/*
+ * If the system is being trashed by something, then
+ * opening mtab may fail with ENFILE. So, go to sleep
+ * for a second and try again. (Yes - this has happened to me.)
+ *
+ * Note that this *may* block the automounter, oh well.
+ * If we get to this state then things are badly wrong anyway...
+ *
+ * Give the system 10 seconds to recover but then give up.
+ * Hopefully something else will exit and free up some file
+ * table slots in that time.
+ */
+#ifdef HAVE_FCNTL_H
+static int
+lock(int fd)
+{
+ int rc;
+ struct flock lk;
+
+ lk.l_type = F_WRLCK;
+ lk.l_whence = 0;
+ lk.l_start = 0;
+ lk.l_len = 0;
+
+again:
+ rc = fcntl(fd, F_SETLKW, (caddr_t) & lk);
+ if (rc < 0 && (errno == EACCES || errno == EAGAIN)) {
+# ifdef DEBUG
+ dlog("Blocked, trying to obtain exclusive mtab lock");
+# endif /* DEBUG */
+ sleep(1);
+ goto again;
+ }
+ return rc;
+}
+#else /* not HAVE_FCNTL_H */
+# define lock(fd) (flock((fd), LOCK_EX))
+#endif /* not HAVE_FCNTL_H */
+
+
+static FILE *
+open_locked_mtab(char *mnttabname, char *mode, char *fs)
+{
+ FILE *mfp = NULL;
+
+ /*
+ * There is a possible race condition if two processes enter
+ * this routine at the same time. One will be blocked by the
+ * exclusive lock below (or by the shared lock in setmntent)
+ * and by the time the second process has the exclusive lock
+ * it will be on the wrong underlying object. To check for this
+ * the mtab file is stat'ed before and after all the locking
+ * sequence, and if it is a different file then we assume that
+ * it may be the wrong file (only "may", since there is another
+ * race between the initial stat and the setmntent).
+ *
+ * Simpler solutions to this problem are invited...
+ */
+ int racing = 2;
+ int rc;
+ int retries = 0;
+ struct stat st_before, st_after;
+
+ if (mnt_file) {
+#ifdef DEBUG
+ dlog("Forced close on %s in read_mtab", mnttabname);
+#endif /* DEBUG */
+ endmntent(mnt_file);
+ mnt_file = NULL;
+ }
+again:
+ if (mfp) {
+ endmntent(mfp);
+ mfp = NULL;
+ }
+ if (stat(mnttabname, &st_before) < 0) {
+ plog(XLOG_ERROR, "%s: stat: %m", mnttabname);
+ if (errno == ESTALE) {
+ /* happens occasionally */
+ sleep(1);
+ goto again;
+ }
+ /*
+ * If 'mnttabname' file does not exist give setmntent() a
+ * chance to create it (depending on the mode).
+ * Otherwise, bail out.
+ */
+ else if (errno != ENOENT) {
+ return 0;
+ }
+ }
+eacces:
+ mfp = setmntent(mnttabname, mode);
+ if (!mfp) {
+ /*
+ * Since setmntent locks the descriptor, it
+ * is possible it can fail... so retry if
+ * needed.
+ */
+ if (errno == EACCES || errno == EAGAIN) {
+#ifdef DEBUG
+ dlog("Blocked, trying to obtain exclusive mtab lock");
+#endif /* DEBUG */
+ goto eacces;
+ } else if (errno == ENFILE && retries++ < NFILE_RETRIES) {
+ sleep(1);
+ goto eacces;
+ }
+ plog(XLOG_ERROR, "setmntent(\"%s\", \"%s\"): %m", mnttabname, mode);
+ return 0;
+ }
+ /*
+ * At this point we have an exclusive lock on the mount list,
+ * but it may be the wrong one so...
+ */
+
+ /*
+ * Need to get an exclusive lock on the current
+ * mount table until we have a new copy written
+ * out, when the lock is released in free_mntlist.
+ * flock is good enough since the mount table is
+ * not shared between machines.
+ */
+ do
+ rc = lock(fileno(mfp));
+ while (rc < 0 && errno == EINTR);
+ if (rc < 0) {
+ plog(XLOG_ERROR, "Couldn't lock %s: %m", mnttabname);
+ endmntent(mfp);
+ return 0;
+ }
+ /*
+ * Now check whether the mtab file has changed under our feet
+ */
+ if (stat(mnttabname, &st_after) < 0) {
+ plog(XLOG_ERROR, "%s: stat", mnttabname);
+ goto again;
+ }
+ if (st_before.st_dev != st_after.st_dev ||
+ st_before.st_ino != st_after.st_ino) {
+ struct timeval tv;
+ if (racing == 0) {
+ /* Sometimes print a warning */
+ plog(XLOG_WARNING,
+ "Possible mount table race - retrying %s", fs);
+ }
+ racing = (racing + 1) & 3;
+ /*
+ * Take a nap. From: Doug Kingston <dpk@morgan.com>
+ */
+ tv.tv_sec = 0;
+ tv.tv_usec = (am_mypid & 0x07) << 17;
+ if (tv.tv_usec)
+ if (select(0, (voidp) 0, (voidp) 0, (voidp) 0, &tv) < 0)
+ plog(XLOG_WARNING, "mtab nap failed: %m");
+
+ goto again;
+ }
+ return mfp;
+}
+
+
+/*
+ * Unlock the mount table
+ */
+void
+unlock_mntlist(void)
+{
+ /*
+ * Release file lock, by closing the file
+ */
+ if (mnt_file) {
+ dlog("unlock_mntlist: releasing");
+ endmntent(mnt_file);
+ mnt_file = NULL;
+ }
+}
+
+
+/*
+ * routine to convert notation "/@honeydew" to the notation
+ * honeydew:/ and vice versa (honeydew:/ to /@honeydew)
+ * This lets you put /@honeydew in /etc/fstab without changing
+ * fstab.c and it lets you use EITHER notation on the command line!
+ */
+static char *
+convert(register char *s, char bad, char good)
+{
+ char *index();
+ register char *t, *p;
+ register int len1, len2, i;
+ char *ptr;
+
+ if ((p = index(s, bad)) == NULL) {
+ return (s);
+ }
+ ptr = t = (char *) xzalloc(MAXPATHLEN * sizeof(char));
+ len1 = p - s;
+ len2 = strlen(s) - len1 - 1;
+ p++;
+ for (i = 0; i < len2; i++)
+ *t++ = p[i];
+ *t++ = good;
+ for (i = 0; i < len1; i++)
+ *t++ = s[i];
+ return (ptr);
+}
+
+
+static
+mntprtent3(FILE *mnttabp, register mntent_t *mnt)
+{
+ char *cvtd = convert(mnt->mnt_fsname, ':', '@');
+
+ dlog("%x:%s:%s:%s:%d:%d:%s:%s:\n",
+ mnttabp,
+ (cvtd ? cvtd : ""),
+ (mnt->mnt_dir ? mnt->mnt_dir : ""),
+ (mnt->mnt_opts ? mnt->mnt_opts : ""),
+ mnt->mnt_freq,
+ mnt->mnt_passno,
+ (mnt->mnt_type ? mnt->mnt_type : ""),
+ (mnt->mnt_opts2 ? mnt->mnt_opts2 : "")
+ );
+ fprintf(mnttabp, "%s:%s:%s:%d:%d:%s:%s:\n",
+ (cvtd ? cvtd : ""),
+ (mnt->mnt_dir ? mnt->mnt_dir : ""),
+ (mnt->mnt_opts ? mnt->mnt_opts : ""),
+ mnt->mnt_freq,
+ mnt->mnt_passno,
+ (mnt->mnt_type ? mnt->mnt_type : ""),
+ (mnt->mnt_opts2 ? mnt->mnt_opts2 : "")
+ );
+ XFREE(cvtd);
+ cvtd = NULL;
+ return (0);
+}
+
+
+addmntent3(FILE *mnttabp, register mntent_t *mnt)
+{
+ if (fseek(mnttabp, 0, 2) < 0) {
+ return (1);
+ }
+ mntprtent3(mnttabp, mnt);
+ return (0);
+}
+
+
+/*
+ * Write out a mount list
+ */
+void
+rewrite_mtab(mntlist *mp, const char *mnttabname)
+{
+ FILE *mfp;
+ int error = 0;
+ /*
+ * Concoct a temporary name in the same directory as the target mount
+ * table so that rename() will work.
+ */
+ char tmpname[64];
+ int retries;
+ int tmpfd;
+ char *cp;
+ char *mcp = mnttabname;
+
+ cp = strrchr(mcp, '/');
+ if (cp) {
+ memmove(tmpname, mcp, cp - mcp);
+ tmpname[cp - mcp] = '\0';
+ } else {
+ plog(XLOG_WARNING, "No '/' in mtab (%s), using \".\" as tmp directory", mnttabname);
+ tmpname[0] = '.';
+ tmpname[1] = '\0';
+ }
+ xstrlcat(tmpname, "/mtabXXXXXX", sizeof(tmpname));
+ retries = 0;
+enfile1:
+#ifdef HAVE_MKSTEMP
+ tmpfd = mkstemp(tmpname);
+ fchmod(tmpfd, 0644);
+#else /* not HAVE_MKSTEMP */
+ mktemp(tmpname);
+ tmpfd = open(tmpname, O_RDWR | O_CREAT | O_TRUNC, 0644);
+#endif /* not HAVE_MKSTEMP */
+ if (tmpfd < 0) {
+ if (errno == ENFILE && retries++ < NFILE_RETRIES) {
+ sleep(1);
+ goto enfile1;
+ }
+ plog(XLOG_ERROR, "%s: open: %m", tmpname);
+ return;
+ }
+ if (close(tmpfd) < 0)
+ plog(XLOG_ERROR, "Couldn't close tmp file descriptor: %m");
+
+ retries = 0;
+enfile2:
+ mfp = setmntent(tmpname, "w");
+ if (!mfp) {
+ if (errno == ENFILE && retries++ < NFILE_RETRIES) {
+ sleep(1);
+ goto enfile2;
+ }
+ plog(XLOG_ERROR, "setmntent(\"%s\", \"w\"): %m", tmpname);
+ error = 1;
+ goto out;
+ }
+ while (mp) {
+ if (mp->mnt) {
+ if (addmntent3(mfp, mp->mnt)) {
+ plog(XLOG_ERROR, "Can't write entry to %s", tmpname);
+ error = 1;
+ goto out;
+ }
+ }
+ mp = mp->mnext;
+ }
+
+ /*
+ * SunOS 4.1 manuals say that the return code from endmntent()
+ * is always 1 and to treat as a void. That means we need to
+ * call fflush() to make sure the new mtab file got written.
+ */
+ if (fflush(mfp)) {
+ plog(XLOG_ERROR, "flush new mtab file: %m");
+ error = 1;
+ goto out;
+ }
+ (void) endmntent(mfp);
+
+ /*
+ * Rename temporary mtab to real mtab
+ */
+ if (rename(tmpname, mnttabname) < 0) {
+ plog(XLOG_ERROR, "rename %s to %s: %m", tmpname, mnttabname);
+ error = 1;
+ goto out;
+ }
+out:
+ if (error)
+ (void) unlink(tmpname);
+}
+
+
+static void
+mtab_stripnl(char *s)
+{
+ do {
+ s = strchr(s, '\n');
+ if (s)
+ *s++ = ' ';
+ } while (s);
+}
+
+
+/*
+ * Append a mntent structure to the
+ * current mount table.
+ */
+void
+write_mntent(mntent_t *mp, const char *mnttabname)
+{
+ int retries = 0;
+ FILE *mfp;
+enfile:
+ mfp = open_locked_mtab(mnttabname, "a", mp->mnt_dir);
+ if (mfp) {
+ mtab_stripnl(mp->mnt_opts);
+ if (addmntent3(mfp, mp))
+ plog(XLOG_ERROR, "Couldn't write %s: %m", mnttabname);
+ if (fflush(mfp))
+ plog(XLOG_ERROR, "Couldn't flush %s: %m", mnttabname);
+ (void) endmntent(mfp);
+ } else {
+ if (errno == ENFILE && retries < NFILE_RETRIES) {
+ sleep(1);
+ goto enfile;
+ }
+ plog(XLOG_ERROR, "setmntent(\"%s\", \"a\"): %m", mnttabname);
+ }
+}
+
+
+static mntent_t *
+mnt_dup(mntent_t *mp)
+{
+ mntent_t *new_mp = ALLOC(mntent_t);
+
+ new_mp->mnt_fsname = convert(mp->mnt_fsname, '@', ':');
+
+ new_mp->mnt_dir = xstrdup(mp->mnt_dir);
+ new_mp->mnt_type = xstrdup(mp->mnt_type);
+ new_mp->mnt_opts = xstrdup(mp->mnt_opts);
+
+ new_mp->mnt_freq = mp->mnt_freq;
+ new_mp->mnt_passno = mp->mnt_passno;
+
+ return new_mp;
+}
+
+
+/*
+ * Read a mount table into memory
+ */
+mntlist *
+read_mtab(char *fs, const char *mnttabname)
+{
+ mntlist **mpp, *mhp;
+
+ mntent_t *mep;
+ FILE *mfp = open_locked_mtab(mnttabname, "r+", fs);
+
+ if (!mfp)
+ return 0;
+
+ mpp = &mhp;
+
+/*
+ * XXX - In SunOS 4 there is (yet another) memory leak
+ * which loses 1K the first time getmntent is called.
+ * (jsp)
+ */
+ while (mep = getmntent(mfp)) {
+ /*
+ * Allocate a new slot
+ */
+ *mpp = ALLOC(struct mntlist);
+
+ /*
+ * Copy the data returned by getmntent
+ */
+ (*mpp)->mnt = mnt_dup(mep);
+
+ /*
+ * Move to next pointer
+ */
+ mpp = &(*mpp)->mnext;
+ }
+ *mpp = NULL;
+
+ /*
+ * If we are not updating the mount table then we
+ * can free the resources held here, otherwise they
+ * must be held until the mount table update is complete
+ */
+ mnt_file = mfp;
+
+ return mhp;
+}
diff --git a/conf/mtab/mtab_osf.c b/conf/mtab/mtab_osf.c
new file mode 100644
index 000000000000..b9a1de533234
--- /dev/null
+++ b/conf/mtab/mtab_osf.c
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/mtab/mtab_osf.c
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <am_defs.h>
+#include <amu.h>
+
+
+static mntent_t *
+mnt_dup(struct statfs *mp)
+{
+ mntent_t *new_mp = ALLOC(mntent_t);
+ char *ty;
+ char *at;
+ char mntfrombuf[MNAMELEN];
+ char *mntfromptr;
+
+ /*
+ * Under DEC OSF/1 T1.2-2 the f_mntfromname fields of
+ * the statfs structure can be in the format <fs>@<host>
+ * instead of <host>:<fs>. Here we check for this and
+ * reformat it if necessary.
+ */
+ mntfromptr = mp->f_mntfromname;
+
+ switch (mp->f_type) {
+ case MOUNT_TYPE_NFS:
+#ifdef HAVE_FS_NFS3
+ case MOUNT_TYPE_NFS3:
+#endif /* HAVE_FS_NFS3 */
+ at = strchr(mp->f_mntfromname, '@');
+ if (at != '\0') {
+ xstrlcpy(mntfrombuf, (at + 1), sizeof(mntfrombuf));
+ xstrlcat(mntfrombuf, ":", sizeof(mntfrombuf));
+ strncat(mntfrombuf, mp->f_mntfromname, (at - mp->f_mntfromname));
+ mntfromptr = mntfrombuf;
+ }
+ }
+ new_mp->mnt_fsname = xstrdup(mntfromptr);
+
+ new_mp->mnt_dir = xstrdup(mp->f_mntonname);
+ switch (mp->f_type) {
+ case MOUNT_TYPE_UFS:
+ ty = MNTTAB_TYPE_UFS;
+ break;
+#ifdef HAVE_FS_NFS3
+ case MOUNT_TYPE_NFS3:
+ ty = MNTTAB_TYPE_NFS3;
+ break;
+#endif /* HAVE_FS_NFS3 */
+ case MOUNT_TYPE_NFS:
+ ty = MNTTAB_TYPE_NFS;
+ break;
+ case MOUNT_TYPE_MFS:
+ ty = MNTTAB_TYPE_MFS;
+ break;
+ default:
+ ty = "unknown";
+ break;
+ }
+
+ new_mp->mnt_type = xstrdup(ty);
+ new_mp->mnt_opts = xstrdup("unset");
+ new_mp->mnt_freq = 0;
+ new_mp->mnt_passno = 0;
+
+ return new_mp;
+}
+
+
+/*
+ * Read a mount table into memory
+ */
+mntlist *
+read_mtab(char *fs, const char *mnttabname)
+{
+ mntlist **mpp, *mhp;
+ struct statfs *mntbufp, *mntp;
+
+ int nloc = getmntinfo(&mntbufp, MNT_NOWAIT);
+
+ if (nloc == 0) {
+ plog(XLOG_ERROR, "Can't read mount table");
+ return 0;
+ }
+ mpp = &mhp;
+ for (mntp = mntbufp; mntp < mntbufp + nloc; mntp++) {
+ /*
+ * Allocate a new slot
+ */
+ *mpp = ALLOC(struct mntlist);
+
+ /*
+ * Copy the data returned by getmntent
+ */
+ (*mpp)->mnt = mnt_dup(mntp);
+
+ /*
+ * Move to next pointer
+ */
+ mpp = &(*mpp)->mnext;
+ }
+
+ /* terminate the linked list */
+ *mpp = NULL;
+
+ return mhp;
+}
diff --git a/conf/mtab/mtab_svr4.c b/conf/mtab/mtab_svr4.c
new file mode 100644
index 000000000000..b9a310a1903c
--- /dev/null
+++ b/conf/mtab/mtab_svr4.c
@@ -0,0 +1,302 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/mtab/mtab_svr4.c
+ *
+ * How to manage the mount table file. Based on other SVR3 ports.
+ * -Erez Zadok <ezk@cs.columbia.edu>
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <am_defs.h>
+#include <amu.h>
+
+/*
+ * file descriptor for lock file
+ * values: -1 no file-descriptor was set yet (or mnttab unlocked, or error
+ * in locking).
+ * >=0 legal file-descriptor value (file lock succeeded)
+ */
+static int mntent_lock_fd = -1;
+
+
+#ifdef MOUNT_TABLE_ON_FILE
+static char mtlckname[] = "/etc/.mnttab.lock";
+#endif /* MOUNT_TABLE_ON_FILE */
+
+
+/****************************************************************************/
+/*** Private functions */
+/****************************************************************************/
+
+static void
+unlockmnttab(void)
+{
+#ifdef MOUNT_TABLE_ON_FILE
+ if (mntent_lock_fd >= 0) {
+ close(mntent_lock_fd);
+ mntent_lock_fd = -1;
+ }
+#endif /* MOUNT_TABLE_ON_FILE */
+}
+
+
+#ifdef MOUNT_TABLE_ON_FILE
+static int
+lockfile(int fd, int type)
+{
+ struct flock lk;
+ int ret;
+
+ lk.l_type = type;
+ lk.l_whence = 0;
+ lk.l_start = 0;
+ lk.l_len = 0;
+
+ /*
+ * F_SETLKW means to block until the read or write block is free to be
+ * locked.
+ */
+ ret = fcntl(fd, F_SETLKW, &lk);
+ return ret;
+}
+#endif /* MOUNT_TABLE_ON_FILE */
+
+
+/* return 0 if locking succeeded, -1 if failed */
+static int
+lockmnttab(void)
+{
+#ifdef MOUNT_TABLE_ON_FILE
+ /* if mnttab file is locked, all is well */
+ if (mntent_lock_fd >= 0)
+ return 0;
+
+ /* need to lock mnttab file. first, open the file */
+ mntent_lock_fd = open(mtlckname, O_RDWR | O_CREAT, 0600);
+ if (mntent_lock_fd < 0) {
+ plog(XLOG_ERROR, "Unable to open/creat %s: %m", mtlckname);
+ return -1;
+ }
+
+ /* if succeeded in opening the file, try to lock it */
+ if (lockfile(mntent_lock_fd, F_WRLCK) < 0) {
+ close(mntent_lock_fd);
+ mntent_lock_fd = -1;
+#ifdef DEBUG
+ dlog("lock %s failed: %m", mtlckname);
+#endif /* DEBUG */
+ return -1;
+ }
+#else /* not MOUNT_TABLE_ON_FILE */
+ /* fake lock for in-kernel mount table */
+#endif /* not MOUNT_TABLE_ON_FILE */
+
+ /* finally, succeeded in also locking the file */
+ return 0;
+}
+
+
+/*
+ * Convert from solaris mnttab to Amd mntent. Since am-utils uses
+ * native "struct mnttab" if available, this really copies fields of
+ * the same structure.
+ */
+static mntent_t *
+mnt_dup(const mntent_t *mtp)
+{
+ mntent_t *mep = ALLOC(mntent_t);
+
+ mep->mnt_fsname = xstrdup(mtp->mnt_fsname);
+ mep->mnt_dir = xstrdup(mtp->mnt_dir);
+ mep->mnt_type = xstrdup(mtp->mnt_type);
+ mep->mnt_opts = xstrdup(mtp->mnt_opts);
+ mep->mnt_time = xstrdup(mtp->mnt_time);
+
+ return mep;
+}
+
+
+/*
+ * Adjust arguments in mntent_t.
+ */
+#ifdef MOUNT_TABLE_ON_FILE
+static mntent_t *
+update_mnttab_fields(const mntent_t *mnt)
+{
+ static mntent_t mt;
+ static char timestr[16];
+ struct timeval tv;
+
+ /* most fields don't change, only update mnt_time below */
+ mt.mnt_fsname = mnt->mnt_fsname;
+ mt.mnt_dir = mnt->mnt_dir;
+ mt.mnt_type = mnt->mnt_type;
+ mt.mnt_opts = mnt->mnt_opts;
+
+ /*
+ * Solaris 2.5 and newer take a second argument to gettimeofday(). If you
+ * find a useful svr4-like OS that uses the old style, and this code here
+ * fails, then create a new autoconf test that will determine the number
+ * of arguments gettimeofday() takes. -Erez.
+ */
+ if (gettimeofday(&tv, NULL) < 0)
+ timestr[0] = '\0';
+ else
+ xsnprintf(timestr, sizeof(timestr), "%ld", tv.tv_sec);
+
+ mt.mnt_time = timestr;
+
+ return &mt;
+}
+#endif /* MOUNT_TABLE_ON_FILE */
+
+
+static void
+write_mntent_to_mtab(FILE *fp, const mntent_t *mnt)
+{
+#ifdef MOUNT_TABLE_ON_FILE
+ putmntent(fp, update_mnttab_fields(mnt));
+#endif /* MOUNT_TABLE_ON_FILE */
+}
+
+
+/****************************************************************************/
+/*** Public functions */
+/****************************************************************************/
+
+
+void
+unlock_mntlist(void)
+{
+ unlockmnttab();
+}
+
+
+/*
+ * Read a mount table into memory
+ */
+mntlist *
+read_mtab(char *fs, const char *mnttabname)
+{
+ mntlist **mpp, *mhp;
+ FILE *fp;
+ mntent_t mountbuf;
+ int ret;
+
+ if (lockmnttab() < 0) /* failed locking */
+ return NULL;
+
+ fp = fopen(mnttabname, "r");
+ if (fp == NULL) {
+ plog(XLOG_ERROR, "Can't open %s: %m", mnttabname);
+ return NULL;
+ }
+ mpp = &mhp;
+
+ while ((ret = getmntent(fp, &mountbuf)) == 0) {
+ /*
+ * Allocate a new slot
+ */
+ *mpp = ALLOC(struct mntlist);
+
+ /*
+ * Copy the data returned by getmntent
+ */
+ (*mpp)->mnt = mnt_dup(&mountbuf);
+
+ /*
+ * Move to next pointer
+ */
+ mpp = &(*mpp)->mnext;
+ }
+
+ if (ret > 0) {
+ plog(XLOG_ERROR, "read error on %s: %m", mnttabname);
+ unlockmnttab();
+ mhp = NULL;
+ }
+ *mpp = NULL;
+
+ fclose(fp);
+ return mhp;
+}
+
+
+void
+rewrite_mtab(mntlist *mp, const char *mnttabname)
+{
+ FILE *fp;
+
+ assert(mntent_lock_fd >= 0); /* ensure lock fd is valid */
+
+ fp = fopen(mnttabname, "r+");
+ if (fp == NULL) {
+ plog(XLOG_ERROR, "Can't open %s: %m", mnttabname);
+ unlockmnttab();
+ return;
+ }
+ while (mp) {
+ if (mp->mnt)
+ write_mntent_to_mtab(fp, mp->mnt);
+ mp = mp->mnext;
+ }
+
+ ftruncate(fileno(fp), ftell(fp));
+ fclose(fp);
+ unlockmnttab();
+}
+
+
+void
+write_mntent(mntent_t *mtp, const char *mnttabname)
+{
+ FILE *fp;
+
+ if (lockmnttab() < 0)
+ return;
+
+ fp = fopen(mnttabname, "a");
+ if (fp == NULL) {
+ plog(XLOG_ERROR, "Unable to append %s: %m", mnttabname);
+ return;
+ }
+ write_mntent_to_mtab(fp, mtp);
+
+ fclose(fp);
+ unlockmnttab();
+}
diff --git a/conf/mtab/mtab_ultrix.c b/conf/mtab/mtab_ultrix.c
new file mode 100644
index 000000000000..ea0eed6e8cf5
--- /dev/null
+++ b/conf/mtab/mtab_ultrix.c
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/mtab/mtab_ultrix.c
+ *
+ */
+
+/*
+ * Include before config.h to force single definition of gt_names[] here.
+ * This can be done unconditionally since this file is Ultrix specific
+ * anyway and <sys/fs_types.h> is properly protected from multiple inclusion.
+ * - Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
+ * Hack hack hack. Sigh. -Erez.
+ */
+#include <sys/fs_types.h>
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+#include <am_defs.h>
+#include <amu.h>
+
+#ifndef NMOUNT
+# define NMOUNT 20
+#endif /* NMOUNT */
+
+
+static mntent_t *
+mnt_dup(struct fs_data *mp)
+{
+ mntent_t *new_mp = ALLOC(mntent_t);
+
+ new_mp->mnt_fsname = xstrdup(mp->fd_devname);
+ new_mp->mnt_dir = xstrdup(mp->fd_path);
+ if (mp->fd_fstype >= GT_NUMTYPES)
+ mp->fd_fstype = GT_UNKWN;
+ else if (gt_names[mp->fd_fstype] == 0)
+ mp->fd_fstype = GT_UNKWN;
+ new_mp->mnt_type = xstrdup(gt_names[mp->fd_fstype]);
+ new_mp->mnt_opts = xstrdup("unset");
+
+ new_mp->mnt_freq = 0;
+ new_mp->mnt_passno = mp->fd_dev;
+
+ return new_mp;
+}
+
+
+/*
+ * Read a mount table into memory
+ */
+mntlist *
+read_mtab(char *fs, const char *mnttabname)
+{
+ mntlist **mpp, *mhp;
+ /* From: Piete Brooks <pb@cl.cam.ac.uk> */
+ int loc = 0;
+ struct fs_data mountbuffer[NMOUNT], *fs_data;
+ int ret;
+
+ mpp = &mhp;
+ while ((ret = getmountent(&loc, mountbuffer, NMOUNT)) > 0) {
+ for (fs_data = mountbuffer; fs_data < &mountbuffer[ret]; fs_data++) {
+ /*
+ * Allocate a new slot
+ */
+ *mpp = ALLOC(struct mntlist);
+
+ /*
+ * Copy the data returned by getmntent
+ */
+ (*mpp)->mnt = mnt_dup(fs_data);
+
+ /*
+ * Move to next pointer
+ */
+ mpp = &(*mpp)->mnext;
+ }
+ }
+ if (ret < 0) {
+ plog(XLOG_ERROR, "getmountent: %m");
+ return 0;
+ }
+ *mpp = NULL;
+
+ return mhp;
+}
diff --git a/conf/nfs_prot/nfs_prot_aix3.h b/conf/nfs_prot/nfs_prot_aix3.h
new file mode 100644
index 000000000000..360f14a78037
--- /dev/null
+++ b/conf/nfs_prot/nfs_prot_aix3.h
@@ -0,0 +1,212 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/nfs_prot/nfs_prot_aix3.h
+ *
+ */
+
+#ifndef _AMU_NFS_PROT_H
+#define _AMU_NFS_PROT_H
+
+#ifdef HAVE_RPCSVC_NFS_PROT_H
+# include <rpcsvc/nfs_prot.h>
+#endif /* HAVE_RPCSVC_NFS_PROT_H */
+#ifdef HAVE_NFS_NFSV2_H
+# include <nfs/nfsv2.h>
+#endif /* HAVE_NFS_NFSV2_H */
+#ifdef HAVE_NFS_RPCV2_H
+# include <nfs/rpcv2.h>
+#endif /* HAVE_NFS_RPCV2_H */
+#ifdef HAVE_SYS_FS_NFS_H
+# include <sys/fs/nfs.h>
+#endif /* HAVE_SYS_FS_NFS_H */
+
+/* don't include this one */
+#ifdef HAVE_RPCSVC_MOUNT_H_not
+# include <rpcsvc/mount.h>
+#endif /* HAVE_RPCSVC_MOUNT_H */
+
+
+/*
+ * MACROS
+ */
+
+#ifndef MNTPATHLEN
+# define MNTPATHLEN 1024
+#endif /* not MNTPATHLEN */
+#ifndef MNTNAMLEN
+# define MNTNAMLEN 255
+#endif /* not MNTNAMLEN */
+
+/* map field names */
+#define ex_dir ex_name
+#define gr_name g_name
+#define gr_next g_next
+#define ml_directory ml_path
+#define ml_hostname ml_name
+#define ml_next ml_nxt
+
+#define dr_drok_u diropres
+#define ca_attributes attributes
+#define ca_where where
+#define da_fhandle dir
+#define da_name name
+#define dl_entries entries
+#define dl_eof eof
+#define dr_status status
+#define dr_u diropres_u
+#define drok_attributes attributes
+#define drok_fhandle file
+#define fh_data data
+#define la_fhandle from
+#define la_to to
+#define na_atime atime
+#define na_blocks blocks
+#define na_blocksize blocksize
+#define na_ctime ctime
+#define na_fileid fileid
+#define na_fsid fsid
+#define na_gid gid
+#define na_mode mode
+#define na_mtime mtime
+#define na_nlink nlink
+#define na_rdev rdev
+#define na_size size
+#define na_type type
+#define na_uid uid
+#define ne_cookie cookie
+#define ne_fileid fileid
+#define ne_name name
+#define ne_nextentry nextentry
+#define ns_attr_u attributes
+#define ns_status status
+#define ns_u attrstat_u
+#define nt_seconds seconds
+#define nt_useconds useconds
+#define ra_count count
+#define ra_fhandle file
+#define ra_offset offset
+#define ra_totalcount totalcount
+#define raok_attributes attributes
+#define raok_len_u data_len
+#define raok_u data
+#define raok_val_u data_val
+#define rda_cookie cookie
+#define rda_count count
+#define rda_fhandle dir
+#define rdr_reply_u reply
+#define rdr_status status
+#define rdr_u readdirres_u
+#define rlr_data_u data
+#define rlr_status status
+#define rlr_u readlinkres_u
+#define rna_from from
+#define rna_to to
+#define rr_reply_u reply
+#define rr_status status
+#define rr_u readres_u
+#define sa_atime atime
+#define sa_gid gid
+#define sa_mode mode
+#define sa_mtime mtime
+#define sa_size size
+#define sa_uid uid
+#define sag_attributes attributes
+#define sag_fhandle file
+#define sfr_reply_u reply
+#define sfr_status status
+#define sfr_u statfsres_u
+#define sfrok_bavail bavail
+#define sfrok_bfree bfree
+#define sfrok_blocks blocks
+#define sfrok_bsize bsize
+#define sfrok_tsize tsize
+#define sla_attributes attributes
+#define sla_from from
+#define sla_to to
+#define wra_beginoffset beginoffset
+#define wra_fhandle file
+#define wra_len_u data_len
+#define wra_offset offset
+#define wra_totalcount totalcount
+#define wra_u data
+#define wra_val_u data_val
+
+
+/*
+ * TYPEDEFS:
+ */
+typedef char *dirpath;
+typedef char *name;
+typedef struct exports *exports;
+typedef struct exports exportnode;
+typedef struct groups *groups;
+typedef struct groups groupnode;
+typedef struct mountlist *mountlist;
+
+typedef attrstat nfsattrstat;
+typedef createargs nfscreateargs;
+typedef dirlist nfsdirlist;
+typedef diropargs nfsdiropargs;
+typedef diropokres nfsdiropokres;
+typedef diropres nfsdiropres;
+typedef entry nfsentry;
+typedef fattr nfsfattr;
+typedef ftype nfsftype;
+typedef linkargs nfslinkargs;
+typedef readargs nfsreadargs;
+typedef readdirargs nfsreaddirargs;
+typedef readdirres nfsreaddirres;
+typedef readlinkres nfsreadlinkres;
+typedef readokres nfsreadokres;
+typedef readres nfsreadres;
+typedef renameargs nfsrenameargs;
+typedef sattr nfssattr;
+typedef sattrargs nfssattrargs;
+typedef statfsokres nfsstatfsokres;
+typedef statfsres nfsstatfsres;
+typedef symlinkargs nfssymlinkargs;
+typedef writeargs nfswriteargs;
+
+/*
+ * EXTERNALS:
+ */
+extern bool_t xdr_groups(XDR *xdrs, groups *objp);
+
+/*
+ * STRUCTURES:
+ */
+
+#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_aix4.h b/conf/nfs_prot/nfs_prot_aix4.h
new file mode 100644
index 000000000000..44f07eb4ecad
--- /dev/null
+++ b/conf/nfs_prot/nfs_prot_aix4.h
@@ -0,0 +1,210 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/nfs_prot/nfs_prot_aix4.h
+ *
+ */
+
+#ifndef _AMU_NFS_PROT_H
+#define _AMU_NFS_PROT_H
+
+#ifdef HAVE_RPCSVC_NFS_PROT_H
+# include <rpcsvc/nfs_prot.h>
+#endif /* HAVE_RPCSVC_NFS_PROT_H */
+#ifdef HAVE_NFS_NFSV2_H
+# include <nfs/nfsv2.h>
+#endif /* HAVE_NFS_NFSV2_H */
+#ifdef HAVE_NFS_RPCV2_H
+# include <nfs/rpcv2.h>
+#endif /* HAVE_NFS_RPCV2_H */
+#ifdef HAVE_SYS_FS_NFS_H
+# include <sys/fs/nfs.h>
+#endif /* HAVE_SYS_FS_NFS_H */
+#ifdef HAVE_RPCSVC_MOUNT_H
+# include <rpcsvc/mount.h>
+#endif /* HAVE_RPCSVC_MOUNT_H */
+
+
+/*
+ * MACROS
+ */
+
+#ifndef MNTPATHLEN
+# define MNTPATHLEN 1024
+#endif /* not MNTPATHLEN */
+#ifndef MNTNAMLEN
+# define MNTNAMLEN 255
+#endif /* not MNTNAMLEN */
+
+/* map field names */
+#define ex_dir ex_name
+#define gr_name g_name
+#define gr_next g_next
+#define ml_directory ml_path
+#define ml_hostname ml_name
+#define ml_next ml_nxt
+
+#define dr_drok_u diropres
+#define ca_attributes attributes
+#define ca_where where
+#define da_fhandle dir
+#define da_name name
+#define dl_entries entries
+#define dl_eof eof
+#define dr_status status
+#define dr_u diropres_u
+#define drok_attributes attributes
+#define drok_fhandle file
+#define fh_data data
+#define la_fhandle from
+#define la_to to
+#define na_atime atime
+#define na_blocks blocks
+#define na_blocksize blocksize
+#define na_ctime ctime
+#define na_fileid fileid
+#define na_fsid fsid
+#define na_gid gid
+#define na_mode mode
+#define na_mtime mtime
+#define na_nlink nlink
+#define na_rdev rdev
+#define na_size size
+#define na_type type
+#define na_uid uid
+#define ne_cookie cookie
+#define ne_fileid fileid
+#define ne_name name
+#define ne_nextentry nextentry
+#define ns_attr_u attributes
+#define ns_status status
+#define ns_u attrstat_u
+#define nt_seconds seconds
+#define nt_useconds useconds
+#define ra_count count
+#define ra_fhandle file
+#define ra_offset offset
+#define ra_totalcount totalcount
+#define raok_attributes attributes
+#define raok_len_u data_len
+#define raok_u data
+#define raok_val_u data_val
+#define rda_cookie cookie
+#define rda_count count
+#define rda_fhandle dir
+#define rdr_reply_u reply
+#define rdr_status status
+#define rdr_u readdirres_u
+#define rlr_data_u data
+#define rlr_status status
+#define rlr_u readlinkres_u
+#define rna_from from
+#define rna_to to
+#define rr_reply_u reply
+#define rr_status status
+#define rr_u readres_u
+#define sa_atime atime
+#define sa_gid gid
+#define sa_mode mode
+#define sa_mtime mtime
+#define sa_size size
+#define sa_uid uid
+#define sag_attributes attributes
+#define sag_fhandle file
+#define sfr_reply_u reply
+#define sfr_status status
+#define sfr_u statfsres_u
+#define sfrok_bavail bavail
+#define sfrok_bfree bfree
+#define sfrok_blocks blocks
+#define sfrok_bsize bsize
+#define sfrok_tsize tsize
+#define sla_attributes attributes
+#define sla_from from
+#define sla_to to
+#define wra_beginoffset beginoffset
+#define wra_fhandle file
+#define wra_len_u data_len
+#define wra_offset offset
+#define wra_totalcount totalcount
+#define wra_u data
+#define wra_val_u data_val
+
+
+/*
+ * TYPEDEFS:
+ */
+typedef char *dirpath;
+typedef char *name;
+typedef struct exports *exports;
+typedef struct exports exportnode;
+typedef struct groups *groups;
+typedef struct groups groupnode;
+typedef struct mountlist *mountlist;
+
+typedef attrstat nfsattrstat;
+typedef createargs nfscreateargs;
+typedef dirlist nfsdirlist;
+typedef diropargs nfsdiropargs;
+typedef diropokres nfsdiropokres;
+typedef diropres nfsdiropres;
+typedef entry nfsentry;
+typedef fattr nfsfattr;
+typedef ftype nfsftype;
+typedef linkargs nfslinkargs;
+typedef readargs nfsreadargs;
+typedef readdirargs nfsreaddirargs;
+typedef readdirres nfsreaddirres;
+typedef readlinkres nfsreadlinkres;
+typedef readokres nfsreadokres;
+typedef readres nfsreadres;
+typedef renameargs nfsrenameargs;
+typedef sattr nfssattr;
+typedef sattrargs nfssattrargs;
+typedef statfsokres nfsstatfsokres;
+typedef statfsres nfsstatfsres;
+typedef symlinkargs nfssymlinkargs;
+typedef writeargs nfswriteargs;
+
+/*
+ * EXTERNALS:
+ */
+extern bool_t xdr_groups(XDR *xdrs, groups *objp);
+
+/*
+ * STRUCTURES:
+ */
+
+#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_aix4_2.h b/conf/nfs_prot/nfs_prot_aix4_2.h
new file mode 100644
index 000000000000..40acae9369e4
--- /dev/null
+++ b/conf/nfs_prot/nfs_prot_aix4_2.h
@@ -0,0 +1,249 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/nfs_prot/nfs_prot_aix4_2.h
+ *
+ */
+
+#ifndef _AMU_NFS_PROT_H
+#define _AMU_NFS_PROT_H
+
+
+/*
+ * AIX 4.2 and newer support NFS V.3, hence the separate header.
+ */
+
+#ifdef HAVE_RPCSVC_NFS_PROT_H
+# include <rpcsvc/nfs_prot.h>
+#endif /* HAVE_RPCSVC_NFS_PROT_H */
+#ifdef HAVE_NFS_NFSV2_H
+# include <nfs/nfsv2.h>
+#endif /* HAVE_NFS_NFSV2_H */
+#ifdef HAVE_NFS_RPCV2_H
+# include <nfs/rpcv2.h>
+#endif /* HAVE_NFS_RPCV2_H */
+#ifdef HAVE_SYS_FS_NFS_H
+# include <sys/fs/nfs.h>
+#endif /* HAVE_SYS_FS_NFS_H */
+#ifdef HAVE_RPCSVC_MOUNT_H
+# include <rpcsvc/mount.h>
+#endif /* HAVE_RPCSVC_MOUNT_H */
+
+
+/*
+ * MACROS
+ */
+
+#ifndef MNTPATHLEN
+# define MNTPATHLEN 1024
+#endif /* not MNTPATHLEN */
+#ifndef MNTNAMLEN
+# define MNTNAMLEN 255
+#endif /* not MNTNAMLEN */
+
+/* map field names */
+#define ex_dir ex_name
+#define gr_name g_name
+#define gr_next g_next
+#define ml_directory ml_path
+#define ml_hostname ml_name
+#define ml_next ml_nxt
+
+#define dr_drok_u diropres
+#define ca_attributes attributes
+#define ca_where where
+#define da_fhandle dir
+#define da_name name
+#define dl_entries entries
+#define dl_eof eof
+#define dr_status status
+#define dr_u diropres_u
+#define drok_attributes attributes
+#define drok_fhandle file
+#define fh_data data
+#define la_fhandle from
+#define la_to to
+#define na_atime atime
+#define na_blocks blocks
+#define na_blocksize blocksize
+#define na_ctime ctime
+#define na_fileid fileid
+#define na_fsid fsid
+#define na_gid gid
+#define na_mode mode
+#define na_mtime mtime
+#define na_nlink nlink
+#define na_rdev rdev
+#define na_size size
+#define na_type type
+#define na_uid uid
+#define ne_cookie cookie
+#define ne_fileid fileid
+#define ne_name name
+#define ne_nextentry nextentry
+#define ns_attr_u attributes
+#define ns_status status
+#define ns_u attrstat_u
+#define nt_seconds seconds
+#define nt_useconds useconds
+#define ra_count count
+#define ra_fhandle file
+#define ra_offset offset
+#define ra_totalcount totalcount
+#define raok_attributes attributes
+#define raok_len_u data_len
+#define raok_u data
+#define raok_val_u data_val
+#define rda_cookie cookie
+#define rda_count count
+#define rda_fhandle dir
+#define rdr_reply_u reply
+#define rdr_status status
+#define rdr_u readdirres_u
+#define rlr_data_u data
+#define rlr_status status
+#define rlr_u readlinkres_u
+#define rna_from from
+#define rna_to to
+#define rr_reply_u reply
+#define rr_status status
+#define rr_u readres_u
+#define sa_atime atime
+#define sa_gid gid
+#define sa_mode mode
+#define sa_mtime mtime
+#define sa_size size
+#define sa_uid uid
+#define sag_attributes attributes
+#define sag_fhandle file
+#define sfr_reply_u reply
+#define sfr_status status
+#define sfr_u statfsres_u
+#define sfrok_bavail bavail
+#define sfrok_bfree bfree
+#define sfrok_blocks blocks
+#define sfrok_bsize bsize
+#define sfrok_tsize tsize
+#define sla_attributes attributes
+#define sla_from from
+#define sla_to to
+#define wra_beginoffset beginoffset
+#define wra_fhandle file
+#define wra_len_u data_len
+#define wra_offset offset
+#define wra_totalcount totalcount
+#define wra_u data
+#define wra_val_u data_val
+
+
+/*
+ * TYPEDEFS:
+ */
+typedef char *dirpath;
+typedef char *name;
+typedef struct exports *exports;
+typedef struct exports exportnode;
+typedef struct groups *groups;
+typedef struct groups groupnode;
+typedef struct mountlist *mountlist;
+
+typedef attrstat nfsattrstat;
+typedef createargs nfscreateargs;
+typedef dirlist nfsdirlist;
+typedef diropargs nfsdiropargs;
+typedef diropokres nfsdiropokres;
+typedef diropres nfsdiropres;
+typedef entry nfsentry;
+typedef fattr nfsfattr;
+typedef ftype nfsftype;
+typedef linkargs nfslinkargs;
+typedef readargs nfsreadargs;
+typedef readdirargs nfsreaddirargs;
+typedef readdirres nfsreaddirres;
+typedef readlinkres nfsreadlinkres;
+typedef readokres nfsreadokres;
+typedef readres nfsreadres;
+typedef renameargs nfsrenameargs;
+typedef sattr nfssattr;
+typedef sattrargs nfssattrargs;
+typedef statfsokres nfsstatfsokres;
+typedef statfsres nfsstatfsres;
+typedef symlinkargs nfssymlinkargs;
+typedef writeargs nfswriteargs;
+
+
+/*
+ * EXTERNALS:
+ */
+
+
+/*
+ * STRUCTURES:
+ */
+
+/*
+ * AIX 4.2 has NFS V3, but it is undefined in the header files.
+ * so I define everything that's needed for NFS V3 here.
+ */
+#ifdef MNT_NFS3
+
+struct aix4_nfs_args {
+ struct sockaddr_in addr; /* server address and port */
+ caddr_t u0; /* ??? UNKNOWN ??? */
+ unsigned long proto; /* IPPROTO_TCP/IPPROTO_UDP */
+ char *hostname; /* pointer to hostname? */
+ char *netname; /* pointer to netname? */
+ caddr_t fh; /* pointer to NFS v3 fh? */
+ unsigned long flags; /* flags */
+ unsigned long wsize; /* wsize */
+ unsigned long rsize; /* rsize */
+ unsigned long timeo; /* timeo */
+ unsigned long retrans; /* retrans */
+ unsigned long acregmin; /* acregmin */
+ unsigned long acregmax; /* acregmax */
+ unsigned long acdirmin; /* acdirmin */
+ unsigned long acdirmax; /* acdirmax */
+ unsigned long u14; /* ??? UNKNOWN ??? */
+ struct pathcnf *pathconf; /* pathconf */
+};
+
+#endif /* MNT_NFS3 */
+
+/*
+ * EXTERNALS:
+ */
+extern bool_t xdr_groups(XDR *xdrs, groups *objp);
+
+#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_aix4_3.h b/conf/nfs_prot/nfs_prot_aix4_3.h
new file mode 100644
index 000000000000..442cd174e3e5
--- /dev/null
+++ b/conf/nfs_prot/nfs_prot_aix4_3.h
@@ -0,0 +1,317 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/nfs_prot/nfs_prot_aix4_3.h
+ *
+ */
+
+#ifndef _AMU_NFS_PROT_H
+#define _AMU_NFS_PROT_H
+
+
+/*
+ * AIX 4.3 and newer support NFS V.3, hence the separate header.
+ */
+
+#ifdef HAVE_RPCSVC_NFS_PROT_H
+# include <rpcsvc/nfs_prot.h>
+#endif /* HAVE_RPCSVC_NFS_PROT_H */
+#ifdef HAVE_NFS_NFSV2_H
+# include <nfs/nfsv2.h>
+#endif /* HAVE_NFS_NFSV2_H */
+#ifdef HAVE_NFS_RPCV2_H
+# include <nfs/rpcv2.h>
+#endif /* HAVE_NFS_RPCV2_H */
+#ifdef HAVE_SYS_FS_NFS_H
+# include <sys/fs/nfs.h>
+#endif /* HAVE_SYS_FS_NFS_H */
+#ifdef HAVE_RPCSVC_MOUNT_H
+# include <rpcsvc/mount.h>
+#endif /* HAVE_RPCSVC_MOUNT_H */
+
+
+/*
+ * MACROS
+ */
+
+#ifndef MNTPATHLEN
+# define MNTPATHLEN 1024
+#endif /* not MNTPATHLEN */
+#ifndef MNTNAMLEN
+# define MNTNAMLEN 255
+#endif /* not MNTNAMLEN */
+
+/* map field names */
+#define ex_dir ex_name
+#define gr_name g_name
+#define gr_next g_next
+#define ml_directory ml_path
+#define ml_hostname ml_name
+#define ml_next ml_nxt
+
+#define dr_drok_u diropres
+#define ca_attributes attributes
+#define ca_where where
+#define da_fhandle dir
+#define da_name name
+#define dl_entries entries
+#define dl_eof eof
+#define dr_status status
+#define dr_u diropres_u
+#define drok_attributes attributes
+#define drok_fhandle file
+#define fh_data data
+#define la_fhandle from
+#define la_to to
+#define na_atime atime
+#define na_blocks blocks
+#define na_blocksize blocksize
+#define na_ctime ctime
+#define na_fileid fileid
+#define na_fsid fsid
+#define na_gid gid
+#define na_mode mode
+#define na_mtime mtime
+#define na_nlink nlink
+#define na_rdev rdev
+#define na_size size
+#define na_type type
+#define na_uid uid
+#define ne_cookie cookie
+#define ne_fileid fileid
+#define ne_name name
+#define ne_nextentry nextentry
+#define ns_attr_u attributes
+#define ns_status status
+#define ns_u attrstat_u
+#define nt_seconds seconds
+#define nt_useconds useconds
+#define ra_count count
+#define ra_fhandle file
+#define ra_offset offset
+#define ra_totalcount totalcount
+#define raok_attributes attributes
+#define raok_len_u data_len
+#define raok_u data
+#define raok_val_u data_val
+#define rda_cookie cookie
+#define rda_count count
+#define rda_fhandle dir
+#define rdr_reply_u reply
+#define rdr_status status
+#define rdr_u readdirres_u
+#define rlr_data_u data
+#define rlr_status status
+#define rlr_u readlinkres_u
+#define rna_from from
+#define rna_to to
+#define rr_reply_u reply
+#define rr_status status
+#define rr_u readres_u
+#define sa_atime atime
+#define sa_gid gid
+#define sa_mode mode
+#define sa_mtime mtime
+#define sa_size size
+#define sa_uid uid
+#define sag_attributes attributes
+#define sag_fhandle file
+#define sfr_reply_u reply
+#define sfr_status status
+#define sfr_u statfsres_u
+#define sfrok_bavail bavail
+#define sfrok_bfree bfree
+#define sfrok_blocks blocks
+#define sfrok_bsize bsize
+#define sfrok_tsize tsize
+#define sla_attributes attributes
+#define sla_from from
+#define sla_to to
+#define wra_beginoffset beginoffset
+#define wra_fhandle file
+#define wra_len_u data_len
+#define wra_offset offset
+#define wra_totalcount totalcount
+#define wra_u data
+#define wra_val_u data_val
+
+
+/*
+ * TYPEDEFS:
+ */
+typedef char *dirpath;
+typedef char *name;
+typedef struct exports *exports;
+typedef struct exports exportnode;
+typedef struct groups *groups;
+typedef struct groups groupnode;
+typedef struct mountlist *mountlist;
+
+typedef attrstat nfsattrstat;
+typedef createargs nfscreateargs;
+typedef dirlist nfsdirlist;
+typedef diropargs nfsdiropargs;
+typedef diropokres nfsdiropokres;
+typedef diropres nfsdiropres;
+typedef entry nfsentry;
+typedef fattr nfsfattr;
+typedef ftype nfsftype;
+typedef linkargs nfslinkargs;
+typedef readargs nfsreadargs;
+typedef readdirargs nfsreaddirargs;
+typedef readdirres nfsreaddirres;
+typedef readlinkres nfsreadlinkres;
+typedef readokres nfsreadokres;
+typedef readres nfsreadres;
+typedef renameargs nfsrenameargs;
+typedef sattr nfssattr;
+typedef sattrargs nfssattrargs;
+typedef statfsokres nfsstatfsokres;
+typedef statfsres nfsstatfsres;
+typedef symlinkargs nfssymlinkargs;
+typedef writeargs nfswriteargs;
+
+
+/*
+ * EXTERNALS:
+ */
+
+
+/*
+ * STRUCTURES:
+ */
+
+/*
+ * AIX 4.3 has NFS V3, but it is undefined in the header files.
+ * so I define everything that's needed for NFS V3 here.
+ */
+#ifdef MNT_NFS3
+
+struct aix4_nfs_args {
+ struct sockaddr_in addr; /* file server address */
+ struct sockaddr_in *syncaddr; /* secure NFS time sync addr */
+ int proto; /* IPPROTO_TCP/IPPROTO_UDP ??? */
+ char *hostname; /* server's hostname */
+ char *netname; /* server's netname */
+ caddr_t fh; /* File handle to be mounted */
+ int flags; /* flags */
+ int wsize; /* write size in bytes */
+ int rsize; /* read size in bytes */
+ int timeo; /* initial timeout in .1 secs */
+ int retrans; /* times to retry send */
+ int acregmin; /* attr cache file min secs */
+ int acregmax; /* attr cache file max secs */
+ int acdirmin; /* attr cache dir min secs */
+ int acdirmax; /* attr cache dir max secs */
+ struct ppathcnf *pathconf; /* static pathconf kludge */
+ int biods; /* biods per mount */
+ int numclust; /* numclust per mount */
+};
+
+#if 0
+/* old structure we hand crafted. no longer needed */
+struct aix4_nfs_args {
+ struct sockaddr_in addr; /* server address and port */
+ caddr_t u0; /* ??? UNKNOWN ??? */
+ unsigned long proto; /* IPPROTO_TCP/IPPROTO_UDP */
+ char *hostname; /* pointer to hostname? */
+ char *netname; /* pointer to netname? */
+ caddr_t fh; /* pointer to NFS v3 fh? */
+ unsigned long flags; /* flags */
+ unsigned long wsize; /* wsize */
+ unsigned long rsize; /* rsize */
+ unsigned long timeo; /* timeo */
+ unsigned long retrans; /* retrans */
+ unsigned long acregmin; /* acregmin */
+ unsigned long acregmax; /* acregmax */
+ unsigned long acdirmin; /* acdirmin */
+ unsigned long acdirmax; /* acdirmax */
+ unsigned long u14; /* ??? UNKNOWN ??? */
+ struct pathcnf *pathconf; /* pathconf */
+};
+#endif /* 0 */
+
+/*
+ * IBM is in dire need of taking a soft-eng class.
+ * They changed the API/ABI (namely the nfs3_args structure)
+ * in a service pack...
+ *
+ * All the following *_bis junk is here to try and deal with this idiocy.
+ */
+#define MOUNT_TYPE_NFS3_BIS 0x12344321
+struct aix4_nfs_args_bis {
+ struct sockaddr_in addr; /* server address and port */
+ struct sockaddr_in *syncaddr; /* secure NFS time sync addr */
+ int proto; /* IPPROTO_TCP/IPPROTO_UDP ??? */
+ char *hostname; /* pointer to hostname? */
+ char *netname; /* pointer to netname? */
+ caddr_t fh; /* pointer to NFS v3 fh? */
+ unsigned long flags; /* flags */
+ unsigned long wsize; /* wsize */
+ unsigned long rsize; /* rsize */
+ unsigned long timeo; /* timeo */
+ unsigned long retrans; /* retrans */
+ unsigned long acregmin; /* acregmin */
+ unsigned long acregmax; /* acregmax */
+ unsigned long acdirmin; /* acdirmin */
+ unsigned long acdirmax; /* acdirmax */
+ unsigned long u14; /* ??? UNKNOWN ??? */
+ struct ppathcnf *pathconf; /* static pathconf kludge */
+ int biods; /* biods per mount */
+ int numclust; /* numclust per mount */
+};
+
+#endif /* MNT_NFS3 */
+
+/*
+ **************************************************************************
+ * AIX 4.3's autofs is not ported or tested yet...
+ * For now, undefine it or define dummy entries.
+ **************************************************************************
+ */
+#ifdef MNT_AUTOFS
+# undef MNT_AUTOFS
+#endif /* MNT_AUTOFS */
+#ifdef HAVE_FS_AUTOFS
+# undef HAVE_FS_AUTOFS
+#endif /* HAVE_FS_AUTOFS */
+
+/*
+ * EXTERNALS:
+ */
+extern bool_t xdr_groups(XDR *xdrs, groups *objp);
+extern char *yperr_string (int incode);
+
+#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_aix5_1.h b/conf/nfs_prot/nfs_prot_aix5_1.h
index e7fb47861c77..a4e67d0fc5f8 100644
--- a/conf/nfs_prot/nfs_prot_aix5_1.h
+++ b/conf/nfs_prot/nfs_prot_aix5_1.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2003 Erez Zadok
+ * Copyright (c) 1997-2014 Erez Zadok
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
@@ -16,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgment:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -36,9 +32,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * %W% (Berkeley) %G%
*
- * $Id: nfs_prot_aix5_1.h,v 1.1.2.3 2002/12/27 22:44:53 ezk Exp $
+ * File: am-utils/conf/nfs_prot/nfs_prot_aix5_1.h
*
*/
@@ -47,7 +42,7 @@
/*
- * AIX 5.1 has a different aix51_nfs_args structure, hence the separate header.
+ * AIX 5.1 has a different aix5_nfs_args structure, hence the separate header.
*/
#ifdef HAVE_RPCSVC_NFS_PROT_H
@@ -224,19 +219,7 @@ typedef writeargs nfswriteargs;
*/
#ifdef MNT_NFS3
-#define FHSIZE3 64 /* size in bytes of a file handle (v3) */
-#define NFS3_FHSIZE 64
-#define MOUNTVERS3 ((unsigned long)(3))
-#define NFS_V3 ((unsigned long)(3))
-
-#if 0
-struct nfs_fh3 {
- u_int len;
- char val[64]; /* !!! */
-};
-#endif
-
-struct aix51_nfs_args {
+struct aix5_nfs_args {
struct sockaddr_in addr; /* server address and port */
caddr_t u0; /* ??? UNKNOWN ??? */
unsigned long proto; /* IPPROTO_TCP/IPPROTO_UDP */
@@ -257,54 +240,56 @@ struct aix51_nfs_args {
struct pathcnf *pathconf; /* pathconf */
};
-typedef struct {
- u_int fhandle3_len;
- char *fhandle3_val;
-} fhandle3;
+#endif /* MNT_NFS3 */
+
+#ifdef MNT_AUTOFS
+#define A_MAXNAME 255
+#define A_MAXOPTS 255
+#define A_MAXPATH 1024
-enum mountstat3 {
- MNT3_OK = 0,
- MNT3ERR_PERM = 1,
- MNT3ERR_NOENT = 2,
- MNT3ERR_IO = 5,
- MNT3ERR_ACCES = 13,
- MNT3ERR_NOTDIR = 20,
- MNT3ERR_INVAL = 22,
- MNT3ERR_NAMETOOLONG = 63,
- MNT3ERR_NOTSUPP = 10004,
- MNT3ERR_SERVERFAULT = 10006
+struct mntrequest {
+ char *name;
+ char *map;
+ char *opts;
+ char *path;
};
-typedef enum mountstat3 mountstat3;
+typedef struct mntrequest mntrequest;
-struct mountres3_ok {
- fhandle3 fhandle;
- struct {
- u_int auth_flavors_len;
- int *auth_flavors_val;
- } auth_flavors;
+struct mntres {
+ int status;
};
-typedef struct mountres3_ok mountres3_ok;
+typedef struct mntres mntres;
-struct mountres3 {
- mountstat3 fhs_status;
- union {
- mountres3_ok mountinfo;
- } mountres3_u;
+struct umntrequest {
+ int isdirect;
+ u_int devid;
+ u_long rdevid;
+ struct umntrequest *next;
};
-typedef struct mountres3 mountres3;
+typedef struct umntrequest umntrequest;
-struct nfs_fh3 {
- u_int fh3_length;
- union nfs_fh3_u {
- struct nfs_fh3_i {
- fhandle_t fh3_i;
- } nfs_fh3_i;
- char data[NFS3_FHSIZE];
- } fh3_u;
+struct umntres {
+ int status;
};
-typedef struct nfs_fh3 nfs_fh3;
+typedef struct umntres umntres;
-#endif /* MNT_NFS3 */
+#define AUTOFS_PROG ((unsigned long)(100099))
+#define AUTOFS_VERS ((unsigned long)(1))
+
+#endif /* MNT_AUTOFS */
+
+/*
+ **************************************************************************
+ * AIX 5.1's autofs is not ported or tested yet...
+ * For now, undefine it or define dummy entries.
+ **************************************************************************
+ */
+#ifdef MNT_AUTOFS
+# undef MNT_AUTOFS
+#endif /* MNT_AUTOFS */
+#ifdef HAVE_FS_AUTOFS
+# undef HAVE_FS_AUTOFS
+#endif /* HAVE_FS_AUTOFS */
/*
* EXTERNALS:
diff --git a/conf/nfs_prot/nfs_prot_aix5_2.h b/conf/nfs_prot/nfs_prot_aix5_2.h
new file mode 100644
index 000000000000..887379055f1b
--- /dev/null
+++ b/conf/nfs_prot/nfs_prot_aix5_2.h
@@ -0,0 +1,365 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/nfs_prot/nfs_prot_aix5_2.h
+ *
+ */
+
+#ifndef _AMU_NFS_PROT_H
+#define _AMU_NFS_PROT_H
+
+
+/*
+ * AIX 5.2 has a different aix5_nfs_args structure, hence the separate header.
+ */
+
+#ifdef HAVE_RPCSVC_NFS_PROT_H
+# include <rpcsvc/nfs_prot.h>
+#endif /* HAVE_RPCSVC_NFS_PROT_H */
+#ifdef HAVE_NFS_NFSV2_H
+# include <nfs/nfsv2.h>
+#endif /* HAVE_NFS_NFSV2_H */
+#ifdef HAVE_NFS_RPCV2_H
+# include <nfs/rpcv2.h>
+#endif /* HAVE_NFS_RPCV2_H */
+#ifdef HAVE_SYS_FS_NFS_H
+# include <sys/fs/nfs.h>
+#endif /* HAVE_SYS_FS_NFS_H */
+#ifdef HAVE_RPCSVC_MOUNT_H
+/*
+ * AIX 5.2 wants 'struct pathcnf', but I couldn't find its definition
+ * anywhere. Luckily, amd doesn't need the size of this structure in
+ * any other structure that it uses. So we sidestep it for now.
+ */
+struct pathcnf;
+# include <rpcsvc/mount.h>
+#endif /* HAVE_RPCSVC_MOUNT_H */
+#ifdef HAVE_SYS_VFS_H
+/* AIX 5.3 (ppc) wants definition of kernel-specific structure */
+struct thread_credentials;
+#endif /* HAVE_SYS_VFS_H */
+
+/*
+ * MACROS
+ */
+
+#ifndef MNTPATHLEN
+# define MNTPATHLEN 1024
+#endif /* not MNTPATHLEN */
+#ifndef MNTNAMLEN
+# define MNTNAMLEN 255
+#endif /* not MNTNAMLEN */
+
+/* compatible macro name with other OSs */
+#ifdef UVMNT_FORCE
+# define MS_FORCE UVMNT_FORCE
+#endif /* UVMNT_FORCE */
+
+/********************************************************************************/
+/*
+ * NFS mount option flags (out of mount.h)
+ * Maybe one day IBM will include them in system headers.
+ */
+#ifndef MNTOPT_ACDIRMAX
+# define MNTOPT_ACDIRMAX "acdirmax" /* max ac timeout for dirs (sec) */
+# define MNTOPT_ACDIRMIN "acdirmin" /* min ac timeout for dirs (sec) */
+# define MNTOPT_ACREGMAX "acregmax" /* max ac timeout for reg files (sec) */
+# define MNTOPT_ACREGMIN "acregmin" /* min ac timeout for reg files (sec) */
+# define MNTOPT_ACTIMEO "actimeo" /* attr cache timeout (sec) */
+# define MNTOPT_BG "bg" /* mount op in background if 1st attempt fails */
+# define MNTOPT_FASTATTR "fastattr" /* no sync_vp in nfs3_getattr */
+# define MNTOPT_FG "fg" /* mount op in fg if 1st attempt fails, default */
+# define MNTOPT_GRPID "grpid" /* SysV-compatible group-id on create */
+# define MNTOPT_HARD "hard" /* hard mount (default) */
+# define MNTOPT_INTR "intr" /* allow interrupts on hard mount */
+# define MNTOPT_NOAC "noac" /* don't cache file attributes */
+# define MNTOPT_NOACL "noacl" /* don't read acl's from server - default */
+# define MNTOPT_ACL "acl" /* read acl's from server means we load ksec */
+# define MNTOPT_NOAUTO "noauto"/* hide entry from mount -a */
+# define MNTOPT_NOCTO "nocto" /* no "close to open" attr consistency */
+# define MNTOPT_NODEV "nodev" /*don't allow opening of devices accross mount*/
+# define MNTOPT_NOINTR "nointr" /* don't allow interrupts on hard mounts */
+# define MNTOPT_NOQUOTA "noquota" /* don't check quotas */
+# define MNTOPT_NOSUID "nosuid" /* no set uid allowed */
+# define MNTOPT_BSY "bsy"
+# define MNTOPT_PORT "port" /* server IP port number */
+# define MNTOPT_POSIX "posix" /* ask for static pathconf values from mountd */
+# define MNTOPT_QUOTA "quota" /* quotas */
+# define MNTOPT_RETRANS "retrans" /* set number of request retries */
+# define MNTOPT_RETRYS "retry" /* # of times mount is attempted, def=10000*/
+# define MNTOPT_RMNT "remount" /* remount to rw if mode ro */
+# define MNTOPT_RO "ro" /* read only */
+# define MNTOPT_RSIZE "rsize" /* set read size (bytes) */
+# define MNTOPT_RW "rw" /* read/write */
+# define MNTOPT_SECURE "secure"/* use secure RPC for NFS */
+# define MNTOPT_SHORTDEV "shortdev" /* server dev */
+# define MNTOPT_SOFT "soft" /* soft mount */
+# define MNTOPT_TIMEO "timeo" /* set initial timeout (1/10 sec) */
+# define MNTOPT_WSIZE "wsize" /* set write size (bytes) */
+# define MNTOPT_VERS "vers" /* protocol version number indicator */
+# define MNTOPT_PROTO "proto" /* protocol network_id indicator */
+# define MNTOPT_LLOCK "llock" /* Local locking (no lock manager) */
+# define MNTOPT_BIODS "biods" /* max biods per mount */
+# define MNTOPT_EXTATTR "extraattr" /* extended attribute usage */
+# define MNTOPT_COMBEHND "combehind" /* extended attribute usage */
+# define MNTOPT_NUMCLUST "numclust" /* max numclust per mount */
+# define MNTOPT_NODIRCACHE "nodircache" /* No readdir cache */
+
+# define NFSMNT_NOACL 0x0 /* turn off acl support (not supported) */
+# define NFSMNT_SHORTDEV 0x0 /* server does not support 32-bit device no.
+ (not supported) */
+# define NFSMNT_SOFT 0x001 /* soft mount (hard is default) */
+# define NFSMNT_WSIZE 0x002 /* set write size */
+# define NFSMNT_RSIZE 0x004 /* set read size */
+# define NFSMNT_TIMEO 0x008 /* set initial timeout */
+# define NFSMNT_RETRANS 0x010 /* set number of request retrys */
+# define NFSMNT_HOSTNAME 0x020 /* set hostname for error printf */
+# define NFSMNT_INT 0x040 /* allow interrupts on hard mount */
+# define NFSMNT_NOAC 0x080 /* don't cache attributes */
+# define NFSMNT_ACREGMIN 0x0100 /* set min secs for file attr cache */
+# define NFSMNT_ACREGMAX 0x0200 /* set max secs for file attr cache */
+# define NFSMNT_ACDIRMIN 0x0400 /* set min secs for dir attr cache */
+# define NFSMNT_ACDIRMAX 0x0800 /* set max secs for dir attr cache */
+# define NFSMNT_SECURE 0x1000 /* secure mount */
+# define NFSMNT_NOCTO 0x2000 /* no close-to-open consistency */
+# define NFSMNT_KNCONF 0x4000 /* transport's knetconfig structure */
+# define NFSMNT_GRPID 0x8000 /* System V-style gid inheritance */
+# define NFSMNT_RPCTIMESYNC 0x10000 /* use RPC to do secure NFS time sync */
+# define NFSMNT_KERBEROS 0x20000 /* use kerberos credentials */
+# define NFSMNT_POSIX 0x40000 /* static pathconf kludge info */
+# define NFSMNT_LLOCK 0x80000 /* Local locking (no lock manager) */
+# define NFSMNT_ACL 0x100000 /* turn on acl support */
+# define NFSMNT_BIODS 0x200000 /* number of biods per mount */
+# define NFSMNT_EXTATTR 0x400000 /* extended attribute usage */
+# define NFSMNT_FASTATTR 0x800000 /* no sync_vp in nfs3_getattr */
+# define NFSMNT_COMBEHND 0x1000000 /* allow commit behind */
+# define NFSMNT_NUMCLUST 0x2000000 /* number of cluster per mount */
+# define NFSMNT_NODIRCACHE 0x4000000 /* No readdir cache */
+#endif /* not MNTOPT_ACDIRMAX */
+/********************************************************************************/
+
+/* map field names */
+#define ex_dir ex_name
+#define gr_name g_name
+#define gr_next g_next
+#define ml_directory ml_path
+#define ml_hostname ml_name
+#define ml_next ml_nxt
+
+#define dr_drok_u diropres
+#define ca_attributes attributes
+#define ca_where where
+#define da_fhandle dir
+#define da_name name
+#define dl_entries entries
+#define dl_eof eof
+#define dr_status status
+#define dr_u diropres_u
+#define drok_attributes attributes
+#define drok_fhandle file
+#define fh_data data
+#define la_fhandle from
+#define la_to to
+#define na_atime atime
+#define na_blocks blocks
+#define na_blocksize blocksize
+#define na_ctime ctime
+#define na_fileid fileid
+#define na_fsid fsid
+#define na_gid gid
+#define na_mode mode
+#define na_mtime mtime
+#define na_nlink nlink
+#define na_rdev rdev
+#define na_size size
+#define na_type type
+#define na_uid uid
+#define ne_cookie cookie
+#define ne_fileid fileid
+#define ne_name name
+#define ne_nextentry nextentry
+#define ns_attr_u attributes
+#define ns_status status
+#define ns_u attrstat_u
+#define nt_seconds seconds
+#define nt_useconds useconds
+#define ra_count count
+#define ra_fhandle file
+#define ra_offset offset
+#define ra_totalcount totalcount
+#define raok_attributes attributes
+#define raok_len_u data_len
+#define raok_u data
+#define raok_val_u data_val
+#define rda_cookie cookie
+#define rda_count count
+#define rda_fhandle dir
+#define rdr_reply_u reply
+#define rdr_status status
+#define rdr_u readdirres_u
+#define rlr_data_u data
+#define rlr_status status
+#define rlr_u readlinkres_u
+#define rna_from from
+#define rna_to to
+#define rr_reply_u reply
+#define rr_status status
+#define rr_u readres_u
+#define sa_atime atime
+#define sa_gid gid
+#define sa_mode mode
+#define sa_mtime mtime
+#define sa_size size
+#define sa_uid uid
+#define sag_attributes attributes
+#define sag_fhandle file
+#define sfr_reply_u reply
+#define sfr_status status
+#define sfr_u statfsres_u
+#define sfrok_bavail bavail
+#define sfrok_bfree bfree
+#define sfrok_blocks blocks
+#define sfrok_bsize bsize
+#define sfrok_tsize tsize
+#define sla_attributes attributes
+#define sla_from from
+#define sla_to to
+#define wra_beginoffset beginoffset
+#define wra_fhandle file
+#define wra_len_u data_len
+#define wra_offset offset
+#define wra_totalcount totalcount
+#define wra_u data
+#define wra_val_u data_val
+
+
+/*
+ * TYPEDEFS:
+ */
+typedef char *dirpath;
+typedef char *name;
+typedef struct exports *exports;
+typedef struct exports exportnode;
+typedef struct groups *groups;
+typedef struct groups groupnode;
+typedef struct mountlist *mountlist;
+
+/*
+ * If these definitions fail to compile on your AIX 5.2 system, be
+ * sure you install all of the necessary header files.
+ */
+typedef attrstat nfsattrstat;
+typedef createargs nfscreateargs;
+typedef dirlist nfsdirlist;
+typedef diropargs nfsdiropargs;
+typedef diropokres nfsdiropokres;
+typedef diropres nfsdiropres;
+typedef entry nfsentry;
+typedef fattr nfsfattr;
+typedef ftype nfsftype;
+typedef linkargs nfslinkargs;
+typedef readargs nfsreadargs;
+typedef readdirargs nfsreaddirargs;
+typedef readdirres nfsreaddirres;
+typedef readlinkres nfsreadlinkres;
+typedef readokres nfsreadokres;
+typedef readres nfsreadres;
+typedef renameargs nfsrenameargs;
+typedef sattr nfssattr;
+typedef sattrargs nfssattrargs;
+typedef statfsokres nfsstatfsokres;
+typedef statfsres nfsstatfsres;
+typedef symlinkargs nfssymlinkargs;
+typedef writeargs nfswriteargs;
+
+
+/*
+ * EXTERNALS:
+ */
+
+
+/*
+ * STRUCTURES:
+ */
+
+/*
+ * AIX 5.2 has NFS V3, but it is undefined in the header files.
+ * so I define everything that's needed for NFS V3 here.
+ */
+#ifdef MNT_NFS3
+
+struct aix5_nfs_args {
+ struct sockaddr_in addr; /* file server address */
+ struct sockaddr_in *syncaddr; /* secure NFS time sync addr */
+ int proto;
+ char *hostname; /* server's hostname */
+ char *netname; /* server's netname */
+ caddr_t fh; /* File handle to be mounted */
+ int flags; /* flags */
+ int wsize; /* write size in bytes */
+ int rsize; /* read size in bytes */
+ int timeo; /* initial timeout in .1 secs */
+ int retrans; /* times to retry send */
+ int acregmin; /* attr cache file min secs */
+ int acregmax; /* attr cache file max secs */
+ int acdirmin; /* attr cache dir min secs */
+ int acdirmax; /* attr cache dir max secs */
+ struct ppathcnf *pathconf; /* static pathconf kludge */
+ int biods; /* biods per mount */
+ int numclust; /* numclust per mount */
+};
+
+#endif /* MNT_NFS3 */
+
+/*
+ **************************************************************************
+ * AIX 5.2's autofs is not ported or tested yet...
+ * For now, undefine it or define dummy entries.
+ **************************************************************************
+ */
+#ifdef MNT_AUTOFS
+# undef MNT_AUTOFS
+#endif /* MNT_AUTOFS */
+#ifdef HAVE_FS_AUTOFS
+# undef HAVE_FS_AUTOFS
+#endif /* HAVE_FS_AUTOFS */
+
+/*
+ * EXTERNALS:
+ */
+extern bool_t xdr_groups(XDR *xdrs, groups *objp);
+extern char *yperr_string (int incode);
+
+#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_bsdi2.h b/conf/nfs_prot/nfs_prot_bsdi2.h
new file mode 100644
index 000000000000..74866e062baf
--- /dev/null
+++ b/conf/nfs_prot/nfs_prot_bsdi2.h
@@ -0,0 +1,496 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/nfs_prot/nfs_prot_bsdi2.h
+ *
+ */
+
+#ifndef _AMU_NFS_PROT_H
+#define _AMU_NFS_PROT_H
+
+#ifdef HAVE_NFS_NFSV2_H
+# include <nfs/nfsv2.h>
+#endif /* HAVE_NFS_NFSV2_H */
+#ifdef HAVE_NFS_RPCV2_H
+# include <nfs/rpcv2.h>
+#endif /* HAVE_NFS_RPCV2_H */
+#ifdef HAVE_NFS_NFS_H
+# include <nfs/nfs.h>
+#endif /* HAVE_NFS_NFS_H */
+#ifdef HAVE_SYS_FS_NFS_H
+# include <sys/fs/nfs.h>
+#endif /* HAVE_SYS_FS_NFS_H */
+#ifdef HAVE_RPCSVC_MOUNT_H
+# include <rpcsvc/mount.h>
+#endif /* HAVE_RPCSVC_MOUNT_H */
+
+#ifdef HAVE_UFS_UFS_UFSMOUNT_H
+# ifndef MAXQUOTAS
+# define MAXQUOTAS 2
+# endif /* not MAXQUOTAS */
+/* fake structure: too difficult to include other headers here */
+struct netexport { int this_is_SO_wrong; };
+# include <ufs/ufs/ufsmount.h>
+#endif /* HAVE_UFS_UFS_UFSMOUNT_H */
+
+/*
+ * <msdosfs/msdosfsmount.h> is for kernel only on bsdi2, so do not
+ * include it.
+ */
+#ifndef ____MSDOSFS_MSDOSFSMOUNT_H__
+# define ____MSDOSFS_MSDOSFSMOUNT_H__
+#endif /* ____MSDOSFS_MSDOSFSMOUNT_H__ */
+
+/*
+ * getifaddrs() on bsdi2 is broken. Don't use it.
+ */
+#ifdef HAVE_GETIFADDRS
+# undef HAVE_GETIFADDRS
+#endif /* HAVE_GETIFADDRS */
+
+
+/*
+ * MACROS
+ */
+
+#define NFS_PORT 2049
+#ifndef NFS_MAXDATA
+# define NFS_MAXDATA 8192
+#endif /* NFS_MAXDATA */
+#define NFS_MAXPATHLEN 1024
+#define NFS_MAXNAMLEN 255
+#define NFS_FHSIZE 32
+#define NFS_COOKIESIZE 4
+#define MNTPATHLEN 1024
+#define MNTNAMLEN 255
+
+#define NFSMODE_FMT 0170000
+#define NFSMODE_DIR 0040000
+#define NFSMODE_CHR 0020000
+#define NFSMODE_BLK 0060000
+#define NFSMODE_REG 0100000
+#define NFSMODE_LNK 0120000
+#define NFSMODE_SOCK 0140000
+#define NFSMODE_FIFO 0010000
+
+#ifndef NFS_PROGRAM
+# define NFS_PROGRAM ((u_long)100003)
+#endif /* not NFS_PROGRAM */
+#ifndef NFS_VERSION
+# define NFS_VERSION ((u_long)2)
+#endif /* not NFS_VERSION */
+
+/*
+ * BSD/OS 2.1 deprecated NFSPROC_ROOT and NFSPROC_WRITECACHE and set them
+ * to NFSPROC_NOOP.
+ * Since amd is its own NFS server, reinstate them.
+ */
+#if (NFSPROC_ROOT == NFSPROC_NOOP)
+# undef NFSPROC_ROOT
+# define NFSPROC_ROOT 3
+#endif /* (NFSPROC_ROOT == NFSPROC_NOOP) */
+#if (NFSPROC_WRITECACHE == NFSPROC_NOOP)
+# undef NFSPROC_WRITECACHE
+# define NFSPROC_WRITECACHE 7
+#endif /* (NFSPROC_WRITECACHE == NFSPROC_NOOP) */
+
+/* map field names */
+#define ex_dir ex_name
+#define gr_name g_name
+#define gr_next g_next
+#define ml_directory ml_path
+#define ml_hostname ml_name
+#define ml_next ml_nxt
+#define fh_data fh_bytes
+
+/*
+ * TYPEDEFS:
+ */
+typedef char *dirpath;
+typedef char *filename;
+typedef char *name;
+typedef char *nfspath;
+typedef char nfscookie[NFS_COOKIESIZE];
+typedef nfstype nfsftype;
+typedef enum nfsstat nfsstat;
+typedef struct attrstat nfsattrstat;
+typedef struct createargs nfscreateargs;
+typedef struct dirlist nfsdirlist;
+typedef struct diropargs nfsdiropargs;
+typedef struct diropokres nfsdiropokres;
+typedef struct diropres nfsdiropres;
+typedef struct entry nfsentry;
+typedef struct exports *exports;
+typedef struct exports exportnode;
+typedef struct fattr nfsfattr;
+typedef struct fhstatus fhstatus;
+typedef struct groups *groups;
+typedef struct groups groupnode;
+typedef struct linkargs nfslinkargs;
+typedef struct mountlist *mountlist;
+typedef struct mountlist mountbody;
+typedef struct nfstime nfstime;
+typedef struct readargs nfsreadargs;
+typedef struct readdirargs nfsreaddirargs;
+typedef struct readdirres nfsreaddirres;
+typedef struct readlinkres nfsreadlinkres;
+typedef struct readokres nfsreadokres;
+typedef struct readres nfsreadres;
+typedef struct renameargs nfsrenameargs;
+typedef struct sattr nfssattr;
+typedef struct sattrargs nfssattrargs;
+typedef struct statfsokres nfsstatfsokres;
+typedef struct statfsres nfsstatfsres;
+typedef struct symlinkargs nfssymlinkargs;
+typedef struct writeargs nfswriteargs;
+
+
+/*
+ * EXTERNALS:
+ */
+
+extern nfsattrstat *nfsproc_getattr_2_svc(nfsv2fh_t *, struct svc_req *);
+extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *);
+extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *);
+extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *);
+extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *);
+extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *);
+extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *);
+extern nfsreadlinkres *nfsproc_readlink_2_svc(nfsv2fh_t *, struct svc_req *);
+extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *);
+extern nfsstatfsres *nfsproc_statfs_2_svc(nfsv2fh_t *, struct svc_req *);
+extern void *nfsproc_null_2_svc(void *, struct svc_req *);
+extern void *nfsproc_root_2_svc(void *, struct svc_req *);
+extern void *nfsproc_writecache_2_svc(void *, struct svc_req *);
+
+extern bool_t xdr_attrstat(XDR *, nfsattrstat*);
+extern bool_t xdr_createargs(XDR *, nfscreateargs*);
+extern bool_t xdr_dirlist(XDR *, nfsdirlist*);
+extern bool_t xdr_diropargs(XDR *, nfsdiropargs*);
+extern bool_t xdr_diropokres(XDR *, nfsdiropokres*);
+extern bool_t xdr_diropres(XDR *, nfsdiropres*);
+extern bool_t xdr_entry(XDR *, nfsentry*);
+extern bool_t xdr_fattr(XDR *, nfsfattr*);
+extern bool_t xdr_filename(XDR *, filename*);
+extern bool_t xdr_ftype(XDR *, nfsftype*);
+extern bool_t xdr_linkargs(XDR *, nfslinkargs*);
+extern bool_t xdr_mountlist(XDR *xdrs, mountlist *objp);
+extern bool_t xdr_nfs_fh(XDR *, nfsv2fh_t*);
+extern bool_t xdr_nfscookie(XDR *, nfscookie);
+extern bool_t xdr_nfspath(XDR *, nfspath*);
+extern bool_t xdr_nfsstat(XDR *, nfsstat*);
+extern bool_t xdr_nfstime(XDR *, nfstime*);
+extern bool_t xdr_readargs(XDR *, nfsreadargs*);
+extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*);
+extern bool_t xdr_readdirres(XDR *, nfsreaddirres*);
+extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*);
+extern bool_t xdr_readokres(XDR *, nfsreadokres*);
+extern bool_t xdr_readres(XDR *, nfsreadres*);
+extern bool_t xdr_renameargs(XDR *, nfsrenameargs*);
+extern bool_t xdr_sattr(XDR *, nfssattr*);
+extern bool_t xdr_sattrargs(XDR *, nfssattrargs*);
+extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*);
+extern bool_t xdr_statfsres(XDR *, nfsstatfsres*);
+extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*);
+extern bool_t xdr_writeargs(XDR *, nfswriteargs*);
+
+
+/*
+ * ENUMS:
+ */
+
+/*
+ * Use AMU_ prefixes so as to not conflict with #define's in <nfs/nfsv2.h>.
+ * It is vital! that the AMU_* match one-to-one with the NFS_OK and NFSERR_*
+ * codes listed in <nfs/nfsv2.h>.
+ */
+enum nfsstat {
+ AMU_NFS_OK = 0,
+ AMU_NFSERR_PERM = 1,
+ AMU_NFSERR_NOENT = 2,
+ AMU_NFSERR_IO = 5,
+ AMU_NFSERR_NXIO = 6,
+ AMU_NFSERR_ACCES = 13,
+ AMU_NFSERR_EXIST = 17,
+ AMU_NFSERR_NODEV = 19,
+ AMU_NFSERR_NOTDIR = 20,
+ AMU_NFSERR_ISDIR = 21,
+ AMU_NFSERR_FBIG = 27,
+ AMU_NFSERR_NOSPC = 28,
+ AMU_NFSERR_ROFS = 30,
+ AMU_NFSERR_NAMETOOLONG = 63,
+ AMU_NFSERR_NOTEMPTY = 66,
+ AMU_NFSERR_DQUOT = 69,
+ AMU_NFSERR_STALE = 70,
+ AMU_NFSERR_WFLUSH = 99
+};
+
+
+/*
+ * STRUCTURES:
+ */
+
+struct nfstime {
+ u_int nt_seconds;
+ u_int nt_useconds;
+};
+
+struct fattr {
+ nfsftype na_type;
+ u_int na_mode;
+ u_int na_nlink;
+ u_int na_uid;
+ u_int na_gid;
+ u_int na_size;
+ u_int na_blocksize;
+ u_int na_rdev;
+ u_int na_blocks;
+ u_int na_fsid;
+ u_int na_fileid;
+ nfstime na_atime;
+ nfstime na_mtime;
+ nfstime na_ctime;
+};
+
+struct sattr {
+ u_int sa_mode;
+ u_int sa_uid;
+ u_int sa_gid;
+ u_int sa_size;
+ nfstime sa_atime;
+ nfstime sa_mtime;
+};
+
+struct attrstat {
+ nfsstat ns_status;
+ union {
+ nfsfattr ns_attr_u;
+ } ns_u;
+};
+
+struct sattrargs {
+ nfsv2fh_t sag_fhandle;
+ nfssattr sag_attributes;
+};
+
+struct diropargs {
+ nfsv2fh_t da_fhandle; /* was dir */
+ filename da_name;
+};
+
+struct diropokres {
+ nfsv2fh_t drok_fhandle;
+ nfsfattr drok_attributes;
+};
+
+struct diropres {
+ nfsstat dr_status; /* was status */
+ union {
+ nfsdiropokres dr_drok_u; /* was diropres */
+ } dr_u; /* was diropres_u */
+};
+
+struct readlinkres {
+ nfsstat rlr_status;
+ union {
+ nfspath rlr_data_u;
+ } rlr_u;
+};
+
+struct readargs {
+ nfsv2fh_t ra_fhandle;
+ u_int ra_offset;
+ u_int ra_count;
+ u_int ra_totalcount;
+};
+
+struct readokres {
+ nfsfattr raok_attributes;
+ struct {
+ u_int raok_len_u;
+ char *raok_val_u;
+ } raok_u;
+};
+
+struct readres {
+ nfsstat rr_status;
+ union {
+ nfsreadokres rr_reply_u;
+ } rr_u;
+};
+
+struct writeargs {
+ nfsv2fh_t wra_fhandle;
+ u_int wra_beginoffset;
+ u_int wra_offset;
+ u_int wra_totalcount;
+ struct {
+ u_int wra_len_u;
+ char *wra_val_u;
+ } wra_u;
+};
+
+struct createargs {
+ nfsdiropargs ca_where;
+ nfssattr ca_attributes;
+};
+
+struct renameargs {
+ nfsdiropargs rna_from;
+ nfsdiropargs rna_to;
+};
+
+struct linkargs {
+ nfsv2fh_t la_fhandle;
+ nfsdiropargs la_to;
+};
+
+struct symlinkargs {
+ nfsdiropargs sla_from;
+ nfspath sla_to;
+ nfssattr sla_attributes;
+};
+
+struct readdirargs {
+ nfsv2fh_t rda_fhandle;
+ nfscookie rda_cookie;
+ u_int rda_count;
+};
+
+struct entry {
+ u_int ne_fileid;
+ filename ne_name;
+ nfscookie ne_cookie;
+ nfsentry *ne_nextentry;
+};
+
+struct dirlist {
+ nfsentry *dl_entries;
+ bool_t dl_eof;
+};
+
+struct readdirres {
+ nfsstat rdr_status;
+ union {
+ nfsdirlist rdr_reply_u;
+ } rdr_u;
+};
+
+struct statfsokres {
+ u_int sfrok_tsize;
+ u_int sfrok_bsize;
+ u_int sfrok_blocks;
+ u_int sfrok_bfree;
+ u_int sfrok_bavail;
+};
+
+struct statfsres {
+ nfsstat sfr_status;
+ union {
+ nfsstatfsokres sfr_reply_u;
+ } sfr_u;
+};
+
+
+/****************************************************************************/
+/*** XDR ADDITIONS ***/
+/****************************************************************************/
+
+struct exports {
+ dirpath ex_dir;
+ groups ex_groups;
+ exports ex_next;
+};
+
+typedef char fhandle[NFS_FHSIZE];
+
+struct fhstatus {
+ u_int fhs_status;
+ union {
+ fhandle fhs_fhandle;
+ } fhstatus_u;
+};
+
+struct groups {
+ name gr_name;
+ groups gr_next;
+};
+
+struct mountlist {
+ name ml_hostname;
+ dirpath ml_directory;
+ mountlist ml_next;
+};
+
+
+/****************************************************************************/
+/*** NFS ADDITIONS ***/
+/****************************************************************************/
+
+#ifndef MOUNTPROG
+# define MOUNTPROG RPCPROG_MNT
+#endif /* not MOUNTPROG */
+
+#ifndef MOUNTVERS
+# define MOUNTVERS RPCMNT_VER1
+#endif /* not MOUNTVERS */
+
+#ifndef MOUNTPROC_MNT
+# define MOUNTPROC_MNT RPCMNT_MOUNT
+#endif /* not MOUNTPROC_MNT */
+
+#ifndef MOUNTPROC_DUMP
+# define MOUNTPROC_DUMP RPCMNT_DUMP
+#endif /* not MOUNTPROC_DUMP */
+
+#ifndef MOUNTPROC_UMNT
+# define MOUNTPROC_UMNT RPCMNT_UMOUNT
+#endif /* not MOUNTPROC_UMNT */
+
+#ifndef MOUNTPROC_UMNTALL
+# define MOUNTPROC_UMNTALL RPCMNT_UMNTALL
+#endif /* not MOUNTPROC_UMNTALL */
+
+#ifndef MOUNTPROC_EXPORT
+# define MOUNTPROC_EXPORT RPCMNT_EXPORT
+#endif /* not MOUNTPROC_EXPORT */
+
+
+#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_bsdi3.h b/conf/nfs_prot/nfs_prot_bsdi3.h
new file mode 100644
index 000000000000..5e387acfcb7c
--- /dev/null
+++ b/conf/nfs_prot/nfs_prot_bsdi3.h
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/nfs_prot/nfs_prot_bsdi3.h
+ *
+ */
+
+#ifndef _AMU_NFS_PROT_H
+#define _AMU_NFS_PROT_H
+
+#ifdef HAVE_RPCSVC_NFS_PROT_H
+# include <rpcsvc/nfs_prot.h>
+#endif /* HAVE_RPCSVC_NFS_PROT_H */
+#ifdef HAVE_NFS_NFSV2_H
+# include <nfs/nfsv2.h>
+#endif /* HAVE_NFS_NFSV2_H */
+#ifdef HAVE_NFS_RPCV2_H
+# include <nfs/rpcv2.h>
+#endif /* HAVE_NFS_RPCV2_H */
+
+#ifndef NFS_NPROCS
+# define NFS_NPROCS 26
+#endif /* not NFS_NPROCS */
+#ifdef HAVE_NFS_NFS_H
+# include <nfs/nfs.h>
+#endif /* HAVE_NFS_NFS_H */
+
+#ifdef HAVE_SYS_FS_NFS_H
+# include <sys/fs/nfs.h>
+#endif /* HAVE_SYS_FS_NFS_H */
+#ifdef HAVE_RPCSVC_MOUNT_H
+# include <rpcsvc/mount.h>
+#endif /* HAVE_RPCSVC_MOUNT_H */
+#ifdef HAVE_UFS_UFS_UFSMOUNT_H
+# include <ufs/ufs/ufsmount.h>
+#endif /* HAVE_UFS_UFS_UFSMOUNT_H */
+
+/****************************************************************************/
+/*
+ * NFS V3 support:
+ * BSD/OS 3.0 has it but no easy way to figure it out from the header files.
+ */
+#ifndef MNTTYPE_NFS3
+# define MNTTYPE_NFS3 "nfs"
+#endif /* MNTTYPE_NFS3 */
+
+/****************************************************************************/
+
+
+/*
+ * MACROS:
+ */
+#define dr_drok_u diropres
+#define ca_where where
+#define da_fhandle dir
+#define da_name name
+#define dl_entries entries
+#define dl_eof eof
+#define dr_status status
+#define dr_u diropres_u
+#define drok_attributes attributes
+#define drok_fhandle file
+#define fh_data data
+#define la_fhandle from
+#define la_to to
+#define na_atime atime
+#define na_ctime ctime
+#define na_fileid fileid
+#define na_fsid fsid
+#define na_mode mode
+#define na_mtime mtime
+#define na_nlink nlink
+#define na_size size
+#define na_type type
+#define na_gid gid
+#define na_uid uid
+#define ne_cookie cookie
+#define ne_fileid fileid
+#define ne_name name
+#define ne_nextentry nextentry
+#define ns_attr_u attributes
+#define ns_status status
+#define ns_u attrstat_u
+#define nt_seconds seconds
+#define nt_useconds useconds
+#define rda_cookie cookie
+#define rda_count count
+#define rda_fhandle dir
+#define rdr_reply_u reply
+#define rdr_status status
+#define rdr_u readdirres_u
+#define rlr_data_u data
+#define rlr_status status
+#define rlr_u readlinkres_u
+#define rna_from from
+#define rna_to to
+#define rr_status status
+#define sag_fhandle file
+#define sfr_reply_u reply
+#define sfr_status status
+#define sfr_u statfsres_u
+#define sfrok_bavail bavail
+#define sfrok_bfree bfree
+#define sfrok_blocks blocks
+#define sfrok_bsize bsize
+#define sfrok_tsize tsize
+#define sla_from from
+#define wra_fhandle file
+
+
+/*
+ * TYPEDEFS:
+ */
+typedef attrstat nfsattrstat;
+typedef createargs nfscreateargs;
+typedef dirlist nfsdirlist;
+typedef diropargs nfsdiropargs;
+typedef diropres nfsdiropres;
+typedef entry nfsentry;
+typedef fattr nfsfattr;
+typedef ftype nfsftype;
+typedef linkargs nfslinkargs;
+typedef readargs nfsreadargs;
+typedef readdirargs nfsreaddirargs;
+typedef readdirres nfsreaddirres;
+typedef readlinkres nfsreadlinkres;
+typedef readres nfsreadres;
+typedef renameargs nfsrenameargs;
+typedef sattrargs nfssattrargs;
+typedef statfsokres nfsstatfsokres;
+typedef statfsres nfsstatfsres;
+typedef symlinkargs nfssymlinkargs;
+typedef writeargs nfswriteargs;
+
+/* missing definitions from bsdi4 */
+#if defined(HAVE_MAP_HESIOD) && !defined(HAVE_HESIOD_H)
+extern int hesiod_init(void **context);
+#endif /* defined(HAVE_MAP_HESIOD) && !defined(HAVE_HESIOD_H) */
+
+/*
+ * On bsdi4, NFS V3/tcp mounts should not use the default resvport option.
+ * Defining this mnt option string will force compute_nfs_args() to not
+ * use reserved ports unless it was specified as a mount option.
+ */
+#ifndef MNTTAB_OPT_RESVPORT
+# define MNTTAB_OPT_RESVPORT "resvport"
+#endif /* not MNTTAB_OPT_RESVPORT */
+
+#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_darwin.h b/conf/nfs_prot/nfs_prot_darwin.h
index 9ef1e721e60d..a505254a4561 100644
--- a/conf/nfs_prot/nfs_prot_darwin.h
+++ b/conf/nfs_prot/nfs_prot_darwin.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2003 Erez Zadok
+ * Copyright (c) 1997-2014 Erez Zadok
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
@@ -16,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgment:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -36,9 +32,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * %W% (Berkeley) %G%
*
- * $Id: nfs_prot_darwin.h,v 1.1.2.4 2002/12/27 22:44:54 ezk Exp $
+ * File: am-utils/conf/nfs_prot/nfs_prot_darwin.h
*
*/
@@ -58,46 +53,6 @@
# include <ufs/ufs/ufsmount.h>
#endif /* HAVE_UFS_UFS_UFSMOUNT_H */
-#define MOUNTVERS3 ((unsigned long)(3))
-
-typedef struct {
- u_int fhandle3_len;
- char *fhandle3_val;
-} fhandle3;
-
-
-enum mountstat3 {
- MNT3_OK = 0,
- MNT3ERR_PERM = 1,
- MNT3ERR_NOENT = 2,
- MNT3ERR_IO = 5,
- MNT3ERR_ACCES = 13,
- MNT3ERR_NOTDIR = 20,
- MNT3ERR_INVAL = 22,
- MNT3ERR_NAMETOOLONG = 63,
- MNT3ERR_NOTSUPP = 10004,
- MNT3ERR_SERVERFAULT = 10006
-};
-typedef enum mountstat3 mountstat3;
-
-struct mountres3_ok {
- fhandle3 fhandle;
- struct {
- u_int auth_flavors_len;
- int *auth_flavors_val;
- } auth_flavors;
-};
-typedef struct mountres3_ok mountres3_ok;
-
-struct mountres3 {
- mountstat3 fhs_status;
- union {
- mountres3_ok mountinfo;
- } mountres3_u;
-};
-typedef struct mountres3 mountres3;
-
-
/*
* MACROS:
*/
@@ -215,45 +170,11 @@ typedef symlinkargs nfssymlinkargs;
typedef writeargs nfswriteargs;
-/*
- *
- * FreeBSD-3.0-RELEASE has NFS V3. Older versions had it only defined
- * in the rpcgen source file. If you are on an older system, and you
- * want NFSv3 support, you need to regenerate the rpcsvc header files as
- * follows:
- * cd /usr/include/rpcsvc
- * rpcgen -h -C -DWANT_NFS3 mount.x
- * rpcgen -h -C -DWANT_NFS3 nfs_prot.x
- * If you don't want NFSv3, then you will have to turn off the NFSMNT_NFSV3
- * macro below. If the code doesn't compile, upgrade to the latest 3.0
- * version...
- */
#ifdef NFSMNT_NFSV3
# define MOUNT_NFS3 "nfs" /* is this right? */
# define MNTOPT_NFS3 "nfs"
-/*
- * as of 3.0-RELEASE the nfs_fh3 that is defined in the system headers
- * (or the one generated by rpcgen) lacks the proper full definition,
- * listed below. A special macro (m4/macros/struct_nfs_fh3.m4) searches
- * for this special name before other names.
- */
-
-#define NFS3_FHSIZE 64
-#define FHSIZE3 64
-
-struct nfs_fh3_freebsd3 {
- u_int fh3_length;
- union nfs_fh3_u {
- struct nfs_fh3_i {
- fhandle_t fh3_i;
- } nfs_fh3_i;
- char data[NFS3_FHSIZE];
- } fh3_u;
-};
-typedef struct nfs_fh3_freebsd3 nfs_fh3;
-
#endif /* NFSMNT_NFSV3 */
#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_default.h b/conf/nfs_prot/nfs_prot_default.h
new file mode 100644
index 000000000000..c5f047d99bf3
--- /dev/null
+++ b/conf/nfs_prot/nfs_prot_default.h
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/nfs_prot/nfs_prot_default.h
+ *
+ */
+
+#ifndef _AMU_NFS_PROT_H
+#define _AMU_NFS_PROT_H
+
+#ifdef HAVE_RPCSVC_NFS_PROT_H
+# include <rpcsvc/nfs_prot.h>
+#endif /* HAVE_RPCSVC_NFS_PROT_H */
+
+
+/*
+ * MACROS:
+ */
+#define dr_drok_u diropres
+#define ca_attributes attributes
+#define ca_where where
+#define da_fhandle dir
+#define da_name name
+#define dl_entries entries
+#define dl_eof eof
+#define dr_status status
+#define dr_u diropres_u
+#define drok_attributes attributes
+#define drok_fhandle file
+#define fh_data data
+#define la_fhandle from
+#define la_to to
+#define na_atime atime
+#define na_blocks blocks
+#define na_blocksize blocksize
+#define na_ctime ctime
+#define na_fileid fileid
+#define na_fsid fsid
+#define na_gid gid
+#define na_mode mode
+#define na_mtime mtime
+#define na_nlink nlink
+#define na_rdev rdev
+#define na_size size
+#define na_type type
+#define na_uid uid
+#define ne_cookie cookie
+#define ne_fileid fileid
+#define ne_name name
+#define ne_nextentry nextentry
+#define ns_attr_u attributes
+#define ns_status status
+#define ns_u attrstat_u
+#define nt_seconds seconds
+#define nt_useconds useconds
+#define ra_count count
+#define ra_fhandle file
+#define ra_offset offset
+#define ra_totalcount totalcount
+#define raok_attributes attributes
+#define raok_len_u data_len
+#define raok_u data
+#define raok_val_u data_val
+#define rda_cookie cookie
+#define rda_count count
+#define rda_fhandle dir
+#define rdr_reply_u reply
+#define rdr_status status
+#define rdr_u readdirres_u
+#define rlr_data_u data
+#define rlr_status status
+#define rlr_u readlinkres_u
+#define rna_from from
+#define rna_to to
+#define rr_reply_u reply
+#define rr_status status
+#define rr_u readres_u
+#define sa_atime atime
+#define sa_gid gid
+#define sa_mode mode
+#define sa_mtime mtime
+#define sa_size size
+#define sa_uid uid
+#define sag_attributes attributes
+#define sag_fhandle file
+#define sfr_reply_u reply
+#define sfr_status status
+#define sfr_u statfsres_u
+#define sfrok_bavail bavail
+#define sfrok_bfree bfree
+#define sfrok_blocks blocks
+#define sfrok_bsize bsize
+#define sfrok_tsize tsize
+#define sla_attributes attributes
+#define sla_from from
+#define sla_to to
+#define wra_beginoffset beginoffset
+#define wra_fhandle file
+#define wra_len_u data_len
+#define wra_offset offset
+#define wra_totalcount totalcount
+#define wra_u data
+#define wra_val_u data_val
+
+
+/*
+ * TYPEDEFS:
+ */
+typedef attrstat nfsattrstat;
+typedef createargs nfscreateargs;
+typedef dirlist nfsdirlist;
+typedef diropargs nfsdiropargs;
+typedef diropokres nfsdiropokres;
+typedef diropres nfsdiropres;
+typedef entry nfsentry;
+typedef fattr nfsfattr;
+typedef ftype nfsftype;
+typedef linkargs nfslinkargs;
+typedef readargs nfsreadargs;
+typedef readdirargs nfsreaddirargs;
+typedef readdirres nfsreaddirres;
+typedef readlinkres nfsreadlinkres;
+typedef readokres nfsreadokres;
+typedef readres nfsreadres;
+typedef renameargs nfsrenameargs;
+typedef sattr nfssattr;
+typedef sattrargs nfssattrargs;
+typedef statfsokres nfsstatfsokres;
+typedef statfsres nfsstatfsres;
+typedef symlinkargs nfssymlinkargs;
+typedef writeargs nfswriteargs;
+
+
+#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_freebsd2.h b/conf/nfs_prot/nfs_prot_freebsd2.h
index cf7ba33ee47b..73661c9da3d8 100644
--- a/conf/nfs_prot/nfs_prot_freebsd2.h
+++ b/conf/nfs_prot/nfs_prot_freebsd2.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2006 Erez Zadok
+ * Copyright (c) 1997-2014 Erez Zadok
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
@@ -16,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgment:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -139,7 +135,7 @@ typedef writeargs nfswriteargs;
*/
#if 0
#define MOUNT_NFS3 MOUNT_NFS
-#endif
+#endif /* 0 */
#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_freebsd3.h b/conf/nfs_prot/nfs_prot_freebsd3.h
index edcc57540fee..51ac31d2aece 100644
--- a/conf/nfs_prot/nfs_prot_freebsd3.h
+++ b/conf/nfs_prot/nfs_prot_freebsd3.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2006 Erez Zadok
+ * Copyright (c) 1997-2014 Erez Zadok
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
@@ -16,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgment:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/conf/nfs_prot/nfs_prot_hpux.h b/conf/nfs_prot/nfs_prot_hpux.h
new file mode 100644
index 000000000000..9d64360afb5e
--- /dev/null
+++ b/conf/nfs_prot/nfs_prot_hpux.h
@@ -0,0 +1,398 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/nfs_prot/nfs_prot_hpux.h
+ *
+ */
+
+#ifndef _AMU_NFS_PROT_H
+#define _AMU_NFS_PROT_H
+
+#ifdef HAVE_NFS_EXPORT_H_not
+/* don't include this b/c it'll get included twice */
+# include <nfs/export.h>
+#endif /* HAVE_NFS_EXPORT_H */
+#ifdef HAVE_NFS_NFSV2_H
+# include <nfs/nfsv2.h>
+#endif /* HAVE_NFS_NFSV2_H */
+#ifdef HAVE_NFS_RPCV2_H
+# include <nfs/rpcv2.h>
+#endif /* HAVE_NFS_RPCV2_H */
+#ifdef HAVE_NFS_NFS_H
+# include <nfs/nfs.h>
+#endif /* HAVE_NFS_NFS_H */
+#ifdef HAVE_SYS_FS_NFS_H
+# include <sys/fs/nfs.h>
+#endif /* HAVE_SYS_FS_NFS_H */
+#ifdef HAVE_RPCSVC_MOUNT_H
+# include <rpcsvc/mount.h>
+#endif /* HAVE_RPCSVC_MOUNT_H */
+
+#ifdef HAVE_NETDB_H
+extern int h_errno; /* missing from older hpux10 systems */
+#endif /* HAVE_NETDB_H */
+
+
+/*
+ * Turn off NFS V.3 support to avoid confusing am-utils.
+ * 10.20 with some patches has incomplete support.
+ */
+#undef MNTTYPE_NFS3
+#undef MNTTAB_TYPE_NFS3
+#undef HAVE_FS_NFS3
+
+
+/*
+ * MACROS
+ */
+
+#define NFS_PORT 2049
+#define NFS_MAXDATA 8192
+#define NFS_MAXPATHLEN 1024
+#define NFS_MAXNAMLEN 255
+#define NFS_FHSIZE 32
+#define NFS_COOKIESIZE 4
+#define MNTPATHLEN 1024
+#define MNTNAMLEN 255
+
+#define NFSMODE_FMT 0170000
+#define NFSMODE_DIR 0040000
+#define NFSMODE_CHR 0020000
+#define NFSMODE_BLK 0060000
+#define NFSMODE_REG 0100000
+#define NFSMODE_LNK 0120000
+#define NFSMODE_SOCK 0140000
+#define NFSMODE_FIFO 0010000
+
+#ifndef NFS_PROGRAM
+# define NFS_PROGRAM ((u_long)100003)
+#endif /* not NFS_PROGRAM */
+#ifndef NFS_VERSION
+# define NFS_VERSION ((u_long)2)
+#endif /* not NFS_VERSION */
+
+#define NFSPROC_NULL ((u_long)0)
+#define NFSPROC_GETATTR ((u_long)1)
+#define NFSPROC_SETATTR ((u_long)2)
+#define NFSPROC_ROOT ((u_long)3)
+#define NFSPROC_LOOKUP ((u_long)4)
+#define NFSPROC_READLINK ((u_long)5)
+#define NFSPROC_READ ((u_long)6)
+#define NFSPROC_WRITECACHE ((u_long)7)
+#define NFSPROC_WRITE ((u_long)8)
+#define NFSPROC_CREATE ((u_long)9)
+#define NFSPROC_REMOVE ((u_long)10)
+#define NFSPROC_RENAME ((u_long)11)
+#define NFSPROC_LINK ((u_long)12)
+#define NFSPROC_SYMLINK ((u_long)13)
+#define NFSPROC_MKDIR ((u_long)14)
+#define NFSPROC_RMDIR ((u_long)15)
+#define NFSPROC_READDIR ((u_long)16)
+#define NFSPROC_STATFS ((u_long)17)
+
+/* map field names */
+#define ml_hostname ml_name
+#define ml_directory ml_path
+#define ml_next ml_nxt
+#define gr_next g_next
+#define gr_name g_name
+#define ex_dir ex_name
+
+
+/*
+ * TYPEDEFS:
+ */
+typedef char *dirpath;
+typedef char *filename;
+typedef char *name;
+typedef char *nfspath;
+typedef char nfscookie[NFS_COOKIESIZE];
+typedef enum nfsftype nfsftype;
+typedef enum nfsstat nfsstat;
+#ifndef HAVE_FHANDLE
+typedef fhandle_t fhandle;
+#endif /* not HAVE_FHANDLE */
+typedef struct attrstat nfsattrstat;
+typedef struct createargs nfscreateargs;
+typedef struct dirlist nfsdirlist;
+typedef struct diropargs nfsdiropargs;
+typedef struct diropokres nfsdiropokres;
+typedef struct diropres nfsdiropres;
+typedef struct entry nfsentry;
+typedef struct exports *exports;
+typedef struct exports exportnode;
+typedef struct fattr nfsfattr;
+typedef struct fhstatus fhstatus;
+typedef struct groups *groups;
+typedef struct groups groupnode;
+typedef struct linkargs nfslinkargs;
+typedef struct mountlist *mountlist;
+typedef struct mountlist mountbody;
+typedef struct nfstime nfstime;
+typedef struct readargs nfsreadargs;
+typedef struct readdirargs nfsreaddirargs;
+typedef struct readdirres nfsreaddirres;
+typedef struct readlinkres nfsreadlinkres;
+typedef struct readokres nfsreadokres;
+typedef struct readres nfsreadres;
+typedef struct renameargs nfsrenameargs;
+typedef struct sattr nfssattr;
+typedef struct sattrargs nfssattrargs;
+typedef struct statfsokres nfsstatfsokres;
+typedef struct statfsres nfsstatfsres;
+typedef struct symlinkargs nfssymlinkargs;
+typedef struct writeargs nfswriteargs;
+
+
+/*
+ * EXTERNALS:
+ */
+
+extern void *nfsproc_null_2_svc(void *, struct svc_req *);
+extern nfsattrstat *nfsproc_getattr_2_svc(fhandle_t *, struct svc_req *);
+extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *);
+extern void *nfsproc_root_2_svc(void *, struct svc_req *);
+extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsreadlinkres *nfsproc_readlink_2_svc(fhandle_t *, struct svc_req *);
+extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *);
+extern void *nfsproc_writecache_2_svc(void *, struct svc_req *);
+extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *);
+extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *);
+extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *);
+extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *);
+extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *);
+extern nfsstatfsres *nfsproc_statfs_2_svc(fhandle_t *, struct svc_req *);
+
+extern bool_t xdr_nfsstat(XDR *, nfsstat*);
+extern bool_t xdr_ftype(XDR *, nfsftype*);
+extern bool_t xdr_nfs_fh(XDR *, fhandle_t*);
+extern bool_t xdr_nfstime(XDR *, nfstime*);
+extern bool_t xdr_fattr(XDR *, nfsfattr*);
+extern bool_t xdr_sattr(XDR *, nfssattr*);
+extern bool_t xdr_filename(XDR *, filename*);
+extern bool_t xdr_nfspath(XDR *, nfspath*);
+extern bool_t xdr_attrstat(XDR *, nfsattrstat*);
+extern bool_t xdr_sattrargs(XDR *, nfssattrargs*);
+extern bool_t xdr_diropargs(XDR *, nfsdiropargs*);
+extern bool_t xdr_diropokres(XDR *, nfsdiropokres*);
+extern bool_t xdr_diropres(XDR *, nfsdiropres*);
+extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*);
+extern bool_t xdr_readargs(XDR *, nfsreadargs*);
+extern bool_t xdr_readokres(XDR *, nfsreadokres*);
+extern bool_t xdr_readres(XDR *, nfsreadres*);
+extern bool_t xdr_writeargs(XDR *, nfswriteargs*);
+extern bool_t xdr_createargs(XDR *, nfscreateargs*);
+extern bool_t xdr_renameargs(XDR *, nfsrenameargs*);
+extern bool_t xdr_linkargs(XDR *, nfslinkargs*);
+extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*);
+extern bool_t xdr_nfscookie(XDR *, nfscookie);
+extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*);
+extern bool_t xdr_entry(XDR *, nfsentry*);
+extern bool_t xdr_dirlist(XDR *, nfsdirlist*);
+extern bool_t xdr_readdirres(XDR *, nfsreaddirres*);
+extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*);
+extern bool_t xdr_statfsres(XDR *, nfsstatfsres*);
+
+
+/*
+ * STRUCTURES:
+ */
+
+struct nfstime {
+ u_int nt_seconds;
+ u_int nt_useconds;
+};
+
+struct fattr {
+ nfsftype na_type;
+ u_int na_mode;
+ u_int na_nlink;
+ u_int na_uid;
+ u_int na_gid;
+ u_int na_size;
+ u_int na_blocksize;
+ u_int na_rdev;
+ u_int na_blocks;
+ u_int na_fsid;
+ u_int na_fileid;
+ nfstime na_atime;
+ nfstime na_mtime;
+ nfstime na_ctime;
+};
+
+struct sattr {
+ u_int sa_mode;
+ u_int sa_uid;
+ u_int sa_gid;
+ u_int sa_size;
+ nfstime sa_atime;
+ nfstime sa_mtime;
+};
+
+struct attrstat {
+ nfsstat ns_status;
+ union {
+ nfsfattr ns_attr_u;
+ } ns_u;
+};
+
+struct sattrargs {
+ fhandle_t sag_fhandle;
+ nfssattr sag_attributes;
+};
+
+struct diropargs {
+ fhandle_t da_fhandle; /* was dir */
+ filename da_name;
+};
+
+struct diropokres {
+ fhandle_t drok_fhandle;
+ nfsfattr drok_attributes;
+};
+
+struct diropres {
+ nfsstat dr_status; /* was status */
+ union {
+ nfsdiropokres dr_drok_u; /* was diropres */
+ } dr_u; /* was diropres_u */
+};
+
+struct readlinkres {
+ nfsstat rlr_status;
+ union {
+ nfspath rlr_data_u;
+ } rlr_u;
+};
+
+struct readargs {
+ fhandle_t ra_fhandle;
+ u_int ra_offset;
+ u_int ra_count;
+ u_int ra_totalcount;
+};
+
+struct readokres {
+ nfsfattr raok_attributes;
+ struct {
+ u_int raok_len_u;
+ char *raok_val_u;
+ } raok_u;
+};
+
+struct readres {
+ nfsstat rr_status;
+ union {
+ nfsreadokres rr_reply_u;
+ } rr_u;
+};
+
+struct writeargs {
+ fhandle_t wra_fhandle;
+ u_int wra_beginoffset;
+ u_int wra_offset;
+ u_int wra_totalcount;
+ struct {
+ u_int wra_len_u;
+ char *wra_val_u;
+ } wra_u;
+};
+
+struct createargs {
+ nfsdiropargs ca_where;
+ nfssattr ca_attributes;
+};
+
+struct renameargs {
+ nfsdiropargs rna_from;
+ nfsdiropargs rna_to;
+};
+
+struct linkargs {
+ fhandle_t la_fhandle;
+ nfsdiropargs la_to;
+};
+
+struct symlinkargs {
+ nfsdiropargs sla_from;
+ nfspath sla_to;
+ nfssattr sla_attributes;
+};
+
+struct readdirargs {
+ fhandle_t rda_fhandle;
+ nfscookie rda_cookie;
+ u_int rda_count;
+};
+
+struct entry {
+ u_int ne_fileid;
+ filename ne_name;
+ nfscookie ne_cookie;
+ nfsentry *ne_nextentry;
+};
+
+struct dirlist {
+ nfsentry *dl_entries;
+ bool_t dl_eof;
+};
+
+struct readdirres {
+ nfsstat rdr_status;
+ union {
+ nfsdirlist rdr_reply_u;
+ } rdr_u;
+};
+
+struct statfsokres {
+ u_int sfrok_tsize;
+ u_int sfrok_bsize;
+ u_int sfrok_blocks;
+ u_int sfrok_bfree;
+ u_int sfrok_bavail;
+};
+
+struct statfsres {
+ nfsstat sfr_status;
+ union {
+ nfsstatfsokres sfr_reply_u;
+ } sfr_u;
+};
+
+#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_hpux11.h b/conf/nfs_prot/nfs_prot_hpux11.h
new file mode 100644
index 000000000000..0dd0286c6388
--- /dev/null
+++ b/conf/nfs_prot/nfs_prot_hpux11.h
@@ -0,0 +1,595 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/nfs_prot/nfs_prot_hpux11.h
+ *
+ */
+
+#ifndef _AMU_NFS_PROT_H
+#define _AMU_NFS_PROT_H
+
+/*
+ * NOTE: HPUX 11 is missing many header definitions which had to be
+ * guessed and copied over from HPUX 10.20.
+ */
+
+/* don't include this file as it isn't needed on hpux */
+#ifndef _TIUSER_H
+# define _TIUSER_H
+#endif /* TIUSER_H */
+#ifndef _TIUSER_INCLUDED
+# define _TIUSER_INCLUDED
+#endif /* TIUSER_INCLUDED */
+#ifndef _SYS_TIUSER_INCLUDED
+# define _SYS_TIUSER_INCLUDED
+#endif /* _SYS_TIUSER_INCLUDED */
+/* if T_NULL is defined, undefine it due to a conflict with <arpa/nameser.h> */
+#ifdef T_NULL
+# undef T_NULL
+#endif /* T_NULL */
+
+#ifdef HAVE_NFS_EXPORT_H_not
+/* don't include this b/c it'll get included twice */
+# include <nfs/export.h>
+#endif /* HAVE_NFS_EXPORT_H */
+#ifdef HAVE_NFS_NFSV2_H
+# include <nfs/nfsv2.h>
+#endif /* HAVE_NFS_NFSV2_H */
+#ifdef HAVE_NFS_RPCV2_H
+# include <nfs/rpcv2.h>
+#endif /* HAVE_NFS_RPCV2_H */
+#ifdef HAVE_NFS_NFS_H
+# include <nfs/nfs.h>
+#endif /* HAVE_NFS_NFS_H */
+#ifdef HAVE_SYS_FS_NFS_H
+# include <sys/fs/nfs.h>
+#endif /* HAVE_SYS_FS_NFS_H */
+#ifdef HAVE_RPCSVC_MOUNT_H
+# include <rpcsvc/mount.h>
+#endif /* HAVE_RPCSVC_MOUNT_H */
+
+
+/*
+ * MACROS
+ */
+
+#define NFS_PORT 2049
+#define NFS_MAXDATA 8192
+#define NFS_MAXPATHLEN 1024
+#define NFS_MAXNAMLEN 255
+#define NFS_FHSIZE 32
+#define NFS_COOKIESIZE 4
+#define MNTPATHLEN 1024
+#define MNTNAMLEN 255
+#define HOSTNAMESZ 32 /* Max size of hostname in struct nfs_args */
+
+#define NFSMODE_FMT 0170000
+#define NFSMODE_DIR 0040000
+#define NFSMODE_CHR 0020000
+#define NFSMODE_BLK 0060000
+#define NFSMODE_REG 0100000
+#define NFSMODE_LNK 0120000
+#define NFSMODE_SOCK 0140000
+#define NFSMODE_FIFO 0010000
+
+#ifndef NFS_PROGRAM
+# define NFS_PROGRAM ((u_long)100003)
+#endif /* not NFS_PROGRAM */
+#ifndef NFS_VERSION
+# define NFS_VERSION ((u_long)2)
+#endif /* not NFS_VERSION */
+
+#define NFSPROC_NULL ((u_long)0)
+#define NFSPROC_GETATTR ((u_long)1)
+#define NFSPROC_SETATTR ((u_long)2)
+#define NFSPROC_ROOT ((u_long)3)
+#define NFSPROC_LOOKUP ((u_long)4)
+#define NFSPROC_READLINK ((u_long)5)
+#define NFSPROC_READ ((u_long)6)
+#define NFSPROC_WRITECACHE ((u_long)7)
+#define NFSPROC_WRITE ((u_long)8)
+#define NFSPROC_CREATE ((u_long)9)
+#define NFSPROC_REMOVE ((u_long)10)
+#define NFSPROC_RENAME ((u_long)11)
+#define NFSPROC_LINK ((u_long)12)
+#define NFSPROC_SYMLINK ((u_long)13)
+#define NFSPROC_MKDIR ((u_long)14)
+#define NFSPROC_RMDIR ((u_long)15)
+#define NFSPROC_READDIR ((u_long)16)
+#define NFSPROC_STATFS ((u_long)17)
+
+/*
+ * NFS mount option flags
+ */
+#define NFSMNT_SOFT 0x001 /* soft mount (hard is default) */
+#define NFSMNT_WSIZE 0x002 /* set write size */
+#define NFSMNT_RSIZE 0x004 /* set read size */
+#define NFSMNT_TIMEO 0x008 /* set initial timeout */
+#define NFSMNT_RETRANS 0x010 /* set number of request retries */
+#define NFSMNT_HOSTNAME 0x020 /* set hostname for error printf */
+#define NFSMNT_INT 0x040 /* allow interrupts on hard mount */
+#define NFSMNT_NOAC 0x080 /* don't cache attributes */
+#define NFSMNT_ACREGMIN 0x0100 /* set min secs for file attr cache */
+#define NFSMNT_ACREGMAX 0x0200 /* set max secs for file attr cache */
+#define NFSMNT_ACDIRMIN 0x0400 /* set min secs for dir attr cache */
+#define NFSMNT_ACDIRMAX 0x0800 /* set max secs for dir attr cache */
+#define NFSMNT_SECURE 0x1000 /* secure mount */
+#define NFSMNT_NOCTO 0x2000 /* no close-to-open consistency */
+#define NFSMNT_KNCONF 0x4000 /* transport's knetconfig structure */
+#define NFSMNT_GRPID 0x8000 /* System V-style gid inheritance */
+#define NFSMNT_RPCTIMESYNC 0x10000 /* use RPC to do secure NFS time sync */
+#define NFSMNT_KERBEROS 0x20000 /* use kerberos credentials */
+#define NFSMNT_POSIX 0x40000 /* static pathconf kludge info */
+#define NFSMNT_LLOCK 0x80000 /* Local locking (no lock manager) */
+#define NFSMNT_REMOUNT 0x100000 /* Remount from r/o to r/w */
+
+#define NFSMNT_FSNAME 0x1000000 /* FS name e.g. "host:/path/" */
+#define NFSMNT_NODEVS 0x2000000 /* no devices access (default on) */
+#define NFSMNT_IGNORE 0x4000000 /* ignore in mnttab */
+
+#define MS_FSS 0x00 /* fake flag to do nothing */
+
+/*
+ * ENUMS:
+ */
+
+/*
+ * Error status
+ * Should include all possible net errors.
+ * For now we just cast errno into an enum nfsstat.
+ */
+enum nfsstat {
+ NFS_OK = 0, /* no error */
+ NFSERR_PERM = 1, /* Not owner */
+ NFSERR_NOENT = 2, /* No such file or directory */
+ NFSERR_IO = 5, /* I/O error */
+ NFSERR_NXIO = 6, /* No such device or address */
+ NFSERR_ACCES = 13, /* Permission denied */
+ NFSERR_EXIST = 17, /* File exists */
+ NFSERR_XDEV = 18, /* Cross-device link */
+ NFSERR_NODEV = 19, /* No such device */
+ NFSERR_NOTDIR = 20, /* Not a directory */
+ NFSERR_ISDIR = 21, /* Is a directory */
+ NFSERR_INVAL = 22, /* Invalid argument */
+ NFSERR_FBIG = 27, /* File too large */
+ NFSERR_NOSPC = 28, /* No space left on device */
+ NFSERR_ROFS = 30, /* Read-only file system */
+ NFSERR_OPNOTSUPP = 45, /* Operation not supported */
+ NFSERR_NAMETOOLONG = 63, /* File name too long */
+ NFSERR_NOTEMPTY = 66, /* Directory not empty */
+ NFSERR_DQUOT = 69, /* Disc quota exceeded */
+ NFSERR_STALE = 70, /* Stale NFS file handle */
+ NFSERR_REMOTE = 71, /* Object is remote */
+ NFSERR_WFLUSH /* write cache flushed */
+};
+
+/*
+ * File types
+ */
+enum nfsftype {
+ NFNON,
+ NFREG, /* regular file */
+ NFDIR, /* directory */
+ NFBLK, /* block special */
+ NFCHR, /* character special */
+ NFLNK, /* symbolic link */
+ NFSOC /* socket */
+};
+
+
+/*
+ * TYPEDEFS:
+ */
+typedef struct nfs_fh nfs_fh;
+typedef char *filename;
+typedef char *nfspath;
+typedef char nfscookie[NFS_COOKIESIZE];
+typedef enum nfsftype nfsftype;
+typedef enum nfsstat nfsstat;
+typedef struct attrstat nfsattrstat;
+typedef struct createargs nfscreateargs;
+typedef struct dirlist nfsdirlist;
+typedef struct diropargs nfsdiropargs;
+typedef struct diropokres nfsdiropokres;
+typedef struct diropres nfsdiropres;
+typedef struct entry nfsentry;
+typedef struct fattr nfsfattr;
+typedef struct linkargs nfslinkargs;
+typedef struct nfstime nfstime;
+typedef struct readargs nfsreadargs;
+typedef struct readdirargs nfsreaddirargs;
+typedef struct readdirres nfsreaddirres;
+typedef struct readlinkres nfsreadlinkres;
+typedef struct readokres nfsreadokres;
+typedef struct readres nfsreadres;
+typedef struct renameargs nfsrenameargs;
+typedef struct sattr nfssattr;
+typedef struct sattrargs nfssattrargs;
+typedef struct statfsokres nfsstatfsokres;
+typedef struct statfsres nfsstatfsres;
+typedef struct symlinkargs nfssymlinkargs;
+typedef struct writeargs nfswriteargs;
+
+/*
+ * NFSv3 handle (copied from am_xdr_func.h, because it is needed here)
+ * we use a different name but same storage size/alignment to avoid
+ * conflicts. Sigh, this is so hacky. -ezk
+ */
+#define HPUX11_FHSIZE3 64 /* size in bytes of a file handle (v3) */
+struct hpux11_nfs_fh3 {
+ u_int am_fh3_length;
+ char am_fh3_data[HPUX11_FHSIZE3];
+};
+typedef struct hpux11_nfs_fh3 hpux11_nfs_fh3;
+
+/*
+ * EXTERNALS:
+ */
+
+extern void *nfsproc_null_2_svc(void *, struct svc_req *);
+extern nfsattrstat *nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *);
+extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *);
+extern void *nfsproc_root_2_svc(void *, struct svc_req *);
+extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsreadlinkres *nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *);
+extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *);
+extern void *nfsproc_writecache_2_svc(void *, struct svc_req *);
+extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *);
+extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *);
+extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *);
+extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *);
+extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *);
+extern nfsstatfsres *nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *);
+
+extern bool_t xdr_nfsstat(XDR *, nfsstat*);
+extern bool_t xdr_ftype(XDR *, nfsftype*);
+extern bool_t xdr_nfs_fh(XDR *, nfs_fh*);
+extern bool_t xdr_nfstime(XDR *, nfstime*);
+extern bool_t xdr_fattr(XDR *, nfsfattr*);
+extern bool_t xdr_sattr(XDR *, nfssattr*);
+extern bool_t xdr_filename(XDR *, filename*);
+extern bool_t xdr_nfspath(XDR *, nfspath*);
+extern bool_t xdr_attrstat(XDR *, nfsattrstat*);
+extern bool_t xdr_sattrargs(XDR *, nfssattrargs*);
+extern bool_t xdr_diropargs(XDR *, nfsdiropargs*);
+extern bool_t xdr_diropokres(XDR *, nfsdiropokres*);
+extern bool_t xdr_diropres(XDR *, nfsdiropres*);
+extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*);
+extern bool_t xdr_readargs(XDR *, nfsreadargs*);
+extern bool_t xdr_readokres(XDR *, nfsreadokres*);
+extern bool_t xdr_readres(XDR *, nfsreadres*);
+extern bool_t xdr_writeargs(XDR *, nfswriteargs*);
+extern bool_t xdr_createargs(XDR *, nfscreateargs*);
+extern bool_t xdr_renameargs(XDR *, nfsrenameargs*);
+extern bool_t xdr_linkargs(XDR *, nfslinkargs*);
+extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*);
+extern bool_t xdr_nfscookie(XDR *, nfscookie);
+extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*);
+extern bool_t xdr_entry(XDR *, nfsentry*);
+extern bool_t xdr_dirlist(XDR *, nfsdirlist*);
+extern bool_t xdr_readdirres(XDR *, nfsreaddirres*);
+extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*);
+extern bool_t xdr_statfsres(XDR *, nfsstatfsres*);
+
+/*
+ * STRUCTURES:
+ */
+
+/* This is similar to Solaris 2.5.1 */
+struct nfs_args {
+ struct netbuf *addr; /* file server address */
+ struct netbuf *syncaddr; /* secure NFS time sync addr */
+ struct knetconfig *knconf; /* transport netconfig struct */
+ char *hostname; /* server's hostname */
+ char *netname; /* server's netname */
+ caddr_t fh; /* File handle to be mounted */
+ int flags; /* flags */
+ int wsize; /* write size in bytes */
+ int rsize; /* read size in bytes */
+ int timeo; /* initial timeout in .1 secs */
+ int retrans; /* times to retry send */
+ int acregmin; /* attr cache file min secs */
+ int acregmax; /* attr cache file max secs */
+ int acdirmin; /* attr cache dir min secs */
+ int acdirmax; /* attr cache dir max secs */
+ char *fsname; /* F/S name */
+#if 0
+ struct pathcnf *pathconf; /* static pathconf kludge */
+#endif /* 0 */
+};
+
+struct nfs_fh {
+ char fh_data[NFS_FHSIZE];
+};
+
+struct nfstime {
+ u_int nt_seconds;
+ u_int nt_useconds;
+};
+
+struct fattr {
+ nfsftype na_type;
+ u_int na_mode;
+ u_int na_nlink;
+ u_int na_uid;
+ u_int na_gid;
+ u_int na_size;
+ u_int na_blocksize;
+ u_int na_rdev;
+ u_int na_blocks;
+ u_int na_fsid;
+ u_int na_fileid;
+ nfstime na_atime;
+ nfstime na_mtime;
+ nfstime na_ctime;
+};
+
+struct sattr {
+ u_int sa_mode;
+ u_int sa_uid;
+ u_int sa_gid;
+ u_int sa_size;
+ nfstime sa_atime;
+ nfstime sa_mtime;
+};
+
+struct attrstat {
+ nfsstat ns_status;
+ union {
+ nfsfattr ns_attr_u;
+ } ns_u;
+};
+
+struct sattrargs {
+ nfs_fh sag_fhandle;
+ nfssattr sag_attributes;
+};
+
+struct diropargs {
+ nfs_fh da_fhandle; /* was dir */
+ filename da_name;
+};
+
+struct diropokres {
+ nfs_fh drok_fhandle;
+ nfsfattr drok_attributes;
+};
+
+struct diropres {
+ nfsstat dr_status; /* was status */
+ union {
+ nfsdiropokres dr_drok_u; /* was diropres */
+ } dr_u; /* was diropres_u */
+};
+
+struct readlinkres {
+ nfsstat rlr_status;
+ union {
+ nfspath rlr_data_u;
+ } rlr_u;
+};
+
+struct readargs {
+ nfs_fh ra_fhandle;
+ u_int ra_offset;
+ u_int ra_count;
+ u_int ra_totalcount;
+};
+
+struct readokres {
+ nfsfattr raok_attributes;
+ struct {
+ u_int raok_len_u;
+ char *raok_val_u;
+ } raok_u;
+};
+
+struct readres {
+ nfsstat rr_status;
+ union {
+ nfsreadokres rr_reply_u;
+ } rr_u;
+};
+
+struct writeargs {
+ nfs_fh wra_fhandle;
+ u_int wra_beginoffset;
+ u_int wra_offset;
+ u_int wra_totalcount;
+ struct {
+ u_int wra_len_u;
+ char *wra_val_u;
+ } wra_u;
+};
+
+struct createargs {
+ nfsdiropargs ca_where;
+ nfssattr ca_attributes;
+};
+
+struct renameargs {
+ nfsdiropargs rna_from;
+ nfsdiropargs rna_to;
+};
+
+struct linkargs {
+ nfs_fh la_fhandle;
+ nfsdiropargs la_to;
+};
+
+struct symlinkargs {
+ nfsdiropargs sla_from;
+ nfspath sla_to;
+ nfssattr sla_attributes;
+};
+
+struct readdirargs {
+ nfs_fh rda_fhandle;
+ nfscookie rda_cookie;
+ u_int rda_count;
+};
+
+struct entry {
+ u_int ne_fileid;
+ filename ne_name;
+ nfscookie ne_cookie;
+ nfsentry *ne_nextentry;
+};
+
+struct dirlist {
+ nfsentry *dl_entries;
+ bool_t dl_eof;
+};
+
+struct readdirres {
+ nfsstat rdr_status;
+ union {
+ nfsdirlist rdr_reply_u;
+ } rdr_u;
+};
+
+struct statfsokres {
+ u_int sfrok_tsize;
+ u_int sfrok_bsize;
+ u_int sfrok_blocks;
+ u_int sfrok_bfree;
+ u_int sfrok_bavail;
+};
+
+struct statfsres {
+ nfsstat sfr_status;
+ union {
+ nfsstatfsokres sfr_reply_u;
+ } sfr_u;
+};
+
+/*
+ **************************************************************************
+ * HP-UX 11 has Autofs support, but we don't support it yet.
+ * For now, undefine it or define dummy entries.
+ **************************************************************************
+ */
+#ifdef MNTTYPE_AUTOFS
+# undef MNTTYPE_AUTOFS
+#endif /* MNTTYPE_AUTOFS */
+#ifdef MNTTAB_TYPE_AUTOFS
+# undef MNTTAB_TYPE_AUTOFS
+#endif /* MNTTAB_TYPE_AUTOFS */
+#ifdef HAVE_FS_AUTOFS
+# undef HAVE_FS_AUTOFS
+#endif /* HAVE_FS_AUTOFS */
+
+#ifdef MNTTYPE_NFS3
+
+#define NFSPROC3_LOOKUP ((u_long) 3)
+enum nfsstat3 {
+ NFS3_OK = 0,
+ NFS3ERR_PERM = 1,
+ NFS3ERR_NOENT = 2,
+ NFS3ERR_IO = 5,
+ NFS3ERR_NXIO = 6,
+ NFS3ERR_ACCES = 13,
+ NFS3ERR_EXIST = 17,
+ NFS3ERR_XDEV = 18,
+ NFS3ERR_NODEV = 19,
+ NFS3ERR_NOTDIR = 20,
+ NFS3ERR_ISDIR = 21,
+ NFS3ERR_INVAL = 22,
+ NFS3ERR_FBIG = 27,
+ NFS3ERR_NOSPC = 28,
+ NFS3ERR_ROFS = 30,
+ NFS3ERR_MLINK = 31,
+ NFS3ERR_NAMETOOLONG = 63,
+ NFS3ERR_NOTEMPTY = 66,
+ NFS3ERR_DQUOT = 69,
+ NFS3ERR_STALE = 70,
+ NFS3ERR_REMOTE = 71,
+ NFS3ERR_BADHANDLE = 10001,
+ NFS3ERR_NOT_SYNC = 10002,
+ NFS3ERR_BAD_COOKIE = 10003,
+ NFS3ERR_NOTSUPP = 10004,
+ NFS3ERR_TOOSMALL = 10005,
+ NFS3ERR_SERVERFAULT = 10006,
+ NFS3ERR_BADTYPE = 10007,
+ NFS3ERR_JUKEBOX = 10008
+};
+typedef enum nfsstat3 nfsstat3;
+
+typedef char *filename3;
+
+struct diropargs3 {
+ hpux11_nfs_fh3 dir;
+ filename3 name;
+};
+typedef struct diropargs3 diropargs3;
+
+struct LOOKUP3args {
+ diropargs3 what;
+};
+typedef struct LOOKUP3args LOOKUP3args;
+
+struct LOOKUP3resok {
+ hpux11_nfs_fh3 object;
+#if 0
+ post_op_attr obj_attributes;
+ post_op_attr dir_attributes;
+#endif /* 0 */
+};
+typedef struct LOOKUP3resok LOOKUP3resok;
+
+struct LOOKUP3resfail {
+ int dummy;
+#if 0
+ post_op_attr dir_attributes;
+#endif /* 0 */
+};
+typedef struct LOOKUP3resfail LOOKUP3resfail;
+
+struct LOOKUP3res {
+ nfsstat3 status;
+ union {
+ LOOKUP3resok ok;
+ LOOKUP3resfail fail;
+ } res_u;
+};
+typedef struct LOOKUP3res LOOKUP3res;
+
+# endif /* MNTTYPE_NFS3 */
+
+#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_irix5.h b/conf/nfs_prot/nfs_prot_irix5.h
new file mode 100644
index 000000000000..de4312a4d40c
--- /dev/null
+++ b/conf/nfs_prot/nfs_prot_irix5.h
@@ -0,0 +1,450 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/nfs_prot/nfs_prot_irix5.h
+ *
+ */
+
+#ifndef _AMU_NFS_PROT_H
+#define _AMU_NFS_PROT_H
+
+#ifdef HAVE_NFS_NFSV2_H
+# include <nfs/nfsv2.h>
+#endif /* HAVE_NFS_NFSV2_H */
+#ifdef HAVE_RPC_RPC_H
+# include <rpc/rpc.h>
+#endif /* HAVE_RPC_RPC_H */
+#ifdef HAVE_NFS_RPCV2_H
+# include <nfs/rpcv2.h>
+#endif /* HAVE_NFS_RPCV2_H */
+#ifdef HAVE_NFS_NFS_H
+# include <nfs/nfs.h>
+#endif /* HAVE_NFS_NFS_H */
+#ifdef HAVE_SYS_UIO_H
+# define _KMEMUSER
+# include <sys/uio.h>
+# undef _KMEMUSER
+#endif /* HAVE_SYS_UIO_H */
+#ifdef HAVE_SYS_VNODE_H
+# include <sys/vnode.h>
+#endif /* HAVE_SYS_VNODE_H */
+#ifdef HAVE_SYS_FS_NFS_H
+# include <sys/fs/nfs.h>
+#endif /* HAVE_SYS_FS_NFS_H */
+
+#ifdef HAVE_RPCSVC_MOUNT_H
+# include <rpcsvc/mount.h>
+#endif /* HAVE_RPCSVC_MOUNT_H */
+#ifdef HAVE_SYS_FSTYP_H
+# include <sys/fstyp.h>
+#endif /* HAVE_SYS_FSTYP_H */
+
+/* XFS isn't really supported in 5.3, but the header files are confusing */
+#undef MNTTYPE_XFS
+#undef MNTTAB_TYPE_XFS
+
+/****************************************************************************/
+/*
+ * NFS V3 SUPPORT:
+ *
+ * IRIX5.3 requires the fh_len field to be added to the struct nfs_args
+ * defined in <sys/fs/nfs_clnt.h> for NFS3 mounts (it doesn't hurt for
+ * NFS2 mounts). The mount syscall however always expects the argument
+ * structure size to be sizeof(struct nfs_args).
+ * So we need to use an extended struct nfs_args in amd/ops_nfs.c,
+ * while using the original struct nfs_arg in libamu/mountutil.c.
+ * -- stolcke 7/4/97
+ */
+
+/*
+ * NFS arguments to the mount system call.
+ */
+struct irix5_nfs_args {
+ struct sockaddr_in *addr; /* file server address */
+ fhandle_t *fh; /* File handle to be mounted */
+ int flags; /* flags */
+ u_int wsize; /* write size in bytes */
+ u_int rsize; /* read size in bytes */
+ u_int timeo; /* initial timeout in .1 secs */
+ u_int retrans; /* times to retry send */
+ char *hostname; /* server's name */
+ u_int acregmin; /* attr cache file min secs */
+ u_int acregmax; /* attr cache file max secs */
+ u_int acdirmin; /* attr cache dir min secs */
+ u_int acdirmax; /* attr cache dir max secs */
+ u_int symttl; /* symlink cache time-to-live */
+ char base[FSTYPSZ]; /* base type for statvfs */
+ u_int namemax; /* name length for statvfs */
+ u_int fh_len; /* length for a v3 filehandle */
+};
+
+#ifndef MNTOPT_PROTO
+# define MNTOPT_PROTO "proto"
+#endif /* not MNTOPT_PROTO */
+#ifndef MNTOPT_VERS
+# define MNTOPT_VERS "vers"
+#endif /* not MNTOPT_VERS */
+
+/****************************************************************************/
+
+
+/*
+ * MACROS
+ */
+
+#define NFS_PORT 2049
+#define NFS_MAXDATA 8192
+#define NFS_MAXPATHLEN 1024
+#define NFS_MAXNAMLEN 255
+#define NFS_FHSIZE 32
+#ifndef FHSIZE
+/* Irix 5.2 is missing the definition for FHSIZE */
+# define FHSIZE NFS_FHSIZE
+#endif /* not FHSIZE */
+#define NFS_COOKIESIZE 4
+#define MNTPATHLEN 1024
+#define MNTNAMLEN 255
+
+#define NFSMODE_FMT 0170000
+#define NFSMODE_DIR 0040000
+#define NFSMODE_CHR 0020000
+#define NFSMODE_BLK 0060000
+#define NFSMODE_REG 0100000
+#define NFSMODE_LNK 0120000
+#define NFSMODE_SOCK 0140000
+#define NFSMODE_FIFO 0010000
+
+#ifndef NFS_PROGRAM
+# define NFS_PROGRAM ((u_long)100003)
+#endif /* not NFS_PROGRAM */
+#ifndef NFS_VERSION
+# define NFS_VERSION ((u_long)2)
+#endif /* not NFS_VERSION */
+
+#define NFSPROC_NULL ((u_long)0)
+#define NFSPROC_GETATTR ((u_long)1)
+#define NFSPROC_SETATTR ((u_long)2)
+#define NFSPROC_ROOT ((u_long)3)
+#define NFSPROC_LOOKUP ((u_long)4)
+#define NFSPROC_READLINK ((u_long)5)
+#define NFSPROC_READ ((u_long)6)
+#define NFSPROC_WRITECACHE ((u_long)7)
+#define NFSPROC_WRITE ((u_long)8)
+#define NFSPROC_CREATE ((u_long)9)
+#define NFSPROC_REMOVE ((u_long)10)
+#define NFSPROC_RENAME ((u_long)11)
+#define NFSPROC_LINK ((u_long)12)
+#define NFSPROC_SYMLINK ((u_long)13)
+#define NFSPROC_MKDIR ((u_long)14)
+#define NFSPROC_RMDIR ((u_long)15)
+#define NFSPROC_READDIR ((u_long)16)
+#define NFSPROC_STATFS ((u_long)17)
+
+/* map field names */
+#define ml_hostname ml_name
+#define ml_directory ml_path
+#define ml_next ml_nxt
+#define gr_next g_next
+#define gr_name g_name
+#define ex_dir ex_name
+
+
+/*
+ * TYPEDEFS:
+ */
+typedef char *dirpath;
+typedef char *filename;
+typedef char *name;
+typedef char *nfspath;
+typedef char nfscookie[NFS_COOKIESIZE];
+typedef enum nfsftype nfsftype;
+typedef enum nfsstat nfsstat;
+typedef struct attrstat nfsattrstat;
+typedef struct createargs nfscreateargs;
+typedef struct dirlist nfsdirlist;
+typedef struct diropargs nfsdiropargs;
+typedef struct diropokres nfsdiropokres;
+typedef struct diropres nfsdiropres;
+typedef struct entry nfsentry;
+typedef struct exports *exports;
+typedef struct exports exportnode;
+typedef struct fattr nfsfattr;
+typedef struct fhstatus fhstatus;
+typedef struct groups *groups;
+typedef struct groups groupnode;
+typedef struct linkargs nfslinkargs;
+typedef struct mountlist *mountlist;
+typedef struct mountlist mountbody;
+typedef struct nfs_fh nfs_fh;
+typedef struct nfstime nfstime;
+typedef struct readargs nfsreadargs;
+typedef struct readdirargs nfsreaddirargs;
+typedef struct readdirres nfsreaddirres;
+typedef struct readlinkres nfsreadlinkres;
+typedef struct readokres nfsreadokres;
+typedef struct readres nfsreadres;
+typedef struct renameargs nfsrenameargs;
+typedef struct sattr nfssattr;
+typedef struct sattrargs nfssattrargs;
+typedef struct statfsokres nfsstatfsokres;
+typedef struct statfsres nfsstatfsres;
+typedef struct symlinkargs nfssymlinkargs;
+typedef struct writeargs nfswriteargs;
+
+
+/*
+ * EXTERNALS:
+ */
+
+extern void *nfsproc_null_2_svc(void *, struct svc_req *);
+extern nfsattrstat *nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *);
+extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *);
+extern void *nfsproc_root_2_svc(void *, struct svc_req *);
+extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsreadlinkres *nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *);
+extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *);
+extern void *nfsproc_writecache_2_svc(void *, struct svc_req *);
+extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *);
+extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *);
+extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *);
+extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *);
+extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *);
+extern nfsstatfsres *nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *);
+
+extern bool_t xdr_nfsstat(XDR *, nfsstat*);
+extern bool_t xdr_ftype(XDR *, nfsftype*);
+extern bool_t xdr_nfs_fh(XDR *, nfs_fh*);
+extern bool_t xdr_nfstime(XDR *, nfstime*);
+extern bool_t xdr_fattr(XDR *, nfsfattr*);
+extern bool_t xdr_sattr(XDR *, nfssattr*);
+extern bool_t xdr_filename(XDR *, filename*);
+extern bool_t xdr_nfspath(XDR *, nfspath*);
+extern bool_t xdr_attrstat(XDR *, nfsattrstat*);
+extern bool_t xdr_sattrargs(XDR *, nfssattrargs*);
+extern bool_t xdr_diropargs(XDR *, nfsdiropargs*);
+extern bool_t xdr_diropokres(XDR *, nfsdiropokres*);
+extern bool_t xdr_diropres(XDR *, nfsdiropres*);
+extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*);
+extern bool_t xdr_readargs(XDR *, nfsreadargs*);
+extern bool_t xdr_readokres(XDR *, nfsreadokres*);
+extern bool_t xdr_readres(XDR *, nfsreadres*);
+extern bool_t xdr_writeargs(XDR *, nfswriteargs*);
+extern bool_t xdr_createargs(XDR *, nfscreateargs*);
+extern bool_t xdr_renameargs(XDR *, nfsrenameargs*);
+extern bool_t xdr_linkargs(XDR *, nfslinkargs*);
+extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*);
+extern bool_t xdr_nfscookie(XDR *, nfscookie);
+extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*);
+extern bool_t xdr_entry(XDR *, nfsentry*);
+extern bool_t xdr_dirlist(XDR *, nfsdirlist*);
+extern bool_t xdr_readdirres(XDR *, nfsreaddirres*);
+extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*);
+extern bool_t xdr_statfsres(XDR *, nfsstatfsres*);
+
+
+/*
+ * STRUCTURES:
+ */
+
+struct nfs_fh {
+ char fh_data[NFS_FHSIZE];
+};
+
+struct nfstime {
+ u_int nt_seconds;
+ u_int nt_useconds;
+};
+
+struct fattr {
+ nfsftype na_type;
+ u_int na_mode;
+ u_int na_nlink;
+ u_int na_uid;
+ u_int na_gid;
+ u_int na_size;
+ u_int na_blocksize;
+ u_int na_rdev;
+ u_int na_blocks;
+ u_int na_fsid;
+ u_int na_fileid;
+ nfstime na_atime;
+ nfstime na_mtime;
+ nfstime na_ctime;
+};
+
+struct sattr {
+ u_int sa_mode;
+ u_int sa_uid;
+ u_int sa_gid;
+ u_int sa_size;
+ nfstime sa_atime;
+ nfstime sa_mtime;
+};
+
+struct attrstat {
+ nfsstat ns_status;
+ union {
+ nfsfattr ns_attr_u;
+ } ns_u;
+};
+
+struct sattrargs {
+ nfs_fh sag_fhandle;
+ nfssattr sag_attributes;
+};
+
+struct diropargs {
+ nfs_fh da_fhandle; /* was dir */
+ filename da_name;
+};
+
+struct diropokres {
+ nfs_fh drok_fhandle;
+ nfsfattr drok_attributes;
+};
+
+struct diropres {
+ nfsstat dr_status; /* was status */
+ union {
+ nfsdiropokres dr_drok_u; /* was diropres */
+ } dr_u; /* was diropres_u */
+};
+
+struct readlinkres {
+ nfsstat rlr_status;
+ union {
+ nfspath rlr_data_u;
+ } rlr_u;
+};
+
+struct readargs {
+ nfs_fh ra_fhandle;
+ u_int ra_offset;
+ u_int ra_count;
+ u_int ra_totalcount;
+};
+
+struct readokres {
+ nfsfattr raok_attributes;
+ struct {
+ u_int raok_len_u;
+ char *raok_val_u;
+ } raok_u;
+};
+
+struct readres {
+ nfsstat rr_status;
+ union {
+ nfsreadokres rr_reply_u;
+ } rr_u;
+};
+
+struct writeargs {
+ nfs_fh wra_fhandle;
+ u_int wra_beginoffset;
+ u_int wra_offset;
+ u_int wra_totalcount;
+ struct {
+ u_int wra_len_u;
+ char *wra_val_u;
+ } wra_u;
+};
+
+struct createargs {
+ nfsdiropargs ca_where;
+ nfssattr ca_attributes;
+};
+
+struct renameargs {
+ nfsdiropargs rna_from;
+ nfsdiropargs rna_to;
+};
+
+struct linkargs {
+ nfs_fh la_fhandle;
+ nfsdiropargs la_to;
+};
+
+struct symlinkargs {
+ nfsdiropargs sla_from;
+ nfspath sla_to;
+ nfssattr sla_attributes;
+};
+
+struct readdirargs {
+ nfs_fh rda_fhandle;
+ nfscookie rda_cookie;
+ u_int rda_count;
+};
+
+struct entry {
+ u_int ne_fileid;
+ filename ne_name;
+ nfscookie ne_cookie;
+ nfsentry *ne_nextentry;
+};
+
+struct dirlist {
+ nfsentry *dl_entries;
+ bool_t dl_eof;
+};
+
+struct readdirres {
+ nfsstat rdr_status;
+ union {
+ nfsdirlist rdr_reply_u;
+ } rdr_u;
+};
+
+struct statfsokres {
+ u_int sfrok_tsize;
+ u_int sfrok_bsize;
+ u_int sfrok_blocks;
+ u_int sfrok_bfree;
+ u_int sfrok_bavail;
+};
+
+struct statfsres {
+ nfsstat sfr_status;
+ union {
+ nfsstatfsokres sfr_reply_u;
+ } sfr_u;
+};
+
+#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_irix6.h b/conf/nfs_prot/nfs_prot_irix6.h
new file mode 100644
index 000000000000..159dfe7ad6ff
--- /dev/null
+++ b/conf/nfs_prot/nfs_prot_irix6.h
@@ -0,0 +1,496 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/nfs_prot/nfs_prot_irix6.h
+ *
+ */
+
+#ifndef _AMU_NFS_PROT_H
+#define _AMU_NFS_PROT_H
+
+#ifdef HAVE_NFS_NFSV2_H
+# include <nfs/nfsv2.h>
+#endif /* HAVE_NFS_NFSV2_H */
+#ifdef HAVE_RPC_RPC_H
+# include <rpc/rpc.h>
+#endif /* HAVE_RPC_RPC_H */
+#ifdef HAVE_NFS_RPCV2_H
+# include <nfs/rpcv2.h>
+#endif /* HAVE_NFS_RPCV2_H */
+#ifdef HAVE_NFS_NFS_H
+# include <nfs/nfs.h>
+#endif /* HAVE_NFS_NFS_H */
+#ifdef HAVE_SYS_FS_NFS_H
+# include <sys/fs/nfs.h>
+#endif /* HAVE_SYS_FS_NFS_H */
+
+#ifdef HAVE_RPCSVC_MOUNT_H_off
+# include <rpcsvc/mount.h>
+#endif /* HAVE_RPCSVC_MOUNT_H */
+
+/* evil: don't include */
+#undef HAVE_RPCSVC_MOUNT_H
+
+/*
+ * MACROS
+ */
+
+#define NFS_PORT 2049
+#define NFS_MAXDATA 8192
+#define NFS_MAXPATHLEN 1024
+#define NFS_MAXNAMLEN 255
+#define NFS_FHSIZE 32
+#define NFS_COOKIESIZE 4
+#define MNTPATHLEN 1024
+#define MNTNAMLEN 255
+#define FHSIZE 32
+
+#define MOUNTPROG 100005
+#define MOUNTPROC_MNT 1
+#define MOUNTPROC_DUMP 2
+#define MOUNTPROC_UMNT 3
+#define MOUNTPROC_UMNTALL 4
+#define MOUNTPROC_EXPORT 5
+#define MOUNTPROC_EXPORTALL 6
+#define MOUNTVERS_ORIG 1
+#define MOUNTVERS 1
+#define MOUNTVERS3 3
+
+#define NFSMODE_FMT 0170000
+#define NFSMODE_DIR 0040000
+#define NFSMODE_CHR 0020000
+#define NFSMODE_BLK 0060000
+#define NFSMODE_REG 0100000
+#define NFSMODE_LNK 0120000
+#define NFSMODE_SOCK 0140000
+#define NFSMODE_FIFO 0010000
+
+#ifndef NFS_PROGRAM
+# define NFS_PROGRAM ((u_long)100003)
+#endif /* not NFS_PROGRAM */
+#ifndef NFS_VERSION
+# define NFS_VERSION ((u_long)2)
+#endif /* not NFS_VERSION */
+
+#define NFSPROC_NULL ((u_long)0)
+#define NFSPROC_GETATTR ((u_long)1)
+#define NFSPROC_SETATTR ((u_long)2)
+#define NFSPROC_ROOT ((u_long)3)
+#define NFSPROC_LOOKUP ((u_long)4)
+#define NFSPROC_READLINK ((u_long)5)
+#define NFSPROC_READ ((u_long)6)
+#define NFSPROC_WRITECACHE ((u_long)7)
+#define NFSPROC_WRITE ((u_long)8)
+#define NFSPROC_CREATE ((u_long)9)
+#define NFSPROC_REMOVE ((u_long)10)
+#define NFSPROC_RENAME ((u_long)11)
+#define NFSPROC_LINK ((u_long)12)
+#define NFSPROC_SYMLINK ((u_long)13)
+#define NFSPROC_MKDIR ((u_long)14)
+#define NFSPROC_RMDIR ((u_long)15)
+#define NFSPROC_READDIR ((u_long)16)
+#define NFSPROC_STATFS ((u_long)17)
+
+/* map field names */
+#define ml_hostname ml_name
+#define ml_directory ml_path
+#define ml_next ml_nxt
+#define gr_next g_next
+#define gr_name g_name
+#define ex_dir ex_name
+
+/*
+ * Irix 6.2 does not define the proto/dev options, although they
+ * do support them for NFS V3.
+ */
+#ifdef MNTTYPE_NFS3
+# ifndef MNTOPT_PROTO
+# define MNTOPT_PROTO "proto"
+# endif /* not MNTOPT_PROTO */
+# ifndef MNTOPT_VERS
+# define MNTOPT_VERS "vers"
+# endif /* not MNTOPT_VERS */
+#endif /* MNTTYPE_NFS3 */
+
+#define AUTOFS_CONFTYPE "udp"
+
+/*
+ * TYPEDEFS:
+ */
+typedef char *dirpath;
+typedef char *filename;
+typedef char *name;
+typedef char *nfspath;
+typedef char nfscookie[NFS_COOKIESIZE];
+typedef enum nfsftype nfsftype;
+typedef enum nfsstat nfsstat;
+typedef struct attrstat nfsattrstat;
+typedef struct createargs nfscreateargs;
+typedef struct dirlist nfsdirlist;
+typedef struct diropargs nfsdiropargs;
+typedef struct diropokres nfsdiropokres;
+typedef struct diropres nfsdiropres;
+typedef struct entry nfsentry;
+typedef struct exports *exports;
+typedef struct exports exportnode;
+typedef struct fattr nfsfattr;
+typedef struct fhstatus fhstatus;
+typedef struct groups *groups;
+typedef struct groups groupnode;
+typedef struct linkargs nfslinkargs;
+typedef struct mountlist *mountlist;
+typedef struct mountlist mountbody;
+typedef struct nfs_fh nfs_fh;
+typedef struct nfstime nfstime;
+typedef struct readargs nfsreadargs;
+typedef struct readdirargs nfsreaddirargs;
+typedef struct readdirres nfsreaddirres;
+typedef struct readlinkres nfsreadlinkres;
+typedef struct readokres nfsreadokres;
+typedef struct readres nfsreadres;
+typedef struct renameargs nfsrenameargs;
+typedef struct sattr nfssattr;
+typedef struct sattrargs nfssattrargs;
+typedef struct statfsokres nfsstatfsokres;
+typedef struct statfsres nfsstatfsres;
+typedef struct symlinkargs nfssymlinkargs;
+typedef struct writeargs nfswriteargs;
+
+
+/*
+ * EXTERNALS:
+ */
+
+extern void *nfsproc_null_2_svc(void *, struct svc_req *);
+extern nfsattrstat *nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *);
+extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *);
+extern void *nfsproc_root_2_svc(void *, struct svc_req *);
+extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsreadlinkres *nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *);
+extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *);
+extern void *nfsproc_writecache_2_svc(void *, struct svc_req *);
+extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *);
+extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *);
+extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *);
+extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *);
+extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *);
+extern nfsstatfsres *nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *);
+
+extern bool_t xdr_nfsstat(XDR *, nfsstat*);
+extern bool_t xdr_ftype(XDR *, nfsftype*);
+extern bool_t xdr_nfs_fh(XDR *, nfs_fh*);
+extern bool_t xdr_nfstime(XDR *, nfstime*);
+extern bool_t xdr_fattr(XDR *, nfsfattr*);
+extern bool_t xdr_sattr(XDR *, nfssattr*);
+extern bool_t xdr_filename(XDR *, filename*);
+extern bool_t xdr_nfspath(XDR *, nfspath*);
+extern bool_t xdr_attrstat(XDR *, nfsattrstat*);
+extern bool_t xdr_sattrargs(XDR *, nfssattrargs*);
+extern bool_t xdr_diropargs(XDR *, nfsdiropargs*);
+extern bool_t xdr_diropokres(XDR *, nfsdiropokres*);
+extern bool_t xdr_diropres(XDR *, nfsdiropres*);
+extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*);
+extern bool_t xdr_readargs(XDR *, nfsreadargs*);
+extern bool_t xdr_readokres(XDR *, nfsreadokres*);
+extern bool_t xdr_readres(XDR *, nfsreadres*);
+extern bool_t xdr_writeargs(XDR *, nfswriteargs*);
+extern bool_t xdr_createargs(XDR *, nfscreateargs*);
+extern bool_t xdr_renameargs(XDR *, nfsrenameargs*);
+extern bool_t xdr_linkargs(XDR *, nfslinkargs*);
+extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*);
+extern bool_t xdr_nfscookie(XDR *, nfscookie);
+extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*);
+extern bool_t xdr_entry(XDR *, nfsentry*);
+extern bool_t xdr_dirlist(XDR *, nfsdirlist*);
+extern bool_t xdr_readdirres(XDR *, nfsreaddirres*);
+extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*);
+extern bool_t xdr_statfsres(XDR *, nfsstatfsres*);
+
+
+/*
+ * STRUCTURES:
+ */
+
+struct nfs_fh {
+ char fh_data[NFS_FHSIZE];
+};
+
+struct nfstime {
+ u_int nt_seconds;
+ u_int nt_useconds;
+};
+
+struct fattr {
+ nfsftype na_type;
+ u_int na_mode;
+ u_int na_nlink;
+ u_int na_uid;
+ u_int na_gid;
+ u_int na_size;
+ u_int na_blocksize;
+ u_int na_rdev;
+ u_int na_blocks;
+ u_int na_fsid;
+ u_int na_fileid;
+ nfstime na_atime;
+ nfstime na_mtime;
+ nfstime na_ctime;
+};
+
+struct sattr {
+ u_int sa_mode;
+ u_int sa_uid;
+ u_int sa_gid;
+ u_int sa_size;
+ nfstime sa_atime;
+ nfstime sa_mtime;
+};
+
+struct attrstat {
+ nfsstat ns_status;
+ union {
+ nfsfattr ns_attr_u;
+ } ns_u;
+};
+
+struct sattrargs {
+ nfs_fh sag_fhandle;
+ nfssattr sag_attributes;
+};
+
+struct diropargs {
+ nfs_fh da_fhandle; /* was dir */
+ filename da_name;
+};
+
+struct diropokres {
+ nfs_fh drok_fhandle;
+ nfsfattr drok_attributes;
+};
+
+struct diropres {
+ nfsstat dr_status; /* was status */
+ union {
+ nfsdiropokres dr_drok_u; /* was diropres */
+ } dr_u; /* was diropres_u */
+};
+
+struct readlinkres {
+ nfsstat rlr_status;
+ union {
+ nfspath rlr_data_u;
+ } rlr_u;
+};
+
+struct readargs {
+ nfs_fh ra_fhandle;
+ u_int ra_offset;
+ u_int ra_count;
+ u_int ra_totalcount;
+};
+
+struct readokres {
+ nfsfattr raok_attributes;
+ struct {
+ u_int raok_len_u;
+ char *raok_val_u;
+ } raok_u;
+};
+
+struct readres {
+ nfsstat rr_status;
+ union {
+ nfsreadokres rr_reply_u;
+ } rr_u;
+};
+
+struct writeargs {
+ nfs_fh wra_fhandle;
+ u_int wra_beginoffset;
+ u_int wra_offset;
+ u_int wra_totalcount;
+ struct {
+ u_int wra_len_u;
+ char *wra_val_u;
+ } wra_u;
+};
+
+struct createargs {
+ nfsdiropargs ca_where;
+ nfssattr ca_attributes;
+};
+
+struct renameargs {
+ nfsdiropargs rna_from;
+ nfsdiropargs rna_to;
+};
+
+struct linkargs {
+ nfs_fh la_fhandle;
+ nfsdiropargs la_to;
+};
+
+struct symlinkargs {
+ nfsdiropargs sla_from;
+ nfspath sla_to;
+ nfssattr sla_attributes;
+};
+
+struct readdirargs {
+ nfs_fh rda_fhandle;
+ nfscookie rda_cookie;
+ u_int rda_count;
+};
+
+struct entry {
+ u_int ne_fileid;
+ filename ne_name;
+ nfscookie ne_cookie;
+ nfsentry *ne_nextentry;
+};
+
+struct dirlist {
+ nfsentry *dl_entries;
+ bool_t dl_eof;
+};
+
+struct readdirres {
+ nfsstat rdr_status;
+ union {
+ nfsdirlist rdr_reply_u;
+ } rdr_u;
+};
+
+struct statfsokres {
+ u_int sfrok_tsize;
+ u_int sfrok_bsize;
+ u_int sfrok_blocks;
+ u_int sfrok_bfree;
+ u_int sfrok_bavail;
+};
+
+struct statfsres {
+ nfsstat sfr_status;
+ union {
+ nfsstatfsokres sfr_reply_u;
+ } sfr_u;
+};
+
+
+/*
+ * Partial definitions from rpcsvc/mount.h (can't use that header
+ * because it includes other "bad" stuff wrt xdr_groups.
+ */
+
+struct mountlist {
+ char *ml_name;
+ char *ml_path;
+ struct mountlist *ml_nxt;
+};
+
+struct fhstatus {
+ int fhs_status;
+ fhandle_t fhs_fh;
+};
+
+typedef char fhandle[FHSIZE];
+
+typedef struct {
+ u_int fhandle3_len;
+ char *fhandle3_val;
+} fhandle3;
+
+enum mountstat3 {
+ MNT_OK = 0,
+ MNT3ERR_PERM = 1,
+ MNT3ERR_NOENT = 2,
+ MNT3ERR_IO = 5,
+ MNT3ERR_ACCES = 13,
+ MNT3ERR_NOTDIR = 20,
+ MNT3ERR_INVAL = 22,
+ MNT3ERR_NAMETOOLONG = 63,
+ MNT3ERR_NOTSUPP = 10004,
+ MNT3ERR_SERVERFAULT = 10006
+};
+typedef enum mountstat3 mountstat3;
+
+struct mountres3_ok {
+ fhandle3 fhandle;
+ struct {
+ u_int auth_flavors_len;
+ int *auth_flavors_val;
+ } auth_flavors;
+};
+typedef struct mountres3_ok mountres3_ok;
+
+struct mountres3 {
+ mountstat3 fhs_status;
+ union {
+ mountres3_ok mountinfo;
+ } mountres3_u;
+};
+typedef struct mountres3 mountres3;
+
+/*
+ * List of exported directories
+ * An export entry with ex_groups
+ * NULL indicates an entry which is exported to the world.
+ */
+struct exports {
+ dev_t ex_dev; /* dev of directory */
+ char *ex_name; /* name of directory */
+ struct groups *ex_groups; /* groups allowed to mount this entry */
+ struct exports *ex_next;
+ short ex_rootmap; /* id to map root requests to */
+ short ex_flags; /* bits to mask off file mode */
+};
+
+struct groups {
+ char *g_name;
+ struct groups *g_next;
+};
+
+extern bool_t xdr_groups(XDR *, groups *);
+extern bool_t xdr_exports(XDR *, struct exports **);
+extern bool_t xdr_mountres3_ok(XDR *, mountres3_ok *);
+extern bool_t xdr_mountres3(XDR *, mountres3 *);
+extern bool_t xdr_fhstatus(XDR *, struct fhstatus *);
+extern bool_t xdr_mountlist(XDR *, struct mountlist **);
+
+#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_linux.h b/conf/nfs_prot/nfs_prot_linux.h
new file mode 100644
index 000000000000..7ccf18f00202
--- /dev/null
+++ b/conf/nfs_prot/nfs_prot_linux.h
@@ -0,0 +1,334 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/nfs_prot/nfs_prot_linux.h
+ *
+ */
+
+#ifndef _AMU_NFS_PROT_H
+#define _AMU_NFS_PROT_H
+
+#ifdef HAVE_RPCSVC_NFS_PROT_H
+# include <rpcsvc/nfs_prot.h>
+#endif /* HAVE_RPCSVC_NFS_PROT_H */
+
+/*
+ * Hard-code support for some file systems so the built amd
+ * binary can always run them. Also, this helps detection of iso9660
+ * file system for which the module isn't named as the file system mount
+ * name.
+ */
+#include <linux/version.h>
+#ifndef KERNEL_VERSION
+# define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
+#endif /* not KERNEL_VERSION */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
+# ifndef MS_BIND
+# define MS_BIND 4096
+# endif /* not MS_BIND */
+
+# ifndef MNTTYPE_LOFS
+# define MNTTYPE_LOFS "bind"
+# endif /* not MNTTYPE_LOFS */
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) */
+
+#ifndef MNTTYPE_ISO9660
+# define MNTTYPE_ISO9660 "iso9660"
+#endif /* not MNTTYPE_ISO9660 */
+
+#ifndef FHSIZE
+# define FHSIZE 32
+#endif /* not FHSIZE */
+#ifndef FHSIZE3
+# define FHSIZE3 64
+#endif /* not FHSIZE3 */
+
+#ifdef HAVE_FS_NFS3
+#ifndef MNTTYPE_NFS3
+# define MNTTYPE_NFS3 "nfs"
+#endif /* not MNTTYPE_NFS3 */
+#endif /* HAVE_FS_NFS3 */
+
+/*
+ * These two force/lazy unmount flags are sometimes missing from some linux
+ * systems' headers.
+ */
+#ifdef HAVE_UMOUNT2
+# ifndef MNT_FORCE
+# define MNT_FORCE 0x1 /* from <sys/mount.h> */
+# endif /* not MNT_FORCE */
+# ifndef MNT_DETACH
+# define MNT_DETACH 0x2 /* from kernel <linux/fs.h> */
+# endif /* not MNT_DETACH */
+#endif /* HAVE_UMOUNT2 */
+
+/* XXX: hack until we have a better way to detect /dev/loop devices */
+#ifdef HAVE_LINUX_LOOP_H
+# define HAVE_LOOP_DEVICE
+extern char *setup_loop_device(const char *file);
+extern int delete_loop_device(const char *device);
+#endif /* HAVE_LINUX_LOOP_H */
+
+
+/*
+ * MACROS:
+ */
+#define dr_drok_u diropres
+#define ca_attributes attributes
+#define ca_where where
+#define da_fhandle dir
+#define da_name name
+#define dl_entries entries
+#define dl_eof eof
+#define dr_status status
+#define dr_u diropres_u
+#define drok_attributes attributes
+#define drok_fhandle file
+#define fh_data data
+#define fhsize root.size
+#define la_fhandle from
+#define la_to to
+#define na_atime atime
+#define na_blocks blocks
+#define na_blocksize blocksize
+#define na_ctime ctime
+#define na_fileid fileid
+#define na_fsid fsid
+#define na_gid gid
+#define na_mode mode
+#define na_mtime mtime
+#define na_nlink nlink
+#define na_rdev rdev
+#define na_size size
+#define na_type type
+#define na_uid uid
+#define ne_cookie cookie
+#define ne_fileid fileid
+#define ne_name name
+#define ne_nextentry nextentry
+#define ns_attr_u attributes
+#define ns_status status
+#define ns_u attrstat_u
+#define nt_seconds seconds
+#define nt_useconds useconds
+#define ra_count count
+#define ra_fhandle file
+#define ra_offset offset
+#define ra_totalcount totalcount
+#define raok_attributes attributes
+#define raok_len_u data_len
+#define raok_u data
+#define raok_val_u data_val
+#define rda_cookie cookie
+#define rda_count count
+#define rda_fhandle dir
+#define rdr_reply_u reply
+#define rdr_status status
+#define rdr_u readdirres_u
+#define rlr_data_u data
+#define rlr_status status
+#define rlr_u readlinkres_u
+#define rna_from from
+#define rna_to to
+#define rr_reply_u reply
+#define rr_status status
+#define rr_u readres_u
+#define sa_atime atime
+#define sa_gid gid
+#define sa_mode mode
+#define sa_mtime mtime
+#define sa_size size
+#define sa_uid uid
+#define sag_attributes attributes
+#define sag_fhandle file
+#define sfr_reply_u reply
+#define sfr_status status
+#define sfr_u statfsres_u
+#define sfrok_bavail bavail
+#define sfrok_bfree bfree
+#define sfrok_blocks blocks
+#define sfrok_bsize bsize
+#define sfrok_tsize tsize
+#define sla_attributes attributes
+#define sla_from from
+#define sla_to to
+#define wra_beginoffset beginoffset
+#define wra_fhandle file
+#define wra_len_u data_len
+#define wra_offset offset
+#define wra_totalcount totalcount
+#define wra_u data
+#define wra_val_u data_val
+
+
+/*
+ * TYPEDEFS:
+ */
+typedef attrstat nfsattrstat;
+typedef createargs nfscreateargs;
+typedef dirlist nfsdirlist;
+typedef diropargs nfsdiropargs;
+typedef diropokres nfsdiropokres;
+typedef diropres nfsdiropres;
+typedef entry nfsentry;
+typedef fattr nfsfattr;
+typedef ftype nfsftype;
+typedef linkargs nfslinkargs;
+typedef readargs nfsreadargs;
+typedef readdirargs nfsreaddirargs;
+typedef readdirres nfsreaddirres;
+typedef readlinkres nfsreadlinkres;
+typedef readokres nfsreadokres;
+typedef readres nfsreadres;
+typedef renameargs nfsrenameargs;
+typedef sattr nfssattr;
+typedef sattrargs nfssattrargs;
+typedef statfsokres nfsstatfsokres;
+typedef statfsres nfsstatfsres;
+typedef symlinkargs nfssymlinkargs;
+typedef writeargs nfswriteargs;
+
+/* Autofs trick */
+typedef int autofs_args_t;
+
+/*
+ * We use our own definitions here, because the definitions in the
+ * kernel change the API (though not the ABI) *way* too often.
+ */
+#undef nfs_args_t
+struct nfs2_fh {
+ char data[FHSIZE];
+};
+
+struct nfs3_fh {
+ u_short size;
+ u_char data[FHSIZE3];
+};
+
+struct nfs_args {
+ int version; /* 1 */
+ int fd; /* 1 */
+ struct nfs2_fh old_root; /* 1 */
+ int flags; /* 1 */
+ int rsize; /* 1 */
+ int wsize; /* 1 */
+ int timeo; /* 1 */
+ int retrans; /* 1 */
+ int acregmin; /* 1 */
+ int acregmax; /* 1 */
+ int acdirmin; /* 1 */
+ int acdirmax; /* 1 */
+ struct sockaddr_in addr; /* 1 */
+ char hostname[256]; /* 1 */
+ int namlen; /* 2 */
+ unsigned int bsize; /* 3 */
+ struct nfs3_fh root; /* 4 */
+ int pseudoflavor; /* 5 */
+ char context[256 + 1];/* 6 */
+};
+typedef struct nfs_args nfs_args_t;
+
+#define NFS4_MOUNT_VERSION 1
+
+struct nfs_string {
+ unsigned int len;
+ char *data;
+};
+
+struct nfs4_args {
+ int version; /* 1 */
+ int flags; /* 1 */
+ int rsize; /* 1 */
+ int wsize; /* 1 */
+ int timeo; /* 1 */
+ int retrans; /* 1 */
+ int acregmin; /* 1 */
+ int acregmax; /* 1 */
+ int acdirmin; /* 1 */
+ int acdirmax; /* 1 */
+ struct nfs_string client_addr; /* 1 */
+ struct nfs_string mnt_path; /* 1 */
+ struct nfs_string hostname; /* 1 */
+ unsigned int host_addrlen; /* 1 */
+ struct sockaddr *host_addr; /* 1 */
+ int proto; /* 1 */
+ int auth_flavourlen;/* 1 */
+ int *auth_flavours; /* 1 */
+};
+
+typedef struct nfs4_args nfs4_args_t;
+
+/* HACK: these are not defined on Linux but we still need them
+ * internally. We have to be able to differentiate between having a
+ * timeout value set to zero and not having the option at all. These
+ * flags are masked off before passing the nfs_args structure to
+ * mount2() */
+
+#define MNT2_NFS_OPT_ACREGMIN 0x10000
+#define MNT2_NFS_OPT_ACREGMAX 0x20000
+#define MNT2_NFS_OPT_ACDIRMIN 0x40000
+#define MNT2_NFS_OPT_ACDIRMAX 0x80000
+#define MNT2_NFS_OPT_FLAGMASK 0xFFFF
+
+/*
+ * Missing definitions on redhat alpha linux
+ */
+#ifdef _SELECTBITS_H
+# ifndef __FD_ZERO
+/* This line MUST be split! Otherwise m4 will not change it. */
+# define __FD_ZERO(set) \
+ ((void) memset ((__ptr_t) (set), 0, sizeof(fd_set)))
+# endif /* not __FD_ZERO */
+# ifndef __FD_SET
+# define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d))
+# endif /* not __FD_SET */
+# ifndef __FD_CLR
+# define __FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d))
+# endif /* not __FD_CLR */
+# ifndef __FD_ISSET
+# define __FD_ISSET(d, set) ((set)->fds_bits[__FDELT(d)] & __FDMASK(d))
+# endif /* not __FD_ISSET */
+
+#endif /* _SELECTBITS_H */
+
+/* turn off this (b/c of hlfsd) */
+#undef HAVE_RPC_AUTH_DES_H
+
+extern int linux_version_code();
+/* use a private mapper from errno's to NFS errors */
+extern int linux_nfs_error(int e);
+#define nfs_error(e) linux_nfs_error(e)
+
+#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_ncr2.h b/conf/nfs_prot/nfs_prot_ncr2.h
new file mode 100644
index 000000000000..7e64f5c692de
--- /dev/null
+++ b/conf/nfs_prot/nfs_prot_ncr2.h
@@ -0,0 +1,476 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/nfs_prot/nfs_prot_ncr2.h
+ *
+ */
+
+#ifndef _AMU_NFS_PROT_H
+#define _AMU_NFS_PROT_H
+
+/*
+ * Do NOT include <rpcsvc/nfs_prot.h> to get NFS V2 specs, because
+ * it will result in conflicts with <nfs/nfs.h>. The latter is a must
+ * for NFS V3 specs.
+ */
+
+#ifdef HAVE_NFS_NFS_H
+# include <nfs/nfs.h>
+#endif /* HAVE_NFS_NFS_H */
+
+#ifdef HAVE_RPCSVC_MOUNT_H
+# include <rpcsvc/mount.h>
+#endif /* HAVE_RPCSVC_MOUNT_H */
+
+#ifdef HAVE_RPC_RPC_H
+# include <rpc/rpc.h>
+#endif /* HAVE_RPC_RPC_H */
+
+
+/*
+ * MACROS
+ */
+
+/* ncr2 does not define this one! Incredible */
+#ifndef MNTTYPE_NFS
+# define MNTTYPE_NFS "nfs"
+#endif /* MNTTYPE_NFS */
+
+#define NFS_PORT 2049
+#define NFS_MAXDATA 8192
+#define NFS_MAXPATHLEN 1024
+#define NFS_MAXNAMLEN 255
+#define NFS_FHSIZE 32
+#define NFS_COOKIESIZE 4
+
+#define NFSMODE_FMT 0170000
+#define NFSMODE_DIR 0040000
+#define NFSMODE_CHR 0020000
+#define NFSMODE_BLK 0060000
+#define NFSMODE_REG 0100000
+#define NFSMODE_LNK 0120000
+#define NFSMODE_SOCK 0140000
+#define NFSMODE_FIFO 0010000
+
+#define NFSPROC_NULL ((unsigned long)(0))
+#define NFSPROC_GETATTR ((unsigned long)(1))
+#define NFSPROC_SETATTR ((unsigned long)(2))
+#define NFSPROC_ROOT ((unsigned long)(3))
+#define NFSPROC_LOOKUP ((unsigned long)(4))
+#define NFSPROC_READLINK ((unsigned long)(5))
+#define NFSPROC_READ ((unsigned long)(6))
+#define NFSPROC_WRITECACHE ((unsigned long)(7))
+#define NFSPROC_WRITE ((unsigned long)(8))
+#define NFSPROC_CREATE ((unsigned long)(9))
+#define NFSPROC_REMOVE ((unsigned long)(10))
+#define NFSPROC_RENAME ((unsigned long)(11))
+#define NFSPROC_LINK ((unsigned long)(12))
+#define NFSPROC_SYMLINK ((unsigned long)(13))
+#define NFSPROC_MKDIR ((unsigned long)(14))
+#define NFSPROC_RMDIR ((unsigned long)(15))
+#define NFSPROC_READDIR ((unsigned long)(16))
+#define NFSPROC_STATFS ((unsigned long)(17))
+
+/* map field names */
+#define ml_hostname ml_name
+#define ml_directory ml_path
+#define ml_next ml_nxt
+#define gr_next g_next
+#define gr_name g_name
+#define ex_dir ex_name
+
+/*
+ * TYPEDEFS:
+ */
+typedef char *dirpath;
+typedef char *filename;
+typedef char *nfspath;
+typedef char nfscookie[NFS_COOKIESIZE];
+typedef enum nfsftype nfsftype;
+typedef enum nfsstat nfsstat;
+typedef struct attrstat nfsattrstat;
+typedef struct createargs nfscreateargs;
+typedef struct dirlist nfsdirlist;
+typedef struct diropargs nfsdiropargs;
+typedef struct diropokres nfsdiropokres;
+typedef struct diropres nfsdiropres;
+typedef struct entry nfsentry;
+typedef struct fattr nfsfattr;
+typedef struct linkargs nfslinkargs;
+typedef struct nfs_fh nfs_fh;
+typedef struct nfstime nfstime;
+typedef struct readargs nfsreadargs;
+typedef struct readdirargs nfsreaddirargs;
+typedef struct readdirres nfsreaddirres;
+typedef struct readlinkres nfsreadlinkres;
+typedef struct readokres nfsreadokres;
+typedef struct readres nfsreadres;
+typedef struct renameargs nfsrenameargs;
+typedef struct sattr nfssattr;
+typedef struct sattrargs nfssattrargs;
+typedef struct statfsokres nfsstatfsokres;
+typedef struct statfsres nfsstatfsres;
+typedef struct symlinkargs nfssymlinkargs;
+typedef struct writeargs nfswriteargs;
+
+typedef char *name;
+typedef fhandle_t fhandle;
+typedef struct exports *exports;
+typedef struct exports exportnode;
+typedef struct fhstatus fhstatus;
+typedef struct groups *groups;
+typedef struct groups groupnode;
+typedef struct mountlist *mountlist;
+typedef struct mountlist mountbody;
+
+
+/*
+ * EXTERNALS:
+ */
+
+extern bool_t xdr_nfsstat(XDR *, nfsstat *);
+extern bool_t xdr_ftype(XDR *, nfsftype *);
+extern bool_t xdr_nfs_fh(XDR *, nfs_fh *);
+extern bool_t xdr_nfstime(XDR *, nfstime *);
+extern bool_t xdr_fattr(XDR *, nfsfattr *);
+extern bool_t xdr_sattr(XDR *, nfssattr *);
+extern bool_t xdr_filename(XDR *, filename *);
+extern bool_t xdr_nfspath(XDR *, nfspath *);
+extern bool_t xdr_attrstat(XDR *, nfsattrstat *);
+extern bool_t xdr_sattrargs(XDR *, nfssattrargs *);
+extern bool_t xdr_diropargs(XDR *, nfsdiropargs *);
+extern bool_t xdr_diropokres(XDR *, nfsdiropokres *);
+extern bool_t xdr_diropres(XDR *, nfsdiropres *);
+extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres *);
+extern bool_t xdr_readargs(XDR *, nfsreadargs *);
+extern bool_t xdr_readokres(XDR *, nfsreadokres *);
+extern bool_t xdr_readres(XDR *, nfsreadres *);
+extern bool_t xdr_writeargs(XDR *, nfswriteargs *);
+extern bool_t xdr_createargs(XDR *, nfscreateargs *);
+extern bool_t xdr_renameargs(XDR *, nfsrenameargs *);
+extern bool_t xdr_linkargs(XDR *, nfslinkargs *);
+extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs *);
+extern bool_t xdr_nfscookie(XDR *, nfscookie);
+extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs *);
+extern bool_t xdr_entry(XDR *, nfsentry *);
+extern bool_t xdr_dirlist(XDR *, nfsdirlist *);
+extern bool_t xdr_readdirres(XDR *, nfsreaddirres *);
+extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres *);
+extern bool_t xdr_statfsres(XDR *, nfsstatfsres *);
+
+extern nfsattrstat *nfsproc_getattr_2(nfs_fh *, CLIENT *);
+extern nfsattrstat *nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *);
+extern nfsattrstat *nfsproc_setattr_2(nfssattrargs *, CLIENT *);
+extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *);
+extern nfsattrstat *nfsproc_write_2(nfswriteargs *, CLIENT *);
+extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_create_2(nfscreateargs *, CLIENT *);
+extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_lookup_2(nfsdiropargs *, CLIENT *);
+extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_mkdir_2(nfscreateargs *, CLIENT *);
+extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *);
+extern nfsstat *nfsproc_link_2(nfslinkargs *, CLIENT *);
+extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *);
+extern nfsstat *nfsproc_remove_2(nfsdiropargs *, CLIENT *);
+extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsstat *nfsproc_rename_2(nfsrenameargs *, CLIENT *);
+extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *);
+extern nfsstat *nfsproc_rmdir_2(nfsdiropargs *, CLIENT *);
+extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsstat *nfsproc_symlink_2(nfssymlinkargs *, CLIENT *);
+extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *);
+extern nfsreaddirres *nfsproc_readdir_2(nfsreaddirargs *, CLIENT *);
+extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *);
+extern nfsreadlinkres *nfsproc_readlink_2(nfs_fh *, CLIENT *);
+extern nfsreadlinkres *nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *);
+extern nfsreadres *nfsproc_read_2(nfsreadargs *, CLIENT *);
+extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *);
+extern nfsstatfsres *nfsproc_statfs_2(nfs_fh *, CLIENT *);
+extern nfsstatfsres *nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *);
+extern void *nfsproc_null_2(void *, CLIENT *);
+extern void *nfsproc_null_2_svc(void *, struct svc_req *);
+extern void *nfsproc_root_2(void *, CLIENT *);
+extern void *nfsproc_root_2_svc(void *, struct svc_req *);
+extern void *nfsproc_writecache_2(void *, CLIENT *);
+extern void *nfsproc_writecache_2_svc(void *, struct svc_req *);
+extern int nfs_program_2_freeresult(SVCXPRT *, xdrproc_t, caddr_t);
+
+
+/*
+ * ENUMS:
+ */
+
+
+/*
+ * STRUCTURES:
+ */
+/* ncr2 (sysv4) forgets to include this in <sys/resource.h> */
+struct rusage {
+ struct timeval ru_utime; /* user time used */
+ struct timeval ru_stime; /* system time used */
+ long ru_maxrss; /* XXX: 0 */
+ long ru_ixrss; /* XXX: 0 */
+ long ru_idrss; /* XXX: sum of rm_asrss */
+ long ru_isrss; /* XXX: 0 */
+ long ru_minflt; /* any page faults not requiring I/O */
+ long ru_majflt; /* any page faults requiring I/O */
+ long ru_nswap; /* swaps */
+ long ru_inblock; /* block input operations */
+ long ru_oublock; /* block output operations */
+ long ru_msgsnd; /* messages sent */
+ long ru_msgrcv; /* messages received */
+ long ru_nsignals; /* signals received */
+ long ru_nvcsw; /* voluntary context switches */
+ long ru_nivcsw; /* involuntary " */
+};
+
+/*
+ * ncr2 has ndbm functions, but no <ndbm.h>
+ * only a partial <rpcsvc/dbm.h>
+ */
+#define PBLKSIZ 1024
+#define DBLKSIZ 4096
+typedef struct {
+ int dbm_dirf; /* open directory file */
+ int dbm_pagf; /* open page file */
+ int dbm_flags; /* flags, see below */
+ long dbm_maxbno; /* last ``bit'' in dir file */
+ long dbm_bitno; /* current bit number */
+ long dbm_hmask; /* hash mask */
+ long dbm_blkptr; /* current block for dbm_nextkey */
+ int dbm_keyptr; /* current key for dbm_nextkey */
+ long dbm_blkno; /* current page to read/write */
+ long dbm_pagbno; /* current page in pagbuf */
+ char dbm_pagbuf[PBLKSIZ]; /* page file block buffer */
+ long dbm_dirbno; /* current block in dirbuf */
+ char dbm_dirbuf[DBLKSIZ]; /* directory file block buffer */
+} DBM;
+#define _DBM_RDONLY 0x1 /* data base open read-only */
+#define _DBM_IOERR 0x2 /* data base I/O error */
+#define dbm_rdonly(db) ((db)->dbm_flags & _DBM_RDONLY)
+#define dbm_error(db) ((db)->dbm_flags & _DBM_IOERR)
+ /* use this one at your own risk! */
+#define dbm_clearerr(db) ((db)->dbm_flags &= ~_DBM_IOERR)
+/* for fstat(2) */
+#define dbm_dirfno(db) ((db)->dbm_dirf)
+#define dbm_pagfno(db) ((db)->dbm_pagf)
+/*
+ * flags to dbm_store()
+ */
+#define DBM_INSERT 0
+#define DBM_REPLACE 1
+extern DBM *dbm_open(char *, int, int);
+extern void dbm_close(DBM *);
+#ifndef DATUM
+typedef struct {
+ char *dptr;
+ int dsize;
+} datum;
+# define DATUM
+#endif /* not DATUM */
+extern datum dbm_fetch(DBM *, datum);
+extern datum dbm_firstkey(DBM *);
+extern datum dbm_nextkey(DBM *);
+extern int dbm_delete(DBM *, datum);
+extern int dbm_store(DBM *, datum, datum, int);
+
+
+struct nfs_fh {
+ char fh_data[NFS_FHSIZE];
+};
+
+struct nfstime {
+ u_int nt_seconds;
+ u_int nt_useconds;
+};
+
+struct fattr {
+ nfsftype na_type;
+ u_int na_mode;
+ u_int na_nlink;
+ u_int na_uid;
+ u_int na_gid;
+ u_int na_size;
+ u_int na_blocksize;
+ u_int na_rdev;
+ u_int na_blocks;
+ u_int na_fsid;
+ u_int na_fileid;
+ nfstime na_atime;
+ nfstime na_mtime;
+ nfstime na_ctime;
+};
+
+struct sattr {
+ u_int sa_mode;
+ u_int sa_uid;
+ u_int sa_gid;
+ u_int sa_size;
+ nfstime sa_atime;
+ nfstime sa_mtime;
+};
+
+struct attrstat {
+ nfsstat ns_status;
+ union {
+ nfsfattr ns_attr_u;
+ } ns_u;
+};
+
+struct sattrargs {
+ nfs_fh sag_fhandle;
+ nfssattr sag_attributes;
+};
+
+struct diropargs {
+ nfs_fh da_fhandle; /* was dir */
+ filename da_name;
+};
+
+struct diropokres {
+ nfs_fh drok_fhandle;
+ nfsfattr drok_attributes;
+};
+
+struct diropres {
+ nfsstat dr_status; /* was status */
+ union {
+ nfsdiropokres dr_drok_u; /* was diropres */
+ } dr_u; /* was diropres_u */
+};
+
+struct readlinkres {
+ nfsstat rlr_status;
+ union {
+ nfspath rlr_data_u;
+ } rlr_u;
+};
+
+struct readargs {
+ nfs_fh ra_fhandle;
+ u_int ra_offset;
+ u_int ra_count;
+ u_int ra_totalcount;
+};
+
+struct readokres {
+ nfsfattr raok_attributes;
+ struct {
+ u_int raok_len_u;
+ char *raok_val_u;
+ } raok_u;
+};
+
+struct readres {
+ nfsstat rr_status;
+ union {
+ nfsreadokres rr_reply_u;
+ } rr_u;
+};
+
+struct writeargs {
+ nfs_fh wra_fhandle;
+ u_int wra_beginoffset;
+ u_int wra_offset;
+ u_int wra_totalcount;
+ struct {
+ u_int wra_len_u;
+ char *wra_val_u;
+ } wra_u;
+};
+
+struct createargs {
+ nfsdiropargs ca_where;
+ nfssattr ca_attributes;
+};
+
+struct renameargs {
+ nfsdiropargs rna_from;
+ nfsdiropargs rna_to;
+};
+
+struct linkargs {
+ nfs_fh la_fhandle;
+ nfsdiropargs la_to;
+};
+
+struct symlinkargs {
+ nfsdiropargs sla_from;
+ nfspath sla_to;
+ nfssattr sla_attributes;
+};
+
+struct readdirargs {
+ nfs_fh rda_fhandle;
+ nfscookie rda_cookie;
+ u_int rda_count;
+};
+
+struct entry {
+ u_int ne_fileid;
+ filename ne_name;
+ nfscookie ne_cookie;
+ nfsentry *ne_nextentry;
+};
+
+struct dirlist {
+ nfsentry *dl_entries;
+ bool_t dl_eof;
+};
+
+struct readdirres {
+ nfsstat rdr_status;
+ union {
+ nfsdirlist rdr_reply_u;
+ } rdr_u;
+};
+
+struct statfsokres {
+ u_int sfrok_tsize;
+ u_int sfrok_bsize;
+ u_int sfrok_blocks;
+ u_int sfrok_bfree;
+ u_int sfrok_bavail;
+};
+
+struct statfsres {
+ nfsstat sfr_status;
+ union {
+ nfsstatfsokres sfr_reply_u;
+ } sfr_u;
+};
+
+#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_netbsd.h b/conf/nfs_prot/nfs_prot_netbsd.h
new file mode 100644
index 000000000000..c134240a54d5
--- /dev/null
+++ b/conf/nfs_prot/nfs_prot_netbsd.h
@@ -0,0 +1,165 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/nfs_prot/nfs_prot_netbsd.h
+ *
+ */
+
+#ifndef _AMU_NFS_PROT_H
+#define _AMU_NFS_PROT_H
+
+#ifdef HAVE_RPCSVC_NFS_PROT_H
+# include <rpcsvc/nfs_prot.h>
+#endif /* HAVE_RPCSVC_NFS_PROT_H */
+#ifdef HAVE_NFS_RPCV2_H
+# include <nfs/rpcv2.h>
+#endif /* HAVE_NFS_RPCV2_H */
+
+#ifndef NFS_NPROCS
+# define NFS_NPROCS 26
+#endif /* not NFS_NPROCS */
+#ifdef HAVE_NFS_NFS_H
+# include <nfs/nfs.h>
+#endif /* HAVE_NFS_NFS_H */
+
+/* NON-NFS STUFF (doesn't really belong here) */
+#ifndef DEFINED_YPALL_CALLBACK_FXN_T
+# define DEFINED_YPALL_CALLBACK_FXN_T
+/* this is RIGHT for 1.2G and 1.2.1 */
+typedef int (*ypall_callback_fxn_t)(u_long, char *, int, char *, int, void *);
+#if 0
+/* this is right for 1.3beta */
+typedef int (*ypall_callback_fxn_t)(int, char *, int, char *, int, char *);
+#endif /* 0 */
+#endif /* DEFINED_YPALL_CALLBACK_FXN_T */
+
+
+/*
+ * MACROS:
+ */
+#define dr_drok_u diropres
+#define ca_where where
+#define da_fhandle dir
+#define da_name name
+#define dl_entries entries
+#define dl_eof eof
+#define dr_status status
+#define dr_u diropres_u
+#define drok_attributes attributes
+#define drok_fhandle file
+#define fh_data data
+#define la_fhandle from
+#define la_to to
+#define na_atime atime
+#define na_ctime ctime
+#define na_fileid fileid
+#define na_fsid fsid
+#define na_mode mode
+#define na_mtime mtime
+#define na_nlink nlink
+#define na_size size
+#define na_type type
+#define ne_cookie cookie
+#define ne_fileid fileid
+#define ne_name name
+#define ne_nextentry nextentry
+#define ns_attr_u attributes
+#define ns_status status
+#define ns_u attrstat_u
+#define nt_seconds seconds
+#define nt_useconds useconds
+#define rda_cookie cookie
+#define rda_count count
+#define rda_fhandle dir
+#define rdr_reply_u reply
+#define rdr_status status
+#define rdr_u readdirres_u
+#define rlr_data_u data
+#define rlr_status status
+#define rlr_u readlinkres_u
+#define rna_from from
+#define rna_to to
+#define rr_status status
+#define sag_fhandle file
+#define sfr_reply_u reply
+#define sfr_status status
+#define sfr_u statfsres_u
+#define sfrok_bavail bavail
+#define sfrok_bfree bfree
+#define sfrok_blocks blocks
+#define sfrok_bsize bsize
+#define sfrok_tsize tsize
+#define sla_from from
+#define wra_fhandle file
+
+
+/*
+ * TYPEDEFS:
+ */
+typedef attrstat nfsattrstat;
+typedef createargs nfscreateargs;
+typedef dirlist nfsdirlist;
+typedef diropargs nfsdiropargs;
+typedef diropres nfsdiropres;
+typedef entry nfsentry;
+typedef fattr nfsfattr;
+typedef ftype nfsftype;
+typedef linkargs nfslinkargs;
+typedef readargs nfsreadargs;
+typedef readdirargs nfsreaddirargs;
+typedef readdirres nfsreaddirres;
+typedef readlinkres nfsreadlinkres;
+typedef readres nfsreadres;
+typedef renameargs nfsrenameargs;
+typedef sattrargs nfssattrargs;
+typedef statfsokres nfsstatfsokres;
+typedef statfsres nfsstatfsres;
+typedef symlinkargs nfssymlinkargs;
+typedef writeargs nfswriteargs;
+
+
+/*
+ *
+ * NetBSD 1.2 has NFS V3, but it is undefined in the header files.
+ * so I define everything that's needed for NFS V3 here.
+ */
+#ifdef NFSMNT_NFSV3
+
+# define MOUNT_NFS3 MOUNT_NFS
+# define MNTOPT_NFS3 "nfs"
+
+#endif /* NFSMNT_NFSV3 */
+
+#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_netbsd1_3.h b/conf/nfs_prot/nfs_prot_netbsd1_3.h
new file mode 100644
index 000000000000..7fbd3a7a4fbd
--- /dev/null
+++ b/conf/nfs_prot/nfs_prot_netbsd1_3.h
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/nfs_prot/nfs_prot_netbsd1_3.h
+ *
+ */
+
+#ifndef _AMU_NFS_PROT_H
+#define _AMU_NFS_PROT_H
+
+#ifdef HAVE_RPCSVC_NFS_PROT_H
+# include <rpcsvc/nfs_prot.h>
+#endif /* HAVE_RPCSVC_NFS_PROT_H */
+
+/* NON-NFS STUFF (doesn't really belong here) */
+#ifndef DEFINED_YPALL_CALLBACK_FXN_T
+# define DEFINED_YPALL_CALLBACK_FXN_T
+#if 0
+/* this is RIGHT for 1.2G and 1.2.1 */
+typedef int (*ypall_callback_fxn_t)(u_long, char *, int, char *, int, void *);
+#endif /* 0 */
+/* this is right for 1.3beta and newer */
+typedef int (*ypall_callback_fxn_t)(int, char *, int, char *, int, char *);
+#endif /* DEFINED_YPALL_CALLBACK_FXN_T */
+
+
+/*
+ * MACROS:
+ */
+#define dr_drok_u diropres
+#define ca_where where
+#define da_fhandle dir
+#define da_name name
+#define dl_entries entries
+#define dl_eof eof
+#define dr_status status
+#define dr_u diropres_u
+#define drok_attributes attributes
+#define drok_fhandle file
+#define fh_data data
+#define la_fhandle from
+#define la_to to
+#define na_atime atime
+#define na_ctime ctime
+#define na_fileid fileid
+#define na_fsid fsid
+#define na_mode mode
+#define na_mtime mtime
+#define na_nlink nlink
+#define na_size size
+#define na_type type
+#define ne_cookie cookie
+#define ne_fileid fileid
+#define ne_name name
+#define ne_nextentry nextentry
+#define ns_attr_u attributes
+#define ns_status status
+#define ns_u attrstat_u
+#define nt_seconds seconds
+#define nt_useconds useconds
+#define rda_cookie cookie
+#define rda_count count
+#define rda_fhandle dir
+#define rdr_reply_u reply
+#define rdr_status status
+#define rdr_u readdirres_u
+#define rlr_data_u data
+#define rlr_status status
+#define rlr_u readlinkres_u
+#define rna_from from
+#define rna_to to
+#define rr_status status
+#define sag_fhandle file
+#define sfr_reply_u reply
+#define sfr_status status
+#define sfr_u statfsres_u
+#define sfrok_bavail bavail
+#define sfrok_bfree bfree
+#define sfrok_blocks blocks
+#define sfrok_bsize bsize
+#define sfrok_tsize tsize
+#define sla_from from
+#define wra_fhandle file
+
+
+/*
+ * TYPEDEFS:
+ */
+typedef attrstat nfsattrstat;
+typedef createargs nfscreateargs;
+typedef dirlist nfsdirlist;
+typedef diropargs nfsdiropargs;
+typedef diropres nfsdiropres;
+typedef entry nfsentry;
+typedef fattr nfsfattr;
+typedef ftype nfsftype;
+typedef linkargs nfslinkargs;
+typedef readargs nfsreadargs;
+typedef readdirargs nfsreaddirargs;
+typedef readdirres nfsreaddirres;
+typedef readlinkres nfsreadlinkres;
+typedef readres nfsreadres;
+typedef renameargs nfsrenameargs;
+typedef sattrargs nfssattrargs;
+typedef statfsokres nfsstatfsokres;
+typedef statfsres nfsstatfsres;
+typedef symlinkargs nfssymlinkargs;
+typedef writeargs nfswriteargs;
+
+/*
+ *
+ * NetBSD 1.2 has NFS V3, but it is undefined in the header files.
+ * so I define everything that's needed for NFS V3 here.
+ */
+#ifdef NFSMNT_NFSV3
+
+# define MOUNT_NFS3 MOUNT_NFS
+# define MNTOPT_NFS3 "nfs"
+
+#endif /* NFSMNT_NFSV3 */
+
+#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_netbsd1_4.h b/conf/nfs_prot/nfs_prot_netbsd1_4.h
new file mode 100644
index 000000000000..c52c75e2cf9b
--- /dev/null
+++ b/conf/nfs_prot/nfs_prot_netbsd1_4.h
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/nfs_prot/nfs_prot_netbsd1_4.h
+ *
+ */
+
+#ifndef _AMU_NFS_PROT_H
+#define _AMU_NFS_PROT_H
+
+#ifdef HAVE_RPCSVC_NFS_PROT_H
+# include <rpcsvc/nfs_prot.h>
+#endif /* HAVE_RPCSVC_NFS_PROT_H */
+#ifdef HAVE_NFS_RPCV2_H
+# include <nfs/rpcv2.h>
+#endif /* HAVE_NFS_RPCV2_H */
+#ifndef NFS_NPROCS
+# define NFS_NPROCS 26
+#endif /* not NFS_NPROCS */
+#ifdef HAVE_NFS_NFS_H
+# include <nfs/nfs.h>
+#endif /* HAVE_NFS_NFS_H */
+#ifdef HAVE_NFS_NFSMOUNT_H
+# include <nfs/nfsmount.h>
+#endif /* HAVE_NFS_NFSMOUNT_H */
+
+#ifdef HAVE_UFS_UFS_UFSMOUNT_H
+/* netbsd-1.4 does't protect <ufs/ufs/ufsmount.h> */
+# ifndef _UFS_UFS_UFSMOUNT_H
+# include <ufs/ufs/ufsmount.h>
+# define _UFS_UFS_UFSMOUNT_H
+# endif /* not _UFS_UFS_UFSMOUNT_H */
+#endif /* HAVE_UFS_UFS_UFSMOUNT_H */
+
+/* NON-NFS STUFF (doesn't really belong here) */
+#ifndef DEFINED_YPALL_CALLBACK_FXN_T
+# define DEFINED_YPALL_CALLBACK_FXN_T
+#if 0
+/* this is RIGHT for 1.2G and 1.2.1 */
+typedef int (*ypall_callback_fxn_t)(u_long, char *, int, char *, int, void *);
+#endif /* 0 */
+/* this is right for 1.3beta and newer */
+typedef int (*ypall_callback_fxn_t)(int, char *, int, char *, int, char *);
+#endif /* DEFINED_YPALL_CALLBACK_FXN_T */
+
+#ifdef HAVE_STATVFS
+# define statfs statvfs
+#endif /* HAVE_STATVFS */
+
+/*
+ * MACROS:
+ */
+#define dr_drok_u diropres
+#define ca_where where
+#define da_fhandle dir
+#define da_name name
+#define dl_entries entries
+#define dl_eof eof
+#define dr_status status
+#define dr_u diropres_u
+#define drok_attributes attributes
+#define drok_fhandle file
+#define fh_data data
+#define la_fhandle from
+#define la_to to
+#define na_atime atime
+#define na_ctime ctime
+#define na_fileid fileid
+#define na_fsid fsid
+#define na_gid gid
+#define na_mode mode
+#define na_mtime mtime
+#define na_nlink nlink
+#define na_rdev rdev
+#define na_size size
+#define na_uid uid
+#define na_type type
+#define ne_cookie cookie
+#define ne_fileid fileid
+#define ne_name name
+#define ne_nextentry nextentry
+#define ns_attr_u attributes
+#define ns_status status
+#define ns_u attrstat_u
+#define nt_seconds seconds
+#define nt_useconds useconds
+#define rda_cookie cookie
+#define rda_count count
+#define rda_fhandle dir
+#define rdr_reply_u reply
+#define rdr_status status
+#define rdr_u readdirres_u
+#define rlr_data_u data
+#define rlr_status status
+#define rlr_u readlinkres_u
+#define rna_from from
+#define rna_to to
+#define rr_status status
+#define sag_fhandle file
+#define sfr_reply_u reply
+#define sfr_status status
+#define sfr_u statfsres_u
+#define sfrok_bavail bavail
+#define sfrok_bfree bfree
+#define sfrok_blocks blocks
+#define sfrok_bsize bsize
+#define sfrok_tsize tsize
+#define sla_from from
+#define wra_fhandle file
+
+
+/*
+ * TYPEDEFS:
+ */
+typedef attrstat nfsattrstat;
+typedef createargs nfscreateargs;
+typedef dirlist nfsdirlist;
+typedef diropargs nfsdiropargs;
+typedef diropres nfsdiropres;
+typedef entry nfsentry;
+typedef fattr nfsfattr;
+typedef ftype nfsftype;
+typedef linkargs nfslinkargs;
+typedef readargs nfsreadargs;
+typedef readdirargs nfsreaddirargs;
+typedef readdirres nfsreaddirres;
+typedef readlinkres nfsreadlinkres;
+typedef readres nfsreadres;
+typedef renameargs nfsrenameargs;
+typedef sattrargs nfssattrargs;
+typedef statfsokres nfsstatfsokres;
+typedef statfsres nfsstatfsres;
+typedef symlinkargs nfssymlinkargs;
+typedef writeargs nfswriteargs;
+
+/*
+ *
+ * NetBSD 1.2 has NFS V3, but it is undefined in the header files.
+ * so I define everything that's needed for NFS V3 here.
+ */
+#ifdef NFSMNT_NFSV3
+
+# define MOUNT_NFS3 MOUNT_NFS
+# define MNTOPT_NFS3 "nfs"
+
+#endif /* NFSMNT_NFSV3 */
+
+#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_nextstep.h b/conf/nfs_prot/nfs_prot_nextstep.h
new file mode 100644
index 000000000000..fadc004cedf9
--- /dev/null
+++ b/conf/nfs_prot/nfs_prot_nextstep.h
@@ -0,0 +1,595 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/nfs_prot/nfs_prot_nextstep.h
+ *
+ */
+
+#ifndef _AMU_NFS_PROT_H
+#define _AMU_NFS_PROT_H
+
+#ifdef HAVE_RPCSVC_NFS_PROT_H
+# include <rpcsvc/nfs_prot.h>
+#endif /* HAVE_RPCSVC_NFS_PROT_H */
+#ifdef HAVE_BSD_RPC_RPC_H
+# include <bsd/rpc/rpc.h>
+#endif /* HAVE_BSD_RPC_RPC_H */
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif /* HAVE_SYS_STAT_H */
+
+/*
+ * odd problems happen during configuration and nextstep's /bin/cc
+ * gets strange errors from /bin/sh. I suspect it may be a conflict
+ * over some memory, a bad /bin/cc, or even kernel bug.
+ * this is what I get, as a result of running cc inside configure:
+ * /bin/cc -o conftest -g -O2 -D_POSIX_SOURCE conftest.c -lrpcsvc
+ * configure:2294: illegal external declaration, found `#'
+ * configure:2388: illegal file name 'AMU_NFS_PROTOCOL_HEADER'
+ * configure:2416: illegal external declaration, found `{'
+ * I have no explanation for it... -Erez
+ * Solution: don't use /bin/cc, but gcc 2.7.2.1 or better!
+ */
+
+#if 0
+/* cannot include this file b/c it refers to non-existing headers */
+# include <bsd/nfs/nfs_mount.h>
+#endif /* 0 */
+
+
+/*
+ * MACROS:
+ */
+
+/* ugly: fix up nextstep's nfs mount type */
+#ifdef MOUNT_TYPE_NFS___off_no_longer_needed
+# undef MOUNT_TYPE_UFS
+# define MOUNT_TYPE_UFS MOUNT_UFS
+# undef MOUNT_TYPE_NFS
+# define MOUNT_TYPE_NFS MOUNT_NFS
+# undef MOUNT_TYPE_PCFS
+# define MOUNT_TYPE_PCFS MOUNT_PC
+# undef MOUNT_TYPE_LOFS
+# define MOUNT_TYPE_LOFS MOUNT_LO
+# undef MOUNT_TYPE_SPECFS
+# define MOUNT_TYPE_SPECFS MOUNT_SPECFS
+# undef MOUNT_TYPE_CFS
+# define MOUNT_TYPE_CFS MOUNT_CFS
+#endif /* MOUNT_TYPE_NFS */
+
+#define dr_drok_u diropres
+#define ca_attributes attributes
+#define ca_where where
+#define da_fhandle dir
+#define da_name name
+#define dl_entries entries
+#define dl_eof eof
+#define dr_status status
+#define dr_u diropres_u
+#define drok_attributes attributes
+#define drok_fhandle file
+#define fh_data data
+#define la_fhandle from
+#define la_to to
+#define na_atime atime
+#define na_blocks blocks
+#define na_blocksize blocksize
+#define na_ctime ctime
+#define na_fileid fileid
+#define na_fsid fsid
+#define na_gid gid
+#define na_mode mode
+#define na_mtime mtime
+#define na_nlink nlink
+#define na_rdev rdev
+#define na_size size
+#define na_type type
+#define na_uid uid
+#define ne_cookie cookie
+#define ne_fileid fileid
+#define ne_name name
+#define ne_nextentry nextentry
+#define ns_attr_u attributes
+#define ns_status status
+#define ns_u attrstat_u
+#define nt_seconds seconds
+#define nt_useconds useconds
+#define ra_count count
+#define ra_fhandle file
+#define ra_offset offset
+#define ra_totalcount totalcount
+#define raok_attributes attributes
+#define raok_len_u data_len
+#define raok_u data
+#define raok_val_u data_val
+#define rda_cookie cookie
+#define rda_count count
+#define rda_fhandle dir
+#define rdr_reply_u reply
+#define rdr_status status
+#define rdr_u readdirres_u
+#define rlr_data_u data
+#define rlr_status status
+#define rlr_u readlinkres_u
+#define rna_from from
+#define rna_to to
+#define rr_reply_u reply
+#define rr_status status
+#define rr_u readres_u
+#define sa_atime atime
+#define sa_gid gid
+#define sa_mode mode
+#define sa_mtime mtime
+#define sa_size size
+#define sa_uid uid
+#define sag_attributes attributes
+#define sag_fhandle file
+#define sfr_reply_u reply
+#define sfr_status status
+#define sfr_u statfsres_u
+#define sfrok_bavail bavail
+#define sfrok_bfree bfree
+#define sfrok_blocks blocks
+#define sfrok_bsize bsize
+#define sfrok_tsize tsize
+#define sla_attributes attributes
+#define sla_from from
+#define sla_to to
+#define wra_beginoffset beginoffset
+#define wra_fhandle file
+#define wra_len_u data_len
+#define wra_offset offset
+#define wra_totalcount totalcount
+#define wra_u data
+#define wra_val_u data_val
+
+/* map field names */
+#define ex_dir ex_name
+#define gr_name g_name
+#define gr_next g_next
+#define ml_directory ml_path
+#define ml_hostname ml_name
+#define ml_next ml_nxt
+
+/*
+ * NFS mount option flags
+ */
+#define NFSMNT_SOFT 0x001 /* soft mount (hard is default) */
+#define NFSMNT_WSIZE 0x002 /* set write size */
+#define NFSMNT_RSIZE 0x004 /* set read size */
+#define NFSMNT_TIMEO 0x008 /* set initial timeout */
+#define NFSMNT_RETRANS 0x010 /* set number of request retries */
+#define NFSMNT_HOSTNAME 0x020 /* set hostname for error printf */
+#define NFSMNT_INT 0x040 /* allow interrupts on hard mount */
+#define NFSMNT_NOAC 0x080 /* don't cache attributes */
+#define NFSMNT_ACREGMIN 0x0100 /* set min secs for file attr cache */
+#define NFSMNT_ACREGMAX 0x0200 /* set max secs for file attr cache */
+#define NFSMNT_ACDIRMIN 0x0400 /* set min secs for dir attr cache */
+#define NFSMNT_ACDIRMAX 0x0800 /* set max secs for dir attr cache */
+#define NFSMNT_SECURE 0x1000 /* secure mount */
+#define NFSMNT_NOCTO 0x2000 /* no close-to-open consistency */
+
+#define NFS_PORT 2049
+#ifndef NFS_MAXDATA
+# define NFS_MAXDATA 8192
+#endif /* NFS_MAXDATA */
+#define NFS_MAXPATHLEN 1024
+#define NFS_MAXNAMLEN 255
+#define NFS_FHSIZE 32
+#define NFS_COOKIESIZE 4
+#define MNTPATHLEN 1024
+#define MNTNAMLEN 255
+
+#define NFSMODE_FMT 0170000
+#define NFSMODE_DIR 0040000
+#define NFSMODE_CHR 0020000
+#define NFSMODE_BLK 0060000
+#define NFSMODE_REG 0100000
+#define NFSMODE_LNK 0120000
+#define NFSMODE_SOCK 0140000
+#define NFSMODE_FIFO 0010000
+
+#ifndef NFS_PROGRAM
+# define NFS_PROGRAM ((u_long)100003)
+#endif /* not NFS_PROGRAM */
+#ifndef NFS_VERSION
+# define NFS_VERSION ((u_long)2)
+#endif /* not NFS_VERSION */
+
+#define NFSPROC_NULL ((u_long)0)
+#define NFSPROC_GETATTR ((u_long)1)
+#define NFSPROC_SETATTR ((u_long)2)
+#define NFSPROC_ROOT ((u_long)3)
+#define NFSPROC_LOOKUP ((u_long)4)
+#define NFSPROC_READLINK ((u_long)5)
+#define NFSPROC_READ ((u_long)6)
+#define NFSPROC_WRITECACHE ((u_long)7)
+#define NFSPROC_WRITE ((u_long)8)
+#define NFSPROC_CREATE ((u_long)9)
+#define NFSPROC_REMOVE ((u_long)10)
+#define NFSPROC_RENAME ((u_long)11)
+#define NFSPROC_LINK ((u_long)12)
+#define NFSPROC_SYMLINK ((u_long)13)
+#define NFSPROC_MKDIR ((u_long)14)
+#define NFSPROC_RMDIR ((u_long)15)
+#define NFSPROC_READDIR ((u_long)16)
+#define NFSPROC_STATFS ((u_long)17)
+
+/*
+ * fix up or complete other some definitions...
+ */
+#define WNOHANG 01
+#define WUNTRACED 02
+#define WIFSTOPPED(status) ((status) & 0100)
+#define WSTOPSIG(status) (int)(WIFSTOPPED(status) ? \
+ (((status) >> 8) & 0177) : -1)
+#define WIFSIGNALED(status) ( !WIFEXITED(status) && \
+ !WIFSTOPPED(status) )
+#define WTERMSIG(status) (int)(WIFSIGNALED(status) ? \
+ ((status) & 0177) : -1)
+/* define missing macros */
+#ifndef S_ISDIR
+# ifdef S_IFMT
+# define S_ISDIR(mode) (((mode) & (S_IFMT)) == (S_IFDIR))
+# else /* not S_IFMT */
+# define S_ISDIR(mode) (((mode) & (_S_IFMT)) == (_S_IFDIR))
+# endif /* not S_IFMT */
+#endif /* not S_ISDIR */
+
+/*
+ * ENUMS:
+ */
+
+enum nfstype {
+ NFNON = 0,
+ NFREG = 1,
+ NFDIR = 2,
+ NFBLK = 3,
+ NFCHR = 4,
+ NFLNK = 5,
+ NFSOCK = 6,
+ NFBAD = 7,
+ NFFIFO = 8,
+};
+
+enum nfsstat {
+ NFS_OK = 0, /* no error */
+ NFSERR_PERM=EPERM, /* Not owner */
+ NFSERR_NOENT=ENOENT, /* No such file or directory */
+ NFSERR_IO=EIO, /* I/O error */
+ NFSERR_NXIO=ENXIO, /* No such device or address */
+ NFSERR_ACCES=EACCES, /* Permission denied */
+ NFSERR_EXIST=EEXIST, /* File exists */
+ NFSERR_NODEV=ENODEV, /* No such device */
+ NFSERR_NOTDIR=ENOTDIR, /* Not a directory */
+ NFSERR_ISDIR=EISDIR, /* Is a directory */
+ NFSERR_FBIG=EFBIG, /* File too large */
+ NFSERR_NOSPC=ENOSPC, /* No space left on device */
+ NFSERR_ROFS=EROFS, /* Read-only file system */
+ NFSERR_NAMETOOLONG=ENAMETOOLONG,/* File name too long */
+ NFSERR_NOTEMPTY=ENOTEMPTY, /* Directory not empty */
+ NFSERR_DQUOT=EDQUOT, /* Disc quota exceeded */
+ NFSERR_STALE=ESTALE, /* Stale NFS file handle */
+ NFSERR_WFLUSH /* write cache flushed */
+};
+
+
+/*
+ * TYPEDEFS:
+ */
+typedef char *dirpath;
+typedef char *filename;
+typedef char *name;
+typedef char *nfspath;
+typedef char fhandle[NFS_FHSIZE];
+typedef char nfscookie[NFS_COOKIESIZE];
+typedef enum ftype ftype;
+typedef enum nfsstat nfsstat;
+typedef enum nfstype nfsftype;
+typedef fhandle fhandle_t;
+typedef struct attrstat nfsattrstat;
+typedef struct createargs nfscreateargs;
+typedef struct dirlist nfsdirlist;
+typedef struct diropargs nfsdiropargs;
+typedef struct diropokres nfsdiropokres;
+typedef struct diropres nfsdiropres;
+typedef struct entry nfsentry;
+typedef struct exports *exports;
+typedef struct exports exportnode;
+typedef struct fattr nfsfattr;
+typedef struct fhstatus fhstatus;
+typedef struct groups *groups;
+typedef struct groups groupnode;
+typedef struct linkargs nfslinkargs;
+typedef struct mountlist *mountlist;
+typedef struct mountlist mountbody;
+typedef struct nfs_fh nfs_fh;
+typedef struct nfstime nfstime;
+typedef struct readargs nfsreadargs;
+typedef struct readdirargs nfsreaddirargs;
+typedef struct readdirres nfsreaddirres;
+typedef struct readlinkres nfsreadlinkres;
+typedef struct readokres nfsreadokres;
+typedef struct readres nfsreadres;
+typedef struct renameargs nfsrenameargs;
+typedef struct sattr nfssattr;
+typedef struct sattrargs nfssattrargs;
+typedef struct statfsokres nfsstatfsokres;
+typedef struct statfsres nfsstatfsres;
+typedef struct symlinkargs nfssymlinkargs;
+typedef struct writeargs nfswriteargs;
+
+
+/*
+ * EXTERNALS:
+ */
+
+extern nfsattrstat *nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *);
+extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *);
+extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *);
+extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *);
+extern nfsreadlinkres *nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *);
+extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *);
+extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *);
+extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *);
+extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *);
+extern nfsstatfsres *nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *);
+extern void *nfsproc_null_2_svc(void *, struct svc_req *);
+extern void *nfsproc_root_2_svc(void *, struct svc_req *);
+extern void *nfsproc_writecache_2_svc(void *, struct svc_req *);
+
+extern bool_t xdr_attrstat(XDR *, nfsattrstat*);
+extern bool_t xdr_createargs(XDR *, nfscreateargs*);
+extern bool_t xdr_dirlist(XDR *, nfsdirlist*);
+extern bool_t xdr_diropargs(XDR *, nfsdiropargs*);
+extern bool_t xdr_diropokres(XDR *, nfsdiropokres*);
+extern bool_t xdr_diropres(XDR *, nfsdiropres*);
+extern bool_t xdr_entry(XDR *, nfsentry*);
+extern bool_t xdr_fattr(XDR *, nfsfattr*);
+extern bool_t xdr_filename(XDR *, filename*);
+extern bool_t xdr_ftype(XDR *, nfsftype*);
+extern bool_t xdr_linkargs(XDR *, nfslinkargs*);
+extern bool_t xdr_mountlist(XDR *xdrs, mountlist *objp);
+extern bool_t xdr_nfs_fh(XDR *, nfs_fh*);
+extern bool_t xdr_nfscookie(XDR *, nfscookie);
+extern bool_t xdr_nfspath(XDR *, nfspath*);
+extern bool_t xdr_nfsstat(XDR *, nfsstat*);
+extern bool_t xdr_nfstime(XDR *, nfstime*);
+extern bool_t xdr_readargs(XDR *, nfsreadargs*);
+extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*);
+extern bool_t xdr_readdirres(XDR *, nfsreaddirres*);
+extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*);
+extern bool_t xdr_readokres(XDR *, nfsreadokres*);
+extern bool_t xdr_readres(XDR *, nfsreadres*);
+extern bool_t xdr_renameargs(XDR *, nfsrenameargs*);
+extern bool_t xdr_sattr(XDR *, nfssattr*);
+extern bool_t xdr_sattrargs(XDR *, nfssattrargs*);
+extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*);
+extern bool_t xdr_statfsres(XDR *, nfsstatfsres*);
+extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*);
+extern bool_t xdr_writeargs(XDR *, nfswriteargs*);
+
+
+/*
+ * STRUCTURES:
+ */
+
+struct nfs_args {
+ struct sockaddr_in *addr; /* file server address */
+ caddr_t fh; /* File handle to be mounted */
+ int flags; /* flags */
+ int wsize; /* write size in bytes */
+ int rsize; /* read size in bytes */
+ int timeo; /* initial timeout in .1 secs */
+ int retrans; /* times to retry send */
+ char *hostname; /* server's hostname */
+ int acregmin; /* attr cache file min secs */
+ int acregmax; /* attr cache file max secs */
+ int acdirmin; /* attr cache dir min secs */
+ int acdirmax; /* attr cache dir max secs */
+ char *netname; /* server's netname */
+};
+
+struct nfs_fh {
+ char data[NFS_FHSIZE];
+};
+
+struct nfstime {
+ u_int nt_seconds;
+ u_int nt_useconds;
+};
+
+struct fattr {
+ nfsftype na_type;
+ u_int na_mode;
+ u_int na_nlink;
+ u_int na_uid;
+ u_int na_gid;
+ u_int na_size;
+ u_int na_blocksize;
+ u_int na_rdev;
+ u_int na_blocks;
+ u_int na_fsid;
+ u_int na_fileid;
+ nfstime na_atime;
+ nfstime na_mtime;
+ nfstime na_ctime;
+};
+
+struct sattr {
+ u_int sa_mode;
+ u_int sa_uid;
+ u_int sa_gid;
+ u_int sa_size;
+ nfstime sa_atime;
+ nfstime sa_mtime;
+};
+
+struct attrstat {
+ nfsstat ns_status;
+ union {
+ nfsfattr ns_attr_u;
+ } ns_u;
+};
+
+struct sattrargs {
+ nfs_fh sag_fhandle;
+ nfssattr sag_attributes;
+};
+
+struct diropargs {
+ nfs_fh da_fhandle; /* was dir */
+ filename da_name;
+};
+
+struct diropokres {
+ nfs_fh drok_fhandle;
+ nfsfattr drok_attributes;
+};
+
+struct diropres {
+ nfsstat dr_status; /* was status */
+ union {
+ nfsdiropokres dr_drok_u; /* was diropres */
+ } dr_u; /* was diropres_u */
+};
+
+struct readlinkres {
+ nfsstat rlr_status;
+ union {
+ nfspath rlr_data_u;
+ } rlr_u;
+};
+
+struct readargs {
+ nfs_fh ra_fhandle;
+ u_int ra_offset;
+ u_int ra_count;
+ u_int ra_totalcount;
+};
+
+struct readokres {
+ nfsfattr raok_attributes;
+ struct {
+ u_int raok_len_u;
+ char *raok_val_u;
+ } raok_u;
+};
+
+struct readres {
+ nfsstat rr_status;
+ union {
+ nfsreadokres rr_reply_u;
+ } rr_u;
+};
+
+struct writeargs {
+ nfs_fh wra_fhandle;
+ u_int wra_beginoffset;
+ u_int wra_offset;
+ u_int wra_totalcount;
+ struct {
+ u_int wra_len_u;
+ char *wra_val_u;
+ } wra_u;
+};
+
+struct createargs {
+ nfsdiropargs ca_where;
+ nfssattr ca_attributes;
+};
+
+struct renameargs {
+ nfsdiropargs rna_from;
+ nfsdiropargs rna_to;
+};
+
+struct linkargs {
+ nfs_fh la_fhandle;
+ nfsdiropargs la_to;
+};
+
+struct symlinkargs {
+ nfsdiropargs sla_from;
+ nfspath sla_to;
+ nfssattr sla_attributes;
+};
+
+struct readdirargs {
+ nfs_fh rda_fhandle;
+ nfscookie rda_cookie;
+ u_int rda_count;
+};
+
+struct entry {
+ u_int ne_fileid;
+ filename ne_name;
+ nfscookie ne_cookie;
+ nfsentry *ne_nextentry;
+};
+
+struct dirlist {
+ nfsentry *dl_entries;
+ bool_t dl_eof;
+};
+
+struct readdirres {
+ nfsstat rdr_status;
+ union {
+ nfsdirlist rdr_reply_u;
+ } rdr_u;
+};
+
+struct statfsokres {
+ u_int sfrok_tsize;
+ u_int sfrok_bsize;
+ u_int sfrok_blocks;
+ u_int sfrok_bfree;
+ u_int sfrok_bavail;
+};
+
+struct statfsres {
+ nfsstat sfr_status;
+ union {
+ nfsstatfsokres sfr_reply_u;
+ } sfr_u;
+};
+
+#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_openbsd.h b/conf/nfs_prot/nfs_prot_openbsd.h
new file mode 100644
index 000000000000..e46978451538
--- /dev/null
+++ b/conf/nfs_prot/nfs_prot_openbsd.h
@@ -0,0 +1,183 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/nfs_prot/nfs_prot_openbsd.h
+ *
+ */
+
+#ifndef _AMU_NFS_PROT_H
+#define _AMU_NFS_PROT_H
+
+#ifdef HAVE_RPCSVC_NFS_PROT_H
+# include <rpcsvc/nfs_prot.h>
+#endif /* HAVE_RPCSVC_NFS_PROT_H */
+#ifdef HAVE_NFS_RPCV2_H
+# include <nfs/rpcv2.h>
+#endif /* HAVE_NFS_RPCV2_H */
+
+#ifndef NFS_NPROCS
+# define NFS_NPROCS 26
+#endif /* not NFS_NPROCS */
+#ifdef HAVE_NFS_NFS_H
+# include <nfs/nfs.h>
+#endif /* HAVE_NFS_NFS_H */
+
+#ifdef HAVE_UFS_UFS_UFSMOUNT_H
+# ifdef HAVE_UFS_UFS_EXTATTR_H
+/*
+ * Need to define _KERNEL to include protected definition of struct
+ * ufs_extattr_per_mount, which is used in struct ufsmount in
+ * <ufs/ufs/ufsmount.h>, but is NOT protected by _KERNEL there.
+ */
+# define _KERNEL
+# include <ufs/ufs/extattr.h>
+# undef _KERNEL
+# endif /* HAVE_UFS_UFS_EXTATTR_H */
+# ifndef MAXQUOTAS
+# define MAXQUOTAS 2
+# endif /* not MAXQUOTAS */
+/*
+ * XXX: fake struct nextexport: trying to include proper headers here is too
+ * difficult: those headers drag many other headers, etc.
+ */
+struct netexport { int this_is_SO_wrong; };
+# include <ufs/ufs/ufsmount.h>
+#endif /* HAVE_UFS_UFS_UFSMOUNT_H */
+
+
+/*
+ * MACROS:
+ */
+#define dr_drok_u diropres
+#define ca_where where
+#define da_fhandle dir
+#define da_name name
+#define dl_entries entries
+#define dl_eof eof
+#define dr_status status
+#define dr_u diropres_u
+#define drok_attributes attributes
+#define drok_fhandle file
+#define fh_data data
+#define la_fhandle from
+#define la_to to
+#define na_atime atime
+#define na_ctime ctime
+#define na_fileid fileid
+#define na_fsid fsid
+#define na_mode mode
+#define na_mtime mtime
+#define na_nlink nlink
+#define na_size size
+#define na_type type
+#define na_uid uid
+#define na_gid gid
+#define ne_cookie cookie
+#define ne_fileid fileid
+#define ne_name name
+#define ne_nextentry nextentry
+#define ns_attr_u attributes
+#define ns_status status
+#define ns_u attrstat_u
+#define nt_seconds seconds
+#define nt_useconds useconds
+#define rda_cookie cookie
+#define rda_count count
+#define rda_fhandle dir
+#define rdr_reply_u reply
+#define rdr_status status
+#define rdr_u readdirres_u
+#define rlr_data_u data
+#define rlr_status status
+#define rlr_u readlinkres_u
+#define rna_from from
+#define rna_to to
+#define rr_status status
+#define sag_fhandle file
+#define sfr_reply_u reply
+#define sfr_status status
+#define sfr_u statfsres_u
+#define sfrok_bavail bavail
+#define sfrok_bfree bfree
+#define sfrok_blocks blocks
+#define sfrok_bsize bsize
+#define sfrok_tsize tsize
+#define sla_from from
+#define wra_fhandle file
+
+
+/*
+ * TYPEDEFS:
+ */
+typedef attrstat nfsattrstat;
+typedef createargs nfscreateargs;
+typedef dirlist nfsdirlist;
+typedef diropargs nfsdiropargs;
+typedef diropres nfsdiropres;
+typedef entry nfsentry;
+typedef fattr nfsfattr;
+typedef ftype nfsftype;
+typedef linkargs nfslinkargs;
+typedef readargs nfsreadargs;
+typedef readdirargs nfsreaddirargs;
+typedef readdirres nfsreaddirres;
+typedef readlinkres nfsreadlinkres;
+typedef readres nfsreadres;
+typedef renameargs nfsrenameargs;
+typedef sattrargs nfssattrargs;
+typedef statfsokres nfsstatfsokres;
+typedef statfsres nfsstatfsres;
+typedef symlinkargs nfssymlinkargs;
+typedef writeargs nfswriteargs;
+
+
+/*
+ * OpenBSD 2.2 has NFS V3, but it is undefined in the header files.
+ * so I define everything that's needed for NFS V3 here.
+ */
+#ifdef NFSMNT_NFSV3
+
+/*
+ * turn of this function so it cannot be used! OpenBSD seems to
+ * require that NFS sockets be connected.
+ * See m4/macros/check_nfs_socket_connection.m4.
+ */
+
+# define MOUNT_NFS3 MOUNT_NFS
+# define MNTOPT_NFS3 "nfs"
+
+#endif /* NFSMNT_NFSV3 */
+
+#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_osf2.h b/conf/nfs_prot/nfs_prot_osf2.h
new file mode 100644
index 000000000000..82f8f38f0e81
--- /dev/null
+++ b/conf/nfs_prot/nfs_prot_osf2.h
@@ -0,0 +1,307 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/nfs_prot/nfs_prot_osf2.h
+ *
+ */
+
+#ifndef _AMU_NFS_PROT_H
+#define _AMU_NFS_PROT_H
+
+#ifdef HAVE_SYS_ERRNO_H
+# include <sys/errno.h>
+#endif /* HAVE_SYS_ERRNO_H */
+#ifdef HAVE_NFS_NFS_H
+# include <nfs/nfs.h>
+#endif /* HAVE_NFS_NFS_H */
+#ifdef HAVE_RPC_RPC_H
+# include <rpc/rpc.h>
+#endif /* HAVE_RPC_RPC_H */
+
+/* avoid conflicts with Irix's EFS */
+#undef MOUNT_EFS /* DCE Episode FS */
+/* <sys/fs_types.h> includes a global symbol in every module! */
+#define _SYS_FS_TYPES_H_
+
+/*
+ * MACROS
+ */
+
+#define NFS_PORT 2049
+#define NFS_MAXDATA 8192
+#define NFS_MAXPATHLEN 1024
+#define NFS_MAXNAMLEN 255
+#define NFS_FHSIZE 32
+#define NFS_COOKIESIZE 4
+#define MNTPATHLEN 1024
+#define MNTNAMLEN 255
+
+#define NFSMODE_FMT 0170000
+#define NFSMODE_DIR 0040000
+#define NFSMODE_CHR 0020000
+#define NFSMODE_BLK 0060000
+#define NFSMODE_REG 0100000
+#define NFSMODE_LNK 0120000
+#define NFSMODE_SOCK 0140000
+#define NFSMODE_FIFO 0010000
+
+#ifndef NFS_PROGRAM
+# define NFS_PROGRAM ((u_long)100003)
+#endif /* not NFS_PROGRAM */
+#ifndef NFS_VERSION
+# define NFS_VERSION ((u_long)2)
+#endif /* not NFS_VERSION */
+
+#define NFSPROC_NULL ((u_long)0)
+#define NFSPROC_GETATTR ((u_long)1)
+#define NFSPROC_SETATTR ((u_long)2)
+#define NFSPROC_ROOT ((u_long)3)
+#define NFSPROC_LOOKUP ((u_long)4)
+#define NFSPROC_READLINK ((u_long)5)
+#define NFSPROC_READ ((u_long)6)
+#define NFSPROC_WRITECACHE ((u_long)7)
+#define NFSPROC_WRITE ((u_long)8)
+#define NFSPROC_CREATE ((u_long)9)
+#define NFSPROC_REMOVE ((u_long)10)
+#define NFSPROC_RENAME ((u_long)11)
+#define NFSPROC_LINK ((u_long)12)
+#define NFSPROC_SYMLINK ((u_long)13)
+#define NFSPROC_MKDIR ((u_long)14)
+#define NFSPROC_RMDIR ((u_long)15)
+#define NFSPROC_READDIR ((u_long)16)
+#define NFSPROC_STATFS ((u_long)17)
+
+/* map field names */
+#define fh_data fh_bytes
+
+#define ml_hostname ml_name
+#define ml_directory ml_path
+#define ml_next ml_nxt
+#define gr_next g_next
+#define gr_name g_name
+#define ex_dir ex_name
+
+#define drok_attributes drok_attr
+#define na_fileid na_nodeid
+#define la_fhandle la_from
+#define nt_seconds tv_sec
+#define nt_useconds tv_usec
+#define ra_totalcount ra_totcount
+#define sla_to sla_tnm
+#define sla_attributes sla_sa
+#define sag_fhandle saa_fh
+#define sag_attributes saa_sa
+#define sfrok_tsize fsok_tsize
+#define sfrok_bsize fsok_bsize
+#define sfrok_blocks fsok_blocks
+#define sfrok_bfree fsok_bfree
+#define sfrok_bavail fsok_bavail
+#define sfr_status fs_status
+#define sfr_u fs_u
+#define sfr_reply_u fs_fsok_u
+#define wra_fhandle wa_fhandle
+#define wra_beginoffset wa_begoff
+#define wra_offset wa_offset
+#define wra_totalcount wa_totcount
+#define wra_u wa_mbuf->m_hdr
+#define wra_val_u mh_data
+#define wra_len_u mh_len
+
+
+/*
+ * TYPEDEFS:
+ */
+typedef char *dirpath;
+typedef char *filename;
+typedef char *name;
+typedef char *nfspath;
+typedef char nfscookie[NFS_COOKIESIZE];
+typedef enum nfsftype nfsftype;
+typedef enum nfsstat nfsstat;
+typedef struct nfssvcfh fhandle;
+typedef struct nfsattrstat nfsattrstat;
+typedef struct nfscreateargs nfscreateargs;
+typedef struct nfsdirlist nfsdirlist;
+typedef struct nfsdiropargs nfsdiropargs;
+typedef struct nfsdrok nfsdiropokres;
+typedef struct nfsdiropres nfsdiropres;
+typedef struct nfsentry nfsentry;
+typedef struct exports *exports;
+typedef struct exports exportnode;
+typedef struct nfsfattr nfsfattr;
+typedef struct fhstatus fhstatus;
+typedef struct groups *groups;
+typedef struct groups groupnode;
+typedef struct nfslinkargs nfslinkargs;
+typedef struct mountlist *mountlist;
+typedef struct mountlist mountbody;
+typedef struct _nfs_fh _nfs_fh;
+typedef struct timeval nfstime;
+typedef struct nfsreadargs nfsreadargs;
+typedef struct nfsreaddirargs nfsreaddirargs;
+typedef struct nfsreaddirres nfsreaddirres;
+typedef struct nfsreadlinkres nfsreadlinkres;
+typedef struct nfsreadokres nfsreadokres;
+typedef struct nfsreadres nfsreadres;
+typedef struct nfsrenameargs nfsrenameargs;
+typedef struct nfssattr nfssattr;
+typedef struct nfssaargs nfssattrargs;
+typedef struct nfsstatfsok nfsstatfsokres;
+typedef struct nfsstatfs nfsstatfsres;
+typedef struct nfsslargs nfssymlinkargs;
+typedef struct nfswriteargs nfswriteargs;
+
+
+/*
+ * EXTERNALS:
+ */
+
+extern void *nfsproc_null_2_svc(void *, struct svc_req *);
+extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *);
+extern void *nfsproc_root_2_svc(void *, struct svc_req *);
+extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *);
+extern void *nfsproc_writecache_2_svc(void *, struct svc_req *);
+extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *);
+extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *);
+extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *);
+extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *);
+extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *);
+
+extern bool_t xdr_nfsstat(XDR *, nfsstat*);
+extern bool_t xdr_ftype(XDR *, nfsftype*);
+extern bool_t xdr_nfstime(XDR *, nfstime*);
+extern bool_t xdr_fattr(XDR *, nfsfattr*);
+extern bool_t xdr_sattr(XDR *, nfssattr*);
+extern bool_t xdr_filename(XDR *, filename*);
+extern bool_t xdr_nfspath(XDR *, nfspath*);
+extern bool_t xdr_attrstat(XDR *, nfsattrstat*);
+extern bool_t xdr_sattrargs(XDR *, nfssattrargs*);
+extern bool_t xdr_diropargs(XDR *, nfsdiropargs*);
+extern bool_t xdr_diropokres(XDR *, nfsdiropokres*);
+extern bool_t xdr_diropres(XDR *, nfsdiropres*);
+extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*);
+extern bool_t xdr_readargs(XDR *, nfsreadargs*);
+extern bool_t xdr_readokres(XDR *, nfsreadokres*);
+extern bool_t xdr_readres(XDR *, nfsreadres*);
+extern bool_t xdr_writeargs(XDR *, nfswriteargs*);
+extern bool_t xdr_createargs(XDR *, nfscreateargs*);
+extern bool_t xdr_renameargs(XDR *, nfsrenameargs*);
+extern bool_t xdr_linkargs(XDR *, nfslinkargs*);
+extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*);
+extern bool_t xdr_nfscookie(XDR *, nfscookie);
+extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*);
+extern bool_t xdr_entry(XDR *, nfsentry*);
+extern bool_t xdr_dirlist(XDR *, nfsdirlist*);
+extern bool_t xdr_readdirres(XDR *, nfsreaddirres*);
+extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*);
+extern bool_t xdr_statfsres(XDR *, nfsstatfsres*);
+
+
+/*
+ * STRUCTURES:
+ */
+
+struct _nfs_fh {
+ char data[NFS_FHSIZE];
+};
+
+struct nfstime {
+ u_int nt_seconds;
+ u_int nt_useconds;
+};
+
+struct nfsreadlinkres {
+ nfsstat rlr_status;
+ union {
+ nfspath rlr_data_u;
+ } rlr_u;
+};
+
+struct nfsreadokres {
+ nfsfattr raok_attributes;
+ struct {
+ u_int raok_len_u;
+ char *raok_val_u;
+ } raok_u;
+};
+
+struct nfsreadres {
+ nfsstat rr_status;
+ union {
+ nfsreadokres rr_reply_u;
+ } rr_u;
+};
+
+struct nfscreateargs {
+ nfsdiropargs ca_where;
+ nfssattr ca_attributes;
+};
+
+struct nfsrenameargs {
+ nfsdiropargs rna_from;
+ nfsdiropargs rna_to;
+};
+
+struct nfsreaddirargs {
+ nfsv2fh_t rda_fhandle;
+ nfscookie rda_cookie;
+ u_int rda_count;
+};
+
+struct nfsentry {
+ u_int ne_fileid;
+ filename ne_name;
+ nfscookie ne_cookie;
+ nfsentry *ne_nextentry;
+};
+
+struct nfsdirlist {
+ nfsentry *dl_entries;
+ bool_t dl_eof;
+};
+
+struct nfsreaddirres {
+ nfsstat rdr_status;
+ union {
+ nfsdirlist rdr_reply_u;
+ } rdr_u;
+};
+
+#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_osf4.h b/conf/nfs_prot/nfs_prot_osf4.h
new file mode 100644
index 000000000000..db74b4aa009d
--- /dev/null
+++ b/conf/nfs_prot/nfs_prot_osf4.h
@@ -0,0 +1,417 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/nfs_prot/nfs_prot_osf4.h
+ *
+ */
+
+#ifndef _AMU_NFS_PROT_H
+#define _AMU_NFS_PROT_H
+
+#ifdef HAVE_RPCSVC_NFS_PROT_H
+# include <rpcsvc/nfs_prot.h>
+#endif /* HAVE_RPCSVC_NFS_PROT_H */
+#ifdef HAVE_NFS_NFS_H
+# include <nfs/nfs.h>
+#endif /* HAVE_NFS_NFS_H */
+#ifdef HAVE_RPCSVC_MOUNTV3_H
+# include <rpcsvc/mountv3.h>
+#endif /* HAVE_RPCSVC_MOUNTV3_H */
+#ifdef HAVE_RPC_RPC_H
+# include <rpc/rpc.h>
+#endif /* HAVE_RPC_RPC_H */
+
+/* avoid conflicts with Irix's EFS */
+#undef MOUNT_EFS /* DCE Episode FS */
+
+/*
+ * MACROS
+ */
+
+#define NFS_PORT 2049
+#define NFS_MAXDATA 8192
+#define NFS_MAXPATHLEN 1024
+#define NFS_MAXNAMLEN 255
+#define NFS_FHSIZE 32
+#define NFS_COOKIESIZE 4
+#define MNTPATHLEN 1024
+#define MNTNAMLEN 255
+
+#define NFSMODE_FMT 0170000
+#define NFSMODE_DIR 0040000
+#define NFSMODE_CHR 0020000
+#define NFSMODE_BLK 0060000
+#define NFSMODE_REG 0100000
+#define NFSMODE_LNK 0120000
+#define NFSMODE_SOCK 0140000
+#define NFSMODE_FIFO 0010000
+
+#ifndef NFS_PROGRAM
+# define NFS_PROGRAM ((u_long)100003)
+#endif /* not NFS_PROGRAM */
+#ifndef NFS_VERSION
+# define NFS_VERSION ((u_long)2)
+#endif /* not NFS_VERSION */
+
+#define NFSPROC_NULL ((u_long)0)
+#define NFSPROC_GETATTR ((u_long)1)
+#define NFSPROC_SETATTR ((u_long)2)
+#define NFSPROC_ROOT ((u_long)3)
+#define NFSPROC_LOOKUP ((u_long)4)
+#define NFSPROC_READLINK ((u_long)5)
+#define NFSPROC_READ ((u_long)6)
+#define NFSPROC_WRITECACHE ((u_long)7)
+#define NFSPROC_WRITE ((u_long)8)
+#define NFSPROC_CREATE ((u_long)9)
+#define NFSPROC_REMOVE ((u_long)10)
+#define NFSPROC_RENAME ((u_long)11)
+#define NFSPROC_LINK ((u_long)12)
+#define NFSPROC_SYMLINK ((u_long)13)
+#define NFSPROC_MKDIR ((u_long)14)
+#define NFSPROC_RMDIR ((u_long)15)
+#define NFSPROC_READDIR ((u_long)16)
+#define NFSPROC_STATFS ((u_long)17)
+
+/* map field names */
+#define ml_hostname ml_name
+#define ml_directory ml_path
+#define ml_next ml_nxt
+#define gr_next g_next
+#define gr_name g_name
+#define ex_dir ex_name
+
+#define drok_attributes drok_attr
+#define na_fileid na_nodeid
+#define la_fhandle la_from
+#define nt_seconds tv_sec
+#define nt_useconds tv_usec
+#define ra_totalcount ra_totcount
+#define sla_to sla_tnm
+#define sla_attributes sla_sa
+#define sag_fhandle saa_fh
+#define sag_attributes saa_sa
+#define sfrok_tsize fsok_tsize
+#define sfrok_bsize fsok_bsize
+#define sfrok_blocks fsok_blocks
+#define sfrok_bfree fsok_bfree
+#define sfrok_bavail fsok_bavail
+#define sfr_status fs_status
+#define sfr_u fs_u
+#define sfr_reply_u fs_fsok_u
+#define wra_fhandle wa_fhandle
+#define wra_beginoffset wa_begoff
+#define wra_offset wa_offset
+#define wra_totalcount wa_totcount
+#define wra_u wa_mbuf->m_hdr
+#define wra_val_u mh_data
+#define wra_len_u mh_len
+
+
+/*
+ * TYPEDEFS:
+ */
+typedef char *dirpath;
+typedef char *filename;
+typedef char *name;
+typedef char *nfspath;
+typedef char nfscookie[NFS_COOKIESIZE];
+typedef enum nfsftype nfsftype;
+typedef enum nfsstat nfsstat;
+typedef struct nfssvcfh fhandle;
+typedef struct nfsattrstat nfsattrstat;
+typedef struct nfscreateargs nfscreateargs;
+typedef struct nfsdirlist nfsdirlist;
+typedef struct nfsdiropargs nfsdiropargs;
+typedef struct nfsdrok nfsdiropokres;
+typedef struct nfsdiropres nfsdiropres;
+typedef struct nfsentry nfsentry;
+typedef struct exports *exports;
+typedef struct exports exportnode;
+typedef struct nfsfattr nfsfattr;
+typedef struct fhstatus fhstatus;
+typedef struct groups *groups;
+typedef struct groups groupnode;
+typedef struct nfslinkargs nfslinkargs;
+typedef struct mountlist *mountlist;
+typedef struct mountlist mountbody;
+typedef struct _nfs_fh _nfs_fh;
+typedef struct timeval nfstime;
+typedef struct nfsreadargs nfsreadargs;
+typedef struct nfsreaddirargs nfsreaddirargs;
+typedef struct nfsreaddirres nfsreaddirres;
+typedef struct nfsreadlinkres nfsreadlinkres;
+typedef struct nfsreadokres nfsreadokres;
+typedef struct nfsreadres nfsreadres;
+typedef struct nfsrenameargs nfsrenameargs;
+typedef struct nfssattr nfssattr;
+typedef struct nfssaargs nfssattrargs;
+typedef struct nfsstatfsok nfsstatfsokres;
+typedef struct nfsstatfs nfsstatfsres;
+typedef struct nfsslargs nfssymlinkargs;
+typedef struct nfswriteargs nfswriteargs;
+
+
+/*
+ * EXTERNALS: (some are missing from system headers)
+ */
+
+extern void *nfsproc_null_2_svc(void *, struct svc_req *);
+extern nfsattrstat *nfsproc_getattr_2_svc(struct nfssvcfh *, struct svc_req *);
+extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *);
+extern void *nfsproc_root_2_svc(void *, struct svc_req *);
+extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsreadlinkres *nfsproc_readlink_2_svc(struct nfssvcfh *, struct svc_req *);
+extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *);
+extern void *nfsproc_writecache_2_svc(void *, struct svc_req *);
+extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *);
+extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *);
+extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *);
+extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *);
+extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *);
+extern nfsstatfsres *nfsproc_statfs_2_svc(struct nfssvcfh *, struct svc_req *);
+extern int plock(int op);
+extern const char *hstrerror(int err);
+extern int getmntinfo(struct statfs **mntbufp, int flags);
+
+extern bool_t xdr_nfsstat(XDR *, nfsstat*);
+extern bool_t xdr_ftype(XDR *, nfsftype*);
+extern bool_t xdr_nfs_fh(XDR *, struct nfssvcfh*);
+extern bool_t xdr_nfstime(XDR *, nfstime*);
+extern bool_t xdr_fattr(XDR *, nfsfattr*);
+extern bool_t xdr_sattr(XDR *, nfssattr*);
+extern bool_t xdr_filename(XDR *, filename*);
+extern bool_t xdr_nfspath(XDR *, nfspath*);
+extern bool_t xdr_attrstat(XDR *, nfsattrstat*);
+extern bool_t xdr_sattrargs(XDR *, nfssattrargs*);
+extern bool_t xdr_diropargs(XDR *, nfsdiropargs*);
+extern bool_t xdr_diropokres(XDR *, nfsdiropokres*);
+extern bool_t xdr_diropres(XDR *, nfsdiropres*);
+extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*);
+extern bool_t xdr_readargs(XDR *, nfsreadargs*);
+extern bool_t xdr_readokres(XDR *, nfsreadokres*);
+extern bool_t xdr_readres(XDR *, nfsreadres*);
+extern bool_t xdr_writeargs(XDR *, nfswriteargs*);
+extern bool_t xdr_createargs(XDR *, nfscreateargs*);
+extern bool_t xdr_renameargs(XDR *, nfsrenameargs*);
+extern bool_t xdr_linkargs(XDR *, nfslinkargs*);
+extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*);
+extern bool_t xdr_nfscookie(XDR *, nfscookie);
+extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*);
+extern bool_t xdr_entry(XDR *, nfsentry*);
+extern bool_t xdr_dirlist(XDR *, nfsdirlist*);
+extern bool_t xdr_readdirres(XDR *, nfsreaddirres*);
+extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*);
+extern bool_t xdr_statfsres(XDR *, nfsstatfsres*);
+extern bool_t xdr_exportnode (XDR *, exportnode*);
+extern bool_t xdr_groups (XDR *, groups*);
+
+
+
+/*
+ * STRUCTURES:
+ */
+
+struct _nfs_fh {
+ char data[NFS_FHSIZE];
+};
+
+struct nfstime {
+ u_int nt_seconds;
+ u_int nt_useconds;
+};
+
+struct _fattr {
+ nfsftype na_type;
+ u_int na_mode;
+ u_int na_nlink;
+ u_int na_uid;
+ u_int na_gid;
+ u_int na_size;
+ u_int na_blocksize;
+ u_int na_rdev;
+ u_int na_blocks;
+ u_int na_fsid;
+ u_int na_fileid;
+ nfstime na_atime;
+ nfstime na_mtime;
+ nfstime na_ctime;
+};
+
+struct _sattr {
+ u_int sa_mode;
+ u_int sa_uid;
+ u_int sa_gid;
+ u_int sa_size;
+ nfstime sa_atime;
+ nfstime sa_mtime;
+};
+
+struct _attrstat {
+ nfsstat ns_status;
+ union {
+ nfsfattr ns_attr_u;
+ } ns_u;
+};
+
+struct _sattrargs {
+ struct nfssvcfh sag_fhandle;
+ nfssattr sag_attributes;
+};
+
+struct _diropargs {
+ struct nfssvcfh da_fhandle; /* was dir */
+ filename da_name;
+};
+
+struct _diropokres {
+ struct nfssvcfh drok_fhandle;
+ nfsfattr drok_attributes;
+};
+
+struct _diropres {
+ nfsstat dr_status; /* was status */
+ union {
+ nfsdiropokres dr_drok_u; /* was diropres */
+ } dr_u; /* was diropres_u */
+};
+
+struct nfsreadlinkres {
+ nfsstat rlr_status;
+ union {
+ nfspath rlr_data_u;
+ } rlr_u;
+};
+
+struct _readargs {
+ struct nfssvcfh ra_fhandle;
+ u_int ra_offset;
+ u_int ra_count;
+ u_int ra_totalcount;
+};
+
+struct nfsreadokres {
+ nfsfattr raok_attributes;
+ struct {
+ u_int raok_len_u;
+ char *raok_val_u;
+ } raok_u;
+};
+
+struct nfsreadres {
+ nfsstat rr_status;
+ union {
+ nfsreadokres rr_reply_u;
+ } rr_u;
+};
+
+#if 0
+struct _writeargs {
+ struct nfssvcfh wra_fhandle;
+ u_int wra_beginoffset;
+ u_int wra_offset;
+ u_int wra_totalcount;
+ struct {
+ u_int wra_len_u;
+ char *wra_val_u;
+ } wra_u;
+};
+#endif /* 0 */
+
+struct nfscreateargs {
+ nfsdiropargs ca_where;
+ nfssattr ca_attributes;
+};
+
+struct nfsrenameargs {
+ nfsdiropargs rna_from;
+ nfsdiropargs rna_to;
+};
+
+struct _linkargs {
+ struct nfssvcfh la_fhandle;
+ nfsdiropargs la_to;
+};
+
+struct _symlinkargs {
+ nfsdiropargs sla_from;
+ nfspath sla_to;
+ nfssattr sla_attributes;
+};
+
+struct nfsreaddirargs {
+ struct nfssvcfh rda_fhandle;
+ nfscookie rda_cookie;
+ u_int rda_count;
+};
+
+struct nfsentry {
+ u_int ne_fileid;
+ filename ne_name;
+ nfscookie ne_cookie;
+ nfsentry *ne_nextentry;
+};
+
+struct nfsdirlist {
+ nfsentry *dl_entries;
+ bool_t dl_eof;
+};
+
+struct nfsreaddirres {
+ nfsstat rdr_status;
+ union {
+ nfsdirlist rdr_reply_u;
+ } rdr_u;
+};
+
+struct _statfsokres {
+ u_int sfrok_tsize;
+ u_int sfrok_bsize;
+ u_int sfrok_blocks;
+ u_int sfrok_bfree;
+ u_int sfrok_bavail;
+};
+
+struct _statfsres {
+ nfsstat sfr_status;
+ union {
+ nfsstatfsokres sfr_reply_u;
+ } sfr_u;
+};
+
+#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_osf5.h b/conf/nfs_prot/nfs_prot_osf5.h
index 655e98d03902..f091a7a2d61c 100644
--- a/conf/nfs_prot/nfs_prot_osf5.h
+++ b/conf/nfs_prot/nfs_prot_osf5.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2003 Erez Zadok
+ * Copyright (c) 1997-2014 Erez Zadok
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
@@ -16,11 +16,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgment:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -36,9 +32,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * %W% (Berkeley) %G%
*
- * $Id: nfs_prot_osf5.h,v 1.1.2.4 2002/12/27 22:44:57 ezk Exp $
+ * File: am-utils/conf/nfs_prot/nfs_prot_osf5.h
*
*/
@@ -365,7 +360,7 @@ struct _writeargs {
char *wra_val_u;
} wra_u;
};
-#endif
+#endif /* 0 */
struct nfscreateargs {
nfsdiropargs ca_where;
@@ -428,4 +423,20 @@ struct _statfsres {
} sfr_u;
};
+/*
+ **************************************************************************
+ * Tru64 5.1's autofs is not ported or tested yet...
+ * For now, undefine it or define dummy entries.
+ **************************************************************************
+ */
+#ifdef MNTTYPE_AUTOFS
+# undef MNTTYPE_AUTOFS
+#endif /* MNTTYPE_AUTOFS */
+#ifdef MNTTAB_TYPE_AUTOFS
+# undef MNTTAB_TYPE_AUTOFS
+#endif /* MNTTAB_TYPE_AUTOFS */
+#ifdef HAVE_FS_AUTOFS
+# undef HAVE_FS_AUTOFS
+#endif /* HAVE_FS_AUTOFS */
+
#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_sunos3.h b/conf/nfs_prot/nfs_prot_sunos3.h
new file mode 100644
index 000000000000..557a2ccbbd75
--- /dev/null
+++ b/conf/nfs_prot/nfs_prot_sunos3.h
@@ -0,0 +1,401 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/nfs_prot/nfs_prot_sunos3.h
+ *
+ */
+
+#ifndef _AMU_NFS_PROT_H
+#define _AMU_NFS_PROT_H
+
+#ifdef HAVE_SYS_ERRNO_H
+#include <sys/errno.h>
+#endif /* HAVE_SYS_ERRNO_H */
+#ifdef HAVE_RPC_RPC_H
+#include <rpc/rpc.h>
+#endif /* HAVE_RPC_RPC_H */
+#ifdef HAVE_NFS_NFSV2_H
+# include <nfs/nfsv2.h>
+#endif /* HAVE_NFS_NFSV2_H */
+#ifdef HAVE_NFS_RPCV2_H
+# include <nfs/rpcv2.h>
+#endif /* HAVE_NFS_RPCV2_H */
+#ifdef HAVE_NFS_NFS_H
+# include <nfs/nfs.h>
+#endif /* HAVE_NFS_NFS_H */
+# ifdef HAVE_NFS_NFS_CLNT_H
+# include <nfs/nfs_clnt.h>
+# endif /* HAVE_NFS_NFS_CLNT_H */
+#ifdef HAVE_SYS_FS_NFS_H
+# include <sys/fs/nfs.h>
+#endif /* HAVE_SYS_FS_NFS_H */
+#ifdef HAVE_RPCSVC_MOUNT_H
+# include <rpcsvc/mount.h>
+#endif /* HAVE_RPCSVC_MOUNT_H */
+
+
+/*
+ * MACROS
+ */
+
+#define NFS_PORT 2049
+#define NFS_MAXDATA 8192
+#define NFS_MAXPATHLEN 1024
+#define NFS_MAXNAMLEN 255
+#define NFS_FHSIZE 32
+#define NFS_COOKIESIZE 4
+#define MNTPATHLEN 1024
+#define MNTNAMLEN 255
+
+#define NFSMODE_FMT 0170000
+#define NFSMODE_DIR 0040000
+#define NFSMODE_CHR 0020000
+#define NFSMODE_BLK 0060000
+#define NFSMODE_REG 0100000
+#define NFSMODE_LNK 0120000
+#define NFSMODE_SOCK 0140000
+#define NFSMODE_FIFO 0010000
+
+#ifndef NFS_PROGRAM
+# define NFS_PROGRAM ((u_long)100003)
+#endif /* not NFS_PROGRAM */
+#ifndef NFS_VERSION
+# define NFS_VERSION ((u_long)2)
+#endif /* not NFS_VERSION */
+
+/* complete missing definition that is actually used in SunOS 3.x */
+#ifndef MNTOPT_DEV
+# define MNTOPT_DEV "dev"
+#endif /* not MNTOPT_DEV */
+
+#define NFSPROC_NULL ((u_long)0)
+#define NFSPROC_GETATTR ((u_long)1)
+#define NFSPROC_SETATTR ((u_long)2)
+#define NFSPROC_ROOT ((u_long)3)
+#define NFSPROC_LOOKUP ((u_long)4)
+#define NFSPROC_READLINK ((u_long)5)
+#define NFSPROC_READ ((u_long)6)
+#define NFSPROC_WRITECACHE ((u_long)7)
+#define NFSPROC_WRITE ((u_long)8)
+#define NFSPROC_CREATE ((u_long)9)
+#define NFSPROC_REMOVE ((u_long)10)
+#define NFSPROC_RENAME ((u_long)11)
+#define NFSPROC_LINK ((u_long)12)
+#define NFSPROC_SYMLINK ((u_long)13)
+#define NFSPROC_MKDIR ((u_long)14)
+#define NFSPROC_RMDIR ((u_long)15)
+#define NFSPROC_READDIR ((u_long)16)
+#define NFSPROC_STATFS ((u_long)17)
+
+/* map field names */
+#define ml_hostname ml_name
+#define ml_directory ml_path
+#define ml_next ml_nxt
+#define gr_next g_next
+#define gr_name g_name
+#define ex_dir ex_name
+#define na_fileid na_nodeid
+#define la_fhandle la_from
+#define ra_totalcount ra_totcount
+
+
+/*
+ * TYPEDEFS:
+ */
+typedef char *dirpath;
+typedef char *filename;
+typedef char *name;
+typedef char *nfspath;
+typedef char nfscookie[NFS_COOKIESIZE];
+typedef enum nfsftype nfsftype;
+typedef enum nfsstat nfsstat;
+typedef char fhandle[NFS_FHSIZE];
+typedef struct attrstat nfsattrstat;
+typedef struct nfscreateargs nfscreateargs;
+typedef struct nfsdirlist nfsdirlist;
+typedef struct nfsdiropargs nfsdiropargs;
+typedef struct nfsdiropokres nfsdiropokres;
+typedef struct diropres nfsdiropres;
+typedef struct nfsentry nfsentry;
+typedef struct exports *exports;
+typedef struct exports exportnode;
+typedef struct fattr nfsfattr;
+typedef struct nfsfhstatus fhstatus;
+typedef struct groups *groups;
+typedef struct groups groupnode;
+typedef struct nfslinkargs nfslinkargs;
+typedef struct mountlist *mountlist;
+typedef struct mountlist mountbody;
+typedef struct nfstime nfstime;
+typedef struct nfsreadargs nfsreadargs;
+typedef struct nfsreaddirargs nfsreaddirargs;
+typedef struct nfsreaddirres nfsreaddirres;
+typedef struct nfsreadlinkres nfsreadlinkres;
+typedef struct nfsreadokres nfsreadokres;
+typedef struct nfsreadres nfsreadres;
+typedef struct nfsrenameargs nfsrenameargs;
+typedef struct sattr nfssattr;
+typedef struct nfssattrargs nfssattrargs;
+typedef struct nfsstatfsokres nfsstatfsokres;
+typedef struct nfsstatfsres nfsstatfsres;
+typedef struct nfssymlinkargs nfssymlinkargs;
+typedef struct writeargs nfswriteargs;
+
+
+/*
+ * EXTERNALS:
+ */
+
+extern void *nfsproc_null_2_svc(void *, struct svc_req *);
+extern nfsattrstat *nfsproc_getattr_2_svc(fhandle_t *, struct svc_req *);
+extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *);
+extern void *nfsproc_root_2_svc(void *, struct svc_req *);
+extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsreadlinkres *nfsproc_readlink_2_svc(fhandle_t *, struct svc_req *);
+extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *);
+extern void *nfsproc_writecache_2_svc(void *, struct svc_req *);
+extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *);
+extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *);
+extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *);
+extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *);
+extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *);
+extern nfsstatfsres *nfsproc_statfs_2_svc(fhandle_t *, struct svc_req *);
+
+extern bool_t xdr_nfsstat(XDR *, nfsstat*);
+extern bool_t xdr_ftype(XDR *, nfsftype*);
+extern bool_t xdr_nfs_fh(XDR *, fhandle_t*);
+extern bool_t xdr_nfstime(XDR *, nfstime*);
+extern bool_t xdr_fattr(XDR *, nfsfattr*);
+extern bool_t xdr_sattr(XDR *, nfssattr*);
+extern bool_t xdr_filename(XDR *, filename*);
+extern bool_t xdr_nfspath(XDR *, nfspath*);
+extern bool_t xdr_attrstat(XDR *, nfsattrstat*);
+extern bool_t xdr_sattrargs(XDR *, nfssattrargs*);
+extern bool_t xdr_diropargs(XDR *, nfsdiropargs*);
+extern bool_t xdr_diropokres(XDR *, nfsdiropokres*);
+extern bool_t xdr_diropres(XDR *, nfsdiropres*);
+extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*);
+extern bool_t xdr_readargs(XDR *, nfsreadargs*);
+extern bool_t xdr_readokres(XDR *, nfsreadokres*);
+extern bool_t xdr_readres(XDR *, nfsreadres*);
+extern bool_t xdr_writeargs(XDR *, nfswriteargs*);
+extern bool_t xdr_createargs(XDR *, nfscreateargs*);
+extern bool_t xdr_renameargs(XDR *, nfsrenameargs*);
+extern bool_t xdr_linkargs(XDR *, nfslinkargs*);
+extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*);
+extern bool_t xdr_nfscookie(XDR *, nfscookie);
+extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*);
+extern bool_t xdr_entry(XDR *, nfsentry*);
+extern bool_t xdr_dirlist(XDR *, nfsdirlist*);
+extern bool_t xdr_readdirres(XDR *, nfsreaddirres*);
+extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*);
+extern bool_t xdr_statfsres(XDR *, nfsstatfsres*);
+
+
+/*
+ * STRUCTURES:
+ */
+
+struct nfstime {
+ u_int nt_seconds;
+ u_int nt_useconds;
+};
+
+struct fattr {
+ nfsftype na_type;
+ u_int na_mode;
+ u_int na_nlink;
+ u_int na_uid;
+ u_int na_gid;
+ u_int na_size;
+ u_int na_blocksize;
+ u_int na_rdev;
+ u_int na_blocks;
+ u_int na_fsid;
+ u_int na_fileid;
+ nfstime na_atime;
+ nfstime na_mtime;
+ nfstime na_ctime;
+};
+
+struct sattr {
+ u_int sa_mode;
+ u_int sa_uid;
+ u_int sa_gid;
+ u_int sa_size;
+ nfstime sa_atime;
+ nfstime sa_mtime;
+};
+
+struct attrstat {
+ nfsstat ns_status;
+ union {
+ nfsfattr ns_attr_u;
+ } ns_u;
+};
+
+struct nfssattrargs {
+ fhandle_t sag_fhandle;
+ nfssattr sag_attributes;
+};
+
+struct _nfsdiropargs {
+ fhandle_t da_fhandle; /* was dir */
+ filename da_name;
+};
+
+struct nfsdiropokres {
+ fhandle_t drok_fhandle;
+ nfsfattr drok_attributes;
+};
+
+struct diropres {
+ nfsstat dr_status; /* was status */
+ union {
+ nfsdiropokres dr_drok_u; /* was diropres */
+ } dr_u; /* was diropres_u */
+};
+
+struct nfsreadlinkres {
+ nfsstat rlr_status;
+ union {
+ nfspath rlr_data_u;
+ } rlr_u;
+};
+
+struct _nfsreadargs {
+ fhandle_t ra_fhandle;
+ u_int ra_offset;
+ u_int ra_count;
+ u_int ra_totalcount;
+};
+
+struct nfsreadokres {
+ nfsfattr raok_attributes;
+ struct {
+ u_int raok_len_u;
+ char *raok_val_u;
+ } raok_u;
+};
+
+struct nfsreadres {
+ nfsstat rr_status;
+ union {
+ nfsreadokres rr_reply_u;
+ } rr_u;
+};
+
+struct writeargs {
+ fhandle_t wra_fhandle;
+ u_int wra_beginoffset;
+ u_int wra_offset;
+ u_int wra_totalcount;
+ struct {
+ u_int wra_len_u;
+ char *wra_val_u;
+ } wra_u;
+};
+
+struct nfscreateargs {
+ nfsdiropargs ca_where;
+ nfssattr ca_attributes;
+};
+
+struct nfsrenameargs {
+ nfsdiropargs rna_from;
+ nfsdiropargs rna_to;
+};
+
+struct _nfslinkargs {
+ fhandle_t la_fhandle;
+ nfsdiropargs la_to;
+};
+
+struct nfssymlinkargs {
+ nfsdiropargs sla_from;
+ nfspath sla_to;
+ nfssattr sla_attributes;
+};
+
+struct nfsreaddirargs {
+ fhandle_t rda_fhandle;
+ nfscookie rda_cookie;
+ u_int rda_count;
+};
+
+struct nfsentry {
+ u_int ne_fileid;
+ filename ne_name;
+ nfscookie ne_cookie;
+ nfsentry *ne_nextentry;
+};
+
+struct nfsdirlist {
+ nfsentry *dl_entries;
+ bool_t dl_eof;
+};
+
+struct nfsreaddirres {
+ nfsstat rdr_status;
+ union {
+ nfsdirlist rdr_reply_u;
+ } rdr_u;
+};
+
+struct nfsstatfsokres {
+ u_int sfrok_tsize;
+ u_int sfrok_bsize;
+ u_int sfrok_blocks;
+ u_int sfrok_bfree;
+ u_int sfrok_bavail;
+};
+
+struct nfsstatfsres {
+ nfsstat sfr_status;
+ union {
+ nfsstatfsokres sfr_reply_u;
+ } sfr_u;
+};
+
+struct nfsfhstatus {
+ int fhs_status;
+ fhandle fhs_fh;
+};
+
+#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_sunos4.h b/conf/nfs_prot/nfs_prot_sunos4.h
new file mode 100644
index 000000000000..c32edd3632b8
--- /dev/null
+++ b/conf/nfs_prot/nfs_prot_sunos4.h
@@ -0,0 +1,401 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/nfs_prot/nfs_prot_sunos4.h
+ *
+ */
+
+#ifndef _AMU_NFS_PROT_H
+#define _AMU_NFS_PROT_H
+
+#ifdef HAVE_SYS_ERRNO_H
+#include <sys/errno.h>
+#endif /* HAVE_SYS_ERRNO_H */
+#ifdef HAVE_RPC_RPC_H
+#include <rpc/rpc.h>
+#endif /* HAVE_RPC_RPC_H */
+#ifdef HAVE_NFS_NFSV2_H
+# include <nfs/nfsv2.h>
+#endif /* HAVE_NFS_NFSV2_H */
+#ifdef HAVE_NFS_RPCV2_H
+# include <nfs/rpcv2.h>
+#endif /* HAVE_NFS_RPCV2_H */
+#ifdef HAVE_NFS_NFS_H
+# include <nfs/nfs.h>
+#endif /* HAVE_NFS_NFS_H */
+# ifdef HAVE_NFS_NFS_CLNT_H
+# include <nfs/nfs_clnt.h>
+# endif /* HAVE_NFS_NFS_CLNT_H */
+#ifdef HAVE_SYS_FS_NFS_H
+# include <sys/fs/nfs.h>
+#endif /* HAVE_SYS_FS_NFS_H */
+#ifdef HAVE_RPCSVC_MOUNT_H
+# include <rpcsvc/mount.h>
+#endif /* HAVE_RPCSVC_MOUNT_H */
+
+
+/*
+ * MACROS
+ */
+
+#define NFS_PORT 2049
+#define NFS_MAXDATA 8192
+#define NFS_MAXPATHLEN 1024
+#define NFS_MAXNAMLEN 255
+#define NFS_FHSIZE 32
+#define NFS_COOKIESIZE 4
+#define MNTPATHLEN 1024
+#define MNTNAMLEN 255
+
+#define NFSMODE_FMT 0170000
+#define NFSMODE_DIR 0040000
+#define NFSMODE_CHR 0020000
+#define NFSMODE_BLK 0060000
+#define NFSMODE_REG 0100000
+#define NFSMODE_LNK 0120000
+#define NFSMODE_SOCK 0140000
+#define NFSMODE_FIFO 0010000
+
+#ifndef NFS_PROGRAM
+# define NFS_PROGRAM ((u_long)100003)
+#endif /* not NFS_PROGRAM */
+#ifndef NFS_VERSION
+# define NFS_VERSION ((u_long)2)
+#endif /* not NFS_VERSION */
+
+/* complete missing definition that is actually used in SunOS 4.x */
+#ifndef MNTOPT_DEV
+# define MNTOPT_DEV "dev"
+#endif /* not MNTOPT_DEV */
+
+#define NFSPROC_NULL ((u_long)0)
+#define NFSPROC_GETATTR ((u_long)1)
+#define NFSPROC_SETATTR ((u_long)2)
+#define NFSPROC_ROOT ((u_long)3)
+#define NFSPROC_LOOKUP ((u_long)4)
+#define NFSPROC_READLINK ((u_long)5)
+#define NFSPROC_READ ((u_long)6)
+#define NFSPROC_WRITECACHE ((u_long)7)
+#define NFSPROC_WRITE ((u_long)8)
+#define NFSPROC_CREATE ((u_long)9)
+#define NFSPROC_REMOVE ((u_long)10)
+#define NFSPROC_RENAME ((u_long)11)
+#define NFSPROC_LINK ((u_long)12)
+#define NFSPROC_SYMLINK ((u_long)13)
+#define NFSPROC_MKDIR ((u_long)14)
+#define NFSPROC_RMDIR ((u_long)15)
+#define NFSPROC_READDIR ((u_long)16)
+#define NFSPROC_STATFS ((u_long)17)
+
+/* map field names */
+#define ml_hostname ml_name
+#define ml_directory ml_path
+#define ml_next ml_nxt
+#define gr_next g_next
+#define gr_name g_name
+#define ex_dir ex_name
+#define na_fileid na_nodeid
+#define la_fhandle la_from
+#define ra_totalcount ra_totcount
+
+
+/*
+ * TYPEDEFS:
+ */
+typedef char *dirpath;
+typedef char *filename;
+typedef char *name;
+typedef char *nfspath;
+typedef char nfscookie[NFS_COOKIESIZE];
+typedef enum nfsftype nfsftype;
+typedef enum nfsstat nfsstat;
+typedef char fhandle[NFS_FHSIZE];
+typedef struct attrstat nfsattrstat;
+typedef struct nfscreateargs nfscreateargs;
+typedef struct nfsdirlist nfsdirlist;
+typedef struct nfsdiropargs nfsdiropargs;
+typedef struct nfsdiropokres nfsdiropokres;
+typedef struct diropres nfsdiropres;
+typedef struct nfsentry nfsentry;
+typedef struct exports *exports;
+typedef struct exports exportnode;
+typedef struct fattr nfsfattr;
+typedef struct nfsfhstatus fhstatus;
+typedef struct groups *groups;
+typedef struct groups groupnode;
+typedef struct nfslinkargs nfslinkargs;
+typedef struct mountlist *mountlist;
+typedef struct mountlist mountbody;
+typedef struct nfstime nfstime;
+typedef struct nfsreadargs nfsreadargs;
+typedef struct nfsreaddirargs nfsreaddirargs;
+typedef struct nfsreaddirres nfsreaddirres;
+typedef struct nfsreadlinkres nfsreadlinkres;
+typedef struct nfsreadokres nfsreadokres;
+typedef struct nfsreadres nfsreadres;
+typedef struct nfsrenameargs nfsrenameargs;
+typedef struct sattr nfssattr;
+typedef struct nfssattrargs nfssattrargs;
+typedef struct nfsstatfsokres nfsstatfsokres;
+typedef struct nfsstatfsres nfsstatfsres;
+typedef struct nfssymlinkargs nfssymlinkargs;
+typedef struct writeargs nfswriteargs;
+
+
+/*
+ * EXTERNALS:
+ */
+
+extern void *nfsproc_null_2_svc(void *, struct svc_req *);
+extern nfsattrstat *nfsproc_getattr_2_svc(fhandle_t *, struct svc_req *);
+extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *);
+extern void *nfsproc_root_2_svc(void *, struct svc_req *);
+extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsreadlinkres *nfsproc_readlink_2_svc(fhandle_t *, struct svc_req *);
+extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *);
+extern void *nfsproc_writecache_2_svc(void *, struct svc_req *);
+extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *);
+extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *);
+extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *);
+extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *);
+extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *);
+extern nfsstatfsres *nfsproc_statfs_2_svc(fhandle_t *, struct svc_req *);
+
+extern bool_t xdr_nfsstat(XDR *, nfsstat*);
+extern bool_t xdr_ftype(XDR *, nfsftype*);
+extern bool_t xdr_nfs_fh(XDR *, fhandle_t*);
+extern bool_t xdr_nfstime(XDR *, nfstime*);
+extern bool_t xdr_fattr(XDR *, nfsfattr*);
+extern bool_t xdr_sattr(XDR *, nfssattr*);
+extern bool_t xdr_filename(XDR *, filename*);
+extern bool_t xdr_nfspath(XDR *, nfspath*);
+extern bool_t xdr_attrstat(XDR *, nfsattrstat*);
+extern bool_t xdr_sattrargs(XDR *, nfssattrargs*);
+extern bool_t xdr_diropargs(XDR *, nfsdiropargs*);
+extern bool_t xdr_diropokres(XDR *, nfsdiropokres*);
+extern bool_t xdr_diropres(XDR *, nfsdiropres*);
+extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*);
+extern bool_t xdr_readargs(XDR *, nfsreadargs*);
+extern bool_t xdr_readokres(XDR *, nfsreadokres*);
+extern bool_t xdr_readres(XDR *, nfsreadres*);
+extern bool_t xdr_writeargs(XDR *, nfswriteargs*);
+extern bool_t xdr_createargs(XDR *, nfscreateargs*);
+extern bool_t xdr_renameargs(XDR *, nfsrenameargs*);
+extern bool_t xdr_linkargs(XDR *, nfslinkargs*);
+extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*);
+extern bool_t xdr_nfscookie(XDR *, nfscookie);
+extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*);
+extern bool_t xdr_entry(XDR *, nfsentry*);
+extern bool_t xdr_dirlist(XDR *, nfsdirlist*);
+extern bool_t xdr_readdirres(XDR *, nfsreaddirres*);
+extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*);
+extern bool_t xdr_statfsres(XDR *, nfsstatfsres*);
+
+
+/*
+ * STRUCTURES:
+ */
+
+struct nfstime {
+ u_int nt_seconds;
+ u_int nt_useconds;
+};
+
+struct fattr {
+ nfsftype na_type;
+ u_int na_mode;
+ u_int na_nlink;
+ u_int na_uid;
+ u_int na_gid;
+ u_int na_size;
+ u_int na_blocksize;
+ u_int na_rdev;
+ u_int na_blocks;
+ u_int na_fsid;
+ u_int na_fileid;
+ nfstime na_atime;
+ nfstime na_mtime;
+ nfstime na_ctime;
+};
+
+struct sattr {
+ u_int sa_mode;
+ u_int sa_uid;
+ u_int sa_gid;
+ u_int sa_size;
+ nfstime sa_atime;
+ nfstime sa_mtime;
+};
+
+struct attrstat {
+ nfsstat ns_status;
+ union {
+ nfsfattr ns_attr_u;
+ } ns_u;
+};
+
+struct nfssattrargs {
+ fhandle_t sag_fhandle;
+ nfssattr sag_attributes;
+};
+
+struct _nfsdiropargs {
+ fhandle_t da_fhandle; /* was dir */
+ filename da_name;
+};
+
+struct nfsdiropokres {
+ fhandle_t drok_fhandle;
+ nfsfattr drok_attributes;
+};
+
+struct diropres {
+ nfsstat dr_status; /* was status */
+ union {
+ nfsdiropokres dr_drok_u; /* was diropres */
+ } dr_u; /* was diropres_u */
+};
+
+struct nfsreadlinkres {
+ nfsstat rlr_status;
+ union {
+ nfspath rlr_data_u;
+ } rlr_u;
+};
+
+struct _nfsreadargs {
+ fhandle_t ra_fhandle;
+ u_int ra_offset;
+ u_int ra_count;
+ u_int ra_totalcount;
+};
+
+struct nfsreadokres {
+ nfsfattr raok_attributes;
+ struct {
+ u_int raok_len_u;
+ char *raok_val_u;
+ } raok_u;
+};
+
+struct nfsreadres {
+ nfsstat rr_status;
+ union {
+ nfsreadokres rr_reply_u;
+ } rr_u;
+};
+
+struct writeargs {
+ fhandle_t wra_fhandle;
+ u_int wra_beginoffset;
+ u_int wra_offset;
+ u_int wra_totalcount;
+ struct {
+ u_int wra_len_u;
+ char *wra_val_u;
+ } wra_u;
+};
+
+struct nfscreateargs {
+ nfsdiropargs ca_where;
+ nfssattr ca_attributes;
+};
+
+struct nfsrenameargs {
+ nfsdiropargs rna_from;
+ nfsdiropargs rna_to;
+};
+
+struct _nfslinkargs {
+ fhandle_t la_fhandle;
+ nfsdiropargs la_to;
+};
+
+struct nfssymlinkargs {
+ nfsdiropargs sla_from;
+ nfspath sla_to;
+ nfssattr sla_attributes;
+};
+
+struct nfsreaddirargs {
+ fhandle_t rda_fhandle;
+ nfscookie rda_cookie;
+ u_int rda_count;
+};
+
+struct nfsentry {
+ u_int ne_fileid;
+ filename ne_name;
+ nfscookie ne_cookie;
+ nfsentry *ne_nextentry;
+};
+
+struct nfsdirlist {
+ nfsentry *dl_entries;
+ bool_t dl_eof;
+};
+
+struct nfsreaddirres {
+ nfsstat rdr_status;
+ union {
+ nfsdirlist rdr_reply_u;
+ } rdr_u;
+};
+
+struct nfsstatfsokres {
+ u_int sfrok_tsize;
+ u_int sfrok_bsize;
+ u_int sfrok_blocks;
+ u_int sfrok_bfree;
+ u_int sfrok_bavail;
+};
+
+struct nfsstatfsres {
+ nfsstat sfr_status;
+ union {
+ nfsstatfsokres sfr_reply_u;
+ } sfr_u;
+};
+
+struct nfsfhstatus {
+ int fhs_status;
+ fhandle fhs_fh;
+};
+
+#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_sunos5_3.h b/conf/nfs_prot/nfs_prot_sunos5_3.h
new file mode 100644
index 000000000000..da760dfe0f46
--- /dev/null
+++ b/conf/nfs_prot/nfs_prot_sunos5_3.h
@@ -0,0 +1,264 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/nfs_prot/nfs_prot_sunos5_3.h
+ *
+ */
+
+#ifndef _AMU_NFS_PROT_H
+#define _AMU_NFS_PROT_H
+
+/*
+ * Do not include <nfs/nfs.h> because Solaris 2.3 really does not have NFS
+ * V.3 support, despite what their header files claim.
+ */
+
+#ifdef HAVE_RPCSVC_NFS_PROT_H
+# include <rpcsvc/nfs_prot.h>
+#endif /* HAVE_RPCSVC_NFS_PROT_H */
+
+#ifndef fhandle_t
+# define fhandle_t nfs_fh
+#endif /* not fhandle_t */
+
+#ifdef HAVE_RPCSVC_MOUNT_H
+# include <rpcsvc/mount.h>
+#endif /* HAVE_RPCSVC_MOUNT_H */
+#ifdef HAVE_RPC_RPC_H
+#include <rpc/rpc.h>
+#endif /* HAVE_RPC_RPC_H */
+
+/* missing mntent definition for cachefs */
+#ifndef MNTTYPE_CACHEFS
+# define MNTTYPE_CACHEFS "cachefs" /* Cache File System */
+#endif /* not MNTTYPE_CACHEFS */
+
+/*
+ * MACROS
+ */
+
+#define NFS_PORT 2049
+#define NFS_MAXDATA 8192
+#define NFS_MAXPATHLEN 1024
+#define NFS_MAXNAMLEN 255
+#define NFS_FHSIZE 32
+#define FHSIZE 32
+#define NFS_COOKIESIZE 4
+
+#define NFSMODE_FMT 0170000
+#define NFSMODE_DIR 0040000
+#define NFSMODE_CHR 0020000
+#define NFSMODE_BLK 0060000
+#define NFSMODE_REG 0100000
+#define NFSMODE_LNK 0120000
+#define NFSMODE_SOCK 0140000
+#define NFSMODE_FIFO 0010000
+
+#define dr_drok_u diropres
+#define ca_attributes attributes
+#define ca_where where
+#define da_fhandle dir
+#define da_name name
+#define dl_entries entries
+#define dl_eof eof
+#define dr_status status
+#define dr_u diropres_u
+#define drok_attributes attributes
+#define drok_fhandle file
+#define fh_data data
+#define la_fhandle from
+#define la_to to
+#define na_atime atime
+#define na_blocks blocks
+#define na_blocksize blocksize
+#define na_ctime ctime
+#define na_fileid fileid
+#define na_fsid fsid
+#define na_gid gid
+#define na_mode mode
+#define na_mtime mtime
+#define na_nlink nlink
+#define na_rdev rdev
+#define na_size size
+#define na_type type
+#define na_uid uid
+#define ne_cookie cookie
+#define ne_fileid fileid
+#define ne_name name
+#define ne_nextentry nextentry
+#define ns_attr_u attributes
+#define ns_status status
+#define ns_u attrstat_u
+#define nt_seconds seconds
+#define nt_useconds useconds
+#define ra_count count
+#define ra_fhandle file
+#define ra_offset offset
+#define ra_totalcount totalcount
+#define raok_attributes attributes
+#define raok_len_u data_len
+#define raok_u data
+#define raok_val_u data_val
+#define rda_cookie cookie
+#define rda_count count
+#define rda_fhandle dir
+#define rdr_reply_u reply
+#define rdr_status status
+#define rdr_u readdirres_u
+#define rlr_data_u data
+#define rlr_status status
+#define rlr_u readlinkres_u
+#define rna_from from
+#define rna_to to
+#define rr_reply_u reply
+#define rr_status status
+#define rr_u readres_u
+#define sa_atime atime
+#define sa_gid gid
+#define sa_mode mode
+#define sa_mtime mtime
+#define sa_size size
+#define sa_uid uid
+#define sag_attributes attributes
+#define sag_fhandle file
+#define sfr_reply_u reply
+#define sfr_status status
+#define sfr_u statfsres_u
+#define sfrok_bavail bavail
+#define sfrok_bfree bfree
+#define sfrok_blocks blocks
+#define sfrok_bsize bsize
+#define sfrok_tsize tsize
+#define sla_attributes attributes
+#define sla_from from
+#define sla_to to
+#define wra_beginoffset beginoffset
+#define wra_fhandle file
+#define wra_len_u data_len
+#define wra_offset offset
+#define wra_totalcount totalcount
+#define wra_u data
+#define wra_val_u data_val
+
+/* map field names */
+#define ex_dir ex_name
+#define gr_name g_name
+#define gr_next g_next
+#define ml_directory ml_path
+#define ml_hostname ml_name
+#define ml_next ml_nxt
+
+
+/*
+ * TYPEDEFS:
+ */
+
+typedef char *dirpath;
+typedef char *name;
+typedef char fhandle[FHSIZE];
+typedef enum ftype nfsftype;
+typedef struct attrstat nfsattrstat;
+typedef struct createargs nfscreateargs;
+typedef struct dirlist nfsdirlist;
+typedef struct diropargs nfsdiropargs;
+typedef struct diropokres nfsdiropokres;
+typedef struct diropres nfsdiropres;
+typedef struct entry nfsentry;
+typedef struct exports *exports;
+typedef struct exports exportnode;
+typedef struct fattr nfsfattr;
+typedef struct nfsfhstatus fhstatus;
+typedef struct groups *groups;
+typedef struct groups groupnode;
+typedef struct linkargs nfslinkargs;
+typedef struct mountlist *mountlist;
+typedef struct mountlist mountbody;
+typedef struct readargs nfsreadargs;
+typedef struct readdirargs nfsreaddirargs;
+typedef struct readdirres nfsreaddirres;
+typedef struct readlinkres nfsreadlinkres;
+typedef struct readokres nfsreadokres;
+typedef struct readres nfsreadres;
+typedef struct renameargs nfsrenameargs;
+typedef struct sattr nfssattr;
+typedef struct sattrargs nfssattrargs;
+typedef struct statfsokres nfsstatfsokres;
+typedef struct statfsres nfsstatfsres;
+typedef struct symlinkargs nfssymlinkargs;
+typedef struct writeargs nfswriteargs;
+
+
+/*
+ * EXTERNALS:
+ */
+
+extern bool_t xdr_createargs(XDR *, nfscreateargs *);
+extern bool_t xdr_dirlist(XDR *, nfsdirlist *);
+extern bool_t xdr_diropokres(XDR *, nfsdiropokres *);
+extern bool_t xdr_entry(XDR *, nfsentry *);
+extern bool_t xdr_filename(XDR *, filename *);
+extern bool_t xdr_ftype(XDR *, nfsftype *);
+extern bool_t xdr_nfs_fh(XDR *, nfs_fh *);
+extern bool_t xdr_nfscookie(XDR *, nfscookie);
+extern bool_t xdr_nfspath(XDR *, nfspath *);
+extern bool_t xdr_nfsstat(XDR *, nfsstat *);
+extern bool_t xdr_nfstime(XDR *, nfstime *);
+extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs *);
+extern bool_t xdr_readdirres(XDR *, nfsreaddirres *);
+extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres *);
+extern bool_t xdr_readokres(XDR *, nfsreadokres *);
+extern bool_t xdr_readres(XDR *, nfsreadres *);
+extern bool_t xdr_renameargs(XDR *, nfsrenameargs *);
+extern bool_t xdr_sattrargs(XDR *, nfssattrargs *);
+extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres *);
+extern bool_t xdr_statfsres(XDR *, nfsstatfsres *);
+extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs *);
+
+
+/*
+ * ENUMS:
+ */
+
+
+/*
+ * STRUCTURES:
+ */
+
+struct nfsfhstatus {
+ int fhs_status;
+ fhandle fhs_fh;
+};
+
+#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_sunos5_4.h b/conf/nfs_prot/nfs_prot_sunos5_4.h
new file mode 100644
index 000000000000..25dc58b896dc
--- /dev/null
+++ b/conf/nfs_prot/nfs_prot_sunos5_4.h
@@ -0,0 +1,266 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/nfs_prot/nfs_prot_sunos5_4.h
+ *
+ */
+
+#ifndef _AMU_NFS_PROT_H
+#define _AMU_NFS_PROT_H
+
+/*
+ * Do not include <nfs/nfs.h> because Solaris 2.4 really does not have NFS
+ * V.3 support, despite what their header files claim.
+ */
+
+#ifdef HAVE_RPCSVC_NFS_PROT_H
+# include <rpcsvc/nfs_prot.h>
+#endif /* HAVE_RPCSVC_NFS_PROT_H */
+
+#define FHSIZE 32
+typedef char fhandle[FHSIZE];
+#define fhandle_t fhandle
+
+#ifdef HAVE_RPCSVC_MOUNT_H
+# include <rpcsvc/mount.h>
+#endif /* HAVE_RPCSVC_MOUNT_H */
+#ifdef HAVE_RPC_RPC_H
+#include <rpc/rpc.h>
+#endif /* HAVE_RPC_RPC_H */
+
+/* missing mntent definition for cachefs */
+#ifndef MNTTYPE_CACHEFS
+# define MNTTYPE_CACHEFS "cachefs" /* Cache File System */
+#endif /* not MNTTYPE_CACHEFS */
+
+/*
+ * Solaris 2.4 has header definitions for NFS V.3, but does not really
+ * have NFS V.3 support in the kernel. So I must undefine these.
+ */
+#ifdef MNTTYPE_NFS3
+# undef MNTTYPE_NFS3
+#endif /* MNTTYPE_NFS3 */
+
+
+/*
+ * MACROS
+ */
+
+#define NFS_PORT 2049
+#define NFS_MAXDATA 8192
+#define NFS_MAXPATHLEN 1024
+#define NFS_MAXNAMLEN 255
+#define NFS_FHSIZE 32
+#define NFS_COOKIESIZE 4
+
+#define NFSMODE_FMT 0170000
+#define NFSMODE_DIR 0040000
+#define NFSMODE_CHR 0020000
+#define NFSMODE_BLK 0060000
+#define NFSMODE_REG 0100000
+#define NFSMODE_LNK 0120000
+#define NFSMODE_SOCK 0140000
+#define NFSMODE_FIFO 0010000
+
+#define dr_drok_u diropres
+#define ca_attributes attributes
+#define ca_where where
+#define da_fhandle dir
+#define da_name name
+#define dl_entries entries
+#define dl_eof eof
+#define dr_status status
+#define dr_u diropres_u
+#define drok_attributes attributes
+#define drok_fhandle file
+#define fh_data data
+#define la_fhandle from
+#define la_to to
+#define na_atime atime
+#define na_blocks blocks
+#define na_blocksize blocksize
+#define na_ctime ctime
+#define na_fileid fileid
+#define na_fsid fsid
+#define na_gid gid
+#define na_mode mode
+#define na_mtime mtime
+#define na_nlink nlink
+#define na_rdev rdev
+#define na_size size
+#define na_type type
+#define na_uid uid
+#define ne_cookie cookie
+#define ne_fileid fileid
+#define ne_name name
+#define ne_nextentry nextentry
+#define ns_attr_u attributes
+#define ns_status status
+#define ns_u attrstat_u
+#define nt_seconds seconds
+#define nt_useconds useconds
+#define ra_count count
+#define ra_fhandle file
+#define ra_offset offset
+#define ra_totalcount totalcount
+#define raok_attributes attributes
+#define raok_len_u data_len
+#define raok_u data
+#define raok_val_u data_val
+#define rda_cookie cookie
+#define rda_count count
+#define rda_fhandle dir
+#define rdr_reply_u reply
+#define rdr_status status
+#define rdr_u readdirres_u
+#define rlr_data_u data
+#define rlr_status status
+#define rlr_u readlinkres_u
+#define rna_from from
+#define rna_to to
+#define rr_reply_u reply
+#define rr_status status
+#define rr_u readres_u
+#define sa_atime atime
+#define sa_gid gid
+#define sa_mode mode
+#define sa_mtime mtime
+#define sa_size size
+#define sa_uid uid
+#define sag_attributes attributes
+#define sag_fhandle file
+#define sfr_reply_u reply
+#define sfr_status status
+#define sfr_u statfsres_u
+#define sfrok_bavail bavail
+#define sfrok_bfree bfree
+#define sfrok_blocks blocks
+#define sfrok_bsize bsize
+#define sfrok_tsize tsize
+#define sla_attributes attributes
+#define sla_from from
+#define sla_to to
+#define wra_beginoffset beginoffset
+#define wra_fhandle file
+#define wra_len_u data_len
+#define wra_offset offset
+#define wra_totalcount totalcount
+#define wra_u data
+#define wra_val_u data_val
+
+/* map field names */
+#define ex_dir ex_name
+#define gr_name g_name
+#define gr_next g_next
+#define ml_directory ml_path
+#define ml_hostname ml_name
+#define ml_next ml_nxt
+
+
+/*
+ * TYPEDEFS:
+ */
+
+typedef char *dirpath;
+typedef char *name;
+typedef enum ftype nfsftype;
+typedef struct attrstat nfsattrstat;
+typedef struct createargs nfscreateargs;
+typedef struct dirlist nfsdirlist;
+typedef struct diropargs nfsdiropargs;
+typedef struct diropokres nfsdiropokres;
+typedef struct diropres nfsdiropres;
+typedef struct entry nfsentry;
+typedef struct exports *exports;
+typedef struct exports exportnode;
+typedef struct fattr nfsfattr;
+typedef struct fhstatus fhstatus;
+typedef struct groups *groups;
+typedef struct groups groupnode;
+typedef struct linkargs nfslinkargs;
+typedef struct mountlist *mountlist;
+typedef struct mountlist mountbody;
+typedef struct readargs nfsreadargs;
+typedef struct readdirargs nfsreaddirargs;
+typedef struct readdirres nfsreaddirres;
+typedef struct readlinkres nfsreadlinkres;
+typedef struct readokres nfsreadokres;
+typedef struct readres nfsreadres;
+typedef struct renameargs nfsrenameargs;
+typedef struct sattr nfssattr;
+typedef struct sattrargs nfssattrargs;
+typedef struct statfsokres nfsstatfsokres;
+typedef struct statfsres nfsstatfsres;
+typedef struct symlinkargs nfssymlinkargs;
+typedef struct writeargs nfswriteargs;
+
+
+/*
+ * EXTERNALS:
+ */
+
+extern bool_t xdr_createargs(XDR *, nfscreateargs *);
+extern bool_t xdr_dirlist(XDR *, nfsdirlist *);
+extern bool_t xdr_diropokres(XDR *, nfsdiropokres *);
+extern bool_t xdr_entry(XDR *, nfsentry *);
+extern bool_t xdr_filename(XDR *, filename *);
+extern bool_t xdr_ftype(XDR *, nfsftype *);
+extern bool_t xdr_nfs_fh(XDR *, nfs_fh *);
+extern bool_t xdr_nfscookie(XDR *, nfscookie);
+extern bool_t xdr_nfspath(XDR *, nfspath *);
+extern bool_t xdr_nfsstat(XDR *, nfsstat *);
+extern bool_t xdr_nfstime(XDR *, nfstime *);
+extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs *);
+extern bool_t xdr_readdirres(XDR *, nfsreaddirres *);
+extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres *);
+extern bool_t xdr_readokres(XDR *, nfsreadokres *);
+extern bool_t xdr_readres(XDR *, nfsreadres *);
+extern bool_t xdr_renameargs(XDR *, nfsrenameargs *);
+extern bool_t xdr_sattrargs(XDR *, nfssattrargs *);
+extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres *);
+extern bool_t xdr_statfsres(XDR *, nfsstatfsres *);
+extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs *);
+
+
+/*
+ * ENUMS:
+ */
+
+
+/*
+ * STRUCTURES:
+ */
+
+#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_sunos5_5.h b/conf/nfs_prot/nfs_prot_sunos5_5.h
new file mode 100644
index 000000000000..6e31ddc242d9
--- /dev/null
+++ b/conf/nfs_prot/nfs_prot_sunos5_5.h
@@ -0,0 +1,381 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/nfs_prot/nfs_prot_sunos5_5.h
+ *
+ */
+
+#ifndef _AMU_NFS_PROT_H
+#define _AMU_NFS_PROT_H
+
+/*
+ * Do NOT include <rpcsvc/nfs_prot.h> to get NFS V2 specs, because
+ * it will result in conflicts with <nfs/nfs.h>. The latter is a must
+ * for NFS V3 specs.
+ */
+
+#ifdef HAVE_NFS_NFS_H
+# include <nfs/nfs.h>
+#endif /* HAVE_NFS_NFS_H */
+
+#ifdef HAVE_RPCSVC_MOUNT_H
+# include <rpcsvc/mount.h>
+#endif /* HAVE_RPCSVC_MOUNT_H */
+
+/*
+ * MACROS
+ */
+
+#define NFS_PORT 2049
+#define NFS_MAXDATA 8192
+#define NFS_MAXPATHLEN 1024
+#define NFS_MAXNAMLEN 255
+#define NFS_FHSIZE 32
+#define NFS_COOKIESIZE 4
+
+#define NFSMODE_FMT 0170000
+#define NFSMODE_DIR 0040000
+#define NFSMODE_CHR 0020000
+#define NFSMODE_BLK 0060000
+#define NFSMODE_REG 0100000
+#define NFSMODE_LNK 0120000
+#define NFSMODE_SOCK 0140000
+#define NFSMODE_FIFO 0010000
+
+#define NFSPROC_NULL ((unsigned long)(0))
+#define NFSPROC_GETATTR ((unsigned long)(1))
+#define NFSPROC_SETATTR ((unsigned long)(2))
+#define NFSPROC_ROOT ((unsigned long)(3))
+#define NFSPROC_LOOKUP ((unsigned long)(4))
+#define NFSPROC_READLINK ((unsigned long)(5))
+#define NFSPROC_READ ((unsigned long)(6))
+#define NFSPROC_WRITECACHE ((unsigned long)(7))
+#define NFSPROC_WRITE ((unsigned long)(8))
+#define NFSPROC_CREATE ((unsigned long)(9))
+#define NFSPROC_REMOVE ((unsigned long)(10))
+#define NFSPROC_RENAME ((unsigned long)(11))
+#define NFSPROC_LINK ((unsigned long)(12))
+#define NFSPROC_SYMLINK ((unsigned long)(13))
+#define NFSPROC_MKDIR ((unsigned long)(14))
+#define NFSPROC_RMDIR ((unsigned long)(15))
+#define NFSPROC_READDIR ((unsigned long)(16))
+#define NFSPROC_STATFS ((unsigned long)(17))
+
+#define AUTOFS_CONFTYPE "ticlts"
+
+
+/*
+ * TYPEDEFS:
+ */
+
+typedef char *filename;
+typedef char *nfspath;
+typedef char nfscookie[NFS_COOKIESIZE];
+typedef enum nfsftype nfsftype;
+typedef enum nfsstat nfsstat;
+typedef struct attrstat nfsattrstat;
+typedef struct createargs nfscreateargs;
+typedef struct dirlist nfsdirlist;
+typedef struct diropargs nfsdiropargs;
+typedef struct diropokres nfsdiropokres;
+typedef struct diropres nfsdiropres;
+typedef struct entry nfsentry;
+typedef struct fattr nfsfattr;
+typedef struct linkargs nfslinkargs;
+typedef struct nfs_fh nfs_fh;
+typedef struct nfstime nfstime;
+typedef struct readargs nfsreadargs;
+typedef struct readdirargs nfsreaddirargs;
+typedef struct readdirres nfsreaddirres;
+typedef struct readlinkres nfsreadlinkres;
+typedef struct readokres nfsreadokres;
+typedef struct readres nfsreadres;
+typedef struct renameargs nfsrenameargs;
+typedef struct sattr nfssattr;
+typedef struct sattrargs nfssattrargs;
+typedef struct statfsokres nfsstatfsokres;
+typedef struct statfsres nfsstatfsres;
+typedef struct symlinkargs nfssymlinkargs;
+typedef struct writeargs nfswriteargs;
+
+
+/*
+ * EXTERNALS:
+ */
+
+extern bool_t xdr_nfsstat(XDR *, nfsstat *);
+extern bool_t xdr_ftype(XDR *, nfsftype *);
+extern bool_t xdr_nfs_fh(XDR *, nfs_fh *);
+extern bool_t xdr_nfstime(XDR *, nfstime *);
+extern bool_t xdr_fattr(XDR *, nfsfattr *);
+extern bool_t xdr_sattr(XDR *, nfssattr *);
+extern bool_t xdr_filename(XDR *, filename *);
+extern bool_t xdr_nfspath(XDR *, nfspath *);
+extern bool_t xdr_attrstat(XDR *, nfsattrstat *);
+extern bool_t xdr_sattrargs(XDR *, nfssattrargs *);
+extern bool_t xdr_diropargs(XDR *, nfsdiropargs *);
+extern bool_t xdr_diropokres(XDR *, nfsdiropokres *);
+extern bool_t xdr_diropres(XDR *, nfsdiropres *);
+extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres *);
+extern bool_t xdr_readargs(XDR *, nfsreadargs *);
+extern bool_t xdr_readokres(XDR *, nfsreadokres *);
+extern bool_t xdr_readres(XDR *, nfsreadres *);
+extern bool_t xdr_writeargs(XDR *, nfswriteargs *);
+extern bool_t xdr_createargs(XDR *, nfscreateargs *);
+extern bool_t xdr_renameargs(XDR *, nfsrenameargs *);
+extern bool_t xdr_linkargs(XDR *, nfslinkargs *);
+extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs *);
+extern bool_t xdr_nfscookie(XDR *, nfscookie);
+extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs *);
+extern bool_t xdr_entry(XDR *, nfsentry *);
+extern bool_t xdr_dirlist(XDR *, nfsdirlist *);
+extern bool_t xdr_readdirres(XDR *, nfsreaddirres *);
+extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres *);
+extern bool_t xdr_statfsres(XDR *, nfsstatfsres *);
+
+extern nfsattrstat *nfsproc_getattr_2(nfs_fh *, CLIENT *);
+extern nfsattrstat *nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *);
+extern nfsattrstat *nfsproc_setattr_2(nfssattrargs *, CLIENT *);
+extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *);
+extern nfsattrstat *nfsproc_write_2(nfswriteargs *, CLIENT *);
+extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_create_2(nfscreateargs *, CLIENT *);
+extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_lookup_2(nfsdiropargs *, CLIENT *);
+extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_mkdir_2(nfscreateargs *, CLIENT *);
+extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *);
+extern nfsstat *nfsproc_link_2(nfslinkargs *, CLIENT *);
+extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *);
+extern nfsstat *nfsproc_remove_2(nfsdiropargs *, CLIENT *);
+extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsstat *nfsproc_rename_2(nfsrenameargs *, CLIENT *);
+extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *);
+extern nfsstat *nfsproc_rmdir_2(nfsdiropargs *, CLIENT *);
+extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsstat *nfsproc_symlink_2(nfssymlinkargs *, CLIENT *);
+extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *);
+extern nfsreaddirres *nfsproc_readdir_2(nfsreaddirargs *, CLIENT *);
+extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *);
+extern nfsreadlinkres *nfsproc_readlink_2(nfs_fh *, CLIENT *);
+extern nfsreadlinkres *nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *);
+extern nfsreadres *nfsproc_read_2(nfsreadargs *, CLIENT *);
+extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *);
+extern nfsstatfsres *nfsproc_statfs_2(nfs_fh *, CLIENT *);
+extern nfsstatfsres *nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *);
+extern void *nfsproc_null_2(void *, CLIENT *);
+extern void *nfsproc_null_2_svc(void *, struct svc_req *);
+extern void *nfsproc_root_2(void *, CLIENT *);
+extern void *nfsproc_root_2_svc(void *, struct svc_req *);
+extern void *nfsproc_writecache_2(void *, CLIENT *);
+extern void *nfsproc_writecache_2_svc(void *, struct svc_req *);
+extern int nfs_program_2_freeresult(SVCXPRT *, xdrproc_t, caddr_t);
+
+
+/*
+ * ENUMS:
+ */
+
+
+/*
+ * STRUCTURES:
+ */
+
+struct nfs_fh {
+ char fh_data[NFS_FHSIZE];
+};
+
+struct nfstime {
+ u_int nt_seconds;
+ u_int nt_useconds;
+};
+
+struct fattr {
+ nfsftype na_type;
+ u_int na_mode;
+ u_int na_nlink;
+ u_int na_uid;
+ u_int na_gid;
+ u_int na_size;
+ u_int na_blocksize;
+ u_int na_rdev;
+ u_int na_blocks;
+ u_int na_fsid;
+ u_int na_fileid;
+ nfstime na_atime;
+ nfstime na_mtime;
+ nfstime na_ctime;
+};
+
+struct sattr {
+ u_int sa_mode;
+ u_int sa_uid;
+ u_int sa_gid;
+ u_int sa_size;
+ nfstime sa_atime;
+ nfstime sa_mtime;
+};
+
+struct attrstat {
+ nfsstat ns_status;
+ union {
+ nfsfattr ns_attr_u;
+ } ns_u;
+};
+
+struct sattrargs {
+ nfs_fh sag_fhandle;
+ nfssattr sag_attributes;
+};
+
+struct diropargs {
+ nfs_fh da_fhandle; /* was dir */
+ filename da_name;
+};
+
+struct diropokres {
+ nfs_fh drok_fhandle;
+ nfsfattr drok_attributes;
+};
+
+struct diropres {
+ nfsstat dr_status; /* was status */
+ union {
+ nfsdiropokres dr_drok_u; /* was diropres */
+ } dr_u; /* was diropres_u */
+};
+
+struct readlinkres {
+ nfsstat rlr_status;
+ union {
+ nfspath rlr_data_u;
+ } rlr_u;
+};
+
+struct readargs {
+ nfs_fh ra_fhandle;
+ u_int ra_offset;
+ u_int ra_count;
+ u_int ra_totalcount;
+};
+
+struct readokres {
+ nfsfattr raok_attributes;
+ struct {
+ u_int raok_len_u;
+ char *raok_val_u;
+ } raok_u;
+};
+
+struct readres {
+ nfsstat rr_status;
+ union {
+ nfsreadokres rr_reply_u;
+ } rr_u;
+};
+
+struct writeargs {
+ nfs_fh wra_fhandle;
+ u_int wra_beginoffset;
+ u_int wra_offset;
+ u_int wra_totalcount;
+ struct {
+ u_int wra_len_u;
+ char *wra_val_u;
+ } wra_u;
+};
+
+struct createargs {
+ nfsdiropargs ca_where;
+ nfssattr ca_attributes;
+};
+
+struct renameargs {
+ nfsdiropargs rna_from;
+ nfsdiropargs rna_to;
+};
+
+struct linkargs {
+ nfs_fh la_fhandle;
+ nfsdiropargs la_to;
+};
+
+struct symlinkargs {
+ nfsdiropargs sla_from;
+ nfspath sla_to;
+ nfssattr sla_attributes;
+};
+
+struct readdirargs {
+ nfs_fh rda_fhandle;
+ nfscookie rda_cookie;
+ u_int rda_count;
+};
+
+struct entry {
+ u_int ne_fileid;
+ filename ne_name;
+ nfscookie ne_cookie;
+ nfsentry *ne_nextentry;
+};
+
+struct dirlist {
+ nfsentry *dl_entries;
+ bool_t dl_eof;
+};
+
+struct readdirres {
+ nfsstat rdr_status;
+ union {
+ nfsdirlist rdr_reply_u;
+ } rdr_u;
+};
+
+struct statfsokres {
+ u_int sfrok_tsize;
+ u_int sfrok_bsize;
+ u_int sfrok_blocks;
+ u_int sfrok_bfree;
+ u_int sfrok_bavail;
+};
+
+struct statfsres {
+ nfsstat sfr_status;
+ union {
+ nfsstatfsokres sfr_reply_u;
+ } sfr_u;
+};
+
+#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_sunos5_6.h b/conf/nfs_prot/nfs_prot_sunos5_6.h
new file mode 100644
index 000000000000..36f613f3f7a3
--- /dev/null
+++ b/conf/nfs_prot/nfs_prot_sunos5_6.h
@@ -0,0 +1,385 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/nfs_prot/nfs_prot_sunos5_6.h
+ *
+ */
+
+#ifndef _AMU_NFS_PROT_H
+#define _AMU_NFS_PROT_H
+
+/*
+ * Do NOT include <rpcsvc/nfs_prot.h> to get NFS V2 specs, because
+ * it will result in conflicts with <nfs/nfs.h>. The latter is a must
+ * for NFS V3 specs.
+ */
+
+#ifdef HAVE_NFS_NFS_H
+# include <nfs/nfs.h>
+#endif /* HAVE_NFS_NFS_H */
+
+#ifdef HAVE_RPCSVC_MOUNT_H
+# include <rpcsvc/mount.h>
+#endif /* HAVE_RPCSVC_MOUNT_H */
+
+#ifdef HAVE_RPC_RPC_H
+# include <rpc/rpc.h>
+#endif /* HAVE_RPC_RPC_H */
+
+
+/*
+ * MACROS
+ */
+
+#define NFS_PORT 2049
+#define NFS_MAXDATA 8192
+#define NFS_MAXPATHLEN 1024
+#define NFS_MAXNAMLEN 255
+#define NFS_FHSIZE 32
+#define NFS_COOKIESIZE 4
+
+#define NFSMODE_FMT 0170000
+#define NFSMODE_DIR 0040000
+#define NFSMODE_CHR 0020000
+#define NFSMODE_BLK 0060000
+#define NFSMODE_REG 0100000
+#define NFSMODE_LNK 0120000
+#define NFSMODE_SOCK 0140000
+#define NFSMODE_FIFO 0010000
+
+#define NFSPROC_NULL ((unsigned long)(0))
+#define NFSPROC_GETATTR ((unsigned long)(1))
+#define NFSPROC_SETATTR ((unsigned long)(2))
+#define NFSPROC_ROOT ((unsigned long)(3))
+#define NFSPROC_LOOKUP ((unsigned long)(4))
+#define NFSPROC_READLINK ((unsigned long)(5))
+#define NFSPROC_READ ((unsigned long)(6))
+#define NFSPROC_WRITECACHE ((unsigned long)(7))
+#define NFSPROC_WRITE ((unsigned long)(8))
+#define NFSPROC_CREATE ((unsigned long)(9))
+#define NFSPROC_REMOVE ((unsigned long)(10))
+#define NFSPROC_RENAME ((unsigned long)(11))
+#define NFSPROC_LINK ((unsigned long)(12))
+#define NFSPROC_SYMLINK ((unsigned long)(13))
+#define NFSPROC_MKDIR ((unsigned long)(14))
+#define NFSPROC_RMDIR ((unsigned long)(15))
+#define NFSPROC_READDIR ((unsigned long)(16))
+#define NFSPROC_STATFS ((unsigned long)(17))
+
+#define AUTOFS_CONFTYPE "ticotsord"
+
+
+/*
+ * TYPEDEFS:
+ */
+
+typedef char *filename;
+typedef char *nfspath;
+typedef char nfscookie[NFS_COOKIESIZE];
+typedef enum nfsftype nfsftype;
+typedef enum nfsstat nfsstat;
+typedef struct attrstat nfsattrstat;
+typedef struct createargs nfscreateargs;
+typedef struct dirlist nfsdirlist;
+typedef struct diropargs nfsdiropargs;
+typedef struct diropokres nfsdiropokres;
+typedef struct diropres nfsdiropres;
+typedef struct entry nfsentry;
+typedef struct fattr nfsfattr;
+typedef struct linkargs nfslinkargs;
+typedef struct nfs_fh nfs_fh;
+typedef struct nfstime nfstime;
+typedef struct readargs nfsreadargs;
+typedef struct readdirargs nfsreaddirargs;
+typedef struct readdirres nfsreaddirres;
+typedef struct readlinkres nfsreadlinkres;
+typedef struct readokres nfsreadokres;
+typedef struct readres nfsreadres;
+typedef struct renameargs nfsrenameargs;
+typedef struct sattr nfssattr;
+typedef struct sattrargs nfssattrargs;
+typedef struct statfsokres nfsstatfsokres;
+typedef struct statfsres nfsstatfsres;
+typedef struct symlinkargs nfssymlinkargs;
+typedef struct writeargs nfswriteargs;
+
+
+/*
+ * EXTERNALS:
+ */
+
+extern bool_t xdr_nfsstat(XDR *, nfsstat *);
+extern bool_t xdr_ftype(XDR *, nfsftype *);
+extern bool_t xdr_nfs_fh(XDR *, nfs_fh *);
+extern bool_t xdr_nfstime(XDR *, nfstime *);
+extern bool_t xdr_fattr(XDR *, nfsfattr *);
+extern bool_t xdr_sattr(XDR *, nfssattr *);
+extern bool_t xdr_filename(XDR *, filename *);
+extern bool_t xdr_nfspath(XDR *, nfspath *);
+extern bool_t xdr_attrstat(XDR *, nfsattrstat *);
+extern bool_t xdr_sattrargs(XDR *, nfssattrargs *);
+extern bool_t xdr_diropargs(XDR *, nfsdiropargs *);
+extern bool_t xdr_diropokres(XDR *, nfsdiropokres *);
+extern bool_t xdr_diropres(XDR *, nfsdiropres *);
+extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres *);
+extern bool_t xdr_readargs(XDR *, nfsreadargs *);
+extern bool_t xdr_readokres(XDR *, nfsreadokres *);
+extern bool_t xdr_readres(XDR *, nfsreadres *);
+extern bool_t xdr_writeargs(XDR *, nfswriteargs *);
+extern bool_t xdr_createargs(XDR *, nfscreateargs *);
+extern bool_t xdr_renameargs(XDR *, nfsrenameargs *);
+extern bool_t xdr_linkargs(XDR *, nfslinkargs *);
+extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs *);
+extern bool_t xdr_nfscookie(XDR *, nfscookie);
+extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs *);
+extern bool_t xdr_entry(XDR *, nfsentry *);
+extern bool_t xdr_dirlist(XDR *, nfsdirlist *);
+extern bool_t xdr_readdirres(XDR *, nfsreaddirres *);
+extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres *);
+extern bool_t xdr_statfsres(XDR *, nfsstatfsres *);
+
+extern nfsattrstat *nfsproc_getattr_2(nfs_fh *, CLIENT *);
+extern nfsattrstat *nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *);
+extern nfsattrstat *nfsproc_setattr_2(nfssattrargs *, CLIENT *);
+extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *);
+extern nfsattrstat *nfsproc_write_2(nfswriteargs *, CLIENT *);
+extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_create_2(nfscreateargs *, CLIENT *);
+extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_lookup_2(nfsdiropargs *, CLIENT *);
+extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsdiropres *nfsproc_mkdir_2(nfscreateargs *, CLIENT *);
+extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *);
+extern nfsstat *nfsproc_link_2(nfslinkargs *, CLIENT *);
+extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *);
+extern nfsstat *nfsproc_remove_2(nfsdiropargs *, CLIENT *);
+extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsstat *nfsproc_rename_2(nfsrenameargs *, CLIENT *);
+extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *);
+extern nfsstat *nfsproc_rmdir_2(nfsdiropargs *, CLIENT *);
+extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *);
+extern nfsstat *nfsproc_symlink_2(nfssymlinkargs *, CLIENT *);
+extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *);
+extern nfsreaddirres *nfsproc_readdir_2(nfsreaddirargs *, CLIENT *);
+extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *);
+extern nfsreadlinkres *nfsproc_readlink_2(nfs_fh *, CLIENT *);
+extern nfsreadlinkres *nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *);
+extern nfsreadres *nfsproc_read_2(nfsreadargs *, CLIENT *);
+extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *);
+extern nfsstatfsres *nfsproc_statfs_2(nfs_fh *, CLIENT *);
+extern nfsstatfsres *nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *);
+extern void *nfsproc_null_2(void *, CLIENT *);
+extern void *nfsproc_null_2_svc(void *, struct svc_req *);
+extern void *nfsproc_root_2(void *, CLIENT *);
+extern void *nfsproc_root_2_svc(void *, struct svc_req *);
+extern void *nfsproc_writecache_2(void *, CLIENT *);
+extern void *nfsproc_writecache_2_svc(void *, struct svc_req *);
+extern int nfs_program_2_freeresult(SVCXPRT *, xdrproc_t, caddr_t);
+
+
+/*
+ * ENUMS:
+ */
+
+
+/*
+ * STRUCTURES:
+ */
+
+struct nfs_fh {
+ char fh_data[NFS_FHSIZE];
+};
+
+struct nfstime {
+ u_int nt_seconds;
+ u_int nt_useconds;
+};
+
+struct fattr {
+ nfsftype na_type;
+ u_int na_mode;
+ u_int na_nlink;
+ u_int na_uid;
+ u_int na_gid;
+ u_int na_size;
+ u_int na_blocksize;
+ u_int na_rdev;
+ u_int na_blocks;
+ u_int na_fsid;
+ u_int na_fileid;
+ nfstime na_atime;
+ nfstime na_mtime;
+ nfstime na_ctime;
+};
+
+struct sattr {
+ u_int sa_mode;
+ u_int sa_uid;
+ u_int sa_gid;
+ u_int sa_size;
+ nfstime sa_atime;
+ nfstime sa_mtime;
+};
+
+struct attrstat {
+ nfsstat ns_status;
+ union {
+ nfsfattr ns_attr_u;
+ } ns_u;
+};
+
+struct sattrargs {
+ nfs_fh sag_fhandle;
+ nfssattr sag_attributes;
+};
+
+struct diropargs {
+ nfs_fh da_fhandle; /* was dir */
+ filename da_name;
+};
+
+struct diropokres {
+ nfs_fh drok_fhandle;
+ nfsfattr drok_attributes;
+};
+
+struct diropres {
+ nfsstat dr_status; /* was status */
+ union {
+ nfsdiropokres dr_drok_u; /* was diropres */
+ } dr_u; /* was diropres_u */
+};
+
+struct readlinkres {
+ nfsstat rlr_status;
+ union {
+ nfspath rlr_data_u;
+ } rlr_u;
+};
+
+struct readargs {
+ nfs_fh ra_fhandle;
+ u_int ra_offset;
+ u_int ra_count;
+ u_int ra_totalcount;
+};
+
+struct readokres {
+ nfsfattr raok_attributes;
+ struct {
+ u_int raok_len_u;
+ char *raok_val_u;
+ } raok_u;
+};
+
+struct readres {
+ nfsstat rr_status;
+ union {
+ nfsreadokres rr_reply_u;
+ } rr_u;
+};
+
+struct writeargs {
+ nfs_fh wra_fhandle;
+ u_int wra_beginoffset;
+ u_int wra_offset;
+ u_int wra_totalcount;
+ struct {
+ u_int wra_len_u;
+ char *wra_val_u;
+ } wra_u;
+};
+
+struct createargs {
+ nfsdiropargs ca_where;
+ nfssattr ca_attributes;
+};
+
+struct renameargs {
+ nfsdiropargs rna_from;
+ nfsdiropargs rna_to;
+};
+
+struct linkargs {
+ nfs_fh la_fhandle;
+ nfsdiropargs la_to;
+};
+
+struct symlinkargs {
+ nfsdiropargs sla_from;
+ nfspath sla_to;
+ nfssattr sla_attributes;
+};
+
+struct readdirargs {
+ nfs_fh rda_fhandle;
+ nfscookie rda_cookie;
+ u_int rda_count;
+};
+
+struct entry {
+ u_int ne_fileid;
+ filename ne_name;
+ nfscookie ne_cookie;
+ nfsentry *ne_nextentry;
+};
+
+struct dirlist {
+ nfsentry *dl_entries;
+ bool_t dl_eof;
+};
+
+struct readdirres {
+ nfsstat rdr_status;
+ union {
+ nfsdirlist rdr_reply_u;
+ } rdr_u;
+};
+
+struct statfsokres {
+ u_int sfrok_tsize;
+ u_int sfrok_bsize;
+ u_int sfrok_blocks;
+ u_int sfrok_bfree;
+ u_int sfrok_bavail;
+};
+
+struct statfsres {
+ nfsstat sfr_status;
+ union {
+ nfsstatfsokres sfr_reply_u;
+ } sfr_u;
+};
+#endif /* not _AMU_NFS_PROT_H */
diff --git a/conf/nfs_prot/nfs_prot_sunos5_7.h b/conf/nfs_prot/nfs_prot_sunos5_7.h
new file mode 100644
index 000000000000..3d0d30f823a1
--- /dev/null
+++ b/conf/nfs_prot/nfs_prot_sunos5_7.h
@@ -0,0 +1,396 @@
+/*
+ * Copyright (c) 1997-2014 Erez Zadok
+ * Copyright (c) 1990 Jan-Simon Pendry
+ * Copyright (c) 1990 Imperial College of Science, Technology & Medicine
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Jan-Simon Pendry at Imperial College, London.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *
+ * File: am-utils/conf/nfs_prot/nfs_prot_sunos5_7.h
+ *
+ */
+
+#ifndef _AMU_NFS_PROT_H
+#define _AMU_NFS_PROT_H
+
+/*
+ * Do NOT include <rpcsvc/nfs_prot.h> to get NFS V2 specs, because
+ * it will result in conflicts with <nfs/nfs.h>. The latter is a must
+ * for NFS V3 specs.
+ */
+
+#ifdef HAVE_NFS_NFS_H
+# include <nfs/nfs.h>
+#endif /* HAVE_NFS_NFS_H */
+
+#ifdef HAVE_RPCSVC_MOUNT_H
+# include <rpcsvc/mount.h>
+#endif /* HAVE_RPCSVC_MOUNT_H */
+
+#ifdef HAVE_RPC_RPC_H
+# include <rpc/rpc.h>
+#endif /* HAVE_RPC_RPC_H */
+
+
+/*
+ * MACROS
+ */
+
+#define NFS_PORT 2049
+#define NFS_MAXDATA 8192
+#define NFS_MAXPATHLEN 1024
+#define NFS_MAXNAMLEN 255
+#define NFS_FHSIZE 32
+#define NFS_COOKIESIZE 4
+
+#define NFSMODE_FMT 0170000
+#define NFSMODE_DIR 0040000
+#define NFSMODE_CHR 0020000
+#define NFSMODE_BLK 0060000
+#define NFSMODE_REG 0100000
+#define NFSMODE_LNK 0120000
+#define NFSMODE_SOCK 0140000
+#define NFSMODE_FIFO 0010000
+
+#define NFSPROC_NULL ((unsigned long)(0))
+#define NFSPROC_GETATTR ((unsigned long)(1))
+#define NFSPROC_SETATTR ((unsigned long)(2))
+#define NFSPROC_ROOT ((unsigned long)(3))
+#define NFSPROC_LOOKUP ((unsigned long)(4))
+#define NFSPROC_READLINK ((unsigned long)(5))
+#define NFSPROC_READ ((unsigned long)(6))
+#define NFSPROC_WRITECACHE ((unsigned long)(7))
+#define NFSPROC_WRITE ((unsigned long)(8))
+#define NFSPROC_CREATE ((unsigned long)(9))
+#define NFSPROC_REMOVE ((unsigned long)(10))
+#define NFSPROC_RENAME ((unsigned long)(11))
+#define NFSPROC_LINK ((unsigned long)(12))
+#define NFSPROC_SYMLINK ((unsigned long)(13))
+#define NFSPROC_MKDIR ((unsigned long)(14))
+#define NFSPROC_RMDIR ((unsigned long)(15))
+#define NFSPROC_READDIR ((unsigned long)(16))
+#define NFSPROC_STATFS ((unsigned long)(17))
+
+#define AUTOFS_CONFTYPE "ticotsord"
+
+/* Sun has incomplete ldap headers, but libraries are ok */
+#ifndef LDAP_VERSION_MAX
+#define LDAP_VERSION_MAX LDAP_VERSION3
+#endif /* LDAP_VERSION_MAX */
+
+
+/*
+ * TYPEDEFS:
+ */
+
+typedef char *filename;