summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCsaba Henk <csaba@gluster.com>2010-05-17 07:09:13 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-05-21 00:31:51 -0700
commit11fb070964adf57eea4191d315a752c96f80a426 (patch)
tree8a66a5cfe14fe22315c2bfe0ea1667b8c6ab0349
parentbfb10f41a8e3fe7326f507451459529c5b39b72e (diff)
OS X: adjustments, minor fixes to eliminate warnings
Signed-off-by: Csaba Henk <csaba@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 361 (GlusterFS 3.0 should work on Mac OS/X) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=361
-rw-r--r--contrib/apple/daemon.c92
-rw-r--r--contrib/apple/daemon.h20
-rw-r--r--glusterfsd/src/Makefile.am6
-rw-r--r--glusterfsd/src/glusterfsd.c16
-rw-r--r--libglusterfs/src/logging.h12
-rw-r--r--xlators/cluster/unify/src/unify.c6
-rw-r--r--xlators/debug/trace/src/trace.c12
-rw-r--r--xlators/storage/posix/src/posix.c4
8 files changed, 153 insertions, 15 deletions
diff --git a/contrib/apple/daemon.c b/contrib/apple/daemon.c
new file mode 100644
index 000000000..9389201a1
--- /dev/null
+++ b/contrib/apple/daemon.c
@@ -0,0 +1,92 @@
+/*
+ Copyright (c) 2010 Gluster, Inc. <http://www.gluster.com>
+
+ Based on http://www.opensource.apple.com/source/Libc/Libc-583/gen/FreeBSD/daemon.c
+ */
+
+/*-
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <paths.h>
+#include <signal.h>
+#include <unistd.h>
+
+int
+os_daemon(nochdir, noclose)
+ int nochdir, noclose;
+{
+ struct sigaction osa, sa;
+ int fd;
+ pid_t newgrp;
+ int oerrno;
+ int osa_ok;
+
+ /* A SIGHUP may be thrown when the parent exits below. */
+ sigemptyset(&sa.sa_mask);
+ sa.sa_handler = SIG_IGN;
+ sa.sa_flags = 0;
+ osa_ok = sigaction(SIGHUP, &sa, &osa);
+
+ switch (fork()) {
+ case -1:
+ return (-1);
+ case 0:
+ break;
+ default:
+ _exit(0);
+ }
+
+ newgrp = setsid();
+ oerrno = errno;
+ if (osa_ok != -1)
+ sigaction(SIGHUP, &osa, NULL);
+
+ if (newgrp == -1) {
+ errno = oerrno;
+ return (-1);
+ }
+
+ if (!nochdir)
+ (void)chdir("/");
+
+ if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
+ (void)dup2(fd, STDIN_FILENO);
+ (void)dup2(fd, STDOUT_FILENO);
+ (void)dup2(fd, STDERR_FILENO);
+ if (fd > 2)
+ (void)close(fd);
+ }
+ return (0);
+}
diff --git a/contrib/apple/daemon.h b/contrib/apple/daemon.h
new file mode 100644
index 000000000..7a2824b6a
--- /dev/null
+++ b/contrib/apple/daemon.h
@@ -0,0 +1,20 @@
+/*
+ Copyright (c) 2010 Gluster, Inc. <http://www.gluster.com>
+ This file is part of GlusterFS.
+
+ GlusterFS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3 of the License,
+ or (at your option) any later version.
+
+ GlusterFS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
+*/
+
+int os_daemon(int nochdir, int noclose);
diff --git a/glusterfsd/src/Makefile.am b/glusterfsd/src/Makefile.am
index 060917930..38151fd5c 100644
--- a/glusterfsd/src/Makefile.am
+++ b/glusterfsd/src/Makefile.am
@@ -1,6 +1,9 @@
sbin_PROGRAMS = glusterfsd
glusterfsd_SOURCES = glusterfsd.c fetch-spec.c
+if GF_DARWIN_HOST_OS
+glusterfsd_SOURCES += $(CONTRIBDIR)/apple/daemon.c
+endif
glusterfsd_LDADD = $(top_builddir)/libglusterfs/src/libglusterfs.la $(GF_LDADD)
glusterfsd_LDFLAGS = $(GF_LDFLAGS) $(GF_GLUSTERFS_LDFLAGS)
noinst_HEADERS = glusterfsd.h
@@ -8,6 +11,9 @@ noinst_HEADERS = glusterfsd.h
AM_CFLAGS = -fPIC -Wall -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D$(GF_HOST_OS)\
-I$(top_srcdir)/libglusterfs/src -DDATADIR=\"$(localstatedir)\" \
-DCONFDIR=\"$(sysconfdir)/glusterfs\" $(GF_GLUSTERFS_CFLAGS)
+if GF_DARWIN_HOST_OS
+AM_CFLAGS += -I$(CONTRIBDIR)/apple
+endif
CLEANFILES =
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c
index afd9cafa6..8ffa3ac46 100644
--- a/glusterfsd/src/glusterfsd.c
+++ b/glusterfsd/src/glusterfsd.c
@@ -73,6 +73,13 @@
#include <fnmatch.h>
+#ifdef GF_DARWIN_HOST_OS
+#include "daemon.h"
+#else
+#define os_daemon(u, v) daemon (u, v)
+#endif
+
+
/* using argp for command line parsing */
static char gf_doc[] = "";
static char argp_doc[] = "--volfile-server=SERVER [MOUNT-POINT]\n" \
@@ -207,7 +214,7 @@ gf_daemon (int *pipe_fd)
/*child continues*/
close (pipe_fd[0]);
- if (daemon (0, 0) == -1) {
+ if (os_daemon (0, 0) == -1) {
gf_log ("glusterfs", GF_LOG_ERROR,
"unable to run in daemon mode: %s",
strerror (errno));
@@ -1063,7 +1070,12 @@ zr_build_process_uuid ()
localtime_r (&tv.tv_sec, &now);
strftime (now_str, 32, "%Y/%m/%d-%H:%M:%S", &now);
- snprintf (tmp_str, 1024, "%s-%d-%s:%ld",
+ snprintf (tmp_str, 1024, "%s-%d-%s:%"
+#ifdef GF_DARWIN_HOST_OS
+ PRId32,
+#else
+ "ld",
+#endif
hostname, getpid(), now_str, tv.tv_usec);
return gf_strdup (tmp_str);
diff --git a/libglusterfs/src/logging.h b/libglusterfs/src/logging.h
index 3c197c015..8c78a3ee1 100644
--- a/libglusterfs/src/logging.h
+++ b/libglusterfs/src/logging.h
@@ -30,11 +30,17 @@
#include <stdio.h>
#include <stdarg.h>
-#define GF_PRI_FSBLK PRId64
+#ifdef GF_DARWIN_HOST_OS
+#define GF_PRI_FSBLK "u"
+#define GF_PRI_DEV PRId32
+#define GF_PRI_NLINK PRIu16
+#else
+#define GF_PRI_FSBLK PRIu64
+#define GF_PRI_DEV PRIu64
+#define GF_PRI_NLINK PRIu32
+#endif
#define GF_PRI_BLKSIZE PRId32
#define GF_PRI_SIZET "zu"
-#define GF_PRI_NLINK PRId32
-#define GF_PRI_DEV PRId64
typedef enum {
GF_LOG_NONE,
diff --git a/xlators/cluster/unify/src/unify.c b/xlators/cluster/unify/src/unify.c
index d1fe847bc..e50d3274f 100644
--- a/xlators/cluster/unify/src/unify.c
+++ b/xlators/cluster/unify/src/unify.c
@@ -1117,7 +1117,8 @@ unify_open_lookup_cbk (call_frame_t *frame,
int32_t op_errno,
inode_t *inode,
struct iatt *buf,
- dict_t *dict)
+ dict_t *dict,
+ struct iatt *postparent)
{
int32_t callcnt = 0;
int16_t index = 0;
@@ -1209,7 +1210,8 @@ unify_open_readlink_cbk (call_frame_t *frame,
xlator_t *this,
int32_t op_ret,
int32_t op_errno,
- const char *path)
+ const char *path,
+ struct iatt *sbuf)
{
int16_t index = 0;
unify_private_t *priv = this->private;
diff --git a/xlators/debug/trace/src/trace.c b/xlators/debug/trace/src/trace.c
index aa9d33f3e..20ac6dbb5 100644
--- a/xlators/debug/trace/src/trace.c
+++ b/xlators/debug/trace/src/trace.c
@@ -171,9 +171,9 @@ trace_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
localtime ((time_t *)&buf->ia_ctime));
gf_log (this->name, GF_LOG_NORMAL,
- "%"PRId64": (op_ret=%d, buf {ia_gen=%"GF_PRI_DEV", "
+ "%"PRId64": (op_ret=%d, buf {ia_gen=%"PRIu64", "
"ia_ino=%"PRIu64", st_mode=%o, ia_nlink=%"GF_PRI_NLINK", "
- "ia_uid=%d, ia_gid=%d, ia_rdev=%"GF_PRI_DEV", ia_size=%"PRId64
+ "ia_uid=%d, ia_gid=%d, ia_rdev=%"PRIu64", ia_size=%"PRId64
", ia_blksize=%"GF_PRI_BLKSIZE", ia_blocks=%"PRId64", "
"ia_atime=%s, ia_mtime=%s, ia_ctime=%s})",
frame->root->unique, op_ret, buf->ia_gen, buf->ia_ino,
@@ -212,9 +212,9 @@ trace_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
localtime ((time_t *)&buf->ia_ctime));
gf_log (this->name, GF_LOG_NORMAL,
- "%"PRId64": (op_ret=%d, op_errno=%d, *buf {ia_gen=%"GF_PRI_DEV", "
+ "%"PRId64": (op_ret=%d, op_errno=%d, *buf {ia_gen=%"PRIu64", "
"ia_ino=%"PRIu64", st_mode=%o, ia_nlink=%"GF_PRI_NLINK", "
- "ia_uid=%d, ia_gid=%d, ia_rdev=%"GF_PRI_DEV", "
+ "ia_uid=%d, ia_gid=%d, ia_rdev=%"PRIu64", "
"ia_size=%"PRId64", ia_blksize=%"GF_PRI_BLKSIZE", "
"ia_blocks=%"PRId64", ia_atime=%s, ia_mtime=%s, ia_ctime=%s})",
frame->root->unique, op_ret, op_errno, buf->ia_gen, buf->ia_ino,
@@ -1052,9 +1052,9 @@ trace_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
localtime ((time_t *)&buf->ia_ctime));
gf_log (this->name, GF_LOG_NORMAL,
- "%"PRId64": (op_ret=%d, *buf {ia_gen=%"GF_PRI_DEV", "
+ "%"PRId64": (op_ret=%d, *buf {ia_gen=%"PRIu64", "
"ia_ino=%"PRIu64", st_mode=%o, ia_nlink=%"GF_PRI_NLINK", "
- "ia_uid=%d, ia_gid=%d, ia_rdev=%"GF_PRI_DEV", ia_size=%"PRId64", "
+ "ia_uid=%d, ia_gid=%d, ia_rdev=%"PRIu64", ia_size=%"PRId64", "
"ia_blksize=%"GF_PRI_BLKSIZE", ia_blocks=%"PRId64", ia_atime=%s, "
"ia_mtime=%s, ia_ctime=%s})",
frame->root->unique, op_ret, buf->ia_gen, buf->ia_ino,
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 22e9fcecb..e9a8fc886 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -273,7 +273,7 @@ posix_lstat_with_gen (xlator_t *this, const char *path, struct iatt *stbuf_p)
}
#ifndef GF_LINUX_HOST_OS
- if (stbuf.ia_type != IA_IFDIR && stbuf.ia_type != IA_IFREG) {
+ if (!IA_ISDIR (stbuf.ia_type) && !IA_ISREG (stbuf.ia_type)) {
stbuf.ia_gen = (typeof(stbuf.ia_gen))stbuf.ia_mtime;
if (stbuf_p)
*stbuf_p = stbuf;
@@ -344,7 +344,7 @@ posix_fstat_with_gen (xlator_t *this, int fd, struct iatt *stbuf_p)
}
#ifndef GF_LINUX_HOST_OS
- if (stbuf.ia_type != IA_IFDIR && stbuf.ia_type != IA_IFREG) {
+ if (!IA_ISDIR (stbuf.ia_type) && !IA_ISREG (stbuf.ia_type)) {
stbuf.ia_gen = (typeof(stbuf.ia_gen))stbuf.ia_mtime;
return 0;
}