Revert FreeBSD compatibility layer
authorDavid Goulet <dgoulet@efficios.com>
Wed, 22 Feb 2012 21:53:12 +0000 (16:53 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Wed, 22 Feb 2012 21:58:32 +0000 (16:58 -0500)
Move those commits to the compat-freebsd branch instead of master branch
which is currently between release canditate and stable and this compat
layer will NOT go into 2.0-stable.

Revert "Fix rest of the code to support compat layer"
This reverts commit a440509044c2828bf6dbfb05e8d9d6d0277ce1a4.

Revert "Fix consumer to handle compat layer"
This reverts commit fbb2c21aac1386b7752f6254b2bd0bf001fa0ac1.

Revert "Multiple fix for FreeBSD compat layer"
This reverts commit bcc5eeb02fcad910c4de961b040351dad31b6f9f.

Revert "Add multiple FreeBSD compat layer"
This reverts commit d50813007e79158828e8ee6e1b5444950bc90847.

Revert "Add FreeBSD compat layer for splice and sync_file_range"
This reverts commit 826a02a292d2bd409be87ea96ba2fccbccee76b1.

Revert "Support XSI strerror_r in error.h"
This reverts commit e672cc585c3d67ee80278e29b538a3aed65df825.

Revert "Add FreeBSD compat layer for socket.h"
This reverts commit ef50a575de02a28aa158d7ba34b3d20ea329751a.

Revert "Fix FreeBSD support for rculfhash mmap"
This reverts commit e21193ea4abf7d93112b8ad3144ba11484d623c6.

Revert "Add FreeBSD compat layer for endian.h"
This reverts commit ae9d96fe577c198df432102cde69a28e82cccc1b.

Signed-off-by: David Goulet <dgoulet@efficios.com>
21 files changed:
src/bin/lttng-sessiond/lttng-sessiond.h
src/bin/lttng-sessiond/main.c
src/bin/lttng/lttng.c
src/common/Makefile.am
src/common/compat/clone.h [deleted file]
src/common/compat/compat-fcntl.c [deleted file]
src/common/compat/endian.h [deleted file]
src/common/compat/fcntl.h [deleted file]
src/common/compat/mman.h [deleted file]
src/common/compat/poll.h
src/common/compat/socket.h [deleted file]
src/common/consumer.c
src/common/consumer.h
src/common/error.h
src/common/hashtable/rculfhash-mm-mmap.c
src/common/hashtable/utils.c
src/common/kernel-consumer/kernel-consumer.c
src/common/runas.c
src/common/sessiond-comm/sessiond-comm.c
src/common/sessiond-comm/sessiond-comm.h
src/common/ust-consumer/ust-consumer.c

index 79e7fcb4383b1765a870a44c2c6576f5c6c7b92c..2ba2550c7a1bda4cdb6fa3d1ff2f1f9313ad35ae 100644 (file)
@@ -24,7 +24,6 @@
 #include <urcu/wfqueue.h>
 
 #include <common/sessiond-comm/sessiond-comm.h>
-#include <common/compat/socket.h>
 
 #include "session.h"
 #include "ust-app.h"
@@ -43,10 +42,10 @@ extern const char default_home_dir[],
 struct command_ctx {
        int ust_sock;
        unsigned int lttng_msg_size;
+       struct ucred creds;
        struct ltt_session *session;
        struct lttcomm_lttng_msg *llm;
        struct lttcomm_session_msg *lsm;
-       lttng_sock_cred creds;
 };
 
 struct ust_command {
index 7dca8ad05203b68944bd4fdd3e20e1dda2152d05..283868970f74e9eb2317e9a7e883c99d3b55f8bf 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #define _GNU_SOURCE
+#include <fcntl.h>
 #include <getopt.h>
 #include <grp.h>
 #include <limits.h>
@@ -294,22 +295,14 @@ static gid_t allowed_group(void)
  */
 static int init_thread_quit_pipe(void)
 {
-       int ret, i;
+       int ret;
 
-       ret = pipe(thread_quit_pipe);
+       ret = pipe2(thread_quit_pipe, O_CLOEXEC);
        if (ret < 0) {
-               PERROR("thread quit pipe");
+               perror("thread quit pipe");
                goto error;
        }
 
-       for (i = 0; i < 2; i++) {
-               ret = fcntl(thread_quit_pipe[i], F_SETFD, FD_CLOEXEC);
-               if (ret < 0) {
-                       PERROR("fcntl");
-                       goto error;
-               }
-       }
-
 error:
        return ret;
 }
@@ -2879,12 +2872,11 @@ error:
 /*
  * Command LTTNG_CREATE_SESSION processed by the client thread.
  */
-static int cmd_create_session(char *name, char *path, lttng_sock_cred *creds)
+static int cmd_create_session(char *name, char *path, struct ucred *creds)
 {
        int ret;
 
-       ret = session_create(name, path, LTTNG_SOCK_GET_UID_CRED(creds),
-                       LTTNG_SOCK_GET_GID_CRED(creds));
+       ret = session_create(name, path, creds->uid, creds->gid);
        if (ret != LTTCOMM_OK) {
                goto error;
        }
@@ -3291,8 +3283,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx)
         */
        if (need_tracing_session) {
                if (!session_access_ok(cmd_ctx->session,
-                               LTTNG_SOCK_GET_UID_CRED(&cmd_ctx->creds),
-                               LTTNG_SOCK_GET_GID_CRED(&cmd_ctx->creds))) {
+                               cmd_ctx->creds.uid, cmd_ctx->creds.gid)) {
                        ret = LTTCOMM_EPERM;
                        goto error;
                }
@@ -3485,9 +3476,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx)
                unsigned int nr_sessions;
 
                session_lock_list();
-               nr_sessions = lttng_sessions_count(
-                               LTTNG_SOCK_GET_UID_CRED(&cmd_ctx->creds),
-                               LTTNG_SOCK_GET_GID_CRED(&cmd_ctx->creds));
+               nr_sessions = lttng_sessions_count(cmd_ctx->creds.uid, cmd_ctx->creds.gid);
 
                ret = setup_lttng_msg(cmd_ctx, sizeof(struct lttng_session) * nr_sessions);
                if (ret < 0) {
@@ -3497,8 +3486,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx)
 
                /* Filled the session array */
                list_lttng_sessions((struct lttng_session *)(cmd_ctx->llm->payload),
-                       LTTNG_SOCK_GET_UID_CRED(&cmd_ctx->creds),
-                       LTTNG_SOCK_GET_GID_CRED(&cmd_ctx->creds));
+                       cmd_ctx->creds.uid, cmd_ctx->creds.gid);
 
                session_unlock_list();
 
