/usr/share/systemtap/tapset/dentry.stp is in systemtap-common 1.7-1+deb7u1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | // dentry tapset
// Copyright (c) 2009-2010 Red Hat Inc.
//
// This file is part of systemtap, and is free software. You can
// redistribute it and/or modify it under the terms of the GNU General
// Public License (GPL); either version 2, or (at your option) any
// later version.
function __dentry_IS_ROOT:long(dentry:long)
{
return (@cast(dentry, "dentry")->d_parent == dentry)
}
function __dentry_prepend:string(dentry:long,name:string)
{
dname = d_name(dentry)
/*
* In case we are following down a mount point trigger, we can get
* multiple instances of a root mount.
*/
c = substr(name, strlen(name)-1, strlen(name)-1)
if (dname == "/" && c == "/")
return name;
if (name == "") {
return dname;
} else {
return sprintf("%s/%s", dname, name);
}
}
/**
* sfunction d_name - get the dirent name
*
* Returns the dirent name (path basename).
* @dentry: Pointer to dentry.
*/
function d_name:string(dentry:long)
{
len = @cast(dentry, "dentry")->d_name->len;
return kernel_string_n(@cast(dentry, "dentry")->d_name->name, len);
}
/**
* sfunction inode_name - get the inode name
*
* Returns the first path basename associated with the given inode.
* @inode: Pointer to inode.
*/
function inode_name:string(inode:long)
{
i_dentry = & @cast(inode, "struct inode")->i_dentry;
d_alias = @cast(i_dentry, "struct list_head")->next;
dentry = d_alias - (& @cast(0, "struct dentry")->d_alias);
return reverse_path_walk(dentry);
}
/**
* sfunction reverse_path_walk - get the full dirent path
*
* Returns the path name (partial path to mount point).
* @dentry: Pointer to dentry.
*/
function reverse_path_walk:string(dentry:long)
{
while(1) {
name = __dentry_prepend(dentry, name);
dentry = @cast(dentry, "dentry")->d_parent;
if (__dentry_IS_ROOT(dentry))
return name;
}
}
/**
* sfunction task_dentry_path - get the full dentry path
*
* Returns the full dirent name (full path to the root), like
* the kernel d_path function.
* @task: task_struct pointer.
* @dentry: direntry pointer.
* @vfsmnt: vfsmnt pointer.
*/
function task_dentry_path:string(task:long,dentry:long,vfsmnt:long)
{
root = & @cast(task, "task_struct")->fs->root
while (1) {
if (dentry == @cast(root, "path")->dentry &&
vfsmnt == @cast(root, "path")->mnt)
break;
if (dentry == @cast(vfsmnt, "vfsmount")->mnt_root ||
__dentry_IS_ROOT(dentry)) {
/* Global root? */
if (@cast(vfsmnt, "vfsmount")->mnt_parent == vfsmnt)
return sprintf("/%s", name);
dentry = @cast(vfsmnt, "vfsmount")->mnt_mountpoint;
vfsmnt = @cast(vfsmnt, "vfsmount")->mnt_parent;
continue;
}
name = __dentry_prepend(dentry, name);
dentry = @cast(dentry, "dentry")->d_parent;
}
return sprintf("/%s", name);
}
/**
* sfunction d_path - get the full nameidata path
*
* Returns the full dirent name (full path to the root), like
* the kernel d_path function.
* @nd: Pointer to nameidata.
*/
function d_path:string(nd:long)
{
dentry = (@defined(@cast(nd,"nameidata")->path->dentry)
? @cast(nd,"nameidata")->path->dentry
: @cast(nd,"nameidata")->dentry)
vfsmnt = (@defined(@cast(nd,"nameidata")->path->mnt)
? @cast(nd,"nameidata")->path->mnt
: @cast(nd,"nameidata")->mnt)
return sprintf("%s/", task_dentry_path(task_current(), dentry, vfsmnt))
}
|