Fix: introduce lttng_get_unused_fd() wrapper for 3.19 kernels
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 24 Dec 2014 17:32:30 +0000 (12:32 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 24 Dec 2014 17:34:21 +0000 (12:34 -0500)
get_unused_fd disappears in 3.19 kernel, where get_unused_fd_flags(0)
should be used instead.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lttng-abi.c
lttng-syscalls.c
wrapper/file.h [new file with mode: 0644]

index 381a73904dfe60e6e6d0a8bc66a0cecf5fd65bf8..5823a1db042d6fa8aa5e88bef4a35235bf5eea4e 100644 (file)
@@ -49,6 +49,7 @@
 #include "wrapper/ringbuffer/backend.h"
 #include "wrapper/ringbuffer/frontend.h"
 #include "wrapper/poll.h"
+#include "wrapper/file.h"
 #include "lttng-abi.h"
 #include "lttng-abi-old.h"
 #include "lttng-events.h"
@@ -83,7 +84,7 @@ int lttng_abi_create_session(void)
        session = lttng_session_create();
        if (!session)
                return -ENOMEM;
-       session_fd = get_unused_fd();
+       session_fd = lttng_get_unused_fd();
        if (session_fd < 0) {
                ret = session_fd;
                goto fd_error;
@@ -112,7 +113,7 @@ int lttng_abi_tracepoint_list(void)
        struct file *tracepoint_list_file;
        int file_fd, ret;
 
-       file_fd = get_unused_fd();
+       file_fd = lttng_get_unused_fd();
        if (file_fd < 0) {
                ret = file_fd;
                goto fd_error;
@@ -332,7 +333,7 @@ int lttng_abi_create_channel(struct file *session_file,
        int chan_fd;
        int ret = 0;
 
-       chan_fd = get_unused_fd();
+       chan_fd = lttng_get_unused_fd();
        if (chan_fd < 0) {
                ret = chan_fd;
                goto fd_error;
@@ -783,7 +784,7 @@ int lttng_abi_create_stream_fd(struct file *channel_file, void *stream_priv,
        int stream_fd, ret;
        struct file *stream_file;
 
-       stream_fd = get_unused_fd();
+       stream_fd = lttng_get_unused_fd();
        if (stream_fd < 0) {
                ret = stream_fd;
                goto fd_error;
@@ -920,7 +921,7 @@ int lttng_abi_create_event(struct file *channel_file,
        }
        switch (event_param->instrumentation) {
        default:
-               event_fd = get_unused_fd();
+               event_fd = lttng_get_unused_fd();
                if (event_fd < 0) {
                        ret = event_fd;
                        goto fd_error;
index 1fc86c8eed5a84502d05b0efd893b052975d06ca..748c6002fc4a79ef3d2692bf997ac0820e60cbc2 100644 (file)
@@ -36,6 +36,7 @@
 
 #include "lib/bitfield.h"
 #include "wrapper/tracepoint.h"
+#include "wrapper/file.h"
 #include "lttng-events.h"
 
 #ifndef CONFIG_COMPAT
@@ -1269,7 +1270,7 @@ int lttng_abi_syscall_list(void)
        struct file *syscall_list_file;
        int file_fd, ret;
 
-       file_fd = get_unused_fd();
+       file_fd = lttng_get_unused_fd();
        if (file_fd < 0) {
                ret = file_fd;
                goto fd_error;
diff --git a/wrapper/file.h b/wrapper/file.h
new file mode 100644 (file)
index 0000000..2440745
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef _LTTNG_WRAPPER_FILE_H
+#define _LTTNG_WRAPPER_FILE_H
+
+/*
+ * wrapper/file.h
+ *
+ * wrapper around linux/file.h.
+ *
+ * Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; only
+ * version 2.1 of the License.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/version.h>
+#include <linux/file.h>
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0)
+
+static
+inline int lttng_get_unused_fd(void)
+{
+       return get_unused_fd_flags(0);
+}
+
+#else /* #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0) */
+
+static
+inline int lttng_get_unused_fd(void)
+{
+       return get_unused_fd();
+}
+
+#endif /* #else #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0) */
+
+#endif /* _LTTNG_WRAPPER_FILE_H */
This page took 0.029755 seconds and 4 git commands to generate.