michael@0: #ifndef _LINUX_FANOTIFY_H michael@0: #define _LINUX_FANOTIFY_H michael@0: michael@0: /* This is a Linux header generated by "make headers_install" */ michael@0: michael@0: #include michael@0: michael@0: /* the following events that user-space can register for */ michael@0: #define FAN_ACCESS 0x00000001 /* File was accessed */ michael@0: #define FAN_MODIFY 0x00000002 /* File was modified */ michael@0: #define FAN_CLOSE_WRITE 0x00000008 /* Writtable file closed */ michael@0: #define FAN_CLOSE_NOWRITE 0x00000010 /* Unwrittable file closed */ michael@0: #define FAN_OPEN 0x00000020 /* File was opened */ michael@0: michael@0: #define FAN_Q_OVERFLOW 0x00004000 /* Event queued overflowed */ michael@0: michael@0: #define FAN_OPEN_PERM 0x00010000 /* File open in perm check */ michael@0: #define FAN_ACCESS_PERM 0x00020000 /* File accessed in perm check */ michael@0: michael@0: #define FAN_ONDIR 0x40000000 /* event occurred against dir */ michael@0: michael@0: #define FAN_EVENT_ON_CHILD 0x08000000 /* interested in child events */ michael@0: michael@0: /* helper events */ michael@0: #define FAN_CLOSE (FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE) /* close */ michael@0: michael@0: /* flags used for fanotify_init() */ michael@0: #define FAN_CLOEXEC 0x00000001 michael@0: #define FAN_NONBLOCK 0x00000002 michael@0: michael@0: /* These are NOT bitwise flags. Both bits are used togther. */ michael@0: #define FAN_CLASS_NOTIF 0x00000000 michael@0: #define FAN_CLASS_CONTENT 0x00000004 michael@0: #define FAN_CLASS_PRE_CONTENT 0x00000008 michael@0: #define FAN_ALL_CLASS_BITS (FAN_CLASS_NOTIF | FAN_CLASS_CONTENT | \ michael@0: FAN_CLASS_PRE_CONTENT) michael@0: michael@0: #define FAN_UNLIMITED_QUEUE 0x00000010 michael@0: #define FAN_UNLIMITED_MARKS 0x00000020 michael@0: michael@0: #define FAN_ALL_INIT_FLAGS (FAN_CLOEXEC | FAN_NONBLOCK | \ michael@0: FAN_ALL_CLASS_BITS | FAN_UNLIMITED_QUEUE |\ michael@0: FAN_UNLIMITED_MARKS) michael@0: michael@0: /* flags used for fanotify_modify_mark() */ michael@0: #define FAN_MARK_ADD 0x00000001 michael@0: #define FAN_MARK_REMOVE 0x00000002 michael@0: #define FAN_MARK_DONT_FOLLOW 0x00000004 michael@0: #define FAN_MARK_ONLYDIR 0x00000008 michael@0: #define FAN_MARK_MOUNT 0x00000010 michael@0: #define FAN_MARK_IGNORED_MASK 0x00000020 michael@0: #define FAN_MARK_IGNORED_SURV_MODIFY 0x00000040 michael@0: #define FAN_MARK_FLUSH 0x00000080 michael@0: michael@0: #define FAN_ALL_MARK_FLAGS (FAN_MARK_ADD |\ michael@0: FAN_MARK_REMOVE |\ michael@0: FAN_MARK_DONT_FOLLOW |\ michael@0: FAN_MARK_ONLYDIR |\ michael@0: FAN_MARK_MOUNT |\ michael@0: FAN_MARK_IGNORED_MASK |\ michael@0: FAN_MARK_IGNORED_SURV_MODIFY |\ michael@0: FAN_MARK_FLUSH) michael@0: michael@0: /* michael@0: * All of the events - we build the list by hand so that we can add flags in michael@0: * the future and not break backward compatibility. Apps will get only the michael@0: * events that they originally wanted. Be sure to add new events here! michael@0: */ michael@0: #define FAN_ALL_EVENTS (FAN_ACCESS |\ michael@0: FAN_MODIFY |\ michael@0: FAN_CLOSE |\ michael@0: FAN_OPEN) michael@0: michael@0: /* michael@0: * All events which require a permission response from userspace michael@0: */ michael@0: #define FAN_ALL_PERM_EVENTS (FAN_OPEN_PERM |\ michael@0: FAN_ACCESS_PERM) michael@0: michael@0: #define FAN_ALL_OUTGOING_EVENTS (FAN_ALL_EVENTS |\ michael@0: FAN_ALL_PERM_EVENTS |\ michael@0: FAN_Q_OVERFLOW) michael@0: michael@0: #define FANOTIFY_METADATA_VERSION 3 michael@0: michael@0: struct fanotify_event_metadata { michael@0: __u32 event_len; michael@0: __u8 vers; michael@0: __u8 reserved; michael@0: __u16 metadata_len; michael@0: __u64 mask; michael@0: __s32 fd; michael@0: __s32 pid; michael@0: }; michael@0: michael@0: struct fanotify_response { michael@0: __s32 fd; michael@0: __u32 response; michael@0: }; michael@0: michael@0: /* Legit userspace responses to a _PERM event */ michael@0: #define FAN_ALLOW 0x01 michael@0: #define FAN_DENY 0x02 michael@0: /* No fd set in event */ michael@0: #define FAN_NOFD -1 michael@0: michael@0: /* Helper functions to deal with fanotify_event_metadata buffers */ michael@0: #define FAN_EVENT_METADATA_LEN (sizeof(struct fanotify_event_metadata)) michael@0: michael@0: #define FAN_EVENT_NEXT(meta, len) ((len) -= (meta)->event_len, \ michael@0: (struct fanotify_event_metadata*)(((char *)(meta)) + \ michael@0: (meta)->event_len)) michael@0: michael@0: #define FAN_EVENT_OK(meta, len) ((long)(len) >= (long)FAN_EVENT_METADATA_LEN && \ michael@0: (long)(meta)->event_len >= (long)FAN_EVENT_METADATA_LEN && \ michael@0: (long)(meta)->event_len <= (long)(len)) michael@0: michael@0: #endif /* _LINUX_FANOTIFY_H */