1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
%{
#include <linux/kernel.h>
#include <linux/fs.h>
%}
function inode_uid:string(_ino:long)
%{
struct inode *inode = (struct inode *)(long) kread(&(THIS->_ino));
snprintf(THIS->__retvalue, MAXSTRINGLEN, "uid=%d gid=%d",
inode->i_uid, inode->i_gid);
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();
%}
|