fanotify.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #ifndef _LINUX_FANOTIFY_H
  2. #define _LINUX_FANOTIFY_H
  3. #include <linux/types.h>
  4. /* the following events that user-space can register for */
  5. #define FAN_ACCESS 0x00000001 /* File was accessed */
  6. #define FAN_MODIFY 0x00000002 /* File was modified */
  7. #define FAN_CLOSE_WRITE 0x00000008 /* Unwrittable file closed */
  8. #define FAN_CLOSE_NOWRITE 0x00000010 /* Writtable file closed */
  9. #define FAN_OPEN 0x00000020 /* File was opened */
  10. #define FAN_EVENT_ON_CHILD 0x08000000 /* interested in child events */
  11. /* FIXME currently Q's have no limit.... */
  12. #define FAN_Q_OVERFLOW 0x00004000 /* Event queued overflowed */
  13. /* helper events */
  14. #define FAN_CLOSE (FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE) /* close */
  15. /* flags used for fanotify_init() */
  16. #define FAN_CLOEXEC 0x00000001
  17. #define FAN_NONBLOCK 0x00000002
  18. #define FAN_ALL_INIT_FLAGS (FAN_CLOEXEC | FAN_NONBLOCK)
  19. /* flags used for fanotify_modify_mark() */
  20. #define FAN_MARK_ADD 0x00000001
  21. #define FAN_MARK_REMOVE 0x00000002
  22. #define FAN_MARK_DONT_FOLLOW 0x00000004
  23. #define FAN_MARK_ONLYDIR 0x00000008
  24. #define FAN_ALL_MARK_FLAGS (FAN_MARK_ADD |\
  25. FAN_MARK_REMOVE |\
  26. FAN_MARK_DONT_FOLLOW |\
  27. FAN_MARK_ONLYDIR)
  28. /*
  29. * All of the events - we build the list by hand so that we can add flags in
  30. * the future and not break backward compatibility. Apps will get only the
  31. * events that they originally wanted. Be sure to add new events here!
  32. */
  33. #define FAN_ALL_EVENTS (FAN_ACCESS |\
  34. FAN_MODIFY |\
  35. FAN_CLOSE |\
  36. FAN_OPEN)
  37. /*
  38. * All legal FAN bits userspace can request (although possibly not all
  39. * at the same time.
  40. */
  41. #define FAN_ALL_INCOMING_EVENTS (FAN_ALL_EVENTS |\
  42. FAN_EVENT_ON_CHILD)
  43. #define FAN_ALL_OUTGOING_EVENTS (FAN_ALL_EVENTS |\
  44. FAN_Q_OVERFLOW)
  45. #define FANOTIFY_METADATA_VERSION 1
  46. struct fanotify_event_metadata {
  47. __u32 event_len;
  48. __u32 vers;
  49. __s32 fd;
  50. __u64 mask;
  51. __s64 pid;
  52. } __attribute__ ((packed));
  53. /* Helper functions to deal with fanotify_event_metadata buffers */
  54. #define FAN_EVENT_METADATA_LEN (sizeof(struct fanotify_event_metadata))
  55. #define FAN_EVENT_NEXT(meta, len) ((len) -= (meta)->event_len, \
  56. (struct fanotify_event_metadata*)(((char *)(meta)) + \
  57. (meta)->event_len))
  58. #define FAN_EVENT_OK(meta, len) ((long)(len) >= (long)FAN_EVENT_METADATA_LEN && \
  59. (long)(meta)->event_len >= (long)FAN_EVENT_METADATA_LEN && \
  60. (long)(meta)->event_len <= (long)(len))
  61. #ifdef __KERNEL__
  62. #endif /* __KERNEL__ */
  63. #endif /* _LINUX_FANOTIFY_H */