inotify.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. //
  2. // Copyright 2026 Aarav Ravindra Kharade
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. /* Copyright (C) 2005-2026 Free Software Foundation, Inc.
  17. This file is part of the GNU C Library.
  18. The GNU C Library is free software; you can redistribute it and/or
  19. modify it under the terms of the GNU Lesser General Public
  20. License as published by the Free Software Foundation; either
  21. version 2.1 of the License, or (at your option) any later version.
  22. The GNU C Library is distributed in the hope that it will be useful,
  23. but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  25. Lesser General Public License for more details.
  26. You should have received a copy of the GNU Lesser General Public
  27. License along with the GNU C Library; if not, see
  28. <https://www.gnu.org/licenses/>. */
  29. #ifndef _SYS_INOTIFY_H
  30. #define _SYS_INOTIFY_H 1
  31. #include <stdint.h>
  32. /* Get the platform-dependent flags. */
  33. #include <bits/inotify.h>
  34. /* Structure describing an inotify event. */
  35. struct inotify_event
  36. {
  37. int wd; /* Watch descriptor. */
  38. uint32_t mask; /* Watch mask. */
  39. uint32_t cookie; /* Cookie to synchronize two events. */
  40. uint32_t len; /* Length (including NULs) of name. */
  41. char name __flexarr; /* Name. */
  42. };
  43. /* Supported events suitable for MASK parameter of INOTIFY_ADD_WATCH. */
  44. #define IN_ACCESS 0x00000001 /* File was accessed. */
  45. #define IN_MODIFY 0x00000002 /* File was modified. */
  46. #define IN_ATTRIB 0x00000004 /* Metadata changed. */
  47. #define IN_CLOSE_WRITE 0x00000008 /* Writtable file was closed. */
  48. #define IN_CLOSE_NOWRITE 0x00000010 /* Unwrittable file closed. */
  49. #define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE) /* Close. */
  50. #define IN_OPEN 0x00000020 /* File was opened. */
  51. #define IN_MOVED_FROM 0x00000040 /* File was moved from X. */
  52. #define IN_MOVED_TO 0x00000080 /* File was moved to Y. */
  53. #define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO) /* Moves. */
  54. #define IN_CREATE 0x00000100 /* Subfile was created. */
  55. #define IN_DELETE 0x00000200 /* Subfile was deleted. */
  56. #define IN_DELETE_SELF 0x00000400 /* Self was deleted. */
  57. #define IN_MOVE_SELF 0x00000800 /* Self was moved. */
  58. /* Events sent by the kernel. */
  59. #define IN_UNMOUNT 0x00002000 /* Backing fs was unmounted. */
  60. #define IN_Q_OVERFLOW 0x00004000 /* Event queued overflowed. */
  61. #define IN_IGNORED 0x00008000 /* File was ignored. */
  62. /* Helper events. */
  63. #define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE) /* Close. */
  64. #define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO) /* Moves. */
  65. /* Special flags. */
  66. #define IN_ONLYDIR 0x01000000 /* Only watch the path if it is a
  67. directory. */
  68. #define IN_DONT_FOLLOW 0x02000000 /* Do not follow a sym link. */
  69. #define IN_EXCL_UNLINK 0x04000000 /* Exclude events on unlinked
  70. objects. */
  71. #define IN_MASK_CREATE 0x10000000 /* Only create watches. */
  72. #define IN_MASK_ADD 0x20000000 /* Add to the mask of an already
  73. existing watch. */
  74. #define IN_ISDIR 0x40000000 /* Event occurred against dir. */
  75. #define IN_ONESHOT 0x80000000 /* Only send event once. */
  76. /* All events which a program can wait on. */
  77. #define IN_ALL_EVENTS (IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE \
  78. | IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM \
  79. | IN_MOVED_TO | IN_CREATE | IN_DELETE \
  80. | IN_DELETE_SELF | IN_MOVE_SELF)
  81. __BEGIN_DECLS
  82. /* Create and initialize inotify instance. */
  83. extern int inotify_init (void) __THROW;
  84. /* Create and initialize inotify instance. */
  85. extern int inotify_init1 (int __flags) __THROW;
  86. /* Add watch of object NAME to inotify instance FD. Notify about
  87. events specified by MASK. */
  88. extern int inotify_add_watch (int __fd, const char *__name, uint32_t __mask)
  89. __THROW;
  90. /* Remove the watch specified by WD from the inotify instance FD. */
  91. extern int inotify_rm_watch (int __fd, int __wd) __THROW;
  92. __END_DECLS
  93. #endif /* sys/inotify.h */