cn_proc.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. * while "next to last" is coredumping event */
  56. PROC_EVENT_COREDUMP = 0x40000000,
  57. PROC_EVENT_EXIT = 0x80000000
  58. } what;
  59. __u32 cpu;
  60. __u64 __attribute__((aligned(8))) timestamp_ns;
  61. /* Number of nano seconds since system boot */
  62. union { /* must be last field of proc_event struct */
  63. struct {
  64. __u32 err;
  65. } ack;
  66. struct fork_proc_event {
  67. __kernel_pid_t parent_pid;
  68. __kernel_pid_t parent_tgid;
  69. __kernel_pid_t child_pid;
  70. __kernel_pid_t child_tgid;
  71. } fork;
  72. struct exec_proc_event {
  73. __kernel_pid_t process_pid;
  74. __kernel_pid_t process_tgid;
  75. } exec;
  76. struct id_proc_event {
  77. __kernel_pid_t process_pid;
  78. __kernel_pid_t process_tgid;
  79. union {
  80. __u32 ruid; /* task uid */
  81. __u32 rgid; /* task gid */
  82. } r;
  83. union {
  84. __u32 euid;
  85. __u32 egid;
  86. } e;
  87. } id;
  88. struct sid_proc_event {
  89. __kernel_pid_t process_pid;
  90. __kernel_pid_t process_tgid;
  91. } sid;
  92. struct ptrace_proc_event {
  93. __kernel_pid_t process_pid;
  94. __kernel_pid_t process_tgid;
  95. __kernel_pid_t tracer_pid;
  96. __kernel_pid_t tracer_tgid;
  97. } ptrace;
  98. struct comm_proc_event {
  99. __kernel_pid_t process_pid;
  100. __kernel_pid_t process_tgid;
  101. char comm[16];
  102. } comm;
  103. struct coredump_proc_event {
  104. __kernel_pid_t process_pid;
  105. __kernel_pid_t process_tgid;
  106. } coredump;
  107. struct exit_proc_event {
  108. __kernel_pid_t process_pid;
  109. __kernel_pid_t process_tgid;
  110. __u32 exit_code, exit_signal;
  111. } exit;
  112. } event_data;
  113. };
  114. #endif /* _UAPICN_PROC_H */