summaryrefslogtreecommitdiffstats
path: root/tapset/fs.stp
blob: f8122bfbb391abf6f4d87890a436e1576a333316 (plain)
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

probe fs.read.return = kernel.function("vfs_read").return {
	bytes = ($return > 0 ? $return : 0)
}

probe fs.write.return = kernel.function("vfs_write").return {
	bytes = ($return > 0 ? $return : 0)
}
function file2name:string(filep:long) 
%{
	char *start = NULL, buf[MAXSTRINGLEN];
	struct file *file = (struct file *)(long) kread(&(THIS->filep));
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
	struct dentry *dentry = NULL;
	struct vfsmount *mnt = NULL;

	if (file) {
		mnt = (struct vfsmount *) kread(&(file->f_vfsmnt));
		dentry = (struct dentry *) kread(&(file->f_dentry));
	}
	if (mnt && dentry)
		start = d_path(dentry, mnt, buf, MAXSTRINGLEN);
#else
	struct path *path = NULL;

	if (file)
		start = d_path(&(file->f_path), buf, MAXSTRINGLEN);
#endif
	if (start > 0)
		strlcpy(THIS->__retvalue, start, MAXSTRINGLEN);

	CATCH_DEREF_FAULT();
%}
function dentry2name:string(dentry_:long) 
%{
	struct dentry *dentry = (struct dentry *)(long) kread(&(THIS->dentry_));

	strlcpy(THIS->__retvalue, dentry->d_name.name, MAXSTRINGLEN);

	CATCH_DEREF_FAULT();
%}