fanotify.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #ifndef _FANOTIFY_H
  2. #define _FANOTIFY_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <sys/statfs.h>
  7. struct fanotify_event_metadata {
  8. unsigned event_len;
  9. unsigned char vers;
  10. unsigned char reserved;
  11. unsigned short metadata_len;
  12. unsigned long long mask
  13. #ifdef __GNUC__
  14. __attribute__((__aligned__(8)))
  15. #endif
  16. ;
  17. int fd;
  18. int pid;
  19. };
  20. struct fanotify_event_info_header {
  21. unsigned char info_type;
  22. unsigned char pad;
  23. unsigned short len;
  24. };
  25. struct fanotify_event_info_fid {
  26. struct fanotify_event_info_header hdr;
  27. fsid_t fsid;
  28. unsigned char handle[];
  29. };
  30. struct fanotify_response {
  31. int fd;
  32. unsigned response;
  33. };
  34. #define FAN_ACCESS 0x01
  35. #define FAN_MODIFY 0x02
  36. #define FAN_ATTRIB 0x04
  37. #define FAN_CLOSE_WRITE 0x08
  38. #define FAN_CLOSE_NOWRITE 0x10
  39. #define FAN_OPEN 0x20
  40. #define FAN_MOVED_FROM 0x40
  41. #define FAN_MOVED_TO 0x80
  42. #define FAN_CREATE 0x100
  43. #define FAN_DELETE 0x200
  44. #define FAN_DELETE_SELF 0x400
  45. #define FAN_MOVE_SELF 0x800
  46. #define FAN_OPEN_EXEC 0x1000
  47. #define FAN_Q_OVERFLOW 0x4000
  48. #define FAN_OPEN_PERM 0x10000
  49. #define FAN_ACCESS_PERM 0x20000
  50. #define FAN_OPEN_EXEC_PERM 0x40000
  51. #define FAN_DIR_MODIFY 0x00080000
  52. #define FAN_EVENT_ON_CHILD 0x08000000
  53. #define FAN_ONDIR 0x40000000
  54. #define FAN_CLOSE (FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE)
  55. #define FAN_MOVE (FAN_MOVED_FROM | FAN_MOVED_TO)
  56. #define FAN_CLOEXEC 0x01
  57. #define FAN_NONBLOCK 0x02
  58. #define FAN_CLASS_NOTIF 0
  59. #define FAN_CLASS_CONTENT 0x04
  60. #define FAN_CLASS_PRE_CONTENT 0x08
  61. #define FAN_ALL_CLASS_BITS (FAN_CLASS_NOTIF | FAN_CLASS_CONTENT | FAN_CLASS_PRE_CONTENT)
  62. #define FAN_UNLIMITED_QUEUE 0x10
  63. #define FAN_UNLIMITED_MARKS 0x20
  64. #define FAN_ENABLE_AUDIT 0x40
  65. #define FAN_REPORT_TID 0x100
  66. #define FAN_REPORT_FID 0x200
  67. #define FAN_REPORT_DIR_FID 0x00000400
  68. #define FAN_REPORT_NAME 0x00000800
  69. #define FAN_REPORT_DFID_NAME (FAN_REPORT_DIR_FID | FAN_REPORT_NAME)
  70. #define FAN_ALL_INIT_FLAGS (FAN_CLOEXEC | FAN_NONBLOCK | FAN_ALL_CLASS_BITS | FAN_UNLIMITED_QUEUE | FAN_UNLIMITED_MARKS)
  71. #define FAN_MARK_ADD 0x01
  72. #define FAN_MARK_REMOVE 0x02
  73. #define FAN_MARK_DONT_FOLLOW 0x04
  74. #define FAN_MARK_ONLYDIR 0x08
  75. #define FAN_MARK_IGNORED_MASK 0x20
  76. #define FAN_MARK_IGNORED_SURV_MODIFY 0x40
  77. #define FAN_MARK_FLUSH 0x80
  78. #define FAN_MARK_INODE 0x00
  79. #define FAN_MARK_MOUNT 0x10
  80. #define FAN_MARK_FILESYSTEM 0x100
  81. #define FAN_MARK_TYPE_MASK (FAN_MARK_INODE | FAN_MARK_MOUNT | FAN_MARK_FILESYSTEM)
  82. #define FAN_ALL_MARK_FLAGS (FAN_MARK_ADD | FAN_MARK_REMOVE | FAN_MARK_DONT_FOLLOW | FAN_MARK_ONLYDIR | FAN_MARK_MOUNT | FAN_MARK_IGNORED_MASK | FAN_MARK_IGNORED_SURV_MODIFY | FAN_MARK_FLUSH)
  83. #define FAN_ALL_EVENTS (FAN_ACCESS | FAN_MODIFY | FAN_CLOSE | FAN_OPEN)
  84. #define FAN_ALL_PERM_EVENTS (FAN_OPEN_PERM | FAN_ACCESS_PERM)
  85. #define FAN_ALL_OUTGOING_EVENTS (FAN_ALL_EVENTS | FAN_ALL_PERM_EVENTS | FAN_Q_OVERFLOW)
  86. #define FANOTIFY_METADATA_VERSION 3
  87. #define FAN_EVENT_INFO_TYPE_FID 1
  88. #define FAN_EVENT_INFO_TYPE_DFID_NAME 2
  89. #define FAN_EVENT_INFO_TYPE_DFID 3
  90. #define FAN_ALLOW 0x01
  91. #define FAN_DENY 0x02
  92. #define FAN_AUDIT 0x10
  93. #define FAN_NOFD -1
  94. #define FAN_EVENT_METADATA_LEN (sizeof(struct fanotify_event_metadata))
  95. #define FAN_EVENT_NEXT(meta, len) ((len) -= (meta)->event_len, (struct fanotify_event_metadata*)(((char *)(meta)) + (meta)->event_len))
  96. #define FAN_EVENT_OK(meta, len) ((long)(len) >= (long)FAN_EVENT_METADATA_LEN && (long)(meta)->event_len >= (long)FAN_EVENT_METADATA_LEN && (long)(meta)->event_len <= (long)(len))
  97. int fanotify_init(unsigned, unsigned);
  98. int fanotify_mark(int, unsigned, unsigned long long, int, const char *);
  99. #ifdef __cplusplus
  100. }
  101. #endif
  102. #endif