fanotify.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef _FANOTIFY_H
  2. #define _FANOTIFY_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. struct fanotify_event_metadata {
  7. unsigned event_len;
  8. unsigned char vers;
  9. unsigned char reserved;
  10. unsigned short metadata_len;
  11. unsigned long long mask
  12. #ifdef __GNUC__
  13. __attribute__((__aligned__(8)))
  14. #endif
  15. ;
  16. int fd;
  17. int pid;
  18. };
  19. struct fanotify_response {
  20. int fd;
  21. unsigned response;
  22. };
  23. #define FAN_ACCESS 0x01
  24. #define FAN_MODIFY 0x02
  25. #define FAN_CLOSE_WRITE 0x08
  26. #define FAN_CLOSE_NOWRITE 0x10
  27. #define FAN_OPEN 0x20
  28. #define FAN_Q_OVERFLOW 0x4000
  29. #define FAN_OPEN_PERM 0x10000
  30. #define FAN_ACCESS_PERM 0x20000
  31. #define FAN_ONDIR 0x40000000
  32. #define FAN_EVENT_ON_CHILD 0x08000000
  33. #define FAN_CLOSE (FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE)
  34. #define FAN_CLOEXEC 0x01
  35. #define FAN_NONBLOCK 0x02
  36. #define FAN_CLASS_NOTIF 0
  37. #define FAN_CLASS_CONTENT 0x04
  38. #define FAN_CLASS_PRE_CONTENT 0x08
  39. #define FAN_ALL_CLASS_BITS (FAN_CLASS_NOTIF | FAN_CLASS_CONTENT | FAN_CLASS_PRE_CONTENT)
  40. #define FAN_UNLIMITED_QUEUE 0x10
  41. #define FAN_UNLIMITED_MARKS 0x20
  42. #define FAN_ALL_INIT_FLAGS (FAN_CLOEXEC | FAN_NONBLOCK | FAN_ALL_CLASS_BITS | FAN_UNLIMITED_QUEUE | FAN_UNLIMITED_MARKS)
  43. #define FAN_MARK_ADD 0x01
  44. #define FAN_MARK_REMOVE 0x02
  45. #define FAN_MARK_DONT_FOLLOW 0x04
  46. #define FAN_MARK_ONLYDIR 0x08
  47. #define FAN_MARK_MOUNT 0x10
  48. #define FAN_MARK_IGNORED_MASK 0x20
  49. #define FAN_MARK_IGNORED_SURV_MODIFY 0x40
  50. #define FAN_MARK_FLUSH 0x80
  51. #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)
  52. #define FAN_ALL_EVENTS (FAN_ACCESS | FAN_MODIFY | FAN_CLOSE | FAN_OPEN)
  53. #define FAN_ALL_PERM_EVENTS (FAN_OPEN_PERM | FAN_ACCESS_PERM)
  54. #define FAN_ALL_OUTGOING_EVENTS (FAN_ALL_EVENTS | FAN_ALL_PERM_EVENTS | FAN_Q_OVERFLOW)
  55. #define FANOTIFY_METADATA_VERSION 3
  56. #define FAN_ALLOW 0x01
  57. #define FAN_DENY 0x02
  58. #define FAN_NOFD -1
  59. #define FAN_EVENT_METADATA_LEN (sizeof(struct fanotify_event_metadata))
  60. #define FAN_EVENT_NEXT(meta, len) ((len) -= (meta)->event_len, (struct fanotify_event_metadata*)(((char *)(meta)) + (meta)->event_len))
  61. #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))
  62. int fanotify_init(unsigned, unsigned);
  63. int fanotify_mark(int, unsigned, unsigned long long, int, const char *);
  64. #ifdef __cplusplus
  65. }
  66. #endif
  67. #endif