OLD | NEW |
1 #ifndef _FANOTIFY_H | 1 #ifndef _FANOTIFY_H |
2 #define _FANOTIFY_H | 2 #define _FANOTIFY_H |
3 | 3 |
4 #ifdef __cplusplus | 4 #ifdef __cplusplus |
5 extern "C" { | 5 extern "C" { |
6 #endif | 6 #endif |
7 | 7 |
8 struct fanotify_event_metadata { | 8 struct fanotify_event_metadata { |
9 » unsigned event_len; | 9 unsigned event_len; |
10 » unsigned char vers; | 10 unsigned char vers; |
11 » unsigned char reserved; | 11 unsigned char reserved; |
12 » unsigned short metadata_len; | 12 unsigned short metadata_len; |
13 » unsigned long long mask | 13 unsigned long long mask |
14 #ifdef __GNUC__ | 14 #ifdef __GNUC__ |
15 » __attribute__((__aligned__(8))) | 15 __attribute__((__aligned__(8))) |
16 #endif | 16 #endif |
17 » ; | 17 ; |
18 » int fd; | 18 int fd; |
19 » int pid; | 19 int pid; |
20 }; | 20 }; |
21 | 21 |
22 struct fanotify_response { | 22 struct fanotify_response { |
23 » int fd; | 23 int fd; |
24 » unsigned response; | 24 unsigned response; |
25 }; | 25 }; |
26 | 26 |
27 #define FAN_ACCESS 0x01 | 27 #define FAN_ACCESS 0x01 |
28 #define FAN_MODIFY 0x02 | 28 #define FAN_MODIFY 0x02 |
29 #define FAN_CLOSE_WRITE 0x08 | 29 #define FAN_CLOSE_WRITE 0x08 |
30 #define FAN_CLOSE_NOWRITE 0x10 | 30 #define FAN_CLOSE_NOWRITE 0x10 |
31 #define FAN_OPEN 0x20 | 31 #define FAN_OPEN 0x20 |
32 #define FAN_Q_OVERFLOW 0x4000 | 32 #define FAN_Q_OVERFLOW 0x4000 |
33 #define FAN_OPEN_PERM 0x10000 | 33 #define FAN_OPEN_PERM 0x10000 |
34 #define FAN_ACCESS_PERM 0x20000 | 34 #define FAN_ACCESS_PERM 0x20000 |
35 #define FAN_ONDIR 0x40000000 | 35 #define FAN_ONDIR 0x40000000 |
36 #define FAN_EVENT_ON_CHILD 0x08000000 | 36 #define FAN_EVENT_ON_CHILD 0x08000000 |
37 #define FAN_CLOSE (FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE) | 37 #define FAN_CLOSE (FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE) |
38 #define FAN_CLOEXEC 0x01 | 38 #define FAN_CLOEXEC 0x01 |
39 #define FAN_NONBLOCK 0x02 | 39 #define FAN_NONBLOCK 0x02 |
40 #define FAN_CLASS_NOTIF 0 | 40 #define FAN_CLASS_NOTIF 0 |
41 #define FAN_CLASS_CONTENT 0x04 | 41 #define FAN_CLASS_CONTENT 0x04 |
42 #define FAN_CLASS_PRE_CONTENT 0x08 | 42 #define FAN_CLASS_PRE_CONTENT 0x08 |
43 #define FAN_ALL_CLASS_BITS (FAN_CLASS_NOTIF | FAN_CLASS_CONTENT | FAN_CLASS_PRE_
CONTENT) | 43 #define FAN_ALL_CLASS_BITS \ |
| 44 (FAN_CLASS_NOTIF | FAN_CLASS_CONTENT | FAN_CLASS_PRE_CONTENT) |
44 #define FAN_UNLIMITED_QUEUE 0x10 | 45 #define FAN_UNLIMITED_QUEUE 0x10 |
45 #define FAN_UNLIMITED_MARKS 0x20 | 46 #define FAN_UNLIMITED_MARKS 0x20 |
46 #define FAN_ALL_INIT_FLAGS (FAN_CLOEXEC | FAN_NONBLOCK | FAN_ALL_CLASS_BITS | FA
N_UNLIMITED_QUEUE | FAN_UNLIMITED_MARKS) | 47 #define FAN_ALL_INIT_FLAGS \ |
| 48 (FAN_CLOEXEC | FAN_NONBLOCK | FAN_ALL_CLASS_BITS | FAN_UNLIMITED_QUEUE | \ |
| 49 FAN_UNLIMITED_MARKS) |
47 #define FAN_MARK_ADD 0x01 | 50 #define FAN_MARK_ADD 0x01 |
48 #define FAN_MARK_REMOVE 0x02 | 51 #define FAN_MARK_REMOVE 0x02 |
49 #define FAN_MARK_DONT_FOLLOW 0x04 | 52 #define FAN_MARK_DONT_FOLLOW 0x04 |
50 #define FAN_MARK_ONLYDIR 0x08 | 53 #define FAN_MARK_ONLYDIR 0x08 |
51 #define FAN_MARK_MOUNT 0x10 | 54 #define FAN_MARK_MOUNT 0x10 |
52 #define FAN_MARK_IGNORED_MASK 0x20 | 55 #define FAN_MARK_IGNORED_MASK 0x20 |
53 #define FAN_MARK_IGNORED_SURV_MODIFY 0x40 | 56 #define FAN_MARK_IGNORED_SURV_MODIFY 0x40 |
54 #define FAN_MARK_FLUSH 0x80 | 57 #define FAN_MARK_FLUSH 0x80 |
55 #define FAN_ALL_MARK_FLAGS (FAN_MARK_ADD | FAN_MARK_REMOVE | FAN_MARK_DONT_FOLLO
W | FAN_MARK_ONLYDIR | FAN_MARK_MOUNT | FAN_MARK_IGNORED_MASK | FAN_MARK_IGNORED
_SURV_MODIFY | FAN_MARK_FLUSH) | 58 #define FAN_ALL_MARK_FLAGS \ |
| 59 (FAN_MARK_ADD | FAN_MARK_REMOVE | FAN_MARK_DONT_FOLLOW | FAN_MARK_ONLYDIR | \ |
| 60 FAN_MARK_MOUNT | FAN_MARK_IGNORED_MASK | FAN_MARK_IGNORED_SURV_MODIFY | \ |
| 61 FAN_MARK_FLUSH) |
56 #define FAN_ALL_EVENTS (FAN_ACCESS | FAN_MODIFY | FAN_CLOSE | FAN_OPEN) | 62 #define FAN_ALL_EVENTS (FAN_ACCESS | FAN_MODIFY | FAN_CLOSE | FAN_OPEN) |
57 #define FAN_ALL_PERM_EVENTS (FAN_OPEN_PERM | FAN_ACCESS_PERM) | 63 #define FAN_ALL_PERM_EVENTS (FAN_OPEN_PERM | FAN_ACCESS_PERM) |
58 #define FAN_ALL_OUTGOING_EVENTS (FAN_ALL_EVENTS | FAN_ALL_PERM_EVENTS | FAN_Q_OV
ERFLOW) | 64 #define FAN_ALL_OUTGOING_EVENTS \ |
| 65 (FAN_ALL_EVENTS | FAN_ALL_PERM_EVENTS | FAN_Q_OVERFLOW) |
59 #define FANOTIFY_METADATA_VERSION 3 | 66 #define FANOTIFY_METADATA_VERSION 3 |
60 #define FAN_ALLOW 0x01 | 67 #define FAN_ALLOW 0x01 |
61 #define FAN_DENY 0x02 | 68 #define FAN_DENY 0x02 |
62 #define FAN_NOFD -1 | 69 #define FAN_NOFD -1 |
63 #define FAN_EVENT_METADATA_LEN (sizeof(struct fanotify_event_metadata)) | 70 #define FAN_EVENT_METADATA_LEN (sizeof(struct fanotify_event_metadata)) |
64 #define FAN_EVENT_NEXT(meta, len) ((len) -= (meta)->event_len, (struct fanotify_
event_metadata*)(((char *)(meta)) + (meta)->event_len)) | 71 #define FAN_EVENT_NEXT(meta, len) \ |
65 #define FAN_EVENT_OK(meta, len) ((long)(len) >= (long)FAN_EVENT_METADATA_LEN &&
(long)(meta)->event_len >= (long)FAN_EVENT_METADATA_LEN && (long)(meta)->event_l
en <= (long)(len)) | 72 ((len) -= (meta)->event_len, \ |
| 73 (struct fanotify_event_metadata*)(((char*)(meta)) + (meta)->event_len)) |
| 74 #define FAN_EVENT_OK(meta, len) \ |
| 75 ((long)(len) >= (long)FAN_EVENT_METADATA_LEN && \ |
| 76 (long)(meta)->event_len >= (long)FAN_EVENT_METADATA_LEN && \ |
| 77 (long)(meta)->event_len <= (long)(len)) |
66 | 78 |
67 int fanotify_init(unsigned, unsigned); | 79 int fanotify_init(unsigned, unsigned); |
68 int fanotify_mark(int, unsigned, unsigned long long, int, const char *); | 80 int fanotify_mark(int, unsigned, unsigned long long, int, const char*); |
69 | 81 |
70 #ifdef __cplusplus | 82 #ifdef __cplusplus |
71 } | 83 } |
72 #endif | 84 #endif |
73 #endif | 85 #endif |
OLD | NEW |