From 8bd0f6dce9effdb8bde2fb2cc6ab2c68be8d32d7 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 19 Mar 2010 13:00:50 +0100 Subject: [PATCH] PR11402 Support pipe2 syscall. The pipe2() was added to Linux in version 2.6.27. It is a variant of the normal pipe syscall, but takes an extra flags argument which can be the ORed value of O_NONBLOCK and O_CLOEXEC. * tapset/aux_syscalls.stp (_sys_pipe2_flag_str:string): New helper function. * tapset/syscalls2.stp (syscall.pipe2, syscall.pipe2.return): New probes. --- tapset/aux_syscalls.stp | 19 +++++++++++++++++++ tapset/syscalls2.stp | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/tapset/aux_syscalls.stp b/tapset/aux_syscalls.stp index fdd6f6afe..84342448a 100644 --- a/tapset/aux_syscalls.stp +++ b/tapset/aux_syscalls.stp @@ -554,6 +554,25 @@ function _flock_cmd_str(c) { return substr(bs,0,strlen(bs)-1) } +/* `man 2 pipe2` for more information */ +function _sys_pipe2_flag_str:string (f:long) +%{ /* pure */ /* unprivileged */ + long flags = THIS->f; + char *str = THIS->__retvalue; + int len; + +#if defined(O_NONBLOCK) && defined(O_CLOEXEC) + if (flags & O_NONBLOCK) + strlcat(str, "O_NONBLOCK|", MAXSTRINGLEN); + if (flags & O_CLOEXEC) + strlcat(str, "O_CLOEXEC|", MAXSTRINGLEN); +#endif + + len = strlen(str); + if (len) + str[strlen(str)-1] = 0; +%} + /* `man 2 open` for more information */ function _sys_open_flag_str:string (f:long) %{ /* pure */ diff --git a/tapset/syscalls2.stp b/tapset/syscalls2.stp index 38f850f0a..8f6e26e3a 100644 --- a/tapset/syscalls2.stp +++ b/tapset/syscalls2.stp @@ -350,6 +350,46 @@ probe syscall.pipe.return = kernel.function("SyS_pipe").return !, retstr = returnstr(1) } +# pipe2 ______________________________________________________ +# +# SYSCALL_DEFINE2(pipe2, int __user *, fildes, int, flags) +# pipe2() was added to Linux in version 2.6.27. +probe syscall.pipe2 = kernel.function("sys_pipe2").call? +{ + name = "pipe2" + flags = $flags + flag_str = _sys_pipe2_flag_str(flags); + fildes_uaddr = $fildes + if (fildes_uaddr == 0) + { + pipe0 = 0; + pipe1 = 0; + argstr = "NULL" + } + else + { + pipe0 = user_int(&$fildes[0]); + pipe1 = user_int(&$fildes[1]); + argstr = sprintf("[%d, %d] %s", pipe0, pipe1, flag_str) + } +} +probe syscall.pipe2.return = kernel.function("sys_pipe2").return? +{ + name = "pipe" + fildes_uaddr = $fildes + if (fildes_uaddr == 0) + { + pipe0 = 0; + pipe1 = 0; + } + else + { + pipe0 = user_int(&$fildes[0]); + pipe1 = user_int(&$fildes[1]); + } + retstr = returnstr(1) +} + # pivot_root _________________________________________________ # # long sys_pivot_root(const char __user *new_root, const char __user *put_old) -- 2.43.5