This patch provides instrumentation for dup system call. It records the oldfd and newfd if the operation succeed. This is required to recover in the trace tre fd that newfd reference to.
Signed-off-by: Francis Giraldeau <[email protected]> --- fs/fcntl.c | 11 +++++++++-- include/trace/fs.h | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/fs/fcntl.c b/fs/fcntl.c index cb10261..3d3b3ac 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -20,11 +20,14 @@ #include <linux/signal.h> #include <linux/rcupdate.h> #include <linux/pid_namespace.h> +#include <trace/fs.h> #include <asm/poll.h> #include <asm/siginfo.h> #include <asm/uaccess.h> +DEFINE_TRACE(fs_dup); + void set_close_on_exec(unsigned int fd, int flag) { struct files_struct *files = current->files; @@ -104,6 +107,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags) if (tofree) filp_close(tofree, files); + trace_fs_dup(oldfd, newfd); return newfd; Ebadf: @@ -135,11 +139,14 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes) if (file) { ret = get_unused_fd(); - if (ret >= 0) + if (ret >= 0) { fd_install(ret, file); - else + trace_fs_dup(fildes, (unsigned int) ret); + } else { fput(file); + } } + return ret; } diff --git a/include/trace/fs.h b/include/trace/fs.h index efe7e47..7712331 100644 --- a/include/trace/fs.h +++ b/include/trace/fs.h @@ -63,4 +63,7 @@ DECLARE_TRACE(fs_select, DECLARE_TRACE(fs_poll, TP_PROTO(int fd), TP_ARGS(fd)); +DECLARE_TRACE(fs_dup, + TP_PROTO(unsigned int oldfd, unsigned int newfd), + TP_ARGS(oldfd, newfd)); #endif -- 1.7.1 _______________________________________________ ltt-dev mailing list [email protected] http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
