From ca4537d385628d3568a918409d909d3042ca7a38 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Wed, 22 Feb 2012 16:53:12 -0500 Subject: [PATCH] Revert FreeBSD compatibility layer 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 --- src/bin/lttng-sessiond/lttng-sessiond.h | 3 +- src/bin/lttng-sessiond/main.c | 68 +++--------------- src/bin/lttng/lttng.c | 1 - src/common/Makefile.am | 24 +++---- src/common/compat/clone.h | 44 ------------ src/common/compat/compat-fcntl.c | 29 -------- src/common/compat/endian.h | 29 -------- src/common/compat/fcntl.h | 76 -------------------- src/common/compat/mman.h | 34 --------- src/common/compat/poll.h | 7 +- src/common/compat/socket.h | 63 ---------------- src/common/consumer.c | 5 +- src/common/consumer.h | 3 +- src/common/error.h | 17 +---- src/common/hashtable/rculfhash-mm-mmap.c | 4 -- src/common/hashtable/utils.c | 2 +- src/common/kernel-consumer/kernel-consumer.c | 7 +- src/common/runas.c | 4 +- src/common/sessiond-comm/sessiond-comm.c | 25 +++---- src/common/sessiond-comm/sessiond-comm.h | 4 +- src/common/ust-consumer/ust-consumer.c | 5 +- 21 files changed, 50 insertions(+), 404 deletions(-) delete mode 100644 src/common/compat/clone.h delete mode 100644 src/common/compat/compat-fcntl.c delete mode 100644 src/common/compat/endian.h delete mode 100644 src/common/compat/fcntl.h delete mode 100644 src/common/compat/mman.h delete mode 100644 src/common/compat/socket.h diff --git a/src/bin/lttng-sessiond/lttng-sessiond.h b/src/bin/lttng-sessiond/lttng-sessiond.h index 79e7fcb43..2ba2550c7 100644 --- a/src/bin/lttng-sessiond/lttng-sessiond.h +++ b/src/bin/lttng-sessiond/lttng-sessiond.h @@ -24,7 +24,6 @@ #include #include -#include #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 { diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 7dca8ad05..283868970 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -17,6 +17,7 @@ */ #define _GNU_SOURCE +#include #include #include #include @@ -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); } /* diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c index 16582b036..1349c20a7 100644 --- a/src/bin/lttng/lttng.c +++ b/src/bin/lttng/lttng.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include diff --git a/src/common/Makefile.am b/src/common/Makefile.am index ba93810a8..37f9acb9a 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -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 index 45eb37982..000000000 --- a/src/common/compat/clone.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2011 - David Goulet - * - * 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 - -#elif __FreeBSD__ - -#include - -#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 index 587df6782..000000000 --- a/src/common/compat/compat-fcntl.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2011 - David Goulet - * - * 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 - -#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 index b9382baaa..000000000 --- a/src/common/compat/endian.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2011 - David Goulet - * - * 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 -#elif __FreeBSD__ -#include -#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 index 575495fe5..000000000 --- a/src/common/compat/fcntl.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2011 - David Goulet - * - * 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 -#include - -#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 - -/* - * 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 index ede8c5883..000000000 --- a/src/common/compat/mman.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2011 - David Goulet - * - * 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 - -#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 */ diff --git a/src/common/compat/poll.h b/src/common/compat/poll.h index ded35410d..1580a4fb2 100644 --- a/src/common/compat/poll.h +++ b/src/common/compat/poll.h @@ -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 index 0eaf87a77..000000000 --- a/src/common/compat/socket.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2011 - David Goulet - * - * 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 -#include - -#include - -#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 */ diff --git a/src/common/consumer.c b/src/common/consumer.c index 80dedd5c6..b605591e4 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -19,6 +19,7 @@ #define _GNU_SOURCE #include +#include #include #include #include @@ -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; } /* diff --git a/src/common/consumer.h b/src/common/consumer.h index 35a72b50f..dc5fc9968 100644 --- a/src/common/consumer.h +++ b/src/common/consumer.h @@ -26,8 +26,7 @@ #include -#include -#include +#include "src/common/hashtable/hashtable.h" /* * When the receiving thread dies, we need to have a way to make the polling diff --git a/src/common/error.h b/src/common/error.h index 14b5e7c67..81c20223d 100644 --- a/src/common/error.h +++ b/src/common/error.h @@ -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 */ diff --git a/src/common/hashtable/rculfhash-mm-mmap.c b/src/common/hashtable/rculfhash-mm-mmap.c index b136e1ae0..4554ed600 100644 --- a/src/common/hashtable/rculfhash-mm-mmap.c +++ b/src/common/hashtable/rculfhash-mm-mmap.c @@ -24,10 +24,6 @@ #include #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) { diff --git a/src/common/hashtable/utils.c b/src/common/hashtable/utils.c index 01cc72b3b..50cd1ba95 100644 --- a/src/common/hashtable/utils.c +++ b/src/common/hashtable/utils.c @@ -50,6 +50,7 @@ */ #include +#include /* attempt to define endianness */ #include /* defines uint32_t etc */ #include /* defines printf for tests */ #include @@ -58,7 +59,6 @@ #include #include "utils.h" -#include /* attempt to define endianness */ /* * My best guess at if you are big-endian or little-endian. This may diff --git a/src/common/kernel-consumer/kernel-consumer.c b/src/common/kernel-consumer/kernel-consumer.c index f32f47b3e..3489ab6ed 100644 --- a/src/common/kernel-consumer/kernel-consumer.c +++ b/src/common/kernel-consumer/kernel-consumer.c @@ -19,6 +19,7 @@ #define _GNU_SOURCE #include +#include #include #include #include @@ -27,12 +28,10 @@ #include #include #include -#include #include #include #include -#include #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; } diff --git a/src/common/runas.c b/src/common/runas.c index bee107951..07912a7d6 100644 --- a/src/common/runas.c +++ b/src/common/runas.c @@ -28,11 +28,9 @@ #include #include #include -#include +#include #include -#include -#include #include "runas.h" diff --git a/src/common/sessiond-comm/sessiond-comm.c b/src/common/sessiond-comm/sessiond-comm.c index f133d5bfb..0c29003a6 100644 --- a/src/common/sessiond-comm/sessiond-comm.c +++ b/src/common/sessiond-comm/sessiond-comm.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -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; } diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h index e4d81f287..31b7fe466 100644 --- a/src/common/sessiond-comm/sessiond-comm.h +++ b/src/common/sessiond-comm/sessiond-comm.h @@ -28,7 +28,7 @@ #define _GNU_SOURCE #include #include -#include +#include /* 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); diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index e81f05041..5f5e95825 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -19,20 +19,19 @@ #define _GNU_SOURCE #include +#include #include #include #include #include #include #include -#include #include #include #include #include #include -#include #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; } -- 2.34.1