diff options
Diffstat (limited to 'tapset/inode.stp')
-rw-r--r-- | tapset/inode.stp | 39 |
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(); +%} |