diff options
author | Mark Wielaard <mjw@redhat.com> | 2010-03-21 09:55:10 +0100 |
---|---|---|
committer | Mark Wielaard <mjw@redhat.com> | 2010-03-21 17:34:41 +0100 |
commit | 6c8598ca45b8c0910fc0f45352b31711164e4d1c (patch) | |
tree | da644055ff15c14340fdc20d55374ca8a9448fdd | |
parent | c01a52256bfbd9a3d2873b2d48f7f94177d14641 (diff) | |
download | systemtap-steved-6c8598ca45b8c0910fc0f45352b31711164e4d1c.tar.gz systemtap-steved-6c8598ca45b8c0910fc0f45352b31711164e4d1c.tar.xz systemtap-steved-6c8598ca45b8c0910fc0f45352b31711164e4d1c.zip |
Add inotify_init1() and inotify_add_watch() mask string support.
* tapset/aux_syscalls.stp (_inotify_watch_mask_str): New helper function.
(_inotify_init1_flag_str): Likewise.
* tapset/syscalls.stp (inotify_add_watch): Stringify watch mask.
(syscall.inotify_init[.return]): Add inotify_init1() support.
* testsuite/systemtap.syscall/inotify.c: New test.
-rw-r--r-- | tapset/aux_syscalls.stp | 37 | ||||
-rw-r--r-- | tapset/syscalls.stp | 27 | ||||
-rw-r--r-- | testsuite/systemtap.syscall/inotify.c | 28 |
3 files changed, 85 insertions, 7 deletions
diff --git a/tapset/aux_syscalls.stp b/tapset/aux_syscalls.stp index 5377bafd..6179719c 100644 --- a/tapset/aux_syscalls.stp +++ b/tapset/aux_syscalls.stp @@ -466,6 +466,22 @@ function _adjtx_mode_str(f) { return substr(bs,0,strlen(bs)-1) } +function _inotify_watch_mask_str(f) { + if (f & 0x00000001) bs="IN_ACCESS|" + if (f & 0x00000002) bs=bs."IN_MODIFY|" + if (f & 0x00000004) bs=bs."IN_ATTRIB|" + if (f & 0x00000008) bs=bs."IN_CLOSE_WRITE|" + if (f & 0x00000010) bs=bs."IN_CLOSE_NOWRITE|" + if (f & 0x00000020) bs=bs."IN_OPEN|" + if (f & 0x00000040) bs=bs."IN_MOVED_FROM|" + if (f & 0x00000080) bs=bs."IN_MOVED_TO|" + if (f & 0x00000100) bs=bs."IN_CREATE|" + if (f & 0x00000200) bs=bs."IN_DELETE|" + if (f & 0x00000400) bs=bs."IN_DELETE_SELF|" + if (f & 0x00000800) bs=bs."IN_MOVE_SELF|" + return substr(bs,0,strlen(bs)-1) +} + /* * Return the symbolic string representation * of the how argument given in *sigprocmask @@ -1668,6 +1684,27 @@ function _eventfd2_flag_str:string(f:long) str[strlen(str)-1] = 0; %} +%{ +#include <linux/inotify.h> +%} +function _inotify_init1_flag_str:string(f:long) +%{ /* pure */ + long flags = THIS->f; + char *str = THIS->__retvalue; + int len; + +#if defined(IN_CLOEXEC) && defined(IN_NONBLOCK) + if (flags & IN_NONBLOCK) + strlcat(str, "IN_NONBLOCK|", MAXSTRINGLEN); + if (flags & IN_CLOEXEC) + strlcat(str, "IN_CLOEXEC|", MAXSTRINGLEN); +#endif + + len = strlen(str); + if (len) + str[strlen(str)-1] = 0; +%} + function _dup3_flag_str:string(f:long) %{ /* pure */ #ifdef O_CLOEXEC diff --git a/tapset/syscalls.stp b/tapset/syscalls.stp index 86f81abf..6bd7a3dd 100644 --- a/tapset/syscalls.stp +++ b/tapset/syscalls.stp @@ -2079,9 +2079,9 @@ probe syscall.inotify_add_watch = kernel.function("SyS_inotify_add_watch").call mask = $mask path_uaddr = (@defined($pathname) ? $pathname : $path) path = user_string(@defined($pathname) ? $pathname : $path) - argstr = sprintf("%d, %s, %d", $fd, + argstr = sprintf("%d, %s, %s", $fd, user_string_quoted(@defined($pathname) ? $pathname : $path), - $mask) + _inotify_watch_mask_str($mask)) } probe syscall.inotify_add_watch.return = kernel.function("SyS_inotify_add_watch").return !, @@ -2095,14 +2095,27 @@ probe syscall.inotify_add_watch.return = kernel.function("SyS_inotify_add_watch" # # long sys_inotify_init(void) # -probe syscall.inotify_init = kernel.function("sys_inotify_init").call ? +probe syscall.inotify_init = kernel.function("SyS_inotify_init1").call !, + kernel.function("sys_inotify_init1").call !, + kernel.function("SyS_inotify_init").call !, + kernel.function("sys_inotify_init").call ? { - name = "inotify_init" - argstr = "" + flags = @defined($flags) ? $flags : 0; + if (flags == 0) { + name = "inotify_init" + argstr = "" + } else { + name = "inotify_init1" + argstr = _inotify_init1_flag_str(flags) + } } -probe syscall.inotify_init.return = kernel.function("sys_inotify_init").return ? +probe syscall.inotify_init.return = kernel.function("SyS_inotify_init1").return !, + kernel.function("sys_inotify_init1").return !, + kernel.function("SyS_inotify_init").return !, + kernel.function("sys_inotify_init").return ? { - name = "inotify_init" + flags = @defined($flags) ? $flags : 0; + name = (flags == 0) ? "inotify_init" : "inotify_init1" retstr = returnstr(1) } diff --git a/testsuite/systemtap.syscall/inotify.c b/testsuite/systemtap.syscall/inotify.c new file mode 100644 index 00000000..8f9c6a01 --- /dev/null +++ b/testsuite/systemtap.syscall/inotify.c @@ -0,0 +1,28 @@ +/* COVERAGE: inotify_init, inotify_init1, inotify_add_watch, inotify_rm_watch */ + +#include <sys/inotify.h> + +int main() +{ + int fd = inotify_init(); + //staptest// inotify_init () = NNNN + + int wd = inotify_add_watch(fd, "/tmp", IN_ALL_EVENTS); + //staptest// inotify_add_watch (NNNN, "/tmp", IN_ACCESS|IN_MODIFY|IN_ATTRIB|IN_CLOSE_WRITE|IN_CLOSE_NOWRITE|IN_OPEN|IN_MOVED_FROM|IN_MOVED_TO|IN_CREATE|IN_DELETE|IN_DELETE_SELF|IN_MOVE_SELF) = NNNN + + inotify_rm_watch(fd, wd); + //staptest// inotify_rm_watch (NNNN, NNNN) = 0 + +#ifdef IN_CLOEXEC + inotify_init1(IN_NONBLOCK); + //staptest// inotify_init1 (IN_NONBLOCK) = NNNN + + inotify_init1(IN_CLOEXEC); + //staptest// inotify_init1 (IN_CLOEXEC) = NNNN + + inotify_init1(IN_NONBLOCK|IN_CLOEXEC); + //staptest// inotify_init1 (IN_NONBLOCK|IN_CLOEXEC) = NNNN +#endif + + return 0; +} |