1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/hal/gonk/fanotify.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,118 @@ 1.4 +#ifndef _LINUX_FANOTIFY_H 1.5 +#define _LINUX_FANOTIFY_H 1.6 + 1.7 +/* This is a Linux header generated by "make headers_install" */ 1.8 + 1.9 +#include <linux/types.h> 1.10 + 1.11 +/* the following events that user-space can register for */ 1.12 +#define FAN_ACCESS 0x00000001 /* File was accessed */ 1.13 +#define FAN_MODIFY 0x00000002 /* File was modified */ 1.14 +#define FAN_CLOSE_WRITE 0x00000008 /* Writtable file closed */ 1.15 +#define FAN_CLOSE_NOWRITE 0x00000010 /* Unwrittable file closed */ 1.16 +#define FAN_OPEN 0x00000020 /* File was opened */ 1.17 + 1.18 +#define FAN_Q_OVERFLOW 0x00004000 /* Event queued overflowed */ 1.19 + 1.20 +#define FAN_OPEN_PERM 0x00010000 /* File open in perm check */ 1.21 +#define FAN_ACCESS_PERM 0x00020000 /* File accessed in perm check */ 1.22 + 1.23 +#define FAN_ONDIR 0x40000000 /* event occurred against dir */ 1.24 + 1.25 +#define FAN_EVENT_ON_CHILD 0x08000000 /* interested in child events */ 1.26 + 1.27 +/* helper events */ 1.28 +#define FAN_CLOSE (FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE) /* close */ 1.29 + 1.30 +/* flags used for fanotify_init() */ 1.31 +#define FAN_CLOEXEC 0x00000001 1.32 +#define FAN_NONBLOCK 0x00000002 1.33 + 1.34 +/* These are NOT bitwise flags. Both bits are used togther. */ 1.35 +#define FAN_CLASS_NOTIF 0x00000000 1.36 +#define FAN_CLASS_CONTENT 0x00000004 1.37 +#define FAN_CLASS_PRE_CONTENT 0x00000008 1.38 +#define FAN_ALL_CLASS_BITS (FAN_CLASS_NOTIF | FAN_CLASS_CONTENT | \ 1.39 + FAN_CLASS_PRE_CONTENT) 1.40 + 1.41 +#define FAN_UNLIMITED_QUEUE 0x00000010 1.42 +#define FAN_UNLIMITED_MARKS 0x00000020 1.43 + 1.44 +#define FAN_ALL_INIT_FLAGS (FAN_CLOEXEC | FAN_NONBLOCK | \ 1.45 + FAN_ALL_CLASS_BITS | FAN_UNLIMITED_QUEUE |\ 1.46 + FAN_UNLIMITED_MARKS) 1.47 + 1.48 +/* flags used for fanotify_modify_mark() */ 1.49 +#define FAN_MARK_ADD 0x00000001 1.50 +#define FAN_MARK_REMOVE 0x00000002 1.51 +#define FAN_MARK_DONT_FOLLOW 0x00000004 1.52 +#define FAN_MARK_ONLYDIR 0x00000008 1.53 +#define FAN_MARK_MOUNT 0x00000010 1.54 +#define FAN_MARK_IGNORED_MASK 0x00000020 1.55 +#define FAN_MARK_IGNORED_SURV_MODIFY 0x00000040 1.56 +#define FAN_MARK_FLUSH 0x00000080 1.57 + 1.58 +#define FAN_ALL_MARK_FLAGS (FAN_MARK_ADD |\ 1.59 + FAN_MARK_REMOVE |\ 1.60 + FAN_MARK_DONT_FOLLOW |\ 1.61 + FAN_MARK_ONLYDIR |\ 1.62 + FAN_MARK_MOUNT |\ 1.63 + FAN_MARK_IGNORED_MASK |\ 1.64 + FAN_MARK_IGNORED_SURV_MODIFY |\ 1.65 + FAN_MARK_FLUSH) 1.66 + 1.67 +/* 1.68 + * All of the events - we build the list by hand so that we can add flags in 1.69 + * the future and not break backward compatibility. Apps will get only the 1.70 + * events that they originally wanted. Be sure to add new events here! 1.71 + */ 1.72 +#define FAN_ALL_EVENTS (FAN_ACCESS |\ 1.73 + FAN_MODIFY |\ 1.74 + FAN_CLOSE |\ 1.75 + FAN_OPEN) 1.76 + 1.77 +/* 1.78 + * All events which require a permission response from userspace 1.79 + */ 1.80 +#define FAN_ALL_PERM_EVENTS (FAN_OPEN_PERM |\ 1.81 + FAN_ACCESS_PERM) 1.82 + 1.83 +#define FAN_ALL_OUTGOING_EVENTS (FAN_ALL_EVENTS |\ 1.84 + FAN_ALL_PERM_EVENTS |\ 1.85 + FAN_Q_OVERFLOW) 1.86 + 1.87 +#define FANOTIFY_METADATA_VERSION 3 1.88 + 1.89 +struct fanotify_event_metadata { 1.90 + __u32 event_len; 1.91 + __u8 vers; 1.92 + __u8 reserved; 1.93 + __u16 metadata_len; 1.94 + __u64 mask; 1.95 + __s32 fd; 1.96 + __s32 pid; 1.97 +}; 1.98 + 1.99 +struct fanotify_response { 1.100 + __s32 fd; 1.101 + __u32 response; 1.102 +}; 1.103 + 1.104 +/* Legit userspace responses to a _PERM event */ 1.105 +#define FAN_ALLOW 0x01 1.106 +#define FAN_DENY 0x02 1.107 +/* No fd set in event */ 1.108 +#define FAN_NOFD -1 1.109 + 1.110 +/* Helper functions to deal with fanotify_event_metadata buffers */ 1.111 +#define FAN_EVENT_METADATA_LEN (sizeof(struct fanotify_event_metadata)) 1.112 + 1.113 +#define FAN_EVENT_NEXT(meta, len) ((len) -= (meta)->event_len, \ 1.114 + (struct fanotify_event_metadata*)(((char *)(meta)) + \ 1.115 + (meta)->event_len)) 1.116 + 1.117 +#define FAN_EVENT_OK(meta, len) ((long)(len) >= (long)FAN_EVENT_METADATA_LEN && \ 1.118 + (long)(meta)->event_len >= (long)FAN_EVENT_METADATA_LEN && \ 1.119 + (long)(meta)->event_len <= (long)(len)) 1.120 + 1.121 +#endif /* _LINUX_FANOTIFY_H */