summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--api/src/glfs-fops.c2
-rwxr-xr-xbuild-aux/xdrgen2
-rw-r--r--configure.ac61
-rw-r--r--contrib/fuse-include/fuse_kernel_macfuse.h470
-rw-r--r--contrib/fuse-lib/mount-common.c15
-rw-r--r--contrib/fuse-lib/mount-gluster-compat.h11
-rw-r--r--contrib/fuse-lib/mount.c87
-rw-r--r--contrib/libexecinfo/execinfo.c442
-rw-r--r--contrib/libexecinfo/execinfo_compat.h51
-rw-r--r--contrib/mount/mntent.c6
-rw-r--r--contrib/mount/mntent_compat.h2
-rw-r--r--contrib/qemu/include/qemu/bswap.h2
-rw-r--r--contrib/qemu/util/oslib-posix.c4
-rw-r--r--extras/geo-rep/Makefile.am2
-rw-r--r--extras/init.d/Makefile.am8
-rw-r--r--extras/init.d/glusterd-FreeBSD.in24
-rw-r--r--libglusterfs/src/Makefile.am13
-rw-r--r--libglusterfs/src/common-utils.c89
-rw-r--r--libglusterfs/src/common-utils.h7
-rw-r--r--libglusterfs/src/compat.h7
-rw-r--r--libglusterfs/src/logging.c14
-rw-r--r--libglusterfs/src/store.h1
-rw-r--r--libglusterfs/src/syscall.c2
-rw-r--r--rpc/rpc-lib/src/xdr-rpc.c2
-rw-r--r--rpc/rpc-transport/socket/src/socket.c2
-rw-r--r--xlators/cluster/dht/src/dht-common.c1
-rw-r--r--xlators/cluster/dht/src/dht-rebalance.c1
-rw-r--r--xlators/encryption/crypt/src/crypt.h2
-rw-r--r--xlators/features/protect/src/Makefile.am6
-rw-r--r--xlators/features/protect/src/prot_client.c44
-rw-r--r--xlators/meta/src/meta-defaults.c1
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-quota.c2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapshot.c11
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c9
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-ops.c2
-rw-r--r--xlators/mount/fuse/src/fuse-bridge.c2
-rw-r--r--xlators/mount/fuse/src/fuse-bridge.h4
-rw-r--r--xlators/mount/fuse/src/fuse-helpers.c33
-rw-r--r--xlators/mount/fuse/utils/Makefile.am9
-rw-r--r--xlators/performance/md-cache/src/md-cache.c1
-rw-r--r--xlators/storage/posix/src/posix-handle.c2
-rw-r--r--xlators/storage/posix/src/posix-helpers.c12
-rw-r--r--xlators/storage/posix/src/posix.c4
45 files changed, 1030 insertions, 445 deletions
diff --git a/.gitignore b/.gitignore
index bb194295576..2a986c13ff5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,6 +37,7 @@ contrib/uuid/uuid_types.h
extras/init.d/glusterd-Debian
extras/init.d/glusterd-Redhat
extras/init.d/glusterd-SuSE
+extras/init.d/glusterd-FreeBSD
extras/init.d/glusterd.plist
extras/systemd/glusterd.service
extras/ocf/glusterd
diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c
index d5f65272c8b..535dad3fea1 100644
--- a/api/src/glfs-fops.c
+++ b/api/src/glfs-fops.c
@@ -1,3 +1,4 @@
+
/*
Copyright (c) 2012 Red Hat, Inc. <http://www.redhat.com>
This file is part of GlusterFS.
@@ -13,6 +14,7 @@
#include "glfs-mem-types.h"
#include "syncop.h"
#include "glfs.h"
+#include "compat-errno.h"
#include <limits.h>
#ifdef NAME_MAX
diff --git a/build-aux/xdrgen b/build-aux/xdrgen
index a2240a235a2..c2a7a781d58 100755
--- a/build-aux/xdrgen
+++ b/build-aux/xdrgen
@@ -23,11 +23,13 @@ append_licence_header ()
#if defined(__GNUC__)
#if __GNUC__ >= 4
#if !defined(__clang__)
+#if !defined(__NetBSD__)
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif
#endif
#endif
+#endif
EOF
diff --git a/configure.ac b/configure.ac
index 2c69ccdc1c3..2a653bd67e0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -170,6 +170,7 @@ AC_CONFIG_FILES([Makefile
extras/init.d/glusterd.plist
extras/init.d/glusterd-Debian
extras/init.d/glusterd-Redhat
+ extras/init.d/glusterd-FreeBSD
extras/init.d/glusterd-SuSE
extras/systemd/Makefile
extras/systemd/glusterd.service
@@ -436,10 +437,10 @@ AC_ARG_ENABLE([fusermount],
BUILD_FUSERMOUNT="yes"
if test "x$enable_fusermount" = "xno"; then
- BUILD_FUSERMOUNT="no"
+ BUILD_FUSERMOUNT="no"
else
- AC_DEFINE(GF_FUSERMOUNT, 1, [Use our own fusermount])
- FUSERMOUNT_SUBDIR="contrib/fuse-util"
+ AC_DEFINE(GF_FUSERMOUNT, 1, [Use our own fusermount])
+ FUSERMOUNT_SUBDIR="contrib/fuse-util"
fi
AC_SUBST(FUSERMOUNT_SUBDIR)
@@ -639,18 +640,14 @@ else
fi
# end of xml-output
-dnl FreeBSD > 5 has execinfo as a Ported library for giving a workaround
-dnl solution to GCC backtrace functionality
-
-AC_CHECK_HEADERS([execinfo.h], [have_backtrace=yes],
- AC_CHECK_LIB([execinfo], [backtrace], [have_backtrace=yes]))
-dnl AC_MSG_ERROR([libexecinfo not found libexecinfo required.])))
-
+AC_CHECK_HEADERS([execinfo.h], [have_backtrace=yes])
if test "x${have_backtrace}" = "xyes"; then
AC_DEFINE(HAVE_BACKTRACE, 1, [define if found backtrace])
fi
AC_SUBST(HAVE_BACKTRACE)
+AC_CHECK_LIB([m], [ceil], , AC_MSG_ERROR([glibc math package missing - required]))
+
dnl glusterfs prints memory usage to stderr by sending it SIGUSR1
AC_CHECK_FUNC([malloc_stats], [have_malloc_stats=yes])
if test "x${have_malloc_stats}" = "xyes"; then
@@ -774,9 +771,23 @@ AC_COMPILE_IFELSE(
AC_MSG_RESULT([$CLANG])
if test "x$CLANG" = "xyes"; then
- GF_COMPILER_FLAGS="-Wno-gnu -Wno-deprecated-declarations -Wno-enum-conversion"
+ GF_COMPILER_FLAGS="-Wno-gnu"
fi
+if test "x$ac_cv_header_execinfo_h" = "xno"; then
+ # The reason is that __builtin_frame_address(n) for n > 0 seems
+ # to just crash on most platforms when -fomit-stack-pointer is
+ # specified, which seems to be the default for many platforms on
+ # -O2. The documentation says that __builtin_frame_address()
+ # should return NULL in case it can't get the frame, but it
+ # seems to crash instead.
+
+ # execinfo.c in ./contrib/libexecinfo uses __builtin_frame_address(n)
+ # for providing cross platform backtrace*() functions.
+ if test "x$CLANG" = "xno"; then
+ CFLAGS="$CFLAGS -fno-omit-frame-pointer"
+ fi
+fi
case $host_os in
linux*)
@@ -799,6 +810,7 @@ case $host_os in
GF_CFLAGS="${ARGP_STANDALONE_CPPFLAGS} -D_INCOMPLETE_XOPEN_C063"
GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_BASENAME"
GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_DIRNAME"
+ GF_FUSE_CFLAGS="-DFUSERMOUNT_DIR=\\\"\$(sbindir)\\\""
GF_LDADD="${ARGP_STANDALONE_LDADD}"
if test "x$ac_cv_header_execinfo_h" = "xyes"; then
GF_GLUSTERFS_LIBS="-lexecinfo"
@@ -806,17 +818,34 @@ case $host_os in
GF_FUSE_LDADD="-lperfuse"
BUILD_FUSE_CLIENT=yes
LEXLIB=""
+ BUILD_FUSERMOUNT=no
+ FUSERMOUNT_SUBDIR=""
;;
- *bsd*)
+ *freebsd*)
GF_HOST_OS="GF_BSD_HOST_OS"
- GF_CFLAGS="${ARGP_STANDALONE_CPPFLAGS}"
+ GF_CFLAGS="${ARGP_STANDALONE_CPPFLAGS} -O0"
GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_BASENAME"
GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_DIRNAME"
- GF_LDADD="${ARGP_STANDALONE_LDADD}"
+ GF_CFLAGS="${GF_CFLAGS} -D_LIBGEN_H_"
+ GF_CFLAGS="${GF_CFLAGS} -DO_DSYNC=0"
+ GF_CFLAGS="${GF_CFLAGS} -Dxdr_quad_t=xdr_longlong_t"
+ GF_CFLAGS="${GF_CFLAGS} -Dxdr_u_quad_t=xdr_u_longlong_t"
+ GF_GLUSTERFS_CFLAGS="${GF_CFLAGS}"
+ GF_FUSE_CFLAGS="-DFUSERMOUNT_DIR=\\\"\$(sbindir)\\\""
+ GF_FUSE_LIBS="${GF_FUSE_LIBS} /usr/lib/libutil.so"
+ GF_FUSE_LDADD="-lutil"
+ GF_CFLAGS=" -I/usr/local/include ${GF_CFLAGS}"
+ CFLAGS=" -std=gnu89 ${CFLAGS}"
+ GF_CFLAGS=" -std=gnu89 ${GF_CFLAGS}"
+ GF_GLUSTERFS_CFLAGS="${GF_CFLAGS}"
+ GF_LDADD="${ARGP_STANDALONE_LDADD} /usr/local/lib/libpython2.7.so /usr/local/lib/libintl.so"
+ LDFLAGS="${LDFLAGS} -L/usr/local/lib"
if test "x$ac_cv_header_execinfo_h" = "xyes"; then
GF_GLUSTERFS_LIBS="-lexecinfo"
fi
- BUILD_FUSE_CLIENT=no
+ BUILD_FUSERMOUNT=no
+ BUILD_QEMU_BLOCK=no
+ FUSERMOUNT_SUBDIR=""
;;
darwin*)
GF_HOST_OS="GF_DARWIN_HOST_OS"
@@ -994,7 +1023,9 @@ GF_CPPINCLUDES='-I$(top_srcdir)/libglusterfs/src -I$(CONTRIBDIR)/uuid'
GF_CPPFLAGS="$GF_CPPDEFINES $GF_CPPINCLUDES"
AC_SUBST([GF_CPPFLAGS])
+AM_CONDITIONAL([GF_LINUX_HOST_OS], test "${GF_HOST_OS}" = "GF_LINUX_HOST_OS")
AM_CONDITIONAL([GF_DARWIN_HOST_OS], test "${GF_HOST_OS}" = "GF_DARWIN_HOST_OS")
+AM_CONDITIONAL([GF_BSD_HOST_OS], test "${GF_HOST_OS}" = "GF_BSD_HOST_OS")
AM_CONDITIONAL([GF_INSTALL_VAR_LIB_GLUSTERD], test ! -d ${localstatedir}/lib/glusterd && test -d ${sysconfdir}/glusterd )
diff --git a/contrib/fuse-include/fuse_kernel_macfuse.h b/contrib/fuse-include/fuse_kernel_macfuse.h
index a003f825a70..31bc495a552 100644
--- a/contrib/fuse-include/fuse_kernel_macfuse.h
+++ b/contrib/fuse-include/fuse_kernel_macfuse.h
@@ -61,67 +61,59 @@
userspace works under 64bit kernels */
struct fuse_attr {
- __u64 ino;
- __u64 size;
- __u64 blocks;
- __u64 atime;
- __u64 mtime;
- __u64 ctime;
-#if (__FreeBSD__ >= 10)
- __u64 crtime;
-#endif /* __FreeBSD__ >= 10 */
- __u32 atimensec;
- __u32 mtimensec;
- __u32 ctimensec;
-#if (__FreeBSD__ >= 10)
- __u32 crtimensec;
-#endif /* __FreeBSD__ >= 10 */
- __u32 mode;
- __u32 nlink;
- __u32 uid;
- __u32 gid;
- __u32 rdev;
-#if (__FreeBSD__ >= 10)
- __u32 flags; /* file flags; see chflags(2) */
-#endif /* __FreeBSD__ >= 10 */
+ __u64 ino;
+ __u64 size;
+ __u64 blocks;
+ __u64 atime;
+ __u64 mtime;
+ __u64 ctime;
+ __u64 crtime;
+ __u32 atimensec;
+ __u32 mtimensec;
+ __u32 ctimensec;
+ __u32 crtimensec;
+ __u32 mode;
+ __u32 nlink;
+ __u32 uid;
+ __u32 gid;
+ __u32 rdev;
+ __u32 flags; /* file flags; see chflags(2) */
};
struct fuse_kstatfs {
- __u64 blocks;
- __u64 bfree;
- __u64 bavail;
- __u64 files;
- __u64 ffree;
- __u32 bsize;
- __u32 namelen;
- __u32 frsize;
- __u32 padding;
- __u32 spare[6];
+ __u64 blocks;
+ __u64 bfree;
+ __u64 bavail;
+ __u64 files;
+ __u64 ffree;
+ __u32 bsize;
+ __u32 namelen;
+ __u32 frsize;
+ __u32 padding;
+ __u32 spare[6];
};
struct fuse_file_lock {
- __u64 start;
- __u64 end;
- __u32 type;
- __u32 pid; /* tgid */
+ __u64 start;
+ __u64 end;
+ __u32 type;
+ __u32 pid; /* tgid */
};
/**
* Bitmasks for fuse_setattr_in.valid
*/
-#define FATTR_MODE (1 << 0)
-#define FATTR_UID (1 << 1)
-#define FATTR_GID (1 << 2)
-#define FATTR_SIZE (1 << 3)
-#define FATTR_ATIME (1 << 4)
-#define FATTR_MTIME (1 << 5)
-#define FATTR_FH (1 << 6)
-#if (__FreeBSD__ >= 10)
-#define FATTR_CRTIME (1 << 28)
-#define FATTR_CHGTIME (1 << 29)
-#define FATTR_BKUPTIME (1 << 30)
-#define FATTR_FLAGS (1 << 31)
-#endif /* __FreeBSD__ >= 10 */
+#define FATTR_MODE (1 << 0)
+#define FATTR_UID (1 << 1)
+#define FATTR_GID (1 << 2)
+#define FATTR_SIZE (1 << 3)
+#define FATTR_ATIME (1 << 4)
+#define FATTR_MTIME (1 << 5)
+#define FATTR_FH (1 << 6)
+#define FATTR_CRTIME (1 << 28)
+#define FATTR_CHGTIME (1 << 29)
+#define FATTR_BKUPTIME (1 << 30)
+#define FATTR_FLAGS (1 << 31)
/**
* Flags returned by the OPEN request
@@ -129,320 +121,304 @@ struct fuse_file_lock {
* FOPEN_DIRECT_IO: bypass page cache for this open file
* FOPEN_KEEP_CACHE: don't invalidate the data cache on open
*/
-#define FOPEN_DIRECT_IO (1 << 0)
-#define FOPEN_KEEP_CACHE (1 << 1)
-#if (__FreeBSD__ >= 10)
-#define FOPEN_PURGE_ATTR (1 << 30)
-#define FOPEN_PURGE_UBC (1 << 31)
-#endif
+#define FOPEN_DIRECT_IO (1 << 0)
+#define FOPEN_KEEP_CACHE (1 << 1)
+#define FOPEN_PURGE_ATTR (1 << 30)
+#define FOPEN_PURGE_UBC (1 << 31)
/**
* INIT request/reply flags
*/
-#define FUSE_ASYNC_READ (1 << 0)
-#define FUSE_POSIX_LOCKS (1 << 1)
-#if (__FreeBSD__ >= 10)
-#define FUSE_CASE_INSENSITIVE (1 << 29)
-#define FUSE_VOL_RENAME (1 << 30)
-#define FUSE_XTIMES (1 << 31)
-#endif /* __FreeBSD__ >= 10 */
+#define FUSE_ASYNC_READ (1 << 0)
+#define FUSE_POSIX_LOCKS (1 << 1)
+#define FUSE_CASE_INSENSITIVE (1 << 29)
+#define FUSE_VOL_RENAME (1 << 30)
+#define FUSE_XTIMES (1 << 31)
/**
* Release flags
*/
-#define FUSE_RELEASE_FLUSH (1 << 0)
+#define FUSE_RELEASE_FLUSH (1 << 0)
enum fuse_opcode {
- FUSE_LOOKUP = 1,
- FUSE_FORGET = 2, /* no reply */
- FUSE_GETATTR = 3,
- FUSE_SETATTR = 4,
- FUSE_READLINK = 5,
- FUSE_SYMLINK = 6,
- FUSE_MKNOD = 8,
- FUSE_MKDIR = 9,
- FUSE_UNLINK = 10,
- FUSE_RMDIR = 11,
- FUSE_RENAME = 12,
- FUSE_LINK = 13,
- FUSE_OPEN = 14,
- FUSE_READ = 15,
- FUSE_WRITE = 16,
- FUSE_STATFS = 17,
- FUSE_RELEASE = 18,
- FUSE_FSYNC = 20,
- FUSE_SETXATTR = 21,
- FUSE_GETXATTR = 22,
- FUSE_LISTXATTR = 23,
- FUSE_REMOVEXATTR = 24,
- FUSE_FLUSH = 25,
- FUSE_INIT = 26,
- FUSE_OPENDIR = 27,
- FUSE_READDIR = 28,
- FUSE_RELEASEDIR = 29,
- FUSE_FSYNCDIR = 30,
- FUSE_GETLK = 31,
- FUSE_SETLK = 32,
- FUSE_SETLKW = 33,
- FUSE_ACCESS = 34,
- FUSE_CREATE = 35,
- 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_LOOKUP = 1,
+ FUSE_FORGET = 2, /* no reply */
+ FUSE_GETATTR = 3,
+ FUSE_SETATTR = 4,
+ FUSE_READLINK = 5,
+ FUSE_SYMLINK = 6,
+ FUSE_MKNOD = 8,
+ FUSE_MKDIR = 9,
+ FUSE_UNLINK = 10,
+ FUSE_RMDIR = 11,
+ FUSE_RENAME = 12,
+ FUSE_LINK = 13,
+ FUSE_OPEN = 14,
+ FUSE_READ = 15,
+ FUSE_WRITE = 16,
+ FUSE_STATFS = 17,
+ FUSE_RELEASE = 18,
+ FUSE_FSYNC = 20,
+ FUSE_SETXATTR = 21,
+ FUSE_GETXATTR = 22,
+ FUSE_LISTXATTR = 23,
+ FUSE_REMOVEXATTR = 24,
+ FUSE_FLUSH = 25,
+ FUSE_INIT = 26,
+ FUSE_OPENDIR = 27,
+ FUSE_READDIR = 28,
+ FUSE_RELEASEDIR = 29,
+ FUSE_FSYNCDIR = 30,
+ FUSE_GETLK = 31,
+ FUSE_SETLK = 32,
+ FUSE_SETLKW = 33,
+ FUSE_ACCESS = 34,
+ FUSE_CREATE = 35,
+ 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,
+ */
+
FUSE_SETVOLNAME = 61,
- FUSE_GETXTIMES = 62,
- FUSE_EXCHANGE = 63,
-#endif /* __FreeBSD__ >= 10 */
+ FUSE_GETXTIMES = 62,
+ FUSE_EXCHANGE = 63,
};
/* The read buffer is required to be at least 8k, but may be much larger */
#define FUSE_MIN_READ_BUFFER 8192
struct fuse_entry_out {
- __u64 nodeid; /* Inode ID */
- __u64 generation; /* Inode generation: nodeid:gen must
- be unique for the fs's lifetime */
- __u64 entry_valid; /* Cache timeout for the name */
- __u64 attr_valid; /* Cache timeout for the attributes */
- __u32 entry_valid_nsec;
- __u32 attr_valid_nsec;
- struct fuse_attr attr;
+ __u64 nodeid; /* Inode ID */
+ __u64 generation; /* Inode generation: nodeid:gen must
+ be unique for the fs's lifetime */
+ __u64 entry_valid; /* Cache timeout for the name */
+ __u64 attr_valid; /* Cache timeout for the attributes */
+ __u32 entry_valid_nsec;
+ __u32 attr_valid_nsec;
+ struct fuse_attr attr;
};
struct fuse_forget_in {
- __u64 nlookup;
+ __u64 nlookup;
};
struct fuse_attr_out {
- __u64 attr_valid; /* Cache timeout for the attributes */
- __u32 attr_valid_nsec;
- __u32 dummy;
- struct fuse_attr attr;
+ __u64 attr_valid; /* Cache timeout for the attributes */
+ __u32 attr_valid_nsec;
+ __u32 dummy;
+ struct fuse_attr attr;
};
-#if (__FreeBSD__ >= 10)
struct fuse_getxtimes_out {
- __u64 bkuptime;
- __u64 crtime;
- __u32 bkuptimensec;
- __u32 crtimensec;
+ __u64 bkuptime;
+ __u64 crtime;
+ __u32 bkuptimensec;
+ __u32 crtimensec;
};
-#endif /* __FreeBSD__ >= 10 */
struct fuse_mknod_in {
- __u32 mode;
- __u32 rdev;
+ __u32 mode;
+ __u32 rdev;
};
struct fuse_mkdir_in {
- __u32 mode;
- __u32 padding;
+ __u32 mode;
+ __u32 padding;
};
struct fuse_rename_in {
- __u64 newdir;
+ __u64 newdir;
};
-#if (__FreeBSD__ >= 10)
struct fuse_exchange_in {
- __u64 olddir;
- __u64 newdir;
- __u64 options;
+ __u64 olddir;
+ __u64 newdir;
+ __u64 options;
};
-#endif /* __FreeBSD__ >= 10 */
struct fuse_link_in {
- __u64 oldnodeid;
+ __u64 oldnodeid;
};
struct fuse_setattr_in {
- __u32 valid;
- __u32 padding;
- __u64 fh;
- __u64 size;
- __u64 unused1;
- __u64 atime;
- __u64 mtime;
- __u64 unused2;
- __u32 atimensec;
- __u32 mtimensec;
- __u32 unused3;
- __u32 mode;
- __u32 unused4;
- __u32 uid;
- __u32 gid;
- __u32 unused5;
-#if (__FreeBSD__ >= 10)
- __u64 bkuptime;
- __u64 chgtime;
- __u64 crtime;
- __u32 bkuptimensec;
- __u32 chgtimensec;
- __u32 crtimensec;
- __u32 flags; /* file flags; see chflags(2) */
-#endif /* __FreeBSD__ >= 10 */
+ __u32 valid;
+ __u32 padding;
+ __u64 fh;
+ __u64 size;
+ __u64 unused1;
+ __u64 atime;
+ __u64 mtime;
+ __u64 unused2;
+ __u32 atimensec;
+ __u32 mtimensec;
+ __u32 unused3;
+ __u32 mode;
+ __u32 unused4;
+ __u32 uid;
+ __u32 gid;
+ __u32 unused5;
+ __u64 bkuptime;
+ __u64 chgtime;
+ __u64 crtime;
+ __u32 bkuptimensec;
+ __u32 chgtimensec;
+ __u32 crtimensec;
+ __u32 flags; /* file flags; see chflags(2) */
};
struct fuse_open_in {
- __u32 flags;
- __u32 mode;
+ __u32 flags;
+ __u32 mode;
};
struct fuse_open_out {
- __u64 fh;
- __u32 open_flags;
- __u32 padding;
+ __u64 fh;
+ __u32 open_flags;
+ __u32 padding;
};
struct fuse_release_in {
- __u64 fh;
- __u32 flags;
- __u32 release_flags;
- __u64 lock_owner;
+ __u64 fh;
+ __u32 flags;
+ __u32 release_flags;
+ __u64 lock_owner;
};
struct fuse_flush_in {
- __u64 fh;
- __u32 unused;
- __u32 padding;
- __u64 lock_owner;
+ __u64 fh;
+ __u32 unused;
+ __u32 padding;
+ __u64 lock_owner;
};
struct fuse_read_in {
- __u64 fh;
- __u64 offset;
- __u32 size;
- __u32 padding;
+ __u64 fh;
+ __u64 offset;
+ __u32 size;
+ __u32 padding;
};
struct fuse_write_in {
- __u64 fh;
- __u64 offset;
- __u32 size;
- __u32 write_flags;
+ __u64 fh;
+ __u64 offset;
+ __u32 size;
+ __u32 write_flags;
};
struct fuse_write_out {
- __u32 size;
- __u32 padding;
+ __u32 size;
+ __u32 padding;
};
#define FUSE_COMPAT_STATFS_SIZE 48
struct fuse_statfs_out {
- struct fuse_kstatfs st;
+ struct fuse_kstatfs st;
};
struct fuse_fsync_in {
- __u64 fh;
- __u32 fsync_flags;
- __u32 padding;
+ __u64 fh;
+ __u32 fsync_flags;
+ __u32 padding;
};
struct fuse_setxattr_in {
- __u32 size;
- __u32 flags;
-#if (__FreeBSD__ >= 10)
- __u32 position;
- __u32 padding;
-#endif /* __FreeBSD__ >= 10 */
+ __u32 size;
+ __u32 flags;
+ __u32 position;
+ __u32 padding;
};
struct fuse_getxattr_in {
- __u32 size;
- __u32 padding;
-#if (__FreeBSD__ >= 10)
- __u32 position;
- __u32 padding2;
-#endif /* __FreeBSD__ >= 10 */
+ __u32 size;
+ __u32 padding;
+ __u32 position;
+ __u32 padding2;
};
struct fuse_getxattr_out {
- __u32 size;
- __u32 padding;
+ __u32 size;
+ __u32 padding;
};
struct fuse_lk_in {
- __u64 fh;
- __u64 owner;
- struct fuse_file_lock lk;
+ __u64 fh;
+ __u64 owner;
+ struct fuse_file_lock lk;
};
struct fuse_lk_out {
- struct fuse_file_lock lk;
+ struct fuse_file_lock lk;
};
struct fuse_access_in {
- __u32 mask;
- __u32 padding;
+ __u32 mask;
+ __u32 padding;
};
struct fuse_init_in {
- __u32 major;
- __u32 minor;
- __u32 max_readahead;
- __u32 flags;
+ __u32 major;
+ __u32 minor;
+ __u32 max_readahead;
+ __u32 flags;
};
struct fuse_init_out {
- __u32 major;
- __u32 minor;
- __u32 max_readahead;
- __u32 flags;
- __u32 unused;
- __u32 max_write;
+ __u32 major;
+ __u32 minor;
+ __u32 max_readahead;
+ __u32 flags;
+ __u32 unused;
+ __u32 max_write;
};
struct fuse_interrupt_in {
- __u64 unique;
+ __u64 unique;
};
struct fuse_bmap_in {
- __u64 block;
- __u32 blocksize;
- __u32 padding;
+ __u64 block;
+ __u32 blocksize;
+ __u32 padding;
};
struct fuse_bmap_out {
- __u64 block;
+ __u64 block;
};
struct fuse_in_header {
- __u32 len;
- __u32 opcode;
- __u64 unique;
- __u64 nodeid;
- __u32 uid;
- __u32 gid;
- __u32 pid;
- __u32 padding;
+ __u32 len;
+ __u32 opcode;
+ __u64 unique;
+ __u64 nodeid;
+ __u32 uid;
+ __u32 gid;
+ __u32 pid;
+ __u32 padding;
};
struct fuse_out_header {
- __u32 len;
- __s32 error;
- __u64 unique;
+ __u32 len;
+ __s32 error;
+ __u64 unique;
};
struct fuse_dirent {
- __u64 ino;
- __u64 off;
- __u32 namelen;
- __u32 type;
- char name[0];
+ __u64 ino;
+ __u64 off;
+ __u32 namelen;
+ __u32 type;
+ char name[0];
};
#define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name)
#define FUSE_DIRENT_ALIGN(x) (((x) + sizeof(__u64) - 1) & ~(sizeof(__u64) - 1))
#define FUSE_DIRENT_SIZE(d) \
- FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)
+ FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)
diff --git a/contrib/fuse-lib/mount-common.c b/contrib/fuse-lib/mount-common.c
index fd6cce44e3d..cd226fa3141 100644
--- a/contrib/fuse-lib/mount-common.c
+++ b/contrib/fuse-lib/mount-common.c
@@ -23,7 +23,7 @@
* see the commit log and per-function comments.
*/
-#ifndef __NetBSD__
+#ifdef GF_LINUX_HOST_OS
/* FUSE: cherry-picked bd99f9cf */
static int
mtab_needs_update (const char *mnt)
@@ -69,9 +69,9 @@ mtab_needs_update (const char *mnt)
return 1;
}
-#else /* __NetBSD__ */
+#else /* GF_LINUX_HOST_OS */
#define mtab_needs_update(x) 1
-#endif /* __NetBSD__ */
+#endif /* GF_LINUX_HOST_OS */
/* FUSE: called add_mount_legacy(); R.I.P. as of cbd3a2a8 */
int
@@ -246,10 +246,17 @@ fuse_mnt_umount (const char *progname, const char *abs_mnt,
if (res == 0) {
sigprocmask (SIG_SETMASK, &oldmask, NULL);
setuid (geteuid ());
+#ifdef GF_LINUX_HOST_OS
execl ("/bin/umount", "/bin/umount", "-i", rel_mnt,
- lazy ? "-l" : NULL, NULL);
+ lazy ? "-l" : NULL, NULL);
GFFUSE_LOGERR ("%s: failed to execute /bin/umount: %s",
progname, strerror (errno));
+#else
+ execl ("/sbin/umount", "/sbin/umount", rel_mnt,
+ lazy ? "-l" : NULL, NULL);
+ GFFUSE_LOGERR ("%s: failed to execute /sbin/umount: %s",
+ progname, strerror (errno));
+#endif /* GF_LINUX_HOST_OS */
exit (1);
}
res = waitpid (res, &status, 0);
diff --git a/contrib/fuse-lib/mount-gluster-compat.h b/contrib/fuse-lib/mount-gluster-compat.h
index 1f76241ab1c..562f089dd1f 100644
--- a/contrib/fuse-lib/mount-gluster-compat.h
+++ b/contrib/fuse-lib/mount-gluster-compat.h
@@ -21,32 +21,31 @@
#include <errno.h>
#include <dirent.h>
#include <signal.h>
-#if !defined(__NetBSD__) && !defined(GF_DARWIN_HOST_OS)
+#if defined(GF_LINUX_HOST_OS)
#include <mntent.h>
-#endif /* __NetBSD__ */
+#endif /* GF_LINUX_HOST_OS */
#include <sys/stat.h>
#include <sys/poll.h>
#include <sys/un.h>
#include <sys/wait.h>
#include <sys/mount.h>
-#ifdef __NetBSD__
+#if defined(__NetBSD__)
#include <perfuse.h>
#define umount2(dir, flags) unmount(dir, ((flags) != 0) ? MNT_FORCE : 0)
#define MS_RDONLY MNT_RDONLY
#endif
-#ifdef GF_DARWIN_HOST_OS
+#if defined(GF_DARWIN_HOST_OS) || defined(__FreeBSD__)
#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 */
+#else /* FreeBSD, NetBSD, MacOS X */
#define _PATH_MOUNT "/sbin/mount"
#endif
diff --git a/contrib/fuse-lib/mount.c b/contrib/fuse-lib/mount.c
index 922d9e464db..a7fd94de464 100644
--- a/contrib/fuse-lib/mount.c
+++ b/contrib/fuse-lib/mount.c
@@ -17,6 +17,11 @@
#endif
#define FUSE_DEVFD_ENV "_FUSE_DEVFD"
+#ifdef __FreeBSD__
+#include <sys/types.h>
+#include <sys/uio.h>
+#include <unistd.h>
+#endif /* __FreeBSD__ */
/* FUSE: function is called fuse_kern_unmount() */
void
@@ -170,6 +175,55 @@ fuse_mount_fusermount (const char *mountpoint, char *fsname,
return ret;
}
+#if defined(__FreeBSD__)
+void
+build_iovec(struct iovec **iov, int *iovlen, const char *name, void *val,
+ size_t len)
+{
+ int i;
+ if (*iovlen < 0)
+ return;
+ i = *iovlen;
+
+ *iov = realloc(*iov, sizeof **iov * (i + 2));
+ if (*iov == NULL) {
+ *iovlen = -1;
+ return;
+ }
+
+ (*iov)[i].iov_base = strdup(name);
+ (*iov)[i].iov_len = strlen(name) + 1;
+
+ i++;
+ (*iov)[i].iov_base = val;
+ if (len == (size_t) -1) {
+ if (val != NULL)
+ len = strlen(val) + 1;
+ else
+ len = 0;
+ }
+ (*iov)[i].iov_len = (int)len;
+ *iovlen = ++i;
+}
+
+/*
+ * This function is needed for compatibility with parameters
+ * which used to use the mount_argf() command for the old mount() syscall.
+ */
+void
+build_iovec_argf(struct iovec **iov, int *iovlen, const char *name,
+ const char *fmt, ...)
+{
+ va_list ap;
+ char val[255] = { 0 };
+
+ va_start(ap, fmt);
+ vsnprintf(val, sizeof(val), fmt, ap);
+ va_end(ap);
+ build_iovec(iov, iovlen, name, strdup(val), (size_t)-1);
+}
+#endif /* __FreeBSD__ */
+
static int
fuse_mount_sys (const char *mountpoint, char *fsname,
unsigned long mountflags, char *mnt_param, int fd)
@@ -188,8 +242,24 @@ fuse_mount_sys (const char *mountpoint, char *fsname,
goto out;
}
+
+#ifdef __FreeBSD__
+ struct iovec *iov = NULL;
+ int iovlen = 0;
+ build_iovec (&iov, &iovlen, "fstype", "fusefs", -1);
+ build_iovec (&iov, &iovlen, "subtype", "glusterfs", -1);
+ build_iovec (&iov, &iovlen, "fspath", mountpoint, -1);
+ build_iovec (&iov, &iovlen, "from", "/dev/fuse", -1);
+ build_iovec (&iov, &iovlen, "volname", source, -1);
+ build_iovec_argf (&iov, &iovlen, "fd", "%d", fd);
+ build_iovec_argf (&iov, &iovlen, "user_id", "%d", getuid());
+ build_iovec_argf (&iov, &iovlen, "group_id", "%d", getgid());
+ ret = nmount (iov, iovlen, mountflags);
+#else
ret = mount (source, mountpoint, fstype, mountflags,
mnt_param_mnt);
+#endif /* __FreeBSD__ */
+#ifdef GF_LINUX_HOST_OS
if (ret == -1 && errno == ENODEV) {
/* fs subtype support was added by 79c0b2df aka
v2.6.21-3159-g79c0b2d. Probably we have an
@@ -204,12 +274,13 @@ fuse_mount_sys (const char *mountpoint, char *fsname,
ret = mount (source, mountpoint, fstype, mountflags,
mnt_param_mnt);
}
+#endif /* GF_LINUX_HOST_OS */
if (ret == -1)
goto out;
else
mounted = 1;
-#ifndef __NetBSD__
+#ifdef GF_LINUX_HOST_OS
if (geteuid () == 0) {
char *newmnt = fuse_mnt_resolve_path ("fuse", mountpoint);
char *mnt_param_mtab = NULL;
@@ -238,10 +309,11 @@ fuse_mount_sys (const char *mountpoint, char *fsname,
goto out;
}
}
-#endif /* __NetBSD__ */
+#endif /* GF_LINUX_HOST_OS */
out:
if (ret == -1) {
+ GFFUSE_LOGERR("ret = -1\n");
if (mounted)
umount2 (mountpoint, 2); /* lazy umount */
}
@@ -282,15 +354,16 @@ gf_fuse_mount (const char *mountpoint, char *fsname,
exit (pid == -1 ? 1 : 0);
}
- ret = fuse_mount_sys (mountpoint, fsname, mountflags, mnt_param, fd);
+ ret = fuse_mount_sys (mountpoint, fsname, mountflags, mnt_param,
+ fd);
if (ret == -1) {
gf_log ("glusterfs-fuse", GF_LOG_INFO,
- "direct mount failed (%s), "
+ "direct mount failed (%s) errno %d, "
"retry to mount via fusermount",
- strerror (errno));
+ strerror (errno), errno);
- ret = fuse_mount_fusermount (mountpoint, fsname, mountflags,
- mnt_param, fd);
+ ret = fuse_mount_fusermount (mountpoint, fsname,
+ mountflags, mnt_param, fd);
}
if (ret == -1)
diff --git a/contrib/libexecinfo/execinfo.c b/contrib/libexecinfo/execinfo.c
new file mode 100644
index 00000000000..03500257788
--- /dev/null
+++ b/contrib/libexecinfo/execinfo.c
@@ -0,0 +1,442 @@
+/*
+ * Copyright (c) 2003 Maxim Sobolev <sobomax@FreeBSD.org>
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ * $Id: execinfo.c,v 1.3 2004/07/19 05:21:09 sobomax Exp $
+ */
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef HAVE_BACKTRACE
+#include <sys/types.h>
+#include <sys/uio.h>
+#include <dlfcn.h>
+#include <math.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <stddef.h>
+
+#include "execinfo_compat.h"
+
+#define D10(x) ceil(log10(((x) == 0) ? 2 : ((x) + 1)))
+
+static void *
+getreturnaddr(int level)
+{
+ switch (level) {
+ case 0: return __builtin_return_address(1);
+ case 1: return __builtin_return_address(2);
+ case 2: return __builtin_return_address(3);
+ case 3: return __builtin_return_address(4);
+ case 4: return __builtin_return_address(5);
+ case 5: return __builtin_return_address(6);
+ case 6: return __builtin_return_address(7);
+ case 7: return __builtin_return_address(8);
+ case 8: return __builtin_return_address(9);
+ case 9: return __builtin_return_address(10);
+ case 10: return __builtin_return_address(11);
+ case 11: return __builtin_return_address(12);
+ case 12: return __builtin_return_address(13);
+ case 13: return __builtin_return_address(14);
+ case 14: return __builtin_return_address(15);
+ case 15: return __builtin_return_address(16);
+ case 16: return __builtin_return_address(17);
+ case 17: return __builtin_return_address(18);
+ case 18: return __builtin_return_address(19);
+ case 19: return __builtin_return_address(20);
+ case 20: return __builtin_return_address(21);
+ case 21: return __builtin_return_address(22);
+ case 22: return __builtin_return_address(23);
+ case 23: return __builtin_return_address(24);
+ case 24: return __builtin_return_address(25);
+ case 25: return __builtin_return_address(26);
+ case 26: return __builtin_return_address(27);
+ case 27: return __builtin_return_address(28);
+ case 28: return __builtin_return_address(29);
+ case 29: return __builtin_return_address(30);
+ case 30: return __builtin_return_address(31);
+ case 31: return __builtin_return_address(32);
+ case 32: return __builtin_return_address(33);
+ case 33: return __builtin_return_address(34);
+ case 34: return __builtin_return_address(35);
+ case 35: return __builtin_return_address(36);
+ case 36: return __builtin_return_address(37);
+ case 37: return __builtin_return_address(38);
+ case 38: return __builtin_return_address(39);
+ case 39: return __builtin_return_address(40);
+ case 40: return __builtin_return_address(41);
+ case 41: return __builtin_return_address(42);
+ case 42: return __builtin_return_address(43);
+ case 43: return __builtin_return_address(44);
+ case 44: return __builtin_return_address(45);
+ case 45: return __builtin_return_address(46);
+ case 46: return __builtin_return_address(47);
+ case 47: return __builtin_return_address(48);
+ case 48: return __builtin_return_address(49);
+ case 49: return __builtin_return_address(50);
+ case 50: return __builtin_return_address(51);
+ case 51: return __builtin_return_address(52);
+ case 52: return __builtin_return_address(53);
+ case 53: return __builtin_return_address(54);
+ case 54: return __builtin_return_address(55);
+ case 55: return __builtin_return_address(56);
+ case 56: return __builtin_return_address(57);
+ case 57: return __builtin_return_address(58);
+ case 58: return __builtin_return_address(59);
+ case 59: return __builtin_return_address(60);
+ case 60: return __builtin_return_address(61);
+ case 61: return __builtin_return_address(62);
+ case 62: return __builtin_return_address(63);
+ case 63: return __builtin_return_address(64);
+ case 64: return __builtin_return_address(65);
+ case 65: return __builtin_return_address(66);
+ case 66: return __builtin_return_address(67);
+ case 67: return __builtin_return_address(68);
+ case 68: return __builtin_return_address(69);
+ case 69: return __builtin_return_address(70);
+ case 70: return __builtin_return_address(71);
+ case 71: return __builtin_return_address(72);
+ case 72: return __builtin_return_address(73);
+ case 73: return __builtin_return_address(74);
+ case 74: return __builtin_return_address(75);
+ case 75: return __builtin_return_address(76);
+ case 76: return __builtin_return_address(77);
+ case 77: return __builtin_return_address(78);
+ case 78: return __builtin_return_address(79);
+ case 79: return __builtin_return_address(80);
+ case 80: return __builtin_return_address(81);
+ case 81: return __builtin_return_address(82);
+ case 82: return __builtin_return_address(83);
+ case 83: return __builtin_return_address(84);
+ case 84: return __builtin_return_address(85);
+ case 85: return __builtin_return_address(86);
+ case 86: return __builtin_return_address(87);
+ case 87: return __builtin_return_address(88);
+ case 88: return __builtin_return_address(89);
+ case 89: return __builtin_return_address(90);
+ case 90: return __builtin_return_address(91);
+ case 91: return __builtin_return_address(92);
+ case 92: return __builtin_return_address(93);
+ case 93: return __builtin_return_address(94);
+ case 94: return __builtin_return_address(95);
+ case 95: return __builtin_return_address(96);
+ case 96: return __builtin_return_address(97);
+ case 97: return __builtin_return_address(98);
+ case 98: return __builtin_return_address(99);
+ case 99: return __builtin_return_address(100);
+ case 100: return __builtin_return_address(101);
+ case 101: return __builtin_return_address(102);
+ case 102: return __builtin_return_address(103);
+ case 103: return __builtin_return_address(104);
+ case 104: return __builtin_return_address(105);
+ case 105: return __builtin_return_address(106);
+ case 106: return __builtin_return_address(107);
+ case 107: return __builtin_return_address(108);
+ case 108: return __builtin_return_address(109);
+ case 109: return __builtin_return_address(110);
+ case 110: return __builtin_return_address(111);
+ case 111: return __builtin_return_address(112);
+ case 112: return __builtin_return_address(113);
+ case 113: return __builtin_return_address(114);
+ case 114: return __builtin_return_address(115);
+ case 115: return __builtin_return_address(116);
+ case 116: return __builtin_return_address(117);
+ case 117: return __builtin_return_address(118);
+ case 118: return __builtin_return_address(119);
+ case 119: return __builtin_return_address(120);
+ case 120: return __builtin_return_address(121);
+ case 121: return __builtin_return_address(122);
+ case 122: return __builtin_return_address(123);
+ case 123: return __builtin_return_address(124);
+ case 124: return __builtin_return_address(125);
+ case 125: return __builtin_return_address(126);
+ case 126: return __builtin_return_address(127);
+ case 127: return __builtin_return_address(128);
+ default: return NULL;
+ }
+}
+
+static void *
+getframeaddr(int level)
+{
+
+ switch (level) {
+ case 0: return __builtin_frame_address(1);
+ case 1: return __builtin_frame_address(2);
+ case 2: return __builtin_frame_address(3);
+ case 3: return __builtin_frame_address(4);
+ case 4: return __builtin_frame_address(5);
+ case 5: return __builtin_frame_address(6);
+ case 6: return __builtin_frame_address(7);
+ case 7: return __builtin_frame_address(8);
+ case 8: return __builtin_frame_address(9);
+ case 9: return __builtin_frame_address(10);
+ case 10: return __builtin_frame_address(11);
+ case 11: return __builtin_frame_address(12);
+ case 12: return __builtin_frame_address(13);
+ case 13: return __builtin_frame_address(14);
+ case 14: return __builtin_frame_address(15);
+ case 15: return __builtin_frame_address(16);
+ case 16: return __builtin_frame_address(17);
+ case 17: return __builtin_frame_address(18);
+ case 18: return __builtin_frame_address(19);
+ case 19: return __builtin_frame_address(20);
+ case 20: return __builtin_frame_address(21);
+ case 21: return __builtin_frame_address(22);
+ case 22: return __builtin_frame_address(23);
+ case 23: return __builtin_frame_address(24);
+ case 24: return __builtin_frame_address(25);
+ case 25: return __builtin_frame_address(26);
+ case 26: return __builtin_frame_address(27);
+ case 27: return __builtin_frame_address(28);
+ case 28: return __builtin_frame_address(29);
+ case 29: return __builtin_frame_address(30);
+ case 30: return __builtin_frame_address(31);
+ case 31: return __builtin_frame_address(32);
+ case 32: return __builtin_frame_address(33);
+ case 33: return __builtin_frame_address(34);
+ case 34: return __builtin_frame_address(35);
+ case 35: return __builtin_frame_address(36);
+ case 36: return __builtin_frame_address(37);
+ case 37: return __builtin_frame_address(38);
+ case 38: return __builtin_frame_address(39);
+ case 39: return __builtin_frame_address(40);
+ case 40: return __builtin_frame_address(41);
+ case 41: return __builtin_frame_address(42);
+ case 42: return __builtin_frame_address(43);
+ case 43: return __builtin_frame_address(44);
+ case 44: return __builtin_frame_address(45);
+ case 45: return __builtin_frame_address(46);
+ case 46: return __builtin_frame_address(47);
+ case 47: return __builtin_frame_address(48);
+ case 48: return __builtin_frame_address(49);
+ case 49: return __builtin_frame_address(50);
+ case 50: return __builtin_frame_address(51);
+ case 51: return __builtin_frame_address(52);
+ case 52: return __builtin_frame_address(53);
+ case 53: return __builtin_frame_address(54);
+ case 54: return __builtin_frame_address(55);
+ case 55: return __builtin_frame_address(56);
+ case 56: return __builtin_frame_address(57);
+ case 57: return __builtin_frame_address(58);
+ case 58: return __builtin_frame_address(59);
+ case 59: return __builtin_frame_address(60);
+ case 60: return __builtin_frame_address(61);
+ case 61: return __builtin_frame_address(62);
+ case 62: return __builtin_frame_address(63);
+ case 63: return __builtin_frame_address(64);
+ case 64: return __builtin_frame_address(65);
+ case 65: return __builtin_frame_address(66);
+ case 66: return __builtin_frame_address(67);
+ case 67: return __builtin_frame_address(68);
+ case 68: return __builtin_frame_address(69);
+ case 69: return __builtin_frame_address(70);
+ case 70: return __builtin_frame_address(71);
+ case 71: return __builtin_frame_address(72);
+ case 72: return __builtin_frame_address(73);
+ case 73: return __builtin_frame_address(74);
+ case 74: return __builtin_frame_address(75);
+ case 75: return __builtin_frame_address(76);
+ case 76: return __builtin_frame_address(77);
+ case 77: return __builtin_frame_address(78);
+ case 78: return __builtin_frame_address(79);
+ case 79: return __builtin_frame_address(80);
+ case 80: return __builtin_frame_address(81);
+ case 81: return __builtin_frame_address(82);
+ case 82: return __builtin_frame_address(83);
+ case 83: return __builtin_frame_address(84);
+ case 84: return __builtin_frame_address(85);
+ case 85: return __builtin_frame_address(86);
+ case 86: return __builtin_frame_address(87);
+ case 87: return __builtin_frame_address(88);
+ case 88: return __builtin_frame_address(89);
+ case 89: return __builtin_frame_address(90);
+ case 90: return __builtin_frame_address(91);
+ case 91: return __builtin_frame_address(92);
+ case 92: return __builtin_frame_address(93);
+ case 93: return __builtin_frame_address(94);
+ case 94: return __builtin_frame_address(95);
+ case 95: return __builtin_frame_address(96);
+ case 96: return __builtin_frame_address(97);
+ case 97: return __builtin_frame_address(98);
+ case 98: return __builtin_frame_address(99);
+ case 99: return __builtin_frame_address(100);
+ case 100: return __builtin_frame_address(101);
+ case 101: return __builtin_frame_address(102);
+ case 102: return __builtin_frame_address(103);
+ case 103: return __builtin_frame_address(104);
+ case 104: return __builtin_frame_address(105);
+ case 105: return __builtin_frame_address(106);
+ case 106: return __builtin_frame_address(107);
+ case 107: return __builtin_frame_address(108);
+ case 108: return __builtin_frame_address(109);
+ case 109: return __builtin_frame_address(110);
+ case 110: return __builtin_frame_address(111);
+ case 111: return __builtin_frame_address(112);
+ case 112: return __builtin_frame_address(113);
+ case 113: return __builtin_frame_address(114);
+ case 114: return __builtin_frame_address(115);
+ case 115: return __builtin_frame_address(116);
+ case 116: return __builtin_frame_address(117);
+ case 117: return __builtin_frame_address(118);
+ case 118: return __builtin_frame_address(119);
+ case 119: return __builtin_frame_address(120);
+ case 120: return __builtin_frame_address(121);
+ case 121: return __builtin_frame_address(122);
+ case 122: return __builtin_frame_address(123);
+ case 123: return __builtin_frame_address(124);
+ case 124: return __builtin_frame_address(125);
+ case 125: return __builtin_frame_address(126);
+ case 126: return __builtin_frame_address(127);
+ case 127: return __builtin_frame_address(128);
+ default: return NULL;
+ }
+}
+
+static inline void *
+realloc_safe(void *ptr, size_t size)
+{
+ void *nptr;
+
+ nptr = realloc (ptr, size);
+ if (nptr == NULL)
+ free (ptr);
+ return nptr;
+}
+
+int
+backtrace(void **buffer, int size)
+{
+ int i;
+
+ for (i = 1; getframeaddr(i + 1) != NULL && i != size + 1; i++) {
+ buffer[i - 1] = getreturnaddr(i);
+ if (buffer[i - 1] == NULL)
+ break;
+ }
+ return i - 1;
+}
+
+char **
+backtrace_symbols(void *const *buffer, int size)
+{
+ size_t clen, alen;
+ int i, offset;
+ char **rval;
+ Dl_info info;
+
+ clen = size * sizeof(char *);
+ rval = malloc(clen);
+ if (rval == NULL)
+ return NULL;
+ for (i = 0; i < size; i++) {
+ if (dladdr(buffer[i], &info) != 0) {
+ if (info.dli_sname == NULL)
+ info.dli_sname = "???";
+ if (info.dli_saddr == NULL)
+ info.dli_saddr = buffer[i];
+ offset = buffer[i] - info.dli_saddr;
+ /* "0x01234567 <function+offset> at filename" */
+ alen = 2 + /* "0x" */
+ (sizeof(void *) * 2) + /* "01234567" */
+ 2 + /* " <" */
+ strlen(info.dli_sname) + /* "function" */
+ 1 + /* "+" */
+ 10 + /* "offset */
+ 5 + /* "> at " */
+ strlen(info.dli_fname) + /* "filename" */
+ 1; /* "\0" */
+ rval = realloc_safe(rval, clen + alen);
+ if (rval == NULL)
+ return NULL;
+ snprintf((char *) rval + clen, alen, "%p <%s+%d> at %s",
+ buffer[i], info.dli_sname, offset, info.dli_fname);
+ } else {
+ alen = 2 + /* "0x" */
+ (sizeof(void *) * 2) + /* "01234567" */
+ 1; /* "\0" */
+ rval = realloc_safe(rval, clen + alen);
+ if (rval == NULL)
+ return NULL;
+ snprintf((char *) rval + clen, alen, "%p", buffer[i]);
+ }
+ rval[i] = (char *) clen;
+ clen += alen;
+ }
+
+ for (i = 0; i < size; i++)
+ rval[i] += (long) rval;
+
+ return rval;
+}
+
+void
+backtrace_symbols_fd(void *const *buffer, int size, int fd)
+{
+ int i, len, offset;
+ char *buf;
+ Dl_info info;
+
+ for (i = 0; i < size; i++) {
+ if (dladdr(buffer[i], &info) != 0) {
+ if (info.dli_sname == NULL)
+ info.dli_sname = "???";
+ if (info.dli_saddr == NULL)
+ info.dli_saddr = buffer[i];
+ offset = buffer[i] - info.dli_saddr;
+ /* "0x01234567 <function+offset> at filename" */
+ len = 2 + /* "0x" */
+ (sizeof(void *) * 2) + /* "01234567" */
+ 2 + /* " <" */
+ strlen(info.dli_sname) + /* "function" */
+ 1 + /* "+" */
+ D10(offset) + /* "offset */
+ 5 + /* "> at " */
+ strlen(info.dli_fname) + /* "filename" */
+ 2; /* "\n\0" */
+ buf = alloca(len);
+ if (buf == NULL)
+ return;
+ snprintf(buf, len, "%p <%s+%d> at %s\n",
+ buffer[i], info.dli_sname, offset, info.dli_fname);
+ } else {
+ len = 2 + /* "0x" */
+ (sizeof(void *) * 2) + /* "01234567" */
+ 2; /* "\n\0" */
+ buf = alloca(len);
+ if (buf == NULL)
+ return;
+ snprintf(buf, len, "%p\n", buffer[i]);
+ }
+ if (write(fd, buf, strlen(buf)) == -1)
+ return;
+ }
+}
+#endif
diff --git a/contrib/libexecinfo/execinfo_compat.h b/contrib/libexecinfo/execinfo_compat.h
new file mode 100644
index 00000000000..85f185dd5f7
--- /dev/null
+++ b/contrib/libexecinfo/execinfo_compat.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2003 Maxim Sobolev <sobomax@FreeBSD.org>
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ * $Id: execinfo.h,v 1.2 2004/07/19 05:20:29 sobomax Exp $
+ */
+
+#ifndef _EXECINFO_H_
+#define _EXECINFO_H_
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef HAVE_BACKTRACE
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int backtrace(void **, int);
+char **backtrace_symbols(void *const *, int);
+void backtrace_symbols_fd(void *const *, int, int);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+#endif /* _EXECINFO_H_ */
diff --git a/contrib/mount/mntent.c b/contrib/mount/mntent.c
index 991e694f1cd..e9b448845a7 100644
--- a/contrib/mount/mntent.c
+++ b/contrib/mount/mntent.c
@@ -35,7 +35,7 @@
* SUCH DAMAGE.
*/
-#if defined(GF_DARWIN_HOST_OS) || defined(__NetBSD__)
+#if !defined(GF_LINUX_HOST_OS)
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
@@ -103,7 +103,9 @@ flags2opts (int flags)
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 !defined(__FreeBSD__)
if (flags & MNT_NODEV) res = concatopt(res, "nodev");
+#endif /* __FreeBSD__ */
if (flags & MNT_UNION) res = concatopt(res, "union");
if (flags & MNT_ASYNC) res = concatopt(res, "async");
#if !defined(GF_DARWIN_HOST_OS)
@@ -211,4 +213,4 @@ endmntent (FILE *fp)
return 1; /* endmntent() always returns 1 */
}
-#endif /* GF_DARWIN_HOST_OS || __NetBSD__ */
+#endif /* !GF_LINUX_HOST_OS */
diff --git a/contrib/mount/mntent_compat.h b/contrib/mount/mntent_compat.h
index 3f9cc931266..ca82e9aa60f 100644
--- a/contrib/mount/mntent_compat.h
+++ b/contrib/mount/mntent_compat.h
@@ -11,7 +11,7 @@
#ifndef _MNTENT_H
#define _MNTENT_H
-#if defined(GF_DARWIN_HOST_OS) || defined(__NetBSD__)
+#if !defined(GF_LINUX_HOST_OS)
#include <stdio.h>
struct mntent {
diff --git a/contrib/qemu/include/qemu/bswap.h b/contrib/qemu/include/qemu/bswap.h
index 1ea5b101e89..bf6457b8c46 100644
--- a/contrib/qemu/include/qemu/bswap.h
+++ b/contrib/qemu/include/qemu/bswap.h
@@ -11,6 +11,8 @@
# include <sys/endian.h>
# include <sys/types.h>
# include <machine/bswap.h>
+#elif defined(__FreeBSD__)
+# include <sys/endian.h>
#elif defined(CONFIG_BYTESWAP_H)
#ifdef GF_DARWIN_HOST_OS
# include <libkern/OSByteOrder.h>
diff --git a/contrib/qemu/util/oslib-posix.c b/contrib/qemu/util/oslib-posix.c
index 3dc8b1b0743..5dceea5f581 100644
--- a/contrib/qemu/util/oslib-posix.c
+++ b/contrib/qemu/util/oslib-posix.c
@@ -93,7 +93,7 @@ void *qemu_memalign(size_t alignment, size_t size)
size, strerror(ret));
abort();
}
-#elif defined(CONFIG_BSD)
+#elif defined(GF_BSD_HOST_OS)
ptr = qemu_oom_check(valloc(size));
#else
ptr = qemu_oom_check(memalign(alignment, size));
@@ -193,7 +193,7 @@ int qemu_utimens(const char *path, const struct timespec *times)
struct timeval tv[2], tv_now;
struct stat st;
int i;
-#ifdef CONFIG_UTIMENSAT
+#if defined(CONFIG_UTIMENSAT) && !defined(__FreeBSD__)
int ret;
ret = utimensat(AT_FDCWD, path, times, AT_SYMLINK_NOFOLLOW);
diff --git a/extras/geo-rep/Makefile.am b/extras/geo-rep/Makefile.am
index 6d3d10b88a0..0cd6b1b7a02 100644
--- a/extras/geo-rep/Makefile.am
+++ b/extras/geo-rep/Makefile.am
@@ -5,7 +5,7 @@ scripts_DATA = gsync-upgrade.sh generate-gfid-file.sh get-gfid.sh \
scripts_PROGRAMS = gsync-sync-gfid
gsync_sync_gfid_CFLAGS = $(GF_CFLAGS) -Wall -I$(top_srcdir)/libglusterfs/src
gsync_sync_gfid_LDFLAGS = $(GF_LDFLAGS)
-gsync_sync_gfid_LDADD = $(GF_LIBS) $(top_builddir)/libglusterfs/src/libglusterfs.la
+gsync_sync_gfid_LDADD = $(GF_LIBS) $(top_builddir)/libglusterfs/src/libglusterfs.la $(GF_GLUSTERFS_LIBS)
gsync_sync_gfid_SOURCES = gsync-sync-gfid.c
EXTRA_DIST = gsync-sync-gfid.c gsync-upgrade.sh generate-gfid-file.sh \
diff --git a/extras/init.d/Makefile.am b/extras/init.d/Makefile.am
index 38898fddd2e..61dde2d396e 100644
--- a/extras/init.d/Makefile.am
+++ b/extras/init.d/Makefile.am
@@ -1,13 +1,13 @@
-EXTRA_DIST = glusterd-Debian glusterd-Redhat glusterd-SuSE glusterd.plist rhel5-load-fuse.modules
+EXTRA_DIST = glusterd-Debian glusterd-FreeBSD glusterd-Redhat glusterd-SuSE glusterd.plist rhel5-load-fuse.modules
-CLEANFILES =
+CLEANFILES =
INIT_DIR = @initdir@
SYSTEMD_DIR = @systemddir@
LAUNCHD_DIR = @launchddir@
-$(GF_DISTRIBUTION):
+$(GF_DISTRIBUTION):
@if [ ! -d $(SYSTEMD_DIR) ]; then \
$(mkdir_p) $(DESTDIR)$(INIT_DIR); \
$(INSTALL_PROGRAM) glusterd-$(GF_DISTRIBUTION) $(DESTDIR)$(INIT_DIR)/glusterd; \
@@ -15,7 +15,7 @@ $(GF_DISTRIBUTION):
install-exec-local: $(GF_DISTRIBUTION)
-install-data-local:
+install-data-local:
if GF_DARWIN_HOST_OS
$(mkdir_p) $(DESTDIR)$(LAUNCHD_DIR)
$(INSTALL_PROGRAM) glusterd.plist $(DESTDIR)$(LAUNCHD_DIR)/com.gluster.glusterd.plist
diff --git a/extras/init.d/glusterd-FreeBSD.in b/extras/init.d/glusterd-FreeBSD.in
new file mode 100644
index 00000000000..5eed6360a89
--- /dev/null
+++ b/extras/init.d/glusterd-FreeBSD.in
@@ -0,0 +1,24 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+# PROVIDE: glusterd
+
+. /etc/rc.subr
+
+name="glusterd"
+rcvar=`set_rcvar`
+command=@prefix@/sbin/${name}
+pidfile="/var/run/${name}.pid"
+glusterd_flags="-p /var/run/${name}.pid"
+start_precmd="glusterd_prestart"
+
+glusterd_prestart()
+{
+ mkdir -p /var/lib/glusterd /var/log/glusterfs
+ return 0
+}
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/libglusterfs/src/Makefile.am b/libglusterfs/src/Makefile.am
index ccac1a1e825..25ee4c27a8b 100644
--- a/libglusterfs/src/Makefile.am
+++ b/libglusterfs/src/Makefile.am
@@ -1,10 +1,10 @@
-libglusterfs_la_CFLAGS = -Wall $(GF_CFLAGS) \
- $(GF_DARWIN_LIBGLUSTERFS_CFLAGS) \
- -DDATADIR=\"$(localstatedir)\"
+libglusterfs_la_CFLAGS = -Wall $(GF_CFLAGS) $(GF_DARWIN_LIBGLUSTERFS_CFLAGS) \
+ -DDATADIR=\"$(localstatedir)\"
libglusterfs_la_CPPFLAGS = $(GF_CPPFLAGS) -D__USE_FILE_OFFSET64 \
-DXLATORDIR=\"$(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator\" \
- -I$(top_srcdir)/rpc/rpc-lib/src/ -I$(CONTRIBDIR)/rbtree
+ -I$(top_srcdir)/rpc/rpc-lib/src/ -I$(CONTRIBDIR)/rbtree \
+ -I$(CONTRIBDIR)/libexecinfo
libglusterfs_la_LIBADD = @LEXLIB@
libglusterfs_la_LDFLAGS = -version-info $(LIBGLUSTERFS_LT_VERSION)
@@ -27,7 +27,7 @@ libglusterfs_la_SOURCES = dict.c xlator.c logging.c \
event-history.c gidcache.c ctx.c client_t.c event-poll.c event-epoll.c \
$(CONTRIBDIR)/libgen/basename_r.c $(CONTRIBDIR)/libgen/dirname_r.c \
$(CONTRIBDIR)/stdlib/gf_mkostemp.c strfd.c \
- $(CONTRIBDIR)/mount/mntent.c
+ $(CONTRIBDIR)/mount/mntent.c $(CONTRIBDIR)/libexecinfo/execinfo.c
nodist_libglusterfs_la_SOURCES = y.tab.c graph.lex.c
@@ -44,7 +44,8 @@ noinst_HEADERS = common-utils.h defaults.h dict.h glusterfs.h hashfn.h timespec.
run.h options.h lkowner.h fd-lk.h circ-buff.h event-history.h \
gidcache.h client_t.h glusterfs-acl.h glfs-message-id.h \
template-component-messages.h strfd.h \
- $(CONTRIBDIR)/mount/mntent_compat.h lvm-defaults.h
+ $(CONTRIBDIR)/mount/mntent_compat.h lvm-defaults.h \
+ $(CONTRIBDIR)/libexecinfo/execinfo_compat.h
EXTRA_DIST = graph.l graph.y
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index 6ba5223da0b..124b312f4a1 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -15,6 +15,8 @@
#ifdef HAVE_BACKTRACE
#include <execinfo.h>
+#else
+#include "execinfo_compat.h"
#endif
#include <stdio.h>
@@ -33,7 +35,7 @@
#include <signal.h>
#include <assert.h>
-#if defined GF_BSD_HOST_OS || defined GF_DARWIN_HOST_OS
+#if defined(GF_BSD_HOST_OS) || defined(GF_DARWIN_HOST_OS)
#include <sys/sysctl.h>
#endif
@@ -531,11 +533,9 @@ gf_print_trace (int32_t signum, glusterfs_ctx_t *ctx)
}
gf_dump_config_flags ();
-#if HAVE_BACKTRACE
gf_msg_backtrace_nomem (GF_LOG_ALERT, 200);
sprintf (msg, "---------");
gf_msg_plain_nomem (GF_LOG_ALERT, msg);
-#endif /* HAVE_BACKTRACE */
/* Send a signal to terminate the process */
signal (signum, SIG_DFL);
@@ -3062,82 +3062,29 @@ gf_set_log_ident (cmd_args_t *cmd_args)
int
gf_thread_create (pthread_t *thread, const pthread_attr_t *attr,
- void *(*start_routine)(void *), void *arg)
-{
- sigset_t set, old;
- int ret;
-
- sigemptyset (&set);
-
- sigfillset (&set);
- sigdelset (&set, SIGSEGV);
- sigdelset (&set, SIGBUS);
- sigdelset (&set, SIGILL);
- sigdelset (&set, SIGSYS);
- sigdelset (&set, SIGFPE);
- sigdelset (&set, SIGABRT);
-
- pthread_sigmask (SIG_BLOCK, &set, &old);
-
- ret = pthread_create (thread, attr, start_routine, arg);
-
- pthread_sigmask (SIG_SETMASK, &old, NULL);
-
- return ret;
-}
-
-#ifdef __NetBSD__
-#ifdef __MACHINE_STACK_GROWS_UP
-#define BELOW >
-#else
-#define BELOW <
-#endif
-
-struct frameinfo {
- struct frameinfo *next;
- void *return_address;
-};
-
-size_t
-backtrace(void **trace, size_t len)
+ void *(*start_routine)(void *), void *arg)
{
- const struct frameinfo *frame = __builtin_frame_address(0);
- void *stack = &stack;
- size_t i;
+ sigset_t set, old;
+ int ret;
- for (i = 0; i < len; i++) {
- if ((void *)frame BELOW stack)
- return i;
- trace[i] = frame->return_address;
- frame = frame->next;
- }
+ sigemptyset (&set);
- return len;
-}
+ sigfillset (&set);
+ sigdelset (&set, SIGSEGV);
+ sigdelset (&set, SIGBUS);
+ sigdelset (&set, SIGILL);
+ sigdelset (&set, SIGSYS);
+ sigdelset (&set, SIGFPE);
+ sigdelset (&set, SIGABRT);
-char **
-backtrace_symbols(void *const *trace, size_t len)
-{
- static const size_t slen = sizeof("0x123456789abcdef");
- char **ptr = calloc(len, sizeof(*ptr) + slen);
- size_t i;
+ pthread_sigmask (SIG_BLOCK, &set, &old);
- if (ptr == NULL)
- return NULL;
+ ret = pthread_create (thread, attr, start_routine, arg);
- char *str = (void *)(ptr + len);
- size_t cur = 0, left = len * slen;
+ pthread_sigmask (SIG_SETMASK, &old, NULL);
- for (i = 0; i < len; i++) {
- ptr[i] = str + cur;
- cur += snprintf(str + cur, left - cur, "%p", trace[i]) + 1;
- assert(cur < left);
- }
-
- return ptr;
+ return ret;
}
-#undef BELOW
-#endif /* __NetBSD__ */
int
gf_skip_header_section (int fd, int header_len)
diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h
index 86848df452d..b4372f10bbc 100644
--- a/libglusterfs/src/common-utils.h
+++ b/libglusterfs/src/common-utils.h
@@ -621,12 +621,7 @@ gf_boolean_t gf_is_same_address (char *host1, char *host2);
void md5_wrapper(const unsigned char *data, size_t len, char *md5);
int gf_thread_create (pthread_t *thread, const pthread_attr_t *attr,
- void *(*start_routine)(void *), void *arg);
-#ifdef __NetBSD__
-size_t backtrace(void **, size_t);
-char **backtrace_symbols(void *const *, size_t);
-#endif
-
+ void *(*start_routine)(void *), void *arg);
gf_boolean_t
gf_is_service_running (char *pidfile, int *pid);
int
diff --git a/libglusterfs/src/compat.h b/libglusterfs/src/compat.h
index 81408dbd0ae..5920fce992b 100644
--- a/libglusterfs/src/compat.h
+++ b/libglusterfs/src/compat.h
@@ -125,6 +125,11 @@ enum {
#define sighandler_t sig_t
#endif
+#ifdef __FreeBSD__
+#undef ino_t
+#define ino_t uint64_t
+#endif /* __FreeBSD__ */
+
#ifndef ino64_t
#define ino64_t ino_t
#endif
@@ -153,6 +158,8 @@ enum {
#define F_GETLK64 F_GETLK
#define F_SETLK64 F_SETLK
#define F_SETLKW64 F_SETLKW
+#define FALLOC_FL_KEEP_SIZE 0x01 /* default is extend size */
+#define FALLOC_FL_PUNCH_HOLE 0x02 /* de-allocates range */
#endif /* GF_BSD_HOST_OS */
diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c
index b3626538b96..e9734bcfca1 100644
--- a/libglusterfs/src/logging.c
+++ b/libglusterfs/src/logging.c
@@ -25,6 +25,8 @@
#ifdef HAVE_BACKTRACE
#include <execinfo.h>
+#else
+#include "execinfo_compat.h"
#endif
#include <sys/stat.h>
@@ -814,8 +816,6 @@ _gf_log_callingfn (const char *domain, const char *file, const char *function,
else
basename = file;
-#if HAVE_BACKTRACE
- /* Print 'calling function' */
do {
void *array[5];
char **callingfn = NULL;
@@ -838,7 +838,6 @@ _gf_log_callingfn (const char *domain, const char *file, const char *function,
free (callingfn);
} while (0);
-#endif /* HAVE_BACKTRACE */
if (ctx->log.log_control_file_found)
{
@@ -1070,7 +1069,6 @@ out:
return ret;
}
-#if HAVE_BACKTRACE
void
_gf_msg_backtrace_nomem (gf_loglevel_t level, int stacksize)
{
@@ -1105,7 +1103,8 @@ _gf_msg_backtrace_nomem (gf_loglevel_t level, int stacksize)
fileno (stderr);
if (bt_size && (fd != -1)) {
/* print to the file fd, to prevent any
- * allocations from backtrace_symbols */
+ allocations from backtrace_symbols
+ */
backtrace_symbols_fd (&array[0], bt_size, fd);
}
}
@@ -1153,7 +1152,6 @@ out:
FREE (callingfn);
return ret;
}
-#endif /* HAVE_BACKTRACE */
int
_gf_msg_nomem (const char *domain, const char *file,
@@ -1261,9 +1259,7 @@ _gf_msg_nomem (const char *domain, const char *file,
}
pthread_mutex_unlock (&ctx->log.logfile_mutex);
-#ifdef HAVE_BACKTRACE
_gf_msg_backtrace_nomem (level, GF_LOG_BACKTRACE_DEPTH);
-#endif
break;
}
@@ -2035,7 +2031,6 @@ _gf_msg (const char *domain, const char *file, const char *function,
if (level > ctx->log.loglevel)
goto out;
-#if HAVE_BACKTRACE
if (trace) {
ret = _gf_msg_backtrace (GF_LOG_BACKTRACE_DEPTH, callstr,
GF_LOG_BACKTRACE_DEPTH);
@@ -2044,7 +2039,6 @@ _gf_msg (const char *domain, const char *file, const char *function,
else
ret = 0;
}
-#endif /* HAVE_BACKTRACE */
pthread_mutex_lock (&ctx->log.logfile_mutex);
{
diff --git a/libglusterfs/src/store.h b/libglusterfs/src/store.h
index beb17ac4a2f..1ffd97c526f 100644
--- a/libglusterfs/src/store.h
+++ b/libglusterfs/src/store.h
@@ -15,6 +15,7 @@
#include "config.h"
#endif
+#include "compat.h"
#include "glusterfs.h"
struct gf_store_handle_ {
diff --git a/libglusterfs/src/syscall.c b/libglusterfs/src/syscall.c
index 7236958677d..48418091676 100644
--- a/libglusterfs/src/syscall.c
+++ b/libglusterfs/src/syscall.c
@@ -311,6 +311,8 @@ sys_fdatasync (int fd)
{
#ifdef GF_DARWIN_HOST_OS
return fcntl (fd, F_FULLFSYNC);
+#elif __FreeBSD__
+ return fsync (fd);
#else
return fdatasync (fd);
#endif
diff --git a/rpc/rpc-lib/src/xdr-rpc.c b/rpc/rpc-lib/src/xdr-rpc.c
index adb48a53186..d016668b9a3 100644
--- a/rpc/rpc-lib/src/xdr-rpc.c
+++ b/rpc/rpc-lib/src/xdr-rpc.c
@@ -193,7 +193,7 @@ xdr_to_auth_unix_cred (char *msgbuf, int msglen, struct authunix_parms *au,
GF_VALIDATE_OR_GOTO ("rpc", au, out);
au->aup_machname = machname;
-#ifdef GF_DARWIN_HOST_OS
+#if defined(GF_DARWIN_HOST_OS) || defined(__FreeBSD__)
au->aup_gids = (int *)gids;
#else
au->aup_gids = gids;
diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c
index 8b8b97370de..61c9f60ff7f 100644
--- a/rpc/rpc-transport/socket/src/socket.c
+++ b/rpc/rpc-transport/socket/src/socket.c
@@ -766,7 +766,7 @@ __socket_keepalive (int fd, int family, int keepalive_intvl, int keepalive_idle)
goto done;
#if !defined(GF_LINUX_HOST_OS) && !defined(__NetBSD__)
-#ifdef GF_SOLARIS_HOST_OS
+#if defined(GF_SOLARIS_HOST_OS) || defined(__FreeBSD__)
ret = setsockopt (fd, SOL_SOCKET, SO_KEEPALIVE, &keepalive_intvl,
sizeof (keepalive_intvl));
#else
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index e172569f3e1..45450d5f383 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -26,6 +26,7 @@
#include <sys/time.h>
#include <libgen.h>
+#include <signal.h>
int
dht_aggregate (dict_t *this, char *key, data_t *value, void *data)
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
index 9cdb4453820..eca1d52b62b 100644
--- a/xlators/cluster/dht/src/dht-rebalance.c
+++ b/xlators/cluster/dht/src/dht-rebalance.c
@@ -18,6 +18,7 @@
#include "xlator.h"
#include <signal.h>
#include <fnmatch.h>
+#include <signal.h>
#define GF_DISK_SECTOR_SIZE 512
#define DHT_REBALANCE_PID 4242 /* Change it if required */
diff --git a/xlators/encryption/crypt/src/crypt.h b/xlators/encryption/crypt/src/crypt.h
index eb7291f13c5..b7aefc3d2c5 100644
--- a/xlators/encryption/crypt/src/crypt.h
+++ b/xlators/encryption/crypt/src/crypt.h
@@ -39,7 +39,7 @@
#define MASTER_VOL_KEY_SIZE (32)
#define NMTD_VOL_KEY_SIZE (16)
-#if defined(__NetBSD__)
+#if defined(GF_BSD_HOST_OS)
typedef off_t loff_t;
#endif
diff --git a/xlators/features/protect/src/Makefile.am b/xlators/features/protect/src/Makefile.am
index 968e88c457a..fdfed4b219e 100644
--- a/xlators/features/protect/src/Makefile.am
+++ b/xlators/features/protect/src/Makefile.am
@@ -14,8 +14,8 @@ prot_server_la_LDFLAGS = -module -avoid-version
prot_server_la_SOURCES = prot_server.c
prot_server_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
-AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src
+AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \
+ -I$(CONTRIBDIR)/libexecinfo
AM_CFLAGS = -Wall $(GF_CFLAGS)
-CLEANFILES =
-
+CLEANFILES =
diff --git a/xlators/features/protect/src/prot_client.c b/xlators/features/protect/src/prot_client.c
index d09715067bd..500c772bedd 100644
--- a/xlators/features/protect/src/prot_client.c
+++ b/xlators/features/protect/src/prot_client.c
@@ -15,8 +15,10 @@
#include "xlator.h"
#include "defaults.h"
-#ifndef __NetBSD__
+#ifdef HAVE_BACKTRACE
#include <execinfo.h>
+#else
+#include "execinfo_compat.h"
#endif
#define NUM_FRAMES 20
@@ -44,20 +46,20 @@ pcli_print_trace (char *name, call_frame_t *frame)
frame = frame->next;
}
- size = backtrace(frames,NUM_FRAMES);
+ size = backtrace (frames, NUM_FRAMES);
if (size <= 0) {
return;
}
- symbols = backtrace_symbols(frames,size);
+ symbols = backtrace_symbols (frames, size);
if (!symbols) {
return;
}
- gf_log(name, GF_LOG_INFO, "Processor stack:");
+ gf_log (name, GF_LOG_INFO, "Processor stack:");
for (i = 0; i < size; ++i) {
gf_log (name, GF_LOG_INFO, "%s", symbols[i]);
}
- free(symbols);
+ free (symbols);
}
int32_t
@@ -73,14 +75,14 @@ pcli_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
if (!oldloc->parent) {
goto simple_unwind;
}
- if (inode_ctx_get(oldloc->parent,this,&value) != 0) {
+ if (inode_ctx_get (oldloc->parent, this, &value) != 0) {
goto simple_unwind;
}
if (value != PROT_ACT_NONE) {
gf_log (this->name, GF_LOG_WARNING,
"got rename for protected %s", oldloc->path);
- pcli_print_trace(this->name,frame->next);
+ pcli_print_trace (this->name, frame->next);
if (value == PROT_ACT_REJECT) {
STACK_UNWIND_STRICT (rename, frame, -1, EPERM,
NULL, NULL, NULL, NULL, NULL,
@@ -181,25 +183,25 @@ simple_unwind:
int32_t
init (xlator_t *this)
{
- if (!this->children || this->children->next) {
- gf_log (this->name, GF_LOG_ERROR,
- "translator not configured with exactly one child");
- return -1;
- }
-
- if (!this->parents) {
- gf_log (this->name, GF_LOG_WARNING,
- "dangling volume. check volfile ");
- }
-
- return 0;
+ if (!this->children || this->children->next) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "translator not configured with exactly one child");
+ return -1;
+ }
+
+ if (!this->parents) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "dangling volume. check volfile ");
+ }
+
+ return 0;
}
void
fini (xlator_t *this)
{
- return;
+ return;
}
@@ -213,5 +215,5 @@ struct xlator_cbks cbks = {
};
struct volume_options options[] = {
- { .key = {NULL} },
+ { .key = {NULL} },
};
diff --git a/xlators/meta/src/meta-defaults.c b/xlators/meta/src/meta-defaults.c
index 0f439c3ab4b..c34055bb221 100644
--- a/xlators/meta/src/meta-defaults.c
+++ b/xlators/meta/src/meta-defaults.c
@@ -19,6 +19,7 @@
#include "meta-mem-types.h"
#include "meta.h"
+#include "compat-errno.h"
int
meta_default_fgetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c
index 3e29a9601bc..e4a48439812 100644
--- a/xlators/mgmt/glusterd/src/glusterd-quota.c
+++ b/xlators/mgmt/glusterd/src/glusterd-quota.c
@@ -482,7 +482,7 @@ glusterd_set_quota_limit (char *volname, char *path, char *hard_limit,
ret = sys_lsetxattr (abspath, "trusted.glusterfs.quota.limit-set",
(char *)(void *)&new_limit, sizeof (new_limit), 0);
- if (ret) {
+ if (ret == -1) {
gf_asprintf (op_errstr, "setxattr of "
"'trusted.glusterfs.quota.limit-set' failed on %s."
" Reason : %s", abspath, strerror (errno));
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
index 3095414b88e..c1ddc0849cc 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
@@ -20,7 +20,7 @@
#include <sys/mount.h>
#include <signal.h>
-#if !defined(__NetBSD__) && !defined(GF_DARWIN_HOST_OS)
+#if defined(GF_LINUX_HOST_OS)
#include <mntent.h>
#else
#include "mntent_compat.h"
@@ -30,7 +30,7 @@
#define umount2(dir, flags) unmount(dir, ((flags) != 0) ? MNT_FORCE : 0)
#endif
-#ifdef GF_DARWIN_HOST_OS
+#if defined(GF_DARWIN_HOST_OS) || defined(__FreeBSD__)
#include <sys/param.h>
#include <sys/mount.h>
#define umount2(dir, flags) unmount(dir, ((flags) != 0) ? MNT_FORCE : 0)
@@ -3743,7 +3743,7 @@ glusterd_snap_brick_create (glusterd_volinfo_t *snap_volinfo,
GF_XATTR_VOL_ID_KEY,
snap_volinfo->volume_id, 16,
XATTR_REPLACE);
- if (ret) {
+ if (ret == -1) {
gf_log (this->name, GF_LOG_ERROR, "Failed to set "
"extended attribute %s on %s. Reason: "
"%s, snap: %s", GF_XATTR_VOL_ID_KEY,
@@ -4043,8 +4043,13 @@ glusterd_update_fs_uuid (glusterd_brickinfo_t *brickinfo)
* file-system which is sharing the UUID with any other
* file-system on the system.
*/
+#ifdef GF_LINUX_HOST_OS
ret = mount (brickinfo->device_path, mount_path,
brickinfo->fstype, 0, "nouuid");
+#else
+ ret = -1;
+#endif
+
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "Failed to mount "
"%s at %s", brickinfo->device_path,
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index 0177ed169fc..e03ec7af9f5 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -45,7 +45,7 @@
#include <inttypes.h>
#include <dirent.h>
-#if !defined(__NetBSD__) && !defined(GF_DARWIN_HOST_OS)
+#if defined(GF_LINUX_HOST_OS)
#include <mntent.h>
#else
#include "mntent_compat.h"
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index fb677200a7e..6b973a3638d 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -13,7 +13,7 @@
#endif
#include <inttypes.h>
-#if !defined(__NetBSD__) && !defined(GF_DARWIN_HOST_OS)
+#if defined(GF_LINUX_HOST_OS)
#include <mntent.h>
#else
#include "mntent_compat.h"
@@ -722,7 +722,7 @@ glusterd_snap_volinfo_restore (dict_t *dict, dict_t *rsp_dict,
new_volinfo->volume_id,
sizeof (new_volinfo->volume_id),
XATTR_REPLACE);
- if (ret) {
+ if (ret == -1) {
gf_log (this->name, GF_LOG_ERROR, "Failed to "
"set extended attribute %s on %s. "
"Reason: %s, snap: %s",
@@ -7438,7 +7438,6 @@ glusterd_add_brick_to_dict (glusterd_volinfo_t *volinfo,
xlator_t *this = NULL;
glusterd_conf_t *priv = NULL;
-
GF_ASSERT (volinfo);
GF_ASSERT (brickinfo);
GF_ASSERT (dict);
@@ -8109,7 +8108,7 @@ glusterd_check_and_set_brick_xattr (char *host, char *path, uuid_t uuid,
/* Check for xattr support in backend fs */
ret = sys_lsetxattr (path, "trusted.glusterfs.test",
"working", 8, 0);
- if (ret) {
+ if (ret == -1) {
snprintf (msg, sizeof (msg), "Glusterfs is not"
" supported on brick: %s:%s.\nSetting"
" extended attributes failed, reason:"
@@ -8135,7 +8134,7 @@ glusterd_check_and_set_brick_xattr (char *host, char *path, uuid_t uuid,
ret = sys_lsetxattr (path, GF_XATTR_VOL_ID_KEY, uuid, 16,
flags);
- if (ret) {
+ if (ret == -1) {
snprintf (msg, sizeof (msg), "Failed to set extended "
"attributes %s, reason: %s",
GF_XATTR_VOL_ID_KEY, strerror (errno));
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
index aa9805092fa..53beebe0555 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
@@ -1055,7 +1055,7 @@ glusterd_op_stage_start_volume (dict_t *dict, char **op_errstr,
GF_XATTR_VOL_ID_KEY,
volinfo->volume_id, 16,
XATTR_CREATE);
- if (ret) {
+ if (ret == -1) {
snprintf (msg, sizeof (msg), "Failed to set "
"extended attribute %s on %s. Reason: "
"%s", GF_XATTR_VOL_ID_KEY,
diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c
index d5ca4d146aa..473911a2cb0 100644
--- a/xlators/mount/fuse/src/fuse-bridge.c
+++ b/xlators/mount/fuse/src/fuse-bridge.c
@@ -12,6 +12,8 @@
#include "fuse-bridge.h"
#include "mount-gluster-compat.h"
#include "glusterfs.h"
+#include "byte-order.h"
+#include "compat-errno.h"
#include "glusterfs-acl.h"
#ifdef __NetBSD__
diff --git a/xlators/mount/fuse/src/fuse-bridge.h b/xlators/mount/fuse/src/fuse-bridge.h
index f1c4cb3f0d8..c08d55daf4b 100644
--- a/xlators/mount/fuse/src/fuse-bridge.h
+++ b/xlators/mount/fuse/src/fuse-bridge.h
@@ -32,8 +32,6 @@
#include "statedump.h"
#ifdef GF_DARWIN_HOST_OS
-/* This is MacFUSE's marker for MacFUSE-specific code */
-#define __FreeBSD__ 10
#include "fuse_kernel_macfuse.h"
#else
#include "fuse_kernel.h"
@@ -47,7 +45,7 @@
#include "syncop.h"
#include "gidcache.h"
-#if defined(GF_LINUX_HOST_OS) || defined(__NetBSD__)
+#if defined(GF_LINUX_HOST_OS) || defined(__FreeBSD__) || defined(__NetBSD__)
#define FUSE_OP_HIGH (FUSE_READDIRPLUS + 1)
#endif
#ifdef GF_DARWIN_HOST_OS
diff --git a/xlators/mount/fuse/src/fuse-helpers.c b/xlators/mount/fuse/src/fuse-helpers.c
index 0936d63111a..ef9bcd4e43e 100644
--- a/xlators/mount/fuse/src/fuse-helpers.c
+++ b/xlators/mount/fuse/src/fuse-helpers.c
@@ -11,13 +11,17 @@
#define _KMEMUSER
#endif
-#include "fuse-bridge.h"
#if defined(GF_SOLARIS_HOST_OS)
#include <sys/procfs.h>
+#elif defined(__FreeBSD__)
+#include <sys/types.h>
+#include <libutil.h>
+#include <sys/user.h>
#else
#include <sys/sysctl.h>
#endif
+#include "fuse-bridge.h"
static void
fuse_resolve_wipe (fuse_resolve_t *resolve)
@@ -154,7 +158,8 @@ frame_fill_groups (call_frame_t *frame)
char *endptr = NULL;
int ret = 0;
- ret = snprintf (filename, sizeof filename, "/proc/%d/status", frame->root->pid);
+ ret = snprintf (filename, sizeof filename, "/proc/%d/status",
+ frame->root->pid);
if (ret >= sizeof filename)
goto out;
@@ -162,8 +167,8 @@ frame_fill_groups (call_frame_t *frame)
if (!fp)
goto out;
- if (call_stack_alloc_groups (frame->root, FUSE_MAX_AUX_GROUPS) != 0)
- goto out;
+ if (call_stack_alloc_groups (frame->root, FUSE_MAX_AUX_GROUPS) != 0)
+ goto out;
while ((ptr = fgets (line, sizeof line, fp))) {
if (strncmp (ptr, "Groups:", 7) != 0)
@@ -197,7 +202,7 @@ out:
prcred_t *prcred = (prcred_t *) scratch;
FILE *fp = NULL;
int ret = 0;
- int ngrps;
+ int ngrps;
ret = snprintf (filename, sizeof filename,
"/proc/%d/cred", frame->root->pid);
@@ -207,21 +212,21 @@ out:
if (fp != NULL) {
if (fgets (scratch, sizeof scratch, fp) != NULL) {
ngrps = MIN(prcred->pr_ngroups,
- GF_MAX_AUX_GROUPS);
- if (call_stack_alloc_groups (frame->root,
- ngrps) != 0)
- return;
+ FUSE_MAX_AUX_GROUPS);
+ if (call_stack_alloc_groups (frame->root,
+ ngrps) != 0)
+ return;
}
fclose (fp);
}
}
#elif defined(CTL_KERN) /* DARWIN and *BSD */
- /*
+ /*
N.B. CTL_KERN is an enum on Linux. (Meaning, if it's not
- obvious, that it's not subject to preprocessor directives
+ obvious, that it's not subject to preprocessor directives
like '#if defined'.)
Unlike Linux, on Mac OS and the BSDs it is a #define. We
- could test to see that KERN_PROC is defined, but, barring any
+ could test to see that KERN_PROC is defined, but, barring any
evidence to the contrary, I think that's overkill.
We might also test that GF_DARWIN_HOST_OS is defined, why
limit this to just Mac OS. It's equally valid for the BSDs
@@ -236,8 +241,8 @@ out:
if (sysctl(name, namelen, &kp, &kplen, NULL, 0) != 0)
return;
ngroups = MIN(kp.kp_eproc.e_ucred.cr_ngroups, NGROUPS_MAX);
- if (call_stack_alloc_groups (frame->root, ngroups) != 0)
- return;
+ if (call_stack_alloc_groups (frame->root, ngroups) != 0)
+ return;
for (i = 0; i < ngroups; i++)
frame->root->groups[i] = kp.kp_eproc.e_ucred.cr_groups[i];
frame->root->ngrps = ngroups;
diff --git a/xlators/mount/fuse/utils/Makefile.am b/xlators/mount/fuse/utils/Makefile.am
index c626e2769fe..fdad27ad103 100644
--- a/xlators/mount/fuse/utils/Makefile.am
+++ b/xlators/mount/fuse/utils/Makefile.am
@@ -1,10 +1,9 @@
utildir = @mountutildir@
-if GF_DARWIN_HOST_OS
-util_SCRIPTS = mount_glusterfs
-else
+if GF_LINUX_HOST_OS
util_SCRIPTS = mount.glusterfs
+else
+util_SCRIPTS = mount_glusterfs
endif
-CLEANFILES =
-
+CLEANFILES =
diff --git a/xlators/performance/md-cache/src/md-cache.c b/xlators/performance/md-cache/src/md-cache.c
index 5de84cdc4d5..7588463b891 100644
--- a/xlators/performance/md-cache/src/md-cache.c
+++ b/xlators/performance/md-cache/src/md-cache.c
@@ -18,6 +18,7 @@
#include "dict.h"
#include "xlator.h"
#include "md-cache-mem-types.h"
+#include "compat-errno.h"
#include "glusterfs-acl.h"
#include <assert.h>
#include <sys/time.h>
diff --git a/xlators/storage/posix/src/posix-handle.c b/xlators/storage/posix/src/posix-handle.c
index 78aba988e31..b6cfbd081ea 100644
--- a/xlators/storage/posix/src/posix-handle.c
+++ b/xlators/storage/posix/src/posix-handle.c
@@ -26,6 +26,8 @@
#include "xlator.h"
#include "syscall.h"
+#include "compat-errno.h"
+
inode_t *
posix_resolve (xlator_t *this, inode_table_t *itable, inode_t *parent,
char *bname, struct iatt *iabuf)
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index 143267637b5..c2f87c893d3 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -686,7 +686,7 @@ posix_gfid_set (xlator_t *this, const char *path, loc_t *loc, dict_t *xattr_req)
}
ret = sys_lsetxattr (path, GFID_XATTR_KEY, uuid_req, 16, XATTR_CREATE);
- if (ret != 0) {
+ if (ret == -1) {
gf_log (this->name, GF_LOG_WARNING,
"setting GFID on %s failed (%s)", path,
strerror (errno));
@@ -1268,6 +1268,11 @@ posix_acl_xattr_set (xlator_t *this, const char *path, dict_t *xattr_req)
if (data) {
ret = sys_lsetxattr (path, POSIX_ACL_ACCESS_XATTR,
data->data, data->len, 0);
+#ifdef __FreeBSD__
+ if (ret != -1) {
+ ret = 0;
+ }
+#endif /* __FreeBSD__ */
if (ret != 0)
goto out;
}
@@ -1276,6 +1281,11 @@ posix_acl_xattr_set (xlator_t *this, const char *path, dict_t *xattr_req)
if (data) {
ret = sys_lsetxattr (path, POSIX_ACL_DEFAULT_XATTR,
data->data, data->len, 0);
+#ifdef __FreeBSD__
+ if (ret != -1) {
+ ret = 0;
+ }
+#endif /* __FreeBSD__ */
if (ret != 0)
goto out;
}
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 35e34c4bec6..ef98939c46d 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -5344,7 +5344,7 @@ init (xlator_t *this)
/* Check for Extended attribute support, if not present, log it */
op_ret = sys_lsetxattr (dir_data->data,
"trusted.glusterfs.test", "working", 8, 0);
- if (op_ret == 0) {
+ if (op_ret != -1) {
sys_lremovexattr (dir_data->data, "trusted.glusterfs.test");
} else {
tmp_data = dict_get (this->options,
@@ -5451,7 +5451,7 @@ init (xlator_t *this)
/* First time volume, set the GFID */
size = sys_lsetxattr (dir_data->data, "trusted.gfid", rootgfid,
16, XATTR_CREATE);
- if (size) {
+ if (size == -1) {
gf_log (this->name, GF_LOG_ERROR,
"%s: failed to set gfid (%s)",
dir_data->data, strerror (errno));