aboutsummaryrefslogtreecommitdiff
path: root/src/3rdParty/efsw/inotify-nosys.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdParty/efsw/inotify-nosys.h')
-rwxr-xr-xsrc/3rdParty/efsw/inotify-nosys.h164
1 files changed, 164 insertions, 0 deletions
diff --git a/src/3rdParty/efsw/inotify-nosys.h b/src/3rdParty/efsw/inotify-nosys.h
new file mode 100755
index 0000000..be1e627
--- /dev/null
+++ b/src/3rdParty/efsw/inotify-nosys.h
@@ -0,0 +1,164 @@
1#ifndef _LINUX_INOTIFY_H
2#define _LINUX_INOTIFY_H
3
4#include <stdint.h>
5#include <sys/syscall.h>
6#include <unistd.h>
7
8/*
9 * struct inotify_event - structure read from the inotify device for each event
10 *
11 * When you are watching a directory, you will receive the filename for events
12 * such as IN_CREATE, IN_DELETE, IN_OPEN, IN_CLOSE, ..., relative to the wd.
13 */
14struct inotify_event {
15 int wd; /* watch descriptor */
16 uint32_t mask; /* watch mask */
17 uint32_t cookie; /* cookie to synchronize two events */
18 uint32_t len; /* length (including nulls) of name */
19 char name __flexarr; /* stub for possible name */
20};
21
22/* the following are legal, implemented events that user-space can watch for */
23#define IN_ACCESS 0x00000001 /* File was accessed */
24#define IN_MODIFY 0x00000002 /* File was modified */
25#define IN_ATTRIB 0x00000004 /* Metadata changed */
26#define IN_CLOSE_WRITE 0x00000008 /* Writtable file was closed */
27#define IN_CLOSE_NOWRITE 0x00000010 /* Unwrittable file closed */
28#define IN_OPEN 0x00000020 /* File was opened */
29#define IN_MOVED_FROM 0x00000040 /* File was moved from X */
30#define IN_MOVED_TO 0x00000080 /* File was moved to Y */
31#define IN_CREATE 0x00000100 /* Subfile was created */
32#define IN_DELETE 0x00000200 /* Subfile was deleted */
33#define IN_DELETE_SELF 0x00000400 /* Self was deleted */
34#define IN_MOVE_SELF 0x00000800 /* Self was moved */
35
36/* the following are legal events. they are sent as needed to any watch */
37#define IN_UNMOUNT 0x00002000 /* Backing fs was unmounted */
38#define IN_Q_OVERFLOW 0x00004000 /* Event queued overflowed */
39#define IN_IGNORED 0x00008000 /* File was ignored */
40
41/* helper events */
42#define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE) /* close */
43#define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO) /* moves */
44
45/* special flags */
46#define IN_ONLYDIR 0x01000000 /* only watch the path if it is a directory */
47#define IN_DONT_FOLLOW 0x02000000 /* don't follow a sym link */
48#define IN_MASK_ADD 0x20000000 /* add to the mask of an already existing watch */
49#define IN_ISDIR 0x40000000 /* event occurred against dir */
50#define IN_ONESHOT 0x80000000 /* only send event once */
51
52/*
53 * All of the events - we build the list by hand so that we can add flags in
54 * the future and not break backward compatibility. Apps will get only the
55 * events that they originally wanted. Be sure to add new events here!
56 */
57#define IN_ALL_EVENTS (IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | \
58 IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | \
59 IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF | \
60 IN_MOVE_SELF)
61
62#if defined (__alpha__)
63# define __NR_inotify_init 444
64# define __NR_inotify_add_watch 445
65# define __NR_inotify_rm_watch 446
66
67#elif defined (__arm__)
68# define __NR_inotify_init (__NR_SYSCALL_BASE+316)
69# define __NR_inotify_add_watch (__NR_SYSCALL_BASE+317)
70# define __NR_inotify_rm_watch (__NR_SYSCALL_BASE+318)
71
72#elif defined (__aarch64__)
73# define __NR_inotify_init 1043
74# define __NR_inotify_add_watch 27
75# define __NR_inotify_rm_watch 28
76
77#elif defined (__frv__)
78# define __NR_inotify_init 291
79# define __NR_inotify_add_watch 292
80# define __NR_inotify_rm_watch 293
81
82#elif defined(__i386__)
83# define __NR_inotify_init 291
84# define __NR_inotify_add_watch 292
85# define __NR_inotify_rm_watch 293
86
87#elif defined (__ia64__)
88# define __NR_inotify_init 1277
89# define __NR_inotify_add_watch 1278
90# define __NR_inotify_rm_watch 1279
91
92#elif defined (__mips__)
93# if _MIPS_SIM == _MIPS_SIM_ABI32
94# define __NR_inotify_init (__NR_Linux + 284)
95# define __NR_inotify_add_watch (__NR_Linux + 285)
96# define __NR_inotify_rm_watch (__NR_Linux + 286)
97# endif
98# if _MIPS_SIM == _MIPS_SIM_ABI64
99# define __NR_inotify_init (__NR_Linux + 243)
100# define __NR_inotify_add_watch (__NR_Linux + 243)
101# define __NR_inotify_rm_watch (__NR_Linux + 243)
102# endif
103# if _MIPS_SIM == _MIPS_SIM_NABI32
104# define __NR_inotify_init (__NR_Linux + 247)
105# define __NR_inotify_add_watch (__NR_Linux + 248)
106# define __NR_inotify_rm_watch (__NR_Linux + 249)
107# endif
108
109#elif defined(__parisc__)
110# define __NR_inotify_init (__NR_Linux + 269)
111# define __NR_inotify_add_watch (__NR_Linux + 270)
112# define __NR_inotify_rm_watch (__NR_Linux + 271)
113
114#elif defined(__powerpc__) || defined(__powerpc64__)
115# define __NR_inotify_init 275
116# define __NR_inotify_add_watch 276
117# define __NR_inotify_rm_watch 277
118
119#elif defined (__s390__)
120# define __NR_inotify_init 284
121# define __NR_inotify_add_watch 285
122# define __NR_inotify_rm_watch 286
123
124#elif defined (__sh__)
125# define __NR_inotify_init 290
126# define __NR_inotify_add_watch 291
127# define __NR_inotify_rm_watch 292
128
129#elif defined (__sh64__)
130# define __NR_inotify_init 318
131# define __NR_inotify_add_watch 319
132# define __NR_inotify_rm_watch 320
133
134#elif defined (__sparc__) || defined (__sparc64__)
135# define __NR_inotify_init 151
136# define __NR_inotify_add_watch 152
137# define __NR_inotify_rm_watch 156
138
139#elif defined(__x86_64__)
140# define __NR_inotify_init 253
141# define __NR_inotify_add_watch 254
142# define __NR_inotify_rm_watch 255
143
144#else
145# error "Unsupported architecture!"
146#endif
147
148static inline int inotify_init (void)
149{
150 return syscall (__NR_inotify_init);
151}
152
153static inline int inotify_add_watch (int fd, const char *name, uint32_t mask)
154{
155 return syscall (__NR_inotify_add_watch, fd, name, mask);
156}
157
158static inline int inotify_rm_watch (int fd, uint32_t wd)
159{
160 return syscall (__NR_inotify_rm_watch, fd, wd);
161}
162
163
164#endif /* _LINUX_INOTIFY_H */