summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorHarshavardhana <harsha@harshavardhana.net>2014-04-17 15:54:34 -0700
committerAnand Avati <avati@redhat.com>2014-04-24 14:41:48 -0700
commita3cb38e3edf005bef73da4c9cfd958474a14d50f (patch)
treea406029332a9eb096c14d441160bb670a42df8cb /contrib
parent9c13471b109587a639662fc690384285bee02bc6 (diff)
build: MacOSX Porting fixes
git@forge.gluster.org:~schafdog/glusterfs-core/osx-glusterfs Working functionality on MacOSX - GlusterD (management daemon) - GlusterCLI (management cli) - GlusterFS FUSE (using OSXFUSE) - GlusterNFS (without NLM - issues with rpc.statd) Change-Id: I20193d3f8904388e47344e523b3787dbeab044ac BUG: 1089172 Signed-off-by: Harshavardhana <harsha@harshavardhana.net> Signed-off-by: Dennis Schafroth <dennis@schafroth.com> Tested-by: Harshavardhana <harsha@harshavardhana.net> Tested-by: Dennis Schafroth <dennis@schafroth.com> Reviewed-on: http://review.gluster.org/7503 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'contrib')
-rw-r--r--contrib/argp-standalone/configure.ac11
-rw-r--r--contrib/fuse-include/fuse_kernel_macfuse.h9
-rw-r--r--contrib/fuse-lib/mount-gluster-compat.h12
-rw-r--r--contrib/fuse-util/Makefile.am2
-rw-r--r--contrib/fuse-util/fusermount.c24
-rw-r--r--contrib/macfuse/fuse_param.h97
-rw-r--r--contrib/macfuse/mount_darwin.c27
-rw-r--r--contrib/mount/mntent.c163
-rw-r--r--contrib/mount/mntent_compat.h35
-rw-r--r--contrib/qemu/include/qemu/bswap.h7
-rw-r--r--contrib/qemu/util/cutils.c2
-rw-r--r--contrib/sunrpc/xdr_sizeof.c204
-rw-r--r--contrib/uuid/gen_uuid.c17
-rw-r--r--contrib/uuid/uuid_time.c4
14 files changed, 550 insertions, 64 deletions
diff --git a/contrib/argp-standalone/configure.ac b/contrib/argp-standalone/configure.ac
index 4e4e67692f8..167b234fc77 100644
--- a/contrib/argp-standalone/configure.ac
+++ b/contrib/argp-standalone/configure.ac
@@ -56,12 +56,12 @@ AC_DEFUN([ARGP_CHECK_FUNC],
[Define to 1 if you have the `]ac_func[' function.])
AC_CACHE_CHECK([for $2], ac_var,
[AC_TRY_LINK([$1], [$2],
- [AS_VAR_SET(ac_var, yes)],
- [AS_VAR_SET(ac_var, no)])])
+ [AS_VAR_SET(ac_var, yes)],
+ [AS_VAR_SET(ac_var, no)])])
if test AS_VAR_GET(ac_var) = yes ; then
ifelse([$3],,
- [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]ac_func))],
- [$3
+ [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]ac_func))],
+ [$3
])
else
ifelse([$4],, true, [$4])
@@ -99,4 +99,7 @@ fi
CPPFLAGS="$CPPFLAGS -I$srcdir"
+dnl Added for C99 standards
+CFLAGS="$CFLAGS -std=gnu89"
+
AC_OUTPUT(Makefile)
diff --git a/contrib/fuse-include/fuse_kernel_macfuse.h b/contrib/fuse-include/fuse_kernel_macfuse.h
index 3fbf24f70aa..a003f825a70 100644
--- a/contrib/fuse-include/fuse_kernel_macfuse.h
+++ b/contrib/fuse-include/fuse_kernel_macfuse.h
@@ -189,6 +189,15 @@ enum fuse_opcode {
FUSE_INTERRUPT = 36,
FUSE_BMAP = 37,
FUSE_DESTROY = 38,
+ /*
+ FUSE_IOCTL = 39,
+ FUSE_POLL = 40,
+ FUSE_NOTIFY_REPLY = 41,
+ FUSE_BATCH_FORGET = 42,
+ FUSE_FALLOCATE = 43,
+ FUSE_READDIRPLUS = 44,
+ */
+
#if (__FreeBSD__ >= 10)
FUSE_SETVOLNAME = 61,
FUSE_GETXTIMES = 62,
diff --git a/contrib/fuse-lib/mount-gluster-compat.h b/contrib/fuse-lib/mount-gluster-compat.h
index 4fc20623bc9..1f76241ab1c 100644
--- a/contrib/fuse-lib/mount-gluster-compat.h
+++ b/contrib/fuse-lib/mount-gluster-compat.h
@@ -21,7 +21,7 @@
#include <errno.h>
#include <dirent.h>
#include <signal.h>
-#ifndef __NetBSD__
+#if !defined(__NetBSD__) && !defined(GF_DARWIN_HOST_OS)
#include <mntent.h>
#endif /* __NetBSD__ */
#include <sys/stat.h>
@@ -36,7 +36,15 @@
#define MS_RDONLY MNT_RDONLY
#endif
-#ifdef linux
+#ifdef GF_DARWIN_HOST_OS
+#include <sys/param.h>
+#include <sys/mount.h>
+#define umount2(dir, flags) unmount(dir, ((flags) != 0) ? MNT_FORCE : 0)
+#define MS_RDONLY MNT_RDONLY
+#endif
+
+
+#ifdef GF_LINUX_HOST_OS
#define _PATH_MOUNT "/bin/mount"
#else /* NetBSD, MacOS X */
#define _PATH_MOUNT "/sbin/mount"
diff --git a/contrib/fuse-util/Makefile.am b/contrib/fuse-util/Makefile.am
index 971d3d22002..abbc10eb6d9 100644
--- a/contrib/fuse-util/Makefile.am
+++ b/contrib/fuse-util/Makefile.am
@@ -3,7 +3,7 @@ bin_PROGRAMS = fusermount-glusterfs
fusermount_glusterfs_SOURCES = fusermount.c mount_util.c $(CONTRIBDIR)/fuse-lib/mount-common.c
noinst_HEADERS = $(CONTRIBDIR)/fuse-include/mount_util.h
-AM_CPPFLAGS = $(GF_CPPFLAGS) -DFUSE_UTIL -I$(CONTRIBDIR)/fuse-include
+AM_CPPFLAGS = $(GF_CPPFLAGS) -DFUSE_UTIL -I$(CONTRIBDIR)/fuse-include -I$(CONTRIBDIR)/fuse-lib
AM_CFLAGS = -Wall $(GF_CFLAGS)
diff --git a/contrib/fuse-util/fusermount.c b/contrib/fuse-util/fusermount.c
index 0ff8d90395c..a64d8e102ff 100644
--- a/contrib/fuse-util/fusermount.c
+++ b/contrib/fuse-util/fusermount.c
@@ -10,6 +10,11 @@
#include <config.h>
#include "mount_util.h"
+
+#ifndef HAVE_UMOUNT2
+#include "mount-gluster-compat.h"
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -20,11 +25,18 @@
#include <fcntl.h>
#include <pwd.h>
#include <limits.h>
+#if !defined(__NetBSD__) && !defined(GF_DARWIN_HOST_OS)
#include <mntent.h>
+#endif /* __NetBSD__ */
#include <sys/wait.h>
#include <sys/stat.h>
-#include <sys/mount.h>
+#ifdef HAVE_SET_FSID
#include <sys/fsuid.h>
+#endif
+#ifdef GF_DARWIN_HOST_OS
+#include <sys/param.h>
+#endif
+#include <sys/mount.h>
#include <sys/socket.h>
#include <sys/utsname.h>
#include <sched.h>
@@ -63,22 +75,32 @@ static const char *get_user_name(void)
}
}
+#ifdef HAVE_SET_FSID
static uid_t oldfsuid;
static gid_t oldfsgid;
+#endif
static void drop_privs(void)
{
if (getuid() != 0) {
+#ifdef HAVE_SET_FSID
oldfsuid = setfsuid(getuid());
oldfsgid = setfsgid(getgid());
+#else
+ fprintf(stderr, "%s: Implement alternative setfsuid/gid \n", progname);
+#endif
}
}
static void restore_privs(void)
{
if (getuid() != 0) {
+#ifdef HAVE_SET_FSID
setfsuid(oldfsuid);
setfsgid(oldfsgid);
+#else
+ fprintf(stderr, "%s: Implement alternative setfsuid/gid \n", progname);
+#endif
}
}
diff --git a/contrib/macfuse/fuse_param.h b/contrib/macfuse/fuse_param.h
index 81d753c6cd7..347db9464bc 100644
--- a/contrib/macfuse/fuse_param.h
+++ b/contrib/macfuse/fuse_param.h
@@ -1,4 +1,9 @@
/*
+ * 'rebel' branch modifications:
+ * Copyright (C) 2010 Tuxera. All Rights Reserved.
+ */
+
+/*
* Copyright (C) 2006-2008 Google. All Rights Reserved.
* Amit Singh <singh@>
*/
@@ -6,69 +11,81 @@
#ifndef _FUSE_PARAM_H_
#define _FUSE_PARAM_H_
-/* Compile-time tunables (M_MACFUSE*) */
-
-#define M_MACFUSE_ENABLE_FIFOFS 0
-#define M_MACFUSE_ENABLE_INTERRUPT 1
-#define M_MACFUSE_ENABLE_SPECFS 0
-#define M_MACFUSE_ENABLE_TSLOCKING 0
-#define M_MACFUSE_ENABLE_UNSUPPORTED 1
-#define M_MACFUSE_ENABLE_XATTR 1
-
-#if M_MACFUSE_ENABLE_UNSUPPORTED
- #define M_MACFUSE_ENABLE_DSELECT 0
- #define M_MACFUSE_ENABLE_EXCHANGE 1
- #define M_MACFUSE_ENABLE_KQUEUE 1
- #define M_MACFUSE_ENABLE_KUNC 0
-#if __LP64__
- #define M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK 1
-#endif /* __LP64__ */
-#endif /* M_MACFUSE_ENABLE_UNSUPPORTED */
-
-#if M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK
-#define FUSE_VNOP_EXPORT __private_extern__
+#include <AvailabilityMacros.h>
+
+/* Compile-time tunables (M_OSXFUSE*) */
+
+#define M_OSXFUSE_ENABLE_FIFOFS 0
+#define M_OSXFUSE_ENABLE_INTERRUPT 1
+#define M_OSXFUSE_ENABLE_SPECFS 0
+#define M_OSXFUSE_ENABLE_TSLOCKING 1
+#define M_OSXFUSE_ENABLE_UNSUPPORTED 1
+#define M_OSXFUSE_ENABLE_XATTR 1
+#define M_OSXFUSE_ENABLE_DSELECT 1
+
+#if M_OSXFUSE_ENABLE_UNSUPPORTED
+# define M_OSXFUSE_ENABLE_EXCHANGE 1
+# define M_OSXFUSE_ENABLE_KUNC 0
+# define M_OSXFUSE_ENABLE_INTERIM_FSNODE_LOCK 1
+#endif /* M_OSXFUSE_ENABLE_UNSUPPORTED */
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
+# if M_OSXFUSE_ENABLE_UNSUPPORTED
+ /*
+ * In Mac OS X 10.5 the file system implementation is responsible for
+ * posting kqueue events. Starting with Mac OS X 10.6 VFS took over that
+ * job.
+ */
+# define M_OSXFUSE_ENABLE_KQUEUE 1
+# endif
+#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1060 */
+
+#if M_OSXFUSE_ENABLE_INTERIM_FSNODE_LOCK
+# define M_OSXFUSE_ENABLE_HUGE_LOCK 0
+# define M_OSXFUSE_ENABLE_LOCK_LOGGING 0
+# define FUSE_VNOP_EXPORT __private_extern__
#else
-#define FUSE_VNOP_EXPORT static
-#endif /* M_MACFUSE_ENABLE_INTERIM_FSNODE_LOCK */
+# define FUSE_VNOP_EXPORT static
+#endif /* M_OSXFUSE_ENABLE_INTERIM_FSNODE_LOCK */
/* User Control */
-#define MACFUSE_POSTUNMOUNT_SIGNAL SIGKILL
+#define OSXFUSE_POSTUNMOUNT_SIGNAL SIGKILL
#define MACOSX_ADMIN_GROUP_NAME "admin"
-#define SYSCTL_MACFUSE_TUNABLES_ADMIN "macfuse.tunables.admin_group"
-#define SYSCTL_MACFUSE_VERSION_NUMBER "macfuse.version.number"
+#define SYSCTL_OSXFUSE_TUNABLES_ADMIN "osxfuse.tunables.admin_group"
+#define SYSCTL_OSXFUSE_VERSION_NUMBER "osxfuse.version.number"
/* Paths */
-#define MACFUSE_BUNDLE_PATH "/Library/Filesystems/fusefs.fs"
-#define MACFUSE_KEXT MACFUSE_BUNDLE_PATH "/Support/fusefs.kext"
-#define MACFUSE_LOAD_PROG MACFUSE_BUNDLE_PATH "/Support/load_fusefs"
-#define MACFUSE_MOUNT_PROG MACFUSE_BUNDLE_PATH "/Support/mount_fusefs"
+#define OSXFUSE_BUNDLE_PATH "/Library/Filesystems/osxfusefs.fs"
+#define OSXFUSE_KEXT OSXFUSE_BUNDLE_PATH "/Support/osxfusefs.kext"
+#define OSXFUSE_LOAD_PROG OSXFUSE_BUNDLE_PATH "/Support/load_osxfusefs"
+#define OSXFUSE_MOUNT_PROG OSXFUSE_BUNDLE_PATH "/Support/mount_osxfusefs"
#define SYSTEM_KEXTLOAD "/sbin/kextload"
#define SYSTEM_KEXTUNLOAD "/sbin/kextunload"
/* Compatible API version */
-#define MACFUSE_MIN_USER_VERSION_MAJOR 7
-#define MACFUSE_MIN_USER_VERSION_MINOR 5
+#define OSXFUSE_MIN_USER_VERSION_MAJOR 7
+#define OSXFUSE_MIN_USER_VERSION_MINOR 5
/* Device Interface */
/*
- * This is the prefix ("fuse" by default) of the name of a FUSE device node
- * in devfs. The suffix is the device number. "/dev/fuse0" is the first FUSE
+ * This is the prefix ("osxfuse" by default) of the name of a FUSE device node
+ * in devfs. The suffix is the device number. "/dev/osxfuse0" is the first FUSE
* device by default. If you change the prefix from the default to something
* else, the user-space FUSE library will need to know about it too.
*/
-#define MACFUSE_DEVICE_BASENAME "fuse"
+#define OSXFUSE_DEVICE_BASENAME "osxfuse"
/*
- * This is the number of /dev/fuse<n> nodes we will create. <n> goes from
- * 0 to (FUSE_NDEVICES - 1).
+ * This is the number of /dev/osxfuse<n> nodes we will create. <n> goes from
+ * 0 to (OSXFUSE_NDEVICES - 1).
*/
-#define MACFUSE_NDEVICES 24
+#define OSXFUSE_NDEVICES 24
/*
* This is the default block size of the virtual storage devices that are
@@ -131,13 +148,13 @@
/* User-Kernel IPC Buffer */
#define FUSE_MIN_USERKERNEL_BUFSIZE (128 * 1024)
-#define FUSE_MAX_USERKERNEL_BUFSIZE (4096 * 1024)
+#define FUSE_MAX_USERKERNEL_BUFSIZE (16 * 1024 * 1024)
#define FUSE_REASONABLE_XATTRSIZE FUSE_MIN_USERKERNEL_BUFSIZE
#endif /* KERNEL */
-#define FUSE_DEFAULT_USERKERNEL_BUFSIZE (4096 * 1024)
+#define FUSE_DEFAULT_USERKERNEL_BUFSIZE (16 * 1024 * 1024)
#define FUSE_LINK_MAX LINK_MAX
#define FUSE_UIO_BACKUP_MAX 8
diff --git a/contrib/macfuse/mount_darwin.c b/contrib/macfuse/mount_darwin.c
index c485583e96b..cac158249aa 100644
--- a/contrib/macfuse/mount_darwin.c
+++ b/contrib/macfuse/mount_darwin.c
@@ -105,7 +105,7 @@ loadkmod(void)
pid = fork();
if (pid == 0) {
- execl(MACFUSE_LOAD_PROG, MACFUSE_LOAD_PROG, NULL);
+ execl(OSXFUSE_LOAD_PROG, OSXFUSE_LOAD_PROG, NULL);
/* exec failed */
exit(ENOENT);
@@ -133,13 +133,17 @@ Return:
}
int
+gf_fuse_mount (const char *mountpoint, char *fsname,
+ unsigned long mountflags, char *mnt_param,
+ pid_t *mnt_pid, int status_fd) /* Not used on OS X */
+/* int
gf_fuse_mount (const char *mountpoint, char *fsname, char *mnt_param,
- pid_t *mtab_pid /* not used on OS X */)
+pid_t *mtab_pid) */
{
int fd, pid;
int result;
char *fdnam, *dev;
- const char *mountprog = MACFUSE_MOUNT_PROG;
+ const char *mountprog = OSXFUSE_MOUNT_PROG;
sig_t chldf;
/* mount_fusefs should not try to spawn the daemon */
@@ -170,7 +174,8 @@ gf_fuse_mount (const char *mountpoint, char *fsname, char *mnt_param,
size_t version_len = MAXHOSTNAMELEN;
size_t version_len_desired = 0;
- result = sysctlbyname(SYSCTL_MACFUSE_VERSION_NUMBER, version,
+ result = sysctlbyname(SYSCTL_OSXFUSE_VERSION_NUMBER
+ , version,
&version_len, NULL, (size_t)0);
if (result == 0) {
/* sysctlbyname() includes the trailing '\0' in version_len */
@@ -197,10 +202,12 @@ gf_fuse_mount (const char *mountpoint, char *fsname, char *mnt_param,
gf_log("glusterfs-fuse", GF_LOG_INFO,
"MacFUSE kext version %s", version);
}
+ // TODO Bypass version check
+ result = 0;
if (result != 0)
- GFFUSE_LOGERR("MacFUSE version %s is not supported", version);
+ GFFUSE_LOGERR("MacFUSE version %s is not supported", version);
} else
- GFFUSE_LOGERR("cannot load MacFUSE kext");
+ GFFUSE_LOGERR("cannot load MacFUSE kext");
if (result != 0)
return -1;
@@ -228,9 +235,9 @@ gf_fuse_mount (const char *mountpoint, char *fsname, char *mnt_param,
int r, devidx = -1;
char devpath[MAXPATHLEN];
- for (r = 0; r < MACFUSE_NDEVICES; r++) {
+ for (r = 0; r < OSXFUSE_NDEVICES; r++) {
snprintf(devpath, MAXPATHLEN - 1,
- _PATH_DEV MACFUSE_DEVICE_BASENAME "%d", r);
+ _PATH_DEV OSXFUSE_DEVICE_BASENAME "%d", r);
fd = open(devpath, O_RDWR);
if (fd >= 0) {
dev = devpath;
@@ -336,8 +343,8 @@ gf_fuse_unmount(const char *mountpoint, int fd)
devname_r(sbuf.st_rdev, S_IFCHR, dev, 128);
- if (strncmp(dev, MACFUSE_DEVICE_BASENAME,
- sizeof(MACFUSE_DEVICE_BASENAME) - 1)) {
+ if (strncmp(dev, OSXFUSE_DEVICE_BASENAME,
+ sizeof(OSXFUSE_DEVICE_BASENAME) - 1)) {
return;
}
diff --git a/contrib/mount/mntent.c b/contrib/mount/mntent.c
new file mode 100644
index 00000000000..5ab5ac19e84
--- /dev/null
+++ b/contrib/mount/mntent.c
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 1980, 1989, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ * Copyright (c) 2001
+ * David Rufino <daverufino@btinternet.com>
+ * Copyright (c) 2014
+ * Red Hat, Inc. <http://www.redhat.com>
+ *
+ * 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. 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
+ * 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.
+ */
+
+#ifdef GF_DARWIN_HOST_OS
+#include <stdlib.h>
+#include <string.h>
+#include <sys/param.h>
+#include <sys/ucred.h>
+#include <sys/mount.h>
+#include "mntent_compat.h"
+
+static int pos = -1;
+static int mntsize = -1;
+static struct mntent _mntent;
+
+char *
+hasmntopt (const struct mntent *mnt, const char *option)
+{
+ int found;
+ char *opt, *optbuf;
+
+ optbuf = strdup(mnt->mnt_opts);
+ found = 0;
+ for (opt = optbuf; (opt = strtok(opt, " ")) != NULL; opt = NULL) {
+ if (!strcasecmp(opt, option)) {
+ opt = opt - optbuf + mnt->mnt_opts;
+ free (optbuf);
+ return (opt);
+ }
+ }
+ free (optbuf);
+ return (NULL);
+}
+
+static char *
+concatopt (char *s0, const char *s1)
+{
+ size_t i;
+ char *cp;
+
+ if (s1 == NULL || *s1 == '\0')
+ return s0;
+ if (s0 && *s0) {
+ i = strlen(s0) + strlen(s1) + 1 + 1;
+ if ((cp = (char *)malloc(i)) == NULL)
+ return (NULL);
+ (void)snprintf(cp, i, "%s %s", s0, s1);
+ } else
+ cp = strdup(s1);
+
+ if (s0)
+ free(s0);
+ return (cp);
+}
+
+
+static char *
+flags2opts (int flags)
+{
+ char *res;
+ res = NULL;
+ res = concatopt(res, (flags & MNT_RDONLY) ? "ro" : "rw");
+ if (flags & MNT_SYNCHRONOUS) res = concatopt(res, "sync");
+ if (flags & MNT_NOEXEC) res = concatopt(res, "noexec");
+ if (flags & MNT_NOSUID) res = concatopt(res, "nosuid");
+ if (flags & MNT_NODEV) res = concatopt(res, "nodev");
+ if (flags & MNT_UNION) res = concatopt(res, "union");
+ if (flags & MNT_ASYNC) res = concatopt(res, "async");
+#if !defined(GF_DARWIN_HOST_OS)
+ if (flags & MNT_NOATIME) res = concatopt(res, "noatime");
+ if (flags & MNT_NOCLUSTERR) res = concatopt(res, "noclusterr");
+ if (flags & MNT_NOCLUSTERW) res = concatopt(res, "noclusterw");
+ if (flags & MNT_NOSYMFOLLOW) res = concatopt(res, "nosymfollow");
+ if (flags & MNT_SUIDDIR) res = concatopt(res, "suiddir");
+#endif
+ return res;
+}
+
+static struct mntent *
+statfs_to_mntent (struct statfs *mntbuf)
+{
+ static char opts_buf[40], *tmp;
+
+ _mntent.mnt_fsname = mntbuf->f_mntfromname;
+ _mntent.mnt_dir = mntbuf->f_mntonname;
+ _mntent.mnt_type = mntbuf->f_fstypename;
+ tmp = flags2opts (mntbuf->f_flags);
+ if (tmp) {
+ opts_buf[sizeof(opts_buf)-1] = '\0';
+ strncpy (opts_buf, tmp, sizeof(opts_buf)-1);
+ free (tmp);
+ } else {
+ *opts_buf = '\0';
+ }
+ _mntent.mnt_opts = opts_buf;
+ _mntent.mnt_freq = _mntent.mnt_passno = 0;
+ return (&_mntent);
+}
+
+struct mntent *
+getmntent (FILE *fp)
+{
+ struct statfs *mntbuf;
+
+ if (pos == -1 || mntsize == -1)
+ mntsize = getmntinfo (&mntbuf, MNT_NOWAIT);
+
+ ++pos;
+ if (pos == mntsize) {
+ pos = mntsize = -1;
+ return (NULL);
+ }
+
+ return (statfs_to_mntent (&mntbuf[pos]));
+}
+
+/* Dummy functions */
+FILE *
+setmntent(const char *filename, const char *type)
+{
+ return (FILE *)0x1;
+}
+
+int
+endmntent (FILE *fp)
+{
+ return 1;
+}
+#endif /* GF_DARWIN_HOST_OS */
diff --git a/contrib/mount/mntent_compat.h b/contrib/mount/mntent_compat.h
new file mode 100644
index 00000000000..76a75754b1c
--- /dev/null
+++ b/contrib/mount/mntent_compat.h
@@ -0,0 +1,35 @@
+/*
+ Copyright (c) 2014 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+
+#ifndef _MNTENT_H
+#define _MNTENT_H
+
+#ifdef GF_DARWIN_HOST_OS
+#include <stdio.h>
+
+struct mntent {
+ char *mnt_fsname;
+ char *mnt_dir;
+ char *mnt_type;
+ char *mnt_opts;
+ int mnt_freq;
+ int mnt_passno;
+};
+
+struct mntent *getmntent (FILE *fp);
+FILE *setmntent (const char *filename, const char *type);
+int endmntent(FILE *fp);
+char * hasmntopt (const struct mntent *mnt, const char *option);
+
+/* Dummy - /etc/mtab has no meaning on OSX platform */
+#define _PATH_MOUNTED "/etc/mtab"
+
+#endif /* GF_DARWIN_HOST_OS */
+#endif /* _MNTENT_H */
diff --git a/contrib/qemu/include/qemu/bswap.h b/contrib/qemu/include/qemu/bswap.h
index 14a5f657ce5..1ea5b101e89 100644
--- a/contrib/qemu/include/qemu/bswap.h
+++ b/contrib/qemu/include/qemu/bswap.h
@@ -12,7 +12,14 @@
# include <sys/types.h>
# include <machine/bswap.h>
#elif defined(CONFIG_BYTESWAP_H)
+#ifdef GF_DARWIN_HOST_OS
+# include <libkern/OSByteOrder.h>
+#define bswap_16(x) OSSwapInt16(x)
+#define bswap_32(x) OSSwapInt32(x)
+#define bswap_64(x) OSSwapInt64(x)
+#else
# include <byteswap.h>
+#endif
static inline uint16_t bswap16(uint16_t x)
{
diff --git a/contrib/qemu/util/cutils.c b/contrib/qemu/util/cutils.c
index 0116fcde74f..6caa4b8ddc4 100644
--- a/contrib/qemu/util/cutils.c
+++ b/contrib/qemu/util/cutils.c
@@ -156,7 +156,7 @@ int qemu_fls(int i)
*/
int qemu_fdatasync(int fd)
{
-#ifdef CONFIG_FDATASYNC
+#ifdef HAVE_FDATASYNC
return fdatasync(fd);
#else
return fsync(fd);
diff --git a/contrib/sunrpc/xdr_sizeof.c b/contrib/sunrpc/xdr_sizeof.c
new file mode 100644
index 00000000000..ca1f7bf0a5e
--- /dev/null
+++ b/contrib/sunrpc/xdr_sizeof.c
@@ -0,0 +1,204 @@
+/*
+ * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
+ * Reserved. This file contains Original Code and/or Modifications of
+ * Original Code as defined in and that are subject to the Apple Public
+ * Source License Version 1.1 (the "License"). You may not use this file
+ * except in compliance with the License. Please obtain a copy of the
+ * License at http://www.apple.com/publicsource and read it before using
+ * this file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+/*
+ * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
+ * unrestricted use provided that this legend is included on all tape
+ * media and as a part of the software program in whole or part. Users
+ * may copy or modify Sun RPC without charge, but are not authorized
+ * to license or distribute it to anyone else except as part of a product or
+ * program developed by the user.
+ *
+ * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
+ * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
+ *
+ * Sun RPC is provided with no support and without any obligation on the
+ * part of Sun Microsystems, Inc. to assist in its use, correction,
+ * modification or enhancement.
+ *
+ * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
+ * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
+ * OR ANY PART THEREOF.
+ *
+ * In no event will Sun Microsystems, Inc. be liable for any lost revenue
+ * or profits or other special, indirect and consequential damages, even if
+ * Sun has been advised of the possibility of such damages.
+ *
+ * Sun Microsystems, Inc.
+ * 2550 Garcia Avenue
+ * Mountain View, California 94043
+ */
+
+/*
+ * xdr_sizeof.c
+ *
+ * Copyright 1990 Sun Microsystems, Inc.
+ *
+ * General purpose routine to see how much space something will use
+ * when serialized using XDR.
+ */
+
+#ifdef GF_DARWIN_HOST_OS
+
+#include <rpc/types.h>
+#include <rpc/xdr.h>
+#include <sys/types.h>
+#include <sys/cdefs.h>
+
+#include <stdlib.h>
+
+/* ARGSUSED */
+#ifdef GF_DARWIN_HOST_OS
+static bool_t
+x_putlong (XDR *xdrs, const int *longp)
+{
+ xdrs->x_handy += BYTES_PER_XDR_UNIT;
+ return TRUE;
+}
+
+#else
+static bool_t
+x_putlong (XDR *xdrs, const long *longp)
+{
+ xdrs->x_handy += BYTES_PER_XDR_UNIT;
+ return TRUE;
+}
+#endif
+
+/* ARGSUSED */
+static bool_t
+x_putbytes (XDR *xdrs, const char *bp, u_int len)
+{
+ xdrs->x_handy += len;
+ return TRUE;
+}
+
+#ifdef GF_DARWIN_HOST_OS
+static u_int
+x_getpostn (XDR *xdrs)
+{
+ return xdrs->x_handy;
+}
+#else
+static u_int
+x_getpostn (const XDR *xdrs)
+{
+ return xdrs->x_handy;
+}
+#endif
+
+/* ARGSUSED */
+static bool_t
+x_setpostn (XDR *xdrs, u_int len)
+{
+ /* This is not allowed */
+ return FALSE;
+}
+
+static int32_t *
+x_inline (XDR *xdrs, u_int len)
+{
+ if (len == 0)
+ return NULL;
+ if (xdrs->x_op != XDR_ENCODE)
+ return NULL;
+ if (len < (u_int) (long int) xdrs->x_base)
+ {
+ /* x_private was already allocated */
+ xdrs->x_handy += len;
+ return (int32_t *) xdrs->x_private;
+ }
+ else
+ {
+ /* Free the earlier space and allocate new area */
+ free (xdrs->x_private);
+ if ((xdrs->x_private = (caddr_t) malloc (len)) == NULL)
+ {
+ xdrs->x_base = 0;
+ return NULL;
+ }
+ xdrs->x_base = (void *) (long) len;
+ xdrs->x_handy += len;
+ return (int32_t *) xdrs->x_private;
+ }
+}
+
+static int
+harmless (void)
+{
+ /* Always return FALSE/NULL, as the case may be */
+ return 0;
+}
+
+static void
+x_destroy (XDR *xdrs)
+{
+ xdrs->x_handy = 0;
+ xdrs->x_base = 0;
+ if (xdrs->x_private)
+ {
+ free (xdrs->x_private);
+ xdrs->x_private = NULL;
+ }
+ return;
+}
+
+unsigned long
+xdr_sizeof (xdrproc_t func, void *data)
+{
+ XDR x;
+ struct xdr_ops ops;
+ bool_t stat;
+
+#ifdef GF_DARWIN_HOST_OS
+ typedef bool_t (*dummyfunc1) (XDR *, int *);
+#else
+ typedef bool_t (*dummyfunc1) (XDR *, long *);
+#endif
+ typedef bool_t (*dummyfunc2) (XDR *, caddr_t, u_int);
+
+ ops.x_putlong = x_putlong;
+ ops.x_putbytes = x_putbytes;
+ ops.x_inline = x_inline;
+ ops.x_getpostn = x_getpostn;
+ ops.x_setpostn = x_setpostn;
+ ops.x_destroy = x_destroy;
+
+ /* the other harmless ones */
+ ops.x_getlong = (dummyfunc1) harmless;
+ ops.x_getbytes = (dummyfunc2) harmless;
+
+ x.x_op = XDR_ENCODE;
+ x.x_ops = &ops;
+ x.x_handy = 0;
+ x.x_private = (caddr_t) NULL;
+ x.x_base = (caddr_t) 0;
+
+ stat = func (&x, data, 0);
+ if (x.x_private)
+ free (x.x_private);
+ return (stat == TRUE ? (unsigned) x.x_handy : 0);
+}
+#endif /* GF_DARWIN_HOST_OS */
diff --git a/contrib/uuid/gen_uuid.c b/contrib/uuid/gen_uuid.c
index b3eda9de387..79923cd542f 100644
--- a/contrib/uuid/gen_uuid.c
+++ b/contrib/uuid/gen_uuid.c
@@ -44,6 +44,18 @@
#include <windows.h>
#define UUID MYUUID
#endif
+
+#ifdef __APPLE__
+#define PRI_TIME "ld"
+#define PRI_TIME_USEC "d"
+#define SCAN_TIME "lu"
+#else
+#define PRI_TIME "lu"
+#define PRI_TIME_USEC "lu"
+#define SCAN_TIME "ld"
+#endif
+
+
#include <stdio.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
@@ -354,8 +366,7 @@ static int get_clock(uint32_t *clock_high, uint32_t *clock_low,
unsigned int cl;
unsigned long tv1, tv2;
int a;
-
- if (fscanf(state_f, "clock: %04x tv: %lu %lu adj: %d\n",
+ if (fscanf(state_f, "clock: %04x tv: %" SCAN_TIME " %" SCAN_TIME " adj: %d\n",
&cl, &tv1, &tv2, &a) == 4) {
clock_seq = cl & 0x3FFF;
last.tv_sec = tv1;
@@ -404,7 +415,7 @@ try_again:
if (state_fd > 0) {
rewind(state_f);
len = fprintf(state_f,
- "clock: %04x tv: %016lu %08lu adj: %08d\n",
+ "clock: %04x tv: %016" PRI_TIME "%08" PRI_TIME_USEC "adj: %08d\n",
clock_seq, last.tv_sec, last.tv_usec, adjustment);
fflush(state_f);
if (ftruncate(state_fd, len) < 0) {
diff --git a/contrib/uuid/uuid_time.c b/contrib/uuid/uuid_time.c
index f25f5c90fe5..ccaa542fed0 100644
--- a/contrib/uuid/uuid_time.c
+++ b/contrib/uuid/uuid_time.c
@@ -52,6 +52,7 @@
#include <time.h>
#include "uuidP.h"
+#include "logging.h"
time_t uuid_time(const uuid_t uu, struct timeval *ret_tv)
{
@@ -163,8 +164,7 @@ main(int argc, char **argv)
printf("Warning: not a time-based UUID, so UUID time "
"decoding will likely not work!\n");
}
- printf("UUID time is: (%ld, %ld): %s\n", tv.tv_sec, tv.tv_usec,
- ctime(&time_reg));
+ printf("UUID time is: (%" GF_PRI_SECOND ", %" GF_PRI_USEC "): %s\n", tv.tv_sec, tv.tv_usec, ctime(&time_reg));
return 0;
}