Advertisement
Guest User

Untitled

a guest
Jul 24th, 2020
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1.  
  2. %{
  3. #include <linux/sched.h>
  4. #include <linux/list.h>
  5. #include <linux/kernfs.h>
  6. #include <linux/cgroup-defs.h>
  7. %}
  8.  
  9.  
  10. probe begin{
  11. print ("Starting...\n")
  12. }
  13.  
  14. probe nd_syscall.* {
  15. if(target() != pid()) next
  16. printf("%d;%s\n", pid(), getCgroup())
  17. }
  18.  
  19. function getCgroup:string()%{
  20. struct task_struct *currently_observed_task = current;
  21. char fileName[200];
  22. struct css_set *cgroups = currently_observed_task->cgroups;
  23. struct cgroup_subsys_state **subsys = cgroups->subsys;
  24. struct cgroup_subsys_state *firstSubsys = subsys[0];
  25. struct cgroup *cgroup = firstSubsys->cgroup;
  26. struct kernfs_node *kn = cgroup->kn;
  27. int result = kernfs_path_from_node(kn, NULL, fileName, 200*sizeof(char));
  28. if (result < 0) STAP_ERROR ("cannot resolve cgroup");
  29. snprintf(STAP_RETVALUE, 200, "%s", fileName);
  30. %}
  31.  
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement