fanotify.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* Copyright (C) 2010-2015 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <http://www.gnu.org/licenses/>. */
  14. #ifndef _SYS_FANOTIFY_H
  15. #define _SYS_FANOTIFY_H 1
  16. #include <linux/types.h>
  17. #include <stdint.h>
  18. #include <sys/statfs.h>
  19. struct fanotify_event_metadata {
  20. unsigned event_len;
  21. unsigned char vers;
  22. unsigned char reserved;
  23. unsigned short metadata_len;
  24. unsigned long long mask
  25. #ifdef __GNUC__
  26. __attribute__((__aligned__(8)))
  27. #endif
  28. ;
  29. int fd;
  30. int pid;
  31. };
  32. struct fanotify_event_info_header {
  33. unsigned char info_type;
  34. unsigned char pad;
  35. unsigned short len;
  36. };
  37. struct fanotify_event_info_fid {
  38. struct fanotify_event_info_header hdr;
  39. __fsid_t fsid;
  40. unsigned char handle[];
  41. };
  42. struct fanotify_response {
  43. int fd;
  44. unsigned response;
  45. };
  46. #define FAN_ACCESS 0x01
  47. #define FAN_MODIFY 0x02
  48. #define FAN_CLOSE_WRITE 0x08
  49. #define FAN_CLOSE_NOWRITE 0x10
  50. #define FAN_OPEN 0x20
  51. #define FAN_Q_OVERFLOW 0x4000
  52. #define FAN_OPEN_PERM 0x10000
  53. #define FAN_ACCESS_PERM 0x20000
  54. #define FAN_ONDIR 0x40000000
  55. #define FAN_EVENT_ON_CHILD 0x08000000
  56. #define FAN_CLOSE (FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE)
  57. #define FAN_CLOEXEC 0x01
  58. #define FAN_NONBLOCK 0x02
  59. #define FAN_CLASS_NOTIF 0
  60. #define FAN_CLASS_CONTENT 0x04
  61. #define FAN_CLASS_PRE_CONTENT 0x08
  62. #define FAN_ALL_CLASS_BITS (FAN_CLASS_NOTIF | FAN_CLASS_CONTENT | FAN_CLASS_PRE_CONTENT)
  63. #define FAN_UNLIMITED_QUEUE 0x10
  64. #define FAN_UNLIMITED_MARKS 0x20
  65. #define FAN_ENABLE_AUDIT 0x40
  66. #define FAN_REPORT_TID 0x100
  67. #define FAN_REPORT_FID 0x200
  68. #define FAN_REPORT_DIR_FID 0x00000400
  69. #define FAN_REPORT_NAME 0x00000800
  70. #define FAN_REPORT_DFID_NAME (FAN_REPORT_DIR_FID | FAN_REPORT_NAME)
  71. #define FAN_ALL_INIT_FLAGS (FAN_CLOEXEC | FAN_NONBLOCK | FAN_ALL_CLASS_BITS | FAN_UNLIMITED_QUEUE | FAN_UNLIMITED_MARKS)
  72. #define FAN_MARK_ADD 0x01
  73. #define FAN_MARK_REMOVE 0x02
  74. #define FAN_MARK_DONT_FOLLOW 0x04
  75. #define FAN_MARK_ONLYDIR 0x08
  76. #define FAN_MARK_MOUNT 0x10
  77. #define FAN_MARK_IGNORED_MASK 0x20
  78. #define FAN_MARK_IGNORED_SURV_MODIFY 0x40
  79. #define FAN_MARK_FLUSH 0x80
  80. #define FAN_MARK_INODE 0x00
  81. #define FAN_MARK_MOUNT 0x10
  82. #define FAN_MARK_FILESYSTEM 0x100
  83. #define FAN_MARK_TYPE_MASK (FAN_MARK_INODE | FAN_MARK_MOUNT | FAN_MARK_FILESYSTEM)
  84. #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)
  85. #define FAN_ALL_EVENTS (FAN_ACCESS | FAN_MODIFY | FAN_CLOSE | FAN_OPEN)
  86. #define FAN_ALL_PERM_EVENTS (FAN_OPEN_PERM | FAN_ACCESS_PERM)
  87. #define FAN_ALL_OUTGOING_EVENTS (FAN_ALL_EVENTS | FAN_ALL_PERM_EVENTS | FAN_Q_OVERFLOW)
  88. #define FANOTIFY_METADATA_VERSION 3
  89. #define FAN_EVENT_INFO_TYPE_FID 1
  90. #define FAN_EVENT_INFO_TYPE_DFID_NAME 2
  91. #define FAN_EVENT_INFO_TYPE_DFID 3
  92. #define FAN_ALLOW 0x01
  93. #define FAN_DENY 0x02
  94. #define FAN_AUDIT 0x10
  95. #define FAN_NOFD -1
  96. #define FAN_EVENT_METADATA_LEN (sizeof(struct fanotify_event_metadata))
  97. #define FAN_EVENT_NEXT(meta, len) ((len) -= (meta)->event_len, (struct fanotify_event_metadata*)(((char *)(meta)) + (meta)->event_len))
  98. #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))
  99. __BEGIN_DECLS
  100. /* Create and initialize fanotify group. */
  101. extern int fanotify_init (unsigned int __flags, unsigned int __event_f_flags)
  102. __THROW;
  103. /* Add, remove, or modify an fanotify mark on a filesystem object. */
  104. extern int fanotify_mark (int __fanotify_fd, unsigned int __flags,
  105. uint64_t __mask, int __dfd, const char *__pathname)
  106. __THROW;
  107. __END_DECLS
  108. #endif /* sys/fanotify.h */