namespaces.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * This program is free software; you can redistribute it and/or modify
  3. * it under the terms of the GNU General Public License, version 2, as
  4. * published by the Free Software Foundation.
  5. *
  6. * Copyright (C) 2017 Hari Bathini, IBM Corporation
  7. */
  8. #ifndef __PERF_NAMESPACES_H
  9. #define __PERF_NAMESPACES_H
  10. #include <sys/types.h>
  11. #include <linux/stddef.h>
  12. #include <linux/perf_event.h>
  13. #include <linux/refcount.h>
  14. #include <linux/types.h>
  15. struct namespaces_event;
  16. struct namespaces {
  17. struct list_head list;
  18. u64 end_time;
  19. struct perf_ns_link_info link_info[];
  20. };
  21. struct namespaces *namespaces__new(struct namespaces_event *event);
  22. void namespaces__free(struct namespaces *namespaces);
  23. struct nsinfo {
  24. pid_t pid;
  25. pid_t tgid;
  26. pid_t nstgid;
  27. bool need_setns;
  28. char *mntns_path;
  29. refcount_t refcnt;
  30. };
  31. struct nscookie {
  32. int oldns;
  33. int newns;
  34. };
  35. int nsinfo__init(struct nsinfo *nsi);
  36. struct nsinfo *nsinfo__new(pid_t pid);
  37. struct nsinfo *nsinfo__copy(struct nsinfo *nsi);
  38. void nsinfo__delete(struct nsinfo *nsi);
  39. struct nsinfo *nsinfo__get(struct nsinfo *nsi);
  40. void nsinfo__put(struct nsinfo *nsi);
  41. void nsinfo__mountns_enter(struct nsinfo *nsi, struct nscookie *nc);
  42. void nsinfo__mountns_exit(struct nscookie *nc);
  43. char *nsinfo__realpath(const char *path, struct nsinfo *nsi);
  44. static inline void __nsinfo__zput(struct nsinfo **nsip)
  45. {
  46. if (nsip) {
  47. nsinfo__put(*nsip);
  48. *nsip = NULL;
  49. }
  50. }
  51. #define nsinfo__zput(nsi) __nsinfo__zput(&nsi)
  52. #endif /* __PERF_NAMESPACES_H */