From ba750d2daecfd5172a2984428e4f9190003fe0e3 Mon Sep 17 00:00:00 2001 From: Steve Dickson Date: Tue, 27 Jul 2010 07:51:04 -0400 Subject: Added file mode decoding Signed-off-by: Steve Dickson --- nfsd/nfsd_permission.stp | 15 ++++++++++++--- 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 +#include %} 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(); +%} -- cgit