TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
inotify-nosys.h
Go to the documentation of this file.
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  */
14 struct 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 (__frv__)
73 # define __NR_inotify_init 291
74 # define __NR_inotify_add_watch 292
75 # define __NR_inotify_rm_watch 293
76 
77 #elif defined(__i386__)
78 # define __NR_inotify_init 291
79 # define __NR_inotify_add_watch 292
80 # define __NR_inotify_rm_watch 293
81 
82 #elif defined (__ia64__)
83 # define __NR_inotify_init 1277
84 # define __NR_inotify_add_watch 1278
85 # define __NR_inotify_rm_watch 1279
86 
87 #elif defined (__mips__)
88 # if _MIPS_SIM == _MIPS_SIM_ABI32
89 # define __NR_inotify_init (__NR_Linux + 284)
90 # define __NR_inotify_add_watch (__NR_Linux + 285)
91 # define __NR_inotify_rm_watch (__NR_Linux + 286)
92 # endif
93 # if _MIPS_SIM == _MIPS_SIM_ABI64
94 # define __NR_inotify_init (__NR_Linux + 243)
95 # define __NR_inotify_add_watch (__NR_Linux + 243)
96 # define __NR_inotify_rm_watch (__NR_Linux + 243)
97 # endif
98 # if _MIPS_SIM == _MIPS_SIM_NABI32
99 # define __NR_inotify_init (__NR_Linux + 247)
100 # define __NR_inotify_add_watch (__NR_Linux + 248)
101 # define __NR_inotify_rm_watch (__NR_Linux + 249)
102 # endif
103 
104 #elif defined(__parisc__)
105 # define __NR_inotify_init (__NR_Linux + 269)
106 # define __NR_inotify_add_watch (__NR_Linux + 270)
107 # define __NR_inotify_rm_watch (__NR_Linux + 271)
108 
109 #elif defined(__powerpc__) || defined(__powerpc64__)
110 # define __NR_inotify_init 275
111 # define __NR_inotify_add_watch 276
112 # define __NR_inotify_rm_watch 277
113 
114 #elif defined (__s390__)
115 # define __NR_inotify_init 284
116 # define __NR_inotify_add_watch 285
117 # define __NR_inotify_rm_watch 286
118 
119 #elif defined (__sh__)
120 # define __NR_inotify_init 290
121 # define __NR_inotify_add_watch 291
122 # define __NR_inotify_rm_watch 292
123 
124 #elif defined (__sh64__)
125 # define __NR_inotify_init 318
126 # define __NR_inotify_add_watch 319
127 # define __NR_inotify_rm_watch 320
128 
129 #elif defined (__sparc__) || defined (__sparc64__)
130 # define __NR_inotify_init 151
131 # define __NR_inotify_add_watch 152
132 # define __NR_inotify_rm_watch 156
133 
134 #elif defined(__x86_64__)
135 # define __NR_inotify_init 253
136 # define __NR_inotify_add_watch 254
137 # define __NR_inotify_rm_watch 255
138 
139 #else
140 # error "Unsupported architecture!"
141 #endif
142 
143 static inline int inotify_init (void)
144 {
145  return syscall (__NR_inotify_init);
146 }
147 
148 static inline int inotify_add_watch (int fd, const char *name, uint32_t mask)
149 {
150  return syscall (__NR_inotify_add_watch, fd, name, mask);
151 }
152 
153 static inline int inotify_rm_watch (int fd, uint32_t wd)
154 {
155  return syscall (__NR_inotify_rm_watch, fd, wd);
156 }
157 
158 
159 #endif /* _LINUX_INOTIFY_H */
char name __flexarr
Definition: inotify-nosys.h:19
static int inotify_add_watch(int fd, const char *name, uint32_t mask)
Definition: inotify-nosys.h:148
static int inotify_rm_watch(int fd, uint32_t wd)
Definition: inotify-nosys.h:153
unsigned int uint32_t
Definition: stdint.h:80
uint32_t len
Definition: inotify-nosys.h:18
Definition: inotify-nosys.h:14
int wd
Definition: inotify-nosys.h:15
uint32_t cookie
Definition: inotify-nosys.h:17
static int inotify_init(void)
Definition: inotify-nosys.h:143
uint32_t mask
Definition: inotify-nosys.h:16