diff options
| author | Harshavardhana <harsha@harshavardhana.net> | 2014-06-21 02:00:23 -0700 | 
|---|---|---|
| committer | Harshavardhana <harsha@harshavardhana.net> | 2014-07-02 17:20:34 -0700 | 
| commit | 1b74cf992986287a510fe3b28a8ee7554e8b0992 (patch) | |
| tree | a5fad911274080947f5874b4d90cc4f67b6f4473 /contrib | |
| parent | e4a3566681acbadfe0f7bd879443116885ada4eb (diff) | |
porting: Port for FreeBSD rebased from Mike Ma's efforts
- Provides a working Gluster Management Daemon, CLI
- Provides a working GlusterFS server, GlusterNFS server
- Provides a working GlusterFS client
- execinfo port from FreeBSD is moved into ./contrib/libexecinfo
  for ease of portability on NetBSD. (FreeBSD 10 and OSX provide
  execinfo natively)
- More portability cleanups for Darwin, FreeBSD and NetBSD
- Provides a new rc script for FreeBSD
Change-Id: I8dff336f97479ca5a7f9b8c6b730051c0f8ac46f
BUG: 1111774
Original-Author: Mike Ma <mikemandarine@gmail.com>
Signed-off-by: Harshavardhana <harsha@harshavardhana.net>
Reviewed-on: http://review.gluster.org/8141
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Diffstat (limited to 'contrib')
| -rw-r--r-- | contrib/fuse-include/fuse_kernel_macfuse.h | 470 | ||||
| -rw-r--r-- | contrib/fuse-lib/mount-common.c | 15 | ||||
| -rw-r--r-- | contrib/fuse-lib/mount-gluster-compat.h | 11 | ||||
| -rw-r--r-- | contrib/fuse-lib/mount.c | 87 | ||||
| -rw-r--r-- | contrib/libexecinfo/execinfo.c | 442 | ||||
| -rw-r--r-- | contrib/libexecinfo/execinfo_compat.h | 51 | ||||
| -rw-r--r-- | contrib/mount/mntent.c | 6 | ||||
| -rw-r--r-- | contrib/mount/mntent_compat.h | 2 | ||||
| -rw-r--r-- | contrib/qemu/include/qemu/bswap.h | 2 | ||||
| -rw-r--r-- | contrib/qemu/util/oslib-posix.c | 4 | 
10 files changed, 821 insertions, 269 deletions
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);  | 
