From 997eff5e7244b15b4450030645b791cef68bf3e0 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Mon, 13 Apr 2020 12:26:59 -0400 Subject: [PATCH] wrapper: remove fdtable wrapper --- Makefile | 3 +-- lttng-statedump-impl.c | 7 +++--- wrapper/fdtable.c | 43 ------------------------------------- wrapper/fdtable.h | 48 ------------------------------------------ 4 files changed, 4 insertions(+), 97 deletions(-) delete mode 100644 wrapper/fdtable.c delete mode 100644 wrapper/fdtable.h diff --git a/Makefile b/Makefile index 4ae26b41..5358701b 100644 --- a/Makefile +++ b/Makefile @@ -122,8 +122,7 @@ ifneq ($(KERNELRELEASE),) endif obj-$(CONFIG_LTTNG) += lttng-statedump.o - lttng-statedump-objs := lttng-statedump-impl.o \ - wrapper/fdtable.o + lttng-statedump-objs := lttng-statedump-impl.o obj-$(CONFIG_LTTNG) += probes/ obj-$(CONFIG_LTTNG) += lib/ diff --git a/lttng-statedump-impl.c b/lttng-statedump-impl.c index ace81a3d..ebe76556 100644 --- a/lttng-statedump-impl.c +++ b/lttng-statedump-impl.c @@ -32,16 +32,15 @@ #include #include #include +#include #include #include -#include #include #include #include #include #include -#include #ifdef CONFIG_LTTNG_HAS_LIST_IRQ #include @@ -236,7 +235,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 && lttng_close_on_exec(fd, fdt)) + if (fd < fdt->max_fds && close_on_exec(fd, fdt)) flags |= O_CLOEXEC; if (IS_ERR(s)) { struct dentry *dentry = file->f_path.dentry; @@ -263,7 +262,7 @@ void lttng_enumerate_files(struct lttng_session *session, { struct lttng_fd_ctx ctx = { .page = tmp, .session = session, .files = files, }; - lttng_iterate_fd(files, 0, lttng_dump_one_fd, &ctx); + iterate_fd(files, 0, lttng_dump_one_fd, &ctx); } #ifdef LTTNG_HAVE_STATEDUMP_CPU_TOPOLOGY diff --git a/wrapper/fdtable.c b/wrapper/fdtable.c deleted file mode 100644 index 26a8367e..00000000 --- a/wrapper/fdtable.c +++ /dev/null @@ -1,43 +0,0 @@ -/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) - * wrapper/fdtable.c - * - * Copyright (C) 2013 Mathieu Desnoyers - */ - -#include -#include -#include - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) - -/* - * Reimplementation of iterate_fd() for kernels between 2.6.32 and 3.6 - * (inclusive). - */ -int lttng_iterate_fd(struct files_struct *files, - unsigned int first, - int (*cb)(const void *, struct file *, unsigned int), - const void *ctx) -{ - struct fdtable *fdt; - struct file *filp; - unsigned int i; - int res = 0; - - if (!files) - return 0; - spin_lock(&files->file_lock); - fdt = files_fdtable(files); - for (i = 0; i < fdt->max_fds; i++) { - filp = fcheck_files(files, i); - if (!filp) - continue; - res = cb(ctx, filp, i); - if (res) - break; - } - spin_unlock(&files->file_lock); - return res; -} - -#endif diff --git a/wrapper/fdtable.h b/wrapper/fdtable.h deleted file mode 100644 index 996199a7..00000000 --- a/wrapper/fdtable.h +++ /dev/null @@ -1,48 +0,0 @@ -/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) - * - * wrapper/fdtable.h - * - * Copyright (C) 2013 Mathieu Desnoyers - */ - -#ifndef _LTTNG_WRAPPER_FDTABLE_H -#define _LTTNG_WRAPPER_FDTABLE_H - -#include -#include - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) - -int lttng_iterate_fd(struct files_struct *files, - unsigned int first, - int (*cb)(const void *, struct file *, unsigned int), - const void *ctx); - -#else - -/* - * iterate_fd() appeared at commit - * c3c073f808b22dfae15ef8412b6f7b998644139a in the Linux kernel (first - * released kernel: v3.7). - */ -#define lttng_iterate_fd iterate_fd - -#endif - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) - -static inline bool lttng_close_on_exec(int fd, const struct fdtable *fdt) -{ - return close_on_exec(fd, fdt); -} - -#else - -static inline bool lttng_close_on_exec(int fd, const struct fdtable *fdt) -{ - return FD_ISSET(fd, fdt->close_on_exec); -} - -#endif - -#endif /* _LTTNG_WRAPPER_FDTABLE_H */ -- 2.34.1