Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function __task_file_handle_filp:long(task:long, fd:long) %{ /* pure */
- struct task_struct *p = (struct task_struct *)((long)THIS->task);
- struct files_struct *files;
- struct file *filp;
- rcu_read_lock();
- if ((files = kread(&p->files))) {
- if ((filp = fcheck_files(files, THIS->fd))) {
- THIS->__retvalue = (long)filp;
- }
- }
- CATCH_DEREF_FAULT();
- rcu_read_unlock();
- %}
- function __task_dentry_prepend:string(dentry:long,name:string)
- {
- dname = d_name(dentry)
- if (name == "")
- return dname
- /*
- * 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
- return sprintf("%s/%s", dname, name)
- }
- function __task_d_path(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 = __task_dentry_prepend(dentry, name)
- dentry = @cast(dentry, "dentry")->d_parent
- }
- return sprintf("/%s", name)
- }
- function task_file_handle_d_path:string(task:long, fd:long)
- {
- filp = __task_file_handle_filp(task, fd)
- if (filp) {
- %( kernel_v >= "2.6.26" %?
- dentry = @cast(filp,"file")->f_path->dentry
- vfsmnt = @cast(filp,"file")->f_path->mnt
- %:
- dentry = @cast(filp,"file")->f_dentry
- vfsmnt = @cast(filp,"file")->f_vfsmnt
- %)
- return __task_d_path(task, dentry, vfsmnt)
- } else {
- return ""
- }
- }
Add Comment
Please, Sign In to add comment