Guest User

Untitled

a guest
Jun 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. function __task_file_handle_filp:long(task:long, fd:long) %{ /* pure */
  2. struct task_struct *p = (struct task_struct *)((long)THIS->task);
  3. struct files_struct *files;
  4. struct file *filp;
  5.  
  6. rcu_read_lock();
  7. if ((files = kread(&p->files))) {
  8. if ((filp = fcheck_files(files, THIS->fd))) {
  9. THIS->__retvalue = (long)filp;
  10. }
  11. }
  12. CATCH_DEREF_FAULT();
  13. rcu_read_unlock();
  14. %}
  15.  
  16. function __task_dentry_prepend:string(dentry:long,name:string)
  17. {
  18. dname = d_name(dentry)
  19.  
  20. if (name == "")
  21. return dname
  22.  
  23. /*
  24. * In case we are following down a mount point trigger, we can get
  25. * multiple instances of a root mount.
  26. */
  27. c = substr(name, strlen(name)-1, strlen(name)-1)
  28. if (dname == "/" && c == "/")
  29. return name
  30.  
  31. return sprintf("%s/%s", dname, name)
  32. }
  33.  
  34. function __task_d_path(task:long, dentry:long, vfsmnt:long)
  35. {
  36. root = & @cast(task, "task_struct")->fs->root
  37.  
  38. while (1) {
  39. if (dentry == @cast(root, "path")->dentry &&
  40. vfsmnt == @cast(root, "path")->mnt)
  41. break;
  42.  
  43. if (dentry == @cast(vfsmnt, "vfsmount")->mnt_root ||
  44. __dentry_IS_ROOT(dentry)) {
  45. /* Global root? */
  46. if (@cast(vfsmnt, "vfsmount")->mnt_parent == vfsmnt) {
  47. return sprintf("/%s", name)
  48. }
  49.  
  50. dentry = @cast(vfsmnt, "vfsmount")->mnt_mountpoint
  51. vfsmnt = @cast(vfsmnt, "vfsmount")->mnt_parent
  52. continue
  53. }
  54.  
  55. name = __task_dentry_prepend(dentry, name)
  56. dentry = @cast(dentry, "dentry")->d_parent
  57. }
  58.  
  59. return sprintf("/%s", name)
  60. }
  61.  
  62. function task_file_handle_d_path:string(task:long, fd:long)
  63. {
  64. filp = __task_file_handle_filp(task, fd)
  65.  
  66. if (filp) {
  67. %( kernel_v >= "2.6.26" %?
  68. dentry = @cast(filp,"file")->f_path->dentry
  69. vfsmnt = @cast(filp,"file")->f_path->mnt
  70. %:
  71. dentry = @cast(filp,"file")->f_dentry
  72. vfsmnt = @cast(filp,"file")->f_vfsmnt
  73. %)
  74.  
  75. return __task_d_path(task, dentry, vfsmnt)
  76. } else {
  77. return ""
  78. }
  79. }
Add Comment
Please, Sign In to add comment