cn_proc.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * cn_proc.h - process events connector
  3. *
  4. * Copyright (C) Matt Helsley, IBM Corp. 2005
  5. * Based on cn_fork.h by Nguyen Anh Quynh and Guillaume Thouvenin
  6. * Copyright (C) 2005 Nguyen Anh Quynh <aquynh@gmail.com>
  7. * Copyright (C) 2005 Guillaume Thouvenin <guillaume.thouvenin@bull.net>
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of version 2.1 of the GNU Lesser General Public License
  11. * as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it would be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  16. */
  17. #ifndef _UAPICN_PROC_H
  18. #define _UAPICN_PROC_H
  19. #include <linux/types.h>
  20. /*
  21. * Userspace sends this enum to register with the kernel that it is listening
  22. * for events on the connector.
  23. */
  24. enum proc_cn_mcast_op {
  25. PROC_CN_MCAST_LISTEN = 1,
  26. PROC_CN_MCAST_IGNORE = 2
  27. };
  28. /*
  29. * From the user's point of view, the process
  30. * ID is the thread group ID and thread ID is the internal
  31. * kernel "pid". So, fields are assigned as follow:
  32. *
  33. * In user space - In kernel space
  34. *
  35. * parent process ID = parent->tgid
  36. * parent thread ID = parent->pid
  37. * child process ID = child->tgid
  38. * child thread ID = child->pid
  39. */
  40. struct proc_event {
  41. enum what {
  42. /* Use successive bits so the enums can be used to record
  43. * sets of events as well
  44. */
  45. PROC_EVENT_NONE = 0x00000000,
  46. PROC_EVENT_FORK = 0x00000001,
  47. PROC_EVENT_EXEC = 0x00000002,
  48. PROC_EVENT_UID = 0x00000004,
  49. PROC_EVENT_GID = 0x00000040,
  50. PROC_EVENT_SID = 0x00000080,
  51. PROC_EVENT_PTRACE = 0x00000100,
  52. PROC_EVENT_COMM = 0x00000200,
  53. /* "next" should be 0x00000400 */
  54. /* "last" is the last process event: exit */
  55. PROC_EVENT_EXIT = 0x80000000
  56. } what;
  57. __u32 cpu;
  58. __u64 __attribute__((aligned(8))) timestamp_ns;
  59. /* Number of nano seconds since system boot */
  60. union { /* must be last field of proc_event struct */
  61. struct {
  62. __u32 err;
  63. } ack;
  64. struct fork_proc_event {
  65. __kernel_pid_t parent_pid;
  66. __kernel_pid_t parent_tgid;
  67. __kernel_pid_t child_pid;
  68. __kernel_pid_t child_tgid;
  69. } fork;
  70. struct exec_proc_event {
  71. __kernel_pid_t process_pid;
  72. __kernel_pid_t process_tgid;
  73. } exec;
  74. struct id_proc_event {
  75. __kernel_pid_t process_pid;
  76. __kernel_pid_t process_tgid;
  77. union {
  78. __u32 ruid; /* task uid */
  79. __u32 rgid; /* task gid */
  80. } r;
  81. union {
  82. __u32 euid;
  83. __u32 egid;
  84. } e;
  85. } id;
  86. struct sid_proc_event {
  87. __kernel_pid_t process_pid;
  88. __kernel_pid_t process_tgid;
  89. } sid;
  90. struct ptrace_proc_event {
  91. __kernel_pid_t process_pid;
  92. __kernel_pid_t process_tgid;
  93. __kernel_pid_t tracer_pid;
  94. __kernel_pid_t tracer_tgid;
  95. } ptrace;
  96. struct comm_proc_event {
  97. __kernel_pid_t process_pid;
  98. __kernel_pid_t process_tgid;
  99. char comm[16];
  100. } comm;
  101. struct exit_proc_event {
  102. __kernel_pid_t process_pid;
  103. __kernel_pid_t process_tgid;
  104. __u32 exit_code, exit_signal;
  105. } exit;
  106. } event_data;
  107. };
  108. #endif /* _UAPICN_PROC_H */