inotify.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #include <syscall.h>
  2. #include <bits/types.h>
  3. #include <bits/fcntl.h>
  4. #define IN_CLOEXEC (1<<19)
  5. #define IN_NONBLOCK (1<<11)
  6. #define IN_ACCESS (1<<0)
  7. #define IN_MODIFY (1<<1)
  8. #define IN_ATTRIB (1<<2)
  9. #define IN_CLOSE_WRITE (1<<3)
  10. #define IN_CLOSE_NOWRITE (1<<4)
  11. #define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE)
  12. #define IN_OPEN (1<<5)
  13. #define IN_MOVED_FROM (1<<6)
  14. #define IN_MOVED_TO (1<<7)
  15. #define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO)
  16. #define IN_CREATE (1<<8)
  17. #define IN_DELETE (1<<9)
  18. #define IN_DELETE_SELF (1<<10)
  19. #define IN_MOVE_SELF (1<<11)
  20. #define IN_ALL_EVENTS ((1<<12)-1)
  21. #define IN_UNMOUNT (1<<13)
  22. #define IN_Q_OVERFLOW (1<<14)
  23. #define IN_IGNORED (1<<15)
  24. #define IN_ONLYDIR (1<<24)
  25. #define IN_DONT_FOLLOW (1<<25)
  26. #define IN_EXCL_UNLINK (1<<26)
  27. #define IN_MASK_ADD (1<<29)
  28. #define IN_ISDIR (1<<30)
  29. #define IN_ONESHOT (1<<31)
  30. struct inotify_event {
  31. int wd;
  32. uint32_t mask;
  33. uint32_t cookie;
  34. uint32_t len;
  35. char name[];
  36. };
  37. inline static long sys_inotify_init(void)
  38. {
  39. return syscall1(NR_inotify_init1, 0);
  40. }
  41. inline static long sys_inotify_init1(int flags)
  42. {
  43. return syscall1(NR_inotify_init1, flags);
  44. }
  45. inline static long sys_inotify_add_watch(int fd, const char* path, unsigned mask)
  46. {
  47. return syscall3(NR_inotify_add_watch, fd, (long)path, mask);
  48. }
  49. inline static long sys_inotify_rm_watch(int fd, int wd)
  50. {
  51. return syscall2(NR_inotify_rm_watch, fd, wd);
  52. }