1 #ifndef _FANOTIFY_H 2 #define _FANOTIFY_H 3 4 #ifdef __cplusplus 5 extern "C" { 6 #endif 7 8 #include <sys/statfs.h> 9 10 struct fanotify_event_metadata { 11 unsigned event_len; 12 unsigned char vers; 13 unsigned char reserved; 14 unsigned short metadata_len; 15 unsigned long long mask 16 #ifdef __GNUC__ 17 __attribute__((__aligned__(8))) 18 #endif 19 ; 20 int fd; 21 int pid; 22 }; 23 24 struct fanotify_event_info_header { 25 unsigned char info_type; 26 unsigned char pad; 27 unsigned short len; 28 }; 29 30 struct fanotify_event_info_fid { 31 struct fanotify_event_info_header hdr; 32 fsid_t fsid; 33 unsigned char handle[]; 34 }; 35 36 struct fanotify_response { 37 int fd; 38 unsigned response; 39 }; 40 41 #define FAN_ACCESS 0x01 42 #define FAN_MODIFY 0x02 43 #define FAN_ATTRIB 0x04 44 #define FAN_CLOSE_WRITE 0x08 45 #define FAN_CLOSE_NOWRITE 0x10 46 #define FAN_OPEN 0x20 47 #define FAN_MOVED_FROM 0x40 48 #define FAN_MOVED_TO 0x80 49 #define FAN_CREATE 0x100 50 #define FAN_DELETE 0x200 51 #define FAN_DELETE_SELF 0x400 52 #define FAN_MOVE_SELF 0x800 53 #define FAN_OPEN_EXEC 0x1000 54 #define FAN_Q_OVERFLOW 0x4000 55 #define FAN_OPEN_PERM 0x10000 56 #define FAN_ACCESS_PERM 0x20000 57 #define FAN_OPEN_EXEC_PERM 0x40000 58 #define FAN_ONDIR 0x40000000 59 #define FAN_EVENT_ON_CHILD 0x08000000 60 #define FAN_CLOSE (FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE) 61 #define FAN_MOVE (FAN_MOVED_FROM | FAN_MOVED_TO) 62 #define FAN_CLOEXEC 0x01 63 #define FAN_NONBLOCK 0x02 64 #define FAN_CLASS_NOTIF 0 65 #define FAN_CLASS_CONTENT 0x04 66 #define FAN_CLASS_PRE_CONTENT 0x08 67 #define FAN_ALL_CLASS_BITS (FAN_CLASS_NOTIF | FAN_CLASS_CONTENT | FAN_CLASS_PRE_CONTENT) 68 #define FAN_UNLIMITED_QUEUE 0x10 69 #define FAN_UNLIMITED_MARKS 0x20 70 #define FAN_ENABLE_AUDIT 0x40 71 #define FAN_REPORT_TID 0x100 72 #define FAN_REPORT_FID 0x200 73 #define FAN_ALL_INIT_FLAGS (FAN_CLOEXEC | FAN_NONBLOCK | FAN_ALL_CLASS_BITS | FAN_UNLIMITED_QUEUE | FAN_UNLIMITED_MARKS) 74 #define FAN_MARK_ADD 0x01 75 #define FAN_MARK_REMOVE 0x02 76 #define FAN_MARK_DONT_FOLLOW 0x04 77 #define FAN_MARK_ONLYDIR 0x08 78 #define FAN_MARK_IGNORED_MASK 0x20 79 #define FAN_MARK_IGNORED_SURV_MODIFY 0x40 80 #define FAN_MARK_FLUSH 0x80 81 #define FAN_MARK_INODE 0x00 82 #define FAN_MARK_MOUNT 0x10 83 #define FAN_MARK_FILESYSTEM 0x100 84 #define FAN_MARK_TYPE_MASK (FAN_MARK_INODE | FAN_MARK_MOUNT | FAN_MARK_FILESYSTEM) 85 #define FAN_ALL_MARK_FLAGS (FAN_MARK_ADD | FAN_MARK_REMOVE | FAN_MARK_DONT_FOLLOW | FAN_MARK_ONLYDIR | FAN_MARK_MOUNT | FAN_MARK_IGNORED_MASK | FAN_MARK_IGNORED_SURV_MODIFY | FAN_MARK_FLUSH) 86 #define FAN_ALL_EVENTS (FAN_ACCESS | FAN_MODIFY | FAN_CLOSE | FAN_OPEN) 87 #define FAN_ALL_PERM_EVENTS (FAN_OPEN_PERM | FAN_ACCESS_PERM) 88 #define FAN_ALL_OUTGOING_EVENTS (FAN_ALL_EVENTS | FAN_ALL_PERM_EVENTS | FAN_Q_OVERFLOW) 89 #define FANOTIFY_METADATA_VERSION 3 90 #define FAN_EVENT_INFO_TYPE_FID 1 91 #define FAN_ALLOW 0x01 92 #define FAN_DENY 0x02 93 #define FAN_AUDIT 0x10 94 #define FAN_NOFD -1 95 #define FAN_EVENT_METADATA_LEN (sizeof(struct fanotify_event_metadata)) 96 #define FAN_EVENT_NEXT(meta, len) ((len) -= (meta)->event_len, (struct fanotify_event_metadata*)(((char *)(meta)) + (meta)->event_len)) 97 #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_len <= (long)(len)) 98 99 int fanotify_init(unsigned, unsigned); 100 int fanotify_mark(int, unsigned, unsigned long long, int, const char *); 101 102 #ifdef __cplusplus 103 } 104 #endif 105 #endif 106