summaryrefslogtreecommitdiffstats
path: root/tapset
diff options
context:
space:
mode:
authorSteve Dickson <steved@redhat.com>2010-07-27 07:51:04 -0400
committerSteve Dickson <steved@redhat.com>2010-07-27 07:51:04 -0400
commitba750d2daecfd5172a2984428e4f9190003fe0e3 (patch)
tree29f0ff679a67107aed184912f7d69a6888ce225c /tapset
parent9135439c59faaff1018e486beb3b03ee48127b92 (diff)
downloadsystemtap-ba750d2daecfd5172a2984428e4f9190003fe0e3.tar.gz
systemtap-ba750d2daecfd5172a2984428e4f9190003fe0e3.tar.xz
systemtap-ba750d2daecfd5172a2984428e4f9190003fe0e3.zip
Added file mode decoding
Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'tapset')
-rw-r--r--tapset/inode.stp39
1 files changed, 39 insertions, 0 deletions
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();
+%}