fanotify.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LINUX_FANOTIFY_H
  3. #define _LINUX_FANOTIFY_H
  4. #include <uapi/linux/fanotify.h>
  5. #define FAN_GROUP_FLAG(group, flag) \
  6. ((group)->fanotify_data.flags & (flag))
  7. /*
  8. * Flags allowed to be passed from/to userspace.
  9. *
  10. * We intentionally do not add new bits to the old FAN_ALL_* constants, because
  11. * they are uapi exposed constants. If there are programs out there using
  12. * these constant, the programs may break if re-compiled with new uapi headers
  13. * and then run on an old kernel.
  14. */
  15. #define FANOTIFY_CLASS_BITS (FAN_CLASS_NOTIF | FAN_CLASS_CONTENT | \
  16. FAN_CLASS_PRE_CONTENT)
  17. #define FANOTIFY_FID_BITS (FAN_REPORT_FID | FAN_REPORT_DFID_NAME)
  18. #define FANOTIFY_INIT_FLAGS (FANOTIFY_CLASS_BITS | FANOTIFY_FID_BITS | \
  19. FAN_REPORT_TID | \
  20. FAN_CLOEXEC | FAN_NONBLOCK | \
  21. FAN_UNLIMITED_QUEUE | FAN_UNLIMITED_MARKS)
  22. #define FANOTIFY_MARK_TYPE_BITS (FAN_MARK_INODE | FAN_MARK_MOUNT | \
  23. FAN_MARK_FILESYSTEM)
  24. #define FANOTIFY_MARK_FLAGS (FANOTIFY_MARK_TYPE_BITS | \
  25. FAN_MARK_ADD | \
  26. FAN_MARK_REMOVE | \
  27. FAN_MARK_DONT_FOLLOW | \
  28. FAN_MARK_ONLYDIR | \
  29. FAN_MARK_IGNORED_MASK | \
  30. FAN_MARK_IGNORED_SURV_MODIFY | \
  31. FAN_MARK_FLUSH)
  32. /*
  33. * Events that can be reported with data type FSNOTIFY_EVENT_PATH.
  34. * Note that FAN_MODIFY can also be reported with data type
  35. * FSNOTIFY_EVENT_INODE.
  36. */
  37. #define FANOTIFY_PATH_EVENTS (FAN_ACCESS | FAN_MODIFY | \
  38. FAN_CLOSE | FAN_OPEN | FAN_OPEN_EXEC)
  39. /*
  40. * Directory entry modification events - reported only to directory
  41. * where entry is modified and not to a watching parent.
  42. */
  43. #define FANOTIFY_DIRENT_EVENTS (FAN_MOVE | FAN_CREATE | FAN_DELETE)
  44. /* Events that can only be reported with data type FSNOTIFY_EVENT_INODE */
  45. #define FANOTIFY_INODE_EVENTS (FANOTIFY_DIRENT_EVENTS | \
  46. FAN_ATTRIB | FAN_MOVE_SELF | FAN_DELETE_SELF)
  47. /* Events that user can request to be notified on */
  48. #define FANOTIFY_EVENTS (FANOTIFY_PATH_EVENTS | \
  49. FANOTIFY_INODE_EVENTS)
  50. /* Events that require a permission response from user */
  51. #define FANOTIFY_PERM_EVENTS (FAN_OPEN_PERM | FAN_ACCESS_PERM | \
  52. FAN_OPEN_EXEC_PERM)
  53. /* Extra flags that may be reported with event or control handling of events */
  54. #define FANOTIFY_EVENT_FLAGS (FAN_EVENT_ON_CHILD | FAN_ONDIR)
  55. /* Events that may be reported to user */
  56. #define FANOTIFY_OUTGOING_EVENTS (FANOTIFY_EVENTS | \
  57. FANOTIFY_PERM_EVENTS | \
  58. FAN_Q_OVERFLOW | FAN_ONDIR)
  59. #define ALL_FANOTIFY_EVENT_BITS (FANOTIFY_OUTGOING_EVENTS | \
  60. FANOTIFY_EVENT_FLAGS)
  61. /* Do not use these old uapi constants internally */
  62. #undef FAN_ALL_CLASS_BITS
  63. #undef FAN_ALL_INIT_FLAGS
  64. #undef FAN_ALL_MARK_FLAGS
  65. #undef FAN_ALL_EVENTS
  66. #undef FAN_ALL_PERM_EVENTS
  67. #undef FAN_ALL_OUTGOING_EVENTS
  68. #endif /* _LINUX_FANOTIFY_H */