00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef _LINUX_INOTIFY_H
00010 #define _LINUX_INOTIFY_H
00011
00012 #include <stdint.h>
00013 #include <sys/syscall.h>
00014 #include <unistd.h>
00015
00016
00017
00018
00019
00020
00021
00022 struct inotify_event {
00023 int wd;
00024 uint32_t mask;
00025 uint32_t cookie;
00026 uint32_t len;
00027 char name __flexarr;
00028 };
00029
00030
00031 #define IN_ACCESS 0x00000001
00032 #define IN_MODIFY 0x00000002
00033 #define IN_ATTRIB 0x00000004
00034 #define IN_CLOSE_WRITE 0x00000008
00035 #define IN_CLOSE_NOWRITE 0x00000010
00036 #define IN_OPEN 0x00000020
00037 #define IN_MOVED_FROM 0x00000040
00038 #define IN_MOVED_TO 0x00000080
00039 #define IN_CREATE 0x00000100
00040 #define IN_DELETE 0x00000200
00041 #define IN_DELETE_SELF 0x00000400
00042 #define IN_MOVE_SELF 0x00000800
00043
00044
00045 #define IN_UNMOUNT 0x00002000
00046 #define IN_Q_OVERFLOW 0x00004000
00047 #define IN_IGNORED 0x00008000
00048
00049
00050 #define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE)
00051 #define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO)
00052
00053
00054 #define IN_ONLYDIR 0x01000000
00055 #define IN_DONT_FOLLOW 0x02000000
00056 #define IN_MASK_ADD 0x20000000
00057 #define IN_ISDIR 0x40000000
00058 #define IN_ONESHOT 0x80000000
00059
00060
00061
00062
00063
00064
00065 #define IN_ALL_EVENTS (IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | \
00066 IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | \
00067 IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF | \
00068 IN_MOVE_SELF)
00069
00070 #if defined (__alpha__)
00071 # define __NR_inotify_init 444
00072 # define __NR_inotify_add_watch 445
00073 # define __NR_inotify_rm_watch 446
00074
00075 #elif defined (__arm__)
00076 # define __NR_inotify_init (__NR_SYSCALL_BASE+316)
00077 # define __NR_inotify_add_watch (__NR_SYSCALL_BASE+317)
00078 # define __NR_inotify_rm_watch (__NR_SYSCALL_BASE+318)
00079
00080 #elif defined (__frv__)
00081 # define __NR_inotify_init 291
00082 # define __NR_inotify_add_watch 292
00083 # define __NR_inotify_rm_watch 293
00084
00085 #elif defined(__i386__)
00086 # define __NR_inotify_init 291
00087 # define __NR_inotify_add_watch 292
00088 # define __NR_inotify_rm_watch 293
00089
00090 #elif defined (__ia64__)
00091 # define __NR_inotify_init 1277
00092 # define __NR_inotify_add_watch 1278
00093 # define __NR_inotify_rm_watch 1279
00094
00095 #elif defined (__mips__)
00096 # if _MIPS_SIM == _MIPS_SIM_ABI32
00097 # define __NR_inotify_init (__NR_Linux + 284)
00098 # define __NR_inotify_add_watch (__NR_Linux + 285)
00099 # define __NR_inotify_rm_watch (__NR_Linux + 286)
00100 # endif
00101 # if _MIPS_SIM == _MIPS_SIM_ABI64
00102 # define __NR_inotify_init (__NR_Linux + 243)
00103 # define __NR_inotify_add_watch (__NR_Linux + 243)
00104 # define __NR_inotify_rm_watch (__NR_Linux + 243)
00105 # endif
00106 # if _MIPS_SIM == _MIPS_SIM_NABI32
00107 # define __NR_inotify_init (__NR_Linux + 247)
00108 # define __NR_inotify_add_watch (__NR_Linux + 248)
00109 # define __NR_inotify_rm_watch (__NR_Linux + 249)
00110 # endif
00111
00112 #elif defined(__parisc__)
00113 # define __NR_inotify_init (__NR_Linux + 269)
00114 # define __NR_inotify_add_watch (__NR_Linux + 270)
00115 # define __NR_inotify_rm_watch (__NR_Linux + 271)
00116
00117 #elif defined(__powerpc__) || defined(__powerpc64__)
00118 # define __NR_inotify_init 275
00119 # define __NR_inotify_add_watch 276
00120 # define __NR_inotify_rm_watch 277
00121
00122 #elif defined (__s390__)
00123 # define __NR_inotify_init 284
00124 # define __NR_inotify_add_watch 285
00125 # define __NR_inotify_rm_watch 286
00126
00127 #elif defined (__sh__)
00128 # define __NR_inotify_init 290
00129 # define __NR_inotify_add_watch 291
00130 # define __NR_inotify_rm_watch 292
00131
00132 #elif defined (__sh64__)
00133 # define __NR_inotify_init 318
00134 # define __NR_inotify_add_watch 319
00135 # define __NR_inotify_rm_watch 320
00136
00137 #elif defined (__sparc__) || defined (__sparc64__)
00138 # define __NR_inotify_init 151
00139 # define __NR_inotify_add_watch 152
00140 # define __NR_inotify_rm_watch 156
00141
00142 #elif defined(__x86_64__)
00143 # define __NR_inotify_init 253
00144 # define __NR_inotify_add_watch 254
00145 # define __NR_inotify_rm_watch 255
00146
00147 #else
00148 # error "Unsupported architecture!"
00149 #endif
00150
00151 static inline int inotify_init (void)
00152 {
00153 return syscall (__NR_inotify_init);
00154 }
00155
00156 static inline int inotify_add_watch (int fd, const char *name, uint32_t mask)
00157 {
00158 return syscall (__NR_inotify_add_watch, fd, name, mask);
00159 }
00160
00161 static inline int inotify_rm_watch (int fd, uint32_t wd)
00162 {
00163 return syscall (__NR_inotify_rm_watch, fd, wd);
00164 }
00165
00166
00167 #endif