diff options
author | Steve Dickson <steved@redhat.com> | 2010-07-27 07:51:04 -0400 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2010-07-27 07:51:04 -0400 |
commit | ba750d2daecfd5172a2984428e4f9190003fe0e3 (patch) | |
tree | 29f0ff679a67107aed184912f7d69a6888ce225c | |
parent | 9135439c59faaff1018e486beb3b03ee48127b92 (diff) | |
download | systemtap-ba750d2daecfd5172a2984428e4f9190003fe0e3.tar.gz systemtap-ba750d2daecfd5172a2984428e4f9190003fe0e3.tar.xz systemtap-ba750d2daecfd5172a2984428e4f9190003fe0e3.zip |
Added file mode decoding
Signed-off-by: Steve Dickson <steved@redhat.com>
-rw-r--r-- | nfsd/nfsd_permission.stp | 15 | ||||
-rw-r--r-- | tapset/inode.stp | 39 |
2 files changed, 51 insertions, 3 deletions
diff --git a/nfsd/nfsd_permission.stp b/nfsd/nfsd_permission.stp index 1b77df1..63969a9 100644 --- a/nfsd/nfsd_permission.stp +++ b/nfsd/nfsd_permission.stp @@ -1,16 +1,25 @@ #!/usr/bin/env stap +global acl_inode, acl_mask, acl_check; + probe module("nfsd").function("nfsd_permission") { - printf("nfsd_permission: rqstp %p exp %p dentry '%s' acc 0x%x\n", - $rqstp, $exp, dentry2name($dentry), $acc); + printf("nfsd_permission: rqstp %p exp %p dentry '%s' %s\n", + $rqstp, $exp, dentry2name($dentry), file_modes($acc)); printf(" : %s\n", svc_export_dump($exp)); } %( kernel_v >= "2.6.25" %? +probe kernel.function("acl_permission_check") +{ + acl_inode = $inode; + acl_mask = $mask; + acl_check = $check_acl; +} probe kernel.function("acl_permission_check").return { if ($return) - printf(" acl_permission_check: error: %d\n", $return); + printf(" acl_permission_check: inode 0x%p uid %s %s error: %d\n", + acl_inode, inode_uid(acl_inode), file_modes(acl_mask), $return); } /* a very busy probe diff --git a/tapset/inode.stp b/tapset/inode.stp index 106cba1..56340d0 100644 --- a/tapset/inode.stp +++ b/tapset/inode.stp @@ -1,5 +1,6 @@ %{ #include <linux/kernel.h> +#include <linux/fs.h> %} function inode_uid:string(_ino:long) @@ -11,3 +12,41 @@ function inode_uid:string(_ino:long) CATCH_DEREF_FAULT(); %} + +function file_modes:string(_m:long) +%{ + char buf[MAXSTRINGLEN]; + int cc=0; + int _mod = (long) kread(&(THIS->_m)); + + if (_mod & MAY_EXEC) { + sprintf(buf+cc, "EXEC|"); + cc = strlen(buf); + } + if (_mod & MAY_WRITE) { + sprintf(buf+cc, "WRITE|"); + cc = strlen(buf); + } + if (_mod & MAY_READ) { + sprintf(buf+cc, "READ|"); + cc = strlen(buf); + } + if (_mod & MAY_APPEND) { + sprintf(buf+cc, "APPEND|"); + cc = strlen(buf); + } + if (_mod & MAY_ACCESS) { + sprintf(buf+cc, "ACCESS|"); + cc = strlen(buf); + } + if (_mod & MAY_OPEN) { + sprintf(buf+cc, "OPEN|"); + cc = strlen(buf); + } + if (cc) + snprintf(THIS->__retvalue, MAXSTRINGLEN, "mode 0%o (%s)", _mod, buf); + else + snprintf(THIS->__retvalue, MAXSTRINGLEN, "mode 0%o", _mod); + + CATCH_DEREF_FAULT(); +%} |