fanotify.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 <stdint.h>
  17. struct fanotify_event_metadata {
  18. unsigned event_len;
  19. unsigned char vers;
  20. unsigned char reserved;
  21. unsigned short metadata_len;
  22. unsigned long long mask
  23. #ifdef __GNUC__
  24. __attribute__((__aligned__(8)))
  25. #endif
  26. ;
  27. int fd;
  28. int pid;
  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_CLOSE_WRITE 0x08
  37. #define FAN_CLOSE_NOWRITE 0x10
  38. #define FAN_OPEN 0x20
  39. #define FAN_Q_OVERFLOW 0x4000
  40. #define FAN_OPEN_PERM 0x10000
  41. #define FAN_ACCESS_PERM 0x20000
  42. #define FAN_ONDIR 0x40000000
  43. #define FAN_EVENT_ON_CHILD 0x08000000
  44. #define FAN_CLOSE (FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE)
  45. #define FAN_CLOEXEC 0x01
  46. #define FAN_NONBLOCK 0x02
  47. #define FAN_CLASS_NOTIF 0
  48. #define FAN_CLASS_CONTENT 0x04
  49. #define FAN_CLASS_PRE_CONTENT 0x08
  50. #define FAN_ALL_CLASS_BITS (FAN_CLASS_NOTIF | FAN_CLASS_CONTENT | FAN_CLASS_PRE_CONTENT)
  51. #define FAN_UNLIMITED_QUEUE 0x10
  52. #define FAN_UNLIMITED_MARKS 0x20
  53. #define FAN_ALL_INIT_FLAGS (FAN_CLOEXEC | FAN_NONBLOCK | FAN_ALL_CLASS_BITS | FAN_UNLIMITED_QUEUE | FAN_UNLIMITED_MARKS)
  54. #define FAN_MARK_ADD 0x01
  55. #define FAN_MARK_REMOVE 0x02
  56. #define FAN_MARK_DONT_FOLLOW 0x04
  57. #define FAN_MARK_ONLYDIR 0x08
  58. #define FAN_MARK_MOUNT 0x10
  59. #define FAN_MARK_IGNORED_MASK 0x20
  60. #define FAN_MARK_IGNORED_SURV_MODIFY 0x40
  61. #define FAN_MARK_FLUSH 0x80
  62. #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)
  63. #define FAN_ALL_EVENTS (FAN_ACCESS | FAN_MODIFY | FAN_CLOSE | FAN_OPEN)
  64. #define FAN_ALL_PERM_EVENTS (FAN_OPEN_PERM | FAN_ACCESS_PERM)
  65. #define FAN_ALL_OUTGOING_EVENTS (FAN_ALL_EVENTS | FAN_ALL_PERM_EVENTS | FAN_Q_OVERFLOW)
  66. #define FANOTIFY_METADATA_VERSION 3
  67. #define FAN_ALLOW 0x01
  68. #define FAN_DENY 0x02
  69. #define FAN_NOFD -1
  70. #define FAN_EVENT_METADATA_LEN (sizeof(struct fanotify_event_metadata))
  71. #define FAN_EVENT_NEXT(meta, len) ((len) -= (meta)->event_len, (struct fanotify_event_metadata*)(((char *)(meta)) + (meta)->event_len))
  72. #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))
  73. __BEGIN_DECLS
  74. /* Create and initialize fanotify group. */
  75. extern int fanotify_init (unsigned int __flags, unsigned int __event_f_flags)
  76. __THROW;
  77. /* Add, remove, or modify an fanotify mark on a filesystem object. */
  78. extern int fanotify_mark (int __fanotify_fd, unsigned int __flags,
  79. uint64_t __mask, int __dfd, const char *__pathname)
  80. __THROW;
  81. __END_DECLS
  82. #endif /* sys/fanotify.h */