cn_proc.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. * Original copyright notice follows:
  7. * Copyright (C) 2005 Nguyen Anh Quynh <aquynh@gmail.com>
  8. * Copyright (C) 2005 Guillaume Thouvenin <guillaume.thouvenin@bull.net>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  23. */
  24. #ifndef CN_PROC_H
  25. #define CN_PROC_H
  26. #include <linux/types.h>
  27. #include <linux/connector.h>
  28. /*
  29. * Userspace sends this enum to register with the kernel that it is listening
  30. * for events on the connector.
  31. */
  32. enum proc_cn_mcast_op {
  33. PROC_CN_MCAST_LISTEN = 1,
  34. PROC_CN_MCAST_IGNORE = 2
  35. };
  36. /*
  37. * From the user's point of view, the process
  38. * ID is the thread group ID and thread ID is the internal
  39. * kernel "pid". So, fields are assigned as follow:
  40. *
  41. * In user space - In kernel space
  42. *
  43. * parent process ID = parent->tgid
  44. * parent thread ID = parent->pid
  45. * child process ID = child->tgid
  46. * child thread ID = child->pid
  47. */
  48. struct proc_event {
  49. enum what {
  50. /* Use successive bits so the enums can be used to record
  51. * sets of events as well
  52. */
  53. PROC_EVENT_NONE = 0x00000000,
  54. PROC_EVENT_FORK = 0x00000001,
  55. PROC_EVENT_EXEC = 0x00000002,
  56. PROC_EVENT_UID = 0x00000004,
  57. PROC_EVENT_GID = 0x00000040,
  58. /* "next" should be 0x00000400 */
  59. /* "last" is the last process event: exit */
  60. PROC_EVENT_EXIT = 0x80000000
  61. } what;
  62. __u32 cpu;
  63. union { /* must be last field of proc_event struct */
  64. struct {
  65. __u32 err;
  66. } ack;
  67. struct fork_proc_event {
  68. pid_t parent_pid;
  69. pid_t parent_tgid;
  70. pid_t child_pid;
  71. pid_t child_tgid;
  72. } fork;
  73. struct exec_proc_event {
  74. pid_t process_pid;
  75. pid_t process_tgid;
  76. } exec;
  77. struct id_proc_event {
  78. pid_t process_pid;
  79. pid_t process_tgid;
  80. union {
  81. __u32 ruid; /* task uid */
  82. __u32 rgid; /* task gid */
  83. } r;
  84. union {
  85. __u32 euid;
  86. __u32 egid;
  87. } e;
  88. } id;
  89. struct exit_proc_event {
  90. pid_t process_pid;
  91. pid_t process_tgid;
  92. __u32 exit_code, exit_signal;
  93. } exit;
  94. } event_data;
  95. };
  96. #ifdef __KERNEL__
  97. #ifdef CONFIG_PROC_EVENTS
  98. void proc_fork_connector(struct task_struct *task);
  99. void proc_exec_connector(struct task_struct *task);
  100. void proc_id_connector(struct task_struct *task, int which_id);
  101. void proc_exit_connector(struct task_struct *task);
  102. #else
  103. static inline void proc_fork_connector(struct task_struct *task)
  104. {}
  105. static inline void proc_exec_connector(struct task_struct *task)
  106. {}
  107. static inline void proc_id_connector(struct task_struct *task,
  108. int which_id)
  109. {}
  110. static inline void proc_exit_connector(struct task_struct *task)
  111. {}
  112. #endif /* CONFIG_PROC_EVENTS */
  113. #endif /* __KERNEL__ */
  114. #endif /* CN_PROC_H */