@@ -3992,24 +3980,7 @@ end:
  */
 static int create_kernel_poll_pipe(void)
 {
-       int ret, i;
-
-       ret = pipe(kernel_poll_pipe);
-       if (ret < 0) {
-               PERROR("kernel poll pipe");
-               goto error;
-       }
-
-       for (i = 0; i < 2; i++) {
-               ret = fcntl(kernel_poll_pipe[i], F_SETFD, FD_CLOEXEC);
-               if (ret < 0) {
-                       PERROR("fcntl kernel_poll_pipe");
-                       goto error;
-               }
-       }
-
-error:
-       return ret;
+       return pipe2(kernel_poll_pipe, O_CLOEXEC);
 }
 
 /*
@@ -4017,24 +3988,7 @@ error:
  */
 static int create_apps_cmd_pipe(void)
 {
-       int ret, i;
-
-       ret = pipe(apps_cmd_pipe);
-       if (ret < 0) {
-               PERROR("apps cmd pipe");
-               goto error;
-       }
-
-       for (i = 0; i < 2; i++) {
-               ret = fcntl(apps_cmd_pipe[i], F_SETFD, FD_CLOEXEC);
-               if (ret < 0) {
-                       PERROR("fcntl apps_cmd_pipe");
-                       goto error;
-               }
-       }
-
-error:
-       return ret;
+       return pipe2(apps_cmd_pipe, O_CLOEXEC);
 }
 
 /*
index 16582b0363b86fa1405d4afd6d1751f3c36b9499..1349c20a726f0cb2b51a88d25c113928522f147c 100644 (file)
@@ -26,7 +26,6 @@
 #include <sys/wait.h>
 #include <unistd.h>
 #include <config.h>
-#include <ctype.h>
 
 #include <lttng/lttng.h>
 #include <common/error.h>
index ba93810a8c3fe6af5bf8bd7c4188d037de4421ec..37f9acb9ab144b9a7ce711b4062d62a82bc78a4a 100644 (file)
@@ -10,17 +10,6 @@ noinst_LTLIBRARIES = libcommon.la
 
 libcommon_la_SOURCES = runas.c runas.h common.h
 
-if COMPAT_EPOLL
-COMPAT=compat/compat-epoll.c
-else
-COMPAT=compat/compat-poll.c
-endif
-
-noinst_LTLIBRARIES += libcompat.la
-
-libcompat_la_SOURCES = compat/poll.h compat/fcntl.h compat/splice.h compat/endian.h \
-                       compat/socket.h compat/compat-fcntl.c $(COMPAT)
-
 # Consumer library
 noinst_LTLIBRARIES += libconsumer.la
 
@@ -29,10 +18,19 @@ libconsumer_la_SOURCES = consumer.c consumer.h
 libconsumer_la_LIBADD = \
                $(top_builddir)/src/common/sessiond-comm/libsessiond-comm.la \
                $(top_builddir)/src/common/kernel-consumer/libkernel-consumer.la \
-               $(top_builddir)/src/common/hashtable/libhashtable.la \
-               $(top_builddir)/src/common/libcompat.la
+               $(top_builddir)/src/common/hashtable/libhashtable.la
 
 if HAVE_LIBLTTNG_UST_CTL
 libconsumer_la_LIBADD += \
                $(top_builddir)/src/common/ust-consumer/libust-consumer.la
 endif
+
+if COMPAT_EPOLL
+COMPAT=compat/compat-epoll.c
+else
+COMPAT=compat/compat-poll.c
+endif
+
+noinst_LTLIBRARIES += libcompat.la
+
+libcompat_la_SOURCES = compat/poll.h $(COMPAT)
diff --git a/src/common/compat/clone.h b/src/common/compat/clone.h
deleted file mode 100644 (file)
index 45eb379..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2011 - David Goulet <dgoulet@efficios.com>
- *
- * This program 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; only version 2 of the License.
- *
- * This program 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, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-
-#ifndef _COMPAT_CLONE_H
-#define _COMPAT_CLONE_H
-
-#ifdef __linux__
-
-#include <sched.h>
-
-#elif __FreeBSD__
-
-#include <unistd.h>
-
-#define CLONE_FILES 0
-
-#define clone(fct_ptr, child_stack, flags, arg, args...) \
-       compat_clone(fct_ptr, child_stack, flags, arg)
-
-int compat_clone(int (*fn)(void *), void *child_stack, int flags,
-               void *arg)
-{
-       return -ENOSYS;
-}
-
-#else
-#error "Please add support for your OS into compat/clone.h."
-#endif /* __linux__ , __FreeBSD__ */
-
-#endif /* _COMPAT_CLONE_H */
diff --git a/src/common/compat/compat-fcntl.c b/src/common/compat/compat-fcntl.c
deleted file mode 100644 (file)
index 587df67..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2011 - David Goulet <dgoulet@efficios.com>
- *
- * This program 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; only version 2 of the License.
- *
- * This program 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, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-
-#define _GNU_SOURCE
-#include <common/compat/fcntl.h>
-
-#ifdef __linux__
-
-int compat_sync_file_range(int fd, off64_t offset, off64_t nbytes,
-               unsigned int flags)
-{
-       return sync_file_range(fd, offset, nbytes, flags);
-}
-
-#endif /* __linux__ */
diff --git a/src/common/compat/endian.h b/src/common/compat/endian.h
deleted file mode 100644 (file)
index b9382ba..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2011 - David Goulet <dgoulet@efficios.com>
- *
- * This program 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; only version 2 of the License.
- *
- * This program 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, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-
-#ifdef _COMPAT_ENDIAN_H
-#define _COMPAT_ENDIAN_H
-
-#ifdef __linux__
-#include <endian.h>
-#elif __FreeBSD__
-#include <machine/endian.h>
-#else
-#error "Please add support for your OS into lttng/ust-endian.h."
-#endif
-
-#endif /* _COMPAT_ENDIAN_H */
diff --git a/src/common/compat/fcntl.h b/src/common/compat/fcntl.h
deleted file mode 100644 (file)
index 575495f..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2011 - David Goulet <dgoulet@efficios.com>
- *
- * This program 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; only version 2 of the License.
- *
- * This program 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, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-
-#ifndef _COMPAT_FCNTL_H
-#define _COMPAT_FCNTL_H
-
-#include <fcntl.h>
-#include <sys/types.h>
-
-#ifdef __linux__
-
-extern int compat_sync_file_range(int fd, off64_t offset, off64_t nbytes,
-               unsigned int flags);
-#define lttng_sync_file_range(fd, offset, nbytes, flags) \
-       compat_sync_file_range(fd, offset, nbytes, flags)
-
-#elif __FreeBSD__
-
-typedef long int off64_t;
-typedef off64_t loff_t;
-
-#include <sys/errno.h>
-
-/*
- * Possible flags under Linux. Simply nullify them and avoid wrapper.
- */
-#define SYNC_FILE_RANGE_WAIT_AFTER    0
-#define SYNC_FILE_RANGE_WAIT_BEFORE   0
-#define SYNC_FILE_RANGE_WRITE         0
-
-/*
- * Possible flags under Linux. Simply nullify them and avoid wrappers.
- */
-#define SPLICE_F_MOVE       0
-#define SPLICE_F_NONBLOCK   0
-#define SPLICE_F_MORE       0
-#define SPLICE_F_GIFT       0
-
-#define POSIX_FADV_DONTNEED 0
-
-static inline int lttng_sync_file_range(int fd, off64_t offset,
-               off64_t nbytes, unsigned int flags)
-{
-       return -ENOSYS;
-}
-
-static inline ssize_t splice(int fd_in, loff_t *off_in, int fd_out, loff_t *off_out,
-               size_t len, unsigned int flags)
-{
-       return -ENOSYS;
-}
-
-static inline int posix_fadvise(int fd, off_t offset, off_t len, int advice)
-{
-       return -ENOSYS;
-}
-
-#else
-#error "Please add support for your OS into compat/fcntl.h."
-#endif /* __linux__ , __FreeBSD__ */
-
-#endif /* _COMPAT_FCNTL_H */
diff --git a/src/common/compat/mman.h b/src/common/compat/mman.h
deleted file mode 100644 (file)
index ede8c58..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2011 - David Goulet <dgoulet@efficios.com>
- *
- * This program 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; only version 2 of the License.
- *
- * This program 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, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-
-#ifndef _COMPAT_MMAN_H
-#define _COMPAT_MMAN_H
-
-#include <sys/mman.h>
-
-#ifdef __linux__
-
-#elif __FreeBSD__
-
-#define MAP_GROWSDOWN 0
-#define MAP_ANONYMOUS MAP_ANON
-
-#else
-#error "Please add support for your OS into compat/mman.h."
-#endif /* __linux__ , __FreeBSD__ */
-
-#endif /* _COMPAT_MMAN_H */
index ded35410d48dd3d7232608746e46f6d334dd7733..1580a4fb211a24def1146d7ec5c721431c34e3b4 100644 (file)
@@ -179,15 +179,10 @@ enum {
        LPOLLRDBAND = POLLRDBAND,
        LPOLLWRNORM = POLLWRNORM,
        LPOLLWRBAND = POLLWRBAND,
-#if __linux__
        LPOLLMSG = POLLMSG,
-       LPOLLRDHUP = POLLRDHUP,
-#elif __FreeBSD__
-       LPOLLMSG = 0,
-       LPOLLRDHUP = 0,
-#endif /* __linux__ */
        LPOLLERR = POLLERR,
        LPOLLHUP = POLLHUP | POLLNVAL,
+       LPOLLRDHUP = POLLRDHUP,
        /* Close on exec feature does not exist for poll(2) */
        LTTNG_CLOEXEC = 0xdead,
 };
diff --git a/src/common/compat/socket.h b/src/common/compat/socket.h
deleted file mode 100644 (file)
index 0eaf87a..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2011 - David Goulet <dgoulet@efficios.com>
- *
- * This program 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; only version 2 of the License.
- *
- * This program 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, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-
-#ifndef _COMPAT_SOCKET_H
-#define _COMPAT_SOCKET_H
-
-#include <sys/socket.h>
-#include <sys/un.h>
-
-#include <common/macros.h>
-
-#ifdef __linux__
-
-#define LTTNG_SOCK_CREDS SCM_CREDENTIALS
-#define LTTNG_SOCK_FDS   SCM_RIGHTS
-
-typedef struct ucred lttng_sock_cred;
-
-#define LTTNG_SOCK_SET_UID_CRED(c, u) LTTNG_REF(c)->uid = u
-#define LTTNG_SOCK_SET_GID_CRED(c, g) LTTNG_REF(c)->gid = g
-#define LTTNG_SOCK_SET_PID_CRED(c, p) LTTNG_REF(c)->pid = p
-
-#define LTTNG_SOCK_GET_UID_CRED(c) LTTNG_REF(c)->uid
-#define LTTNG_SOCK_GET_GID_CRED(c) LTTNG_REF(c)->gid
-#define LTTNG_SOCK_GET_PID_CRED(c) LTTNG_REF(c)->pid
-
-#elif __FreeBSD__
-
-#undef SO_PASSCRED
-#define SO_PASSCRED 0
-
-#define LTTNG_SOCK_CREDS SCM_CREDS
-#define LTTNG_SOCK_FDS   SCM_RIGHTS
-
-typedef struct cmsgcred lttng_sock_cred;
-
-#define LTTNG_SOCK_SET_UID_CRED(c, uid) LTTNG_REF(c)->cmcred_uid = uid
-#define LTTNG_SOCK_SET_GID_CRED(c, gid) LTTNG_REF(c)->cmcred_gid = gid
-#define LTTNG_SOCK_SET_PID_CRED(c, pid) LTTNG_REF(c)->cmcred_pid = pid
-
-#define LTTNG_SOCK_GET_UID_CRED(c) LTTNG_REF(c)->cmcred_uid
-#define LTTNG_SOCK_GET_GID_CRED(c) LTTNG_REF(c)->cmcred_gid
-#define LTTNG_SOCK_GET_PID_CRED(c) LTTNG_REF(c)->cmcred_pid
-
-#else
-#error "Please add support for your OS into lttng/ust-endian.h."
-#endif /* __linux__ , __FreeBSD__ */
-
-#endif /* _COMPAT_SOCKET_H */
index 80dedd5c6cfd057397eef3706ec62ef9717889e7..b605591e478a1c2a40dd13a25228bd2ad80bc684 100644 (file)
@@ -19,6 +19,7 @@
 
 #define _GNU_SOURCE
 #include <assert.h>
+#include <fcntl.h>
 #include <poll.h>
 #include <pthread.h>
 #include <stdlib.h>
@@ -600,7 +601,7 @@ void lttng_consumer_sync_trace_file(
        if (orig_offset < stream->chan->max_sb_size) {
                return;
        }
-       lttng_sync_file_range(outfd, orig_offset - stream->chan->max_sb_size,
+       sync_file_range(outfd, orig_offset - stream->chan->max_sb_size,
                        stream->chan->max_sb_size,
                        SYNC_FILE_RANGE_WAIT_BEFORE
                        | SYNC_FILE_RANGE_WRITE
@@ -741,8 +742,6 @@ int lttng_consumer_on_read_subbuffer_mmap(
                ERR("Unknown consumer_data type");
                assert(0);
        }
-
-       return 0;
 }
 
 /*
index 35a72b50f6078e333f1fe754de5f183417b71767..dc5fc9968be02fbf45b223ef20a8371fdc4e0005 100644 (file)
@@ -26,8 +26,7 @@
 
 #include <lttng/lttng.h>
 
-#include <common/hashtable/hashtable.h>
-#include <common/compat/fcntl.h>
+#include "src/common/hashtable/hashtable.h"
 
 /*
  * When the receiving thread dies, we need to have a way to make the polling
index 14b5e7c67ea1eda8f519f2cfe42a48cd32a3a7ca..81c20223d124282b59bb8ea23801cd714156f441 100644 (file)
@@ -77,27 +77,12 @@ extern int opt_verbose;
 #define _PERROR(fmt, args...) \
        __lttng_print(PRINT_ERR, "perror " fmt "\n", ## args)
 
-#if !defined(__linux__) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE))
-/*
- * Version using XSI strerror_r.
- */
-#define PERROR(call, args...) \
-       do { \
-               char buf[200]; \
-               strerror_r(errno, buf, sizeof(buf)); \
-               _PERROR(call ": %s", ## args, buf); \
-       } while(0);
-#else
-/*
- * Version using GNU strerror_r, for linux with appropriate defines.
- */
 #define PERROR(call, args...) \
-       do { \
+    do { \
                char *buf; \
                char tmp[200]; \
                buf = strerror_r(errno, tmp, sizeof(tmp)); \
                _PERROR(call ": %s", ## args, buf); \
        } while(0);
-#endif
 
 #endif /* _ERROR_H */
index b136e1ae0eb73b46d2035cf2bbd9e470f96861d3..4554ed6007f20df68bfac3f2fe74a5a9e39c55fc 100644 (file)
 #include <sys/mman.h>
 #include "rculfhash-internal.h"
 
-#ifndef MAP_ANONYMOUS
-#define MAP_ANONYMOUS MAP_ANON
-#endif
-
 /* reserve inaccessible memory space without allocation any memory */
 static void *memory_map(size_t length)
 {
index 01cc72b3b4f8e5151a815e7461724160331ba82a..50cd1ba959cd8dbb838b9785deaa83ffae8e4501 100644 (file)
@@ -50,6 +50,7 @@
  */
 
 #include <assert.h>
+#include <endian.h>    /* attempt to define endianness */
 #include <stdint.h>     /* defines uint32_t etc */
 #include <stdio.h>      /* defines printf for tests */
 #include <string.h>
@@ -58,7 +59,6 @@
 #include <urcu/compiler.h>
 
 #include "utils.h"
-#include <common/compat/endian.h>    /* attempt to define endianness */
 
 /*
  * My best guess at if you are big-endian or little-endian.  This may
index f32f47b3eeb1f6faf6b615700529dea5e990c7e5..3489ab6ed866970eec6915701ffef029d27d6c36 100644 (file)
@@ -19,6 +19,7 @@
 
 #define _GNU_SOURCE
 #include <assert.h>
+#include <fcntl.h>
 #include <poll.h>
 #include <pthread.h>
 #include <stdlib.h>
 #include <sys/socket.h>
 #include <sys/types.h>
 #include <unistd.h>
-#include <sys/stat.h>
 
 #include <common/common.h>
 #include <common/kernel-ctl/kernel-ctl.h>
 #include <common/sessiond-comm/sessiond-comm.h>
-#include <common/compat/fcntl.h>
 
 #include "kernel-consumer.h"
 
@@ -73,7 +72,7 @@ int lttng_kconsumer_on_read_subbuffer_mmap(
                        goto end;
                }
                /* This won't block, but will start writeout asynchronously */
-               lttng_sync_file_range(outfd, stream->out_fd_offset, ret,
+               sync_file_range(outfd, stream->out_fd_offset, ret,
                                SYNC_FILE_RANGE_WRITE);
                stream->out_fd_offset += ret;
        }
@@ -123,7 +122,7 @@ int lttng_kconsumer_on_read_subbuffer_splice(
                }
                len -= ret;
                /* This won't block, but will start writeout asynchronously */
-               lttng_sync_file_range(outfd, stream->out_fd_offset, ret,
+               sync_file_range(outfd, stream->out_fd_offset, ret,
                                SYNC_FILE_RANGE_WRITE);
                stream->out_fd_offset += ret;
        }
index bee107951d8664e6f111ed5ff260574407f0c3a3..07912a7d68bf7ce97cf7ba765194fd66e28334c8 100644 (file)
 #include <unistd.h>
 #include <fcntl.h>
 #include <sched.h>
-#include <sys/signal.h>
+#include <sys/mman.h>
 
 #include <common/error.h>
-#include <common/compat/mman.h>
-#include <common/compat/clone.h>
 
 #include "runas.h"
 
index f133d5bfbabe1892c868c6ccb7d6784cc707ac2f..0c29003a6267a382b204a6f277a9d0a1468ad182 100644 (file)
@@ -24,6 +24,7 @@
 #include <string.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <sys/un.h>
 #include <unistd.h>
 #include <errno.h>
 
@@ -411,7 +412,7 @@ ssize_t lttcomm_recv_fds_unix_sock(int sock, int *fds, size_t nb_fd)
        }
        if (cmsg->cmsg_len != CMSG_LEN(sizeof_fds)) {
                fprintf(stderr, "Error: Received %zu bytes of ancillary data, expected %zu\n",
-                               (size_t) cmsg->cmsg_len, (size_t) CMSG_LEN(sizeof_fds));
+                               cmsg->cmsg_len, CMSG_LEN(sizeof_fds));
                ret = -1;
                goto end;
        }
@@ -432,9 +433,9 @@ ssize_t lttcomm_send_creds_unix_sock(int sock, void *buf, size_t len)
        struct cmsghdr *cmptr;
        struct iovec iov[1];
        ssize_t ret = -1;
-       size_t sizeof_cred = sizeof(lttng_sock_cred);
+       struct ucred *creds;
+       size_t sizeof_cred = sizeof(struct ucred);
        char anc_buf[CMSG_SPACE(sizeof_cred)];
-       lttng_sock_cred *creds;
 
        memset(&msg, 0, sizeof(msg));
 
@@ -448,14 +449,14 @@ ssize_t lttcomm_send_creds_unix_sock(int sock, void *buf, size_t len)
 
        cmptr = CMSG_FIRSTHDR(&msg);
        cmptr->cmsg_level = SOL_SOCKET;
-       cmptr->cmsg_type = LTTNG_SOCK_CREDS;
+       cmptr->cmsg_type = SCM_CREDENTIALS;
        cmptr->cmsg_len = CMSG_LEN(sizeof_cred);
 
-       creds = (lttng_sock_cred*) CMSG_DATA(cmptr);
+       creds = (struct ucred *) CMSG_DATA(cmptr);
 
-       LTTNG_SOCK_SET_UID_CRED(creds, geteuid());
-       LTTNG_SOCK_SET_GID_CRED(creds, getegid());
-       LTTNG_SOCK_SET_PID_CRED(creds, getpid());
+       creds->uid = geteuid();
+       creds->gid = getegid();
+       creds->pid = getpid();
 
        ret = sendmsg(sock, &msg, 0);
        if (ret < 0) {
@@ -471,13 +472,13 @@ ssize_t lttcomm_send_creds_unix_sock(int sock, void *buf, size_t len)
  * Returns the size of received data, or negative error value.
  */
 ssize_t lttcomm_recv_creds_unix_sock(int sock, void *buf, size_t len,
-               lttng_sock_cred *creds)
+               struct ucred *creds)
 {
        struct msghdr msg;
        struct cmsghdr *cmptr;
        struct iovec iov[1];
        ssize_t ret;
-       size_t sizeof_cred = sizeof(lttng_sock_cred);
+       size_t sizeof_cred = sizeof(struct ucred);
        char anc_buf[CMSG_SPACE(sizeof_cred)];
 
        memset(&msg, 0, sizeof(msg));
@@ -517,7 +518,7 @@ ssize_t lttcomm_recv_creds_unix_sock(int sock, void *buf, size_t len,
        }
 
        if (cmptr->cmsg_level != SOL_SOCKET ||
-                       cmptr->cmsg_type != LTTNG_SOCK_CREDS) {
+                       cmptr->cmsg_type != SCM_CREDENTIALS) {
                fprintf(stderr, "Didn't received any credentials\n");
                ret = -1;
                goto end;
@@ -525,7 +526,7 @@ ssize_t lttcomm_recv_creds_unix_sock(int sock, void *buf, size_t len,
 
        if (cmptr->cmsg_len != CMSG_LEN(sizeof_cred)) {
                fprintf(stderr, "Error: Received %zu bytes of ancillary data, expected %zu\n",
-                               (size_t) cmptr->cmsg_len, (size_t) CMSG_LEN(sizeof_cred));
+                               cmptr->cmsg_len, CMSG_LEN(sizeof_cred));
                ret = -1;
                goto end;
        }
index e4d81f28718f7adf4e8cb73d50252e4a7cd29304..31b7fe4661cbd1db37acb52013d31048b873df2e 100644 (file)
@@ -28,7 +28,7 @@
 #define _GNU_SOURCE
 #include <limits.h>
 #include <lttng/lttng.h>
-#include <common/compat/socket.h>
+#include <sys/socket.h>
 
 /* Queue size of listen(2) */
 #define LTTNG_SESSIOND_COMM_MAX_LISTEN 64
@@ -291,7 +291,7 @@ extern ssize_t lttcomm_send_unix_sock(int sock, void *buf, size_t len);
 
 extern ssize_t lttcomm_send_creds_unix_sock(int sock, void *buf, size_t len);
 extern ssize_t lttcomm_recv_creds_unix_sock(int sock, void *buf, size_t len,
-               lttng_sock_cred *creds);
+               struct ucred *creds);
 
 extern const char *lttcomm_get_readable_code(enum lttcomm_return_code code);
 extern int lttcomm_setsockopt_creds_unix_sock(int sock);
index e81f05041249a164ce09151e9907c0602b41d6be..5f5e9582574011577297bf36123a64958a752793 100644 (file)
 
 #define _GNU_SOURCE
 #include <assert.h>
+#include <fcntl.h>
 #include <poll.h>
 #include <pthread.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/mman.h>
 #include <sys/socket.h>
-#include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
 #include <lttng/ust-ctl.h>
 
 #include <common/common.h>
 #include <common/sessiond-comm/sessiond-comm.h>
-#include <common/compat/fcntl.h>
 
 #include "ust-consumer.h"
 
@@ -72,7 +71,7 @@ int lttng_ustconsumer_on_read_subbuffer_mmap(
                        goto end;
                }
                /* This won't block, but will start writeout asynchronously */
-               lttng_sync_file_range(outfd, stream->out_fd_offset, ret,
+               sync_file_range(outfd, stream->out_fd_offset, ret,
                                SYNC_FILE_RANGE_WRITE);
                stream->out_fd_offset += ret;
        }
This page took 0.061924 seconds and 4 git commands to generate.