Fix: statedump: close_on_exec flag backward compat
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 26 Sep 2014 22:09:29 +0000 (18:09 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 26 Sep 2014 22:10:32 +0000 (18:10 -0400)
Older kernels (e.g. 3.2.62) use FD_ISSET() to test close_on_exec flag.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lttng-statedump-impl.c

index dad51ddaa25013f1bd5453aca4352854bd1ec6eb..17b02faf2be564385ff3c2bd5b7a210ef77988d8 100644 (file)
@@ -213,6 +213,18 @@ int lttng_enumerate_network_ip_interface(struct lttng_session *session)
 }
 #endif /* CONFIG_INET */
 
+#ifdef FD_ISSET        /* For old kernels lacking close_on_exec() */
+static inline bool lttng_close_on_exec(int fd, const struct fdtable *fdt)
+{
+       return FD_ISSET(fd, fdt->close_on_exec);
+}
+#else
+static inline bool lttng_close_on_exec(int fd, const struct fdtable *fdt)
+{
+       return close_on_exec(fd, fdt);
+}
+#endif
+
 static
 int lttng_dump_one_fd(const void *p, struct file *file, unsigned int fd)
 {
@@ -236,7 +248,7 @@ int lttng_dump_one_fd(const void *p, struct file *file, unsigned int fd)
         * the lock is taken, but we are not aware whether this is
         * guaranteed or not, so play safe.
         */
-       if (fd < fdt->max_fds && test_bit(fd, fdt->close_on_exec))
+       if (fd < fdt->max_fds && lttng_close_on_exec(fd, fdt))
                flags |= O_CLOEXEC;
        if (IS_ERR(s)) {
                struct dentry *dentry = file->f_path.dentry;
This page took 0.033112 seconds and 4 git commands to generate.