hal/gonk/fanotify.h

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

michael@0 1 #ifndef _LINUX_FANOTIFY_H
michael@0 2 #define _LINUX_FANOTIFY_H
michael@0 3
michael@0 4 /* This is a Linux header generated by "make headers_install" */
michael@0 5
michael@0 6 #include <linux/types.h>
michael@0 7
michael@0 8 /* the following events that user-space can register for */
michael@0 9 #define FAN_ACCESS 0x00000001 /* File was accessed */
michael@0 10 #define FAN_MODIFY 0x00000002 /* File was modified */
michael@0 11 #define FAN_CLOSE_WRITE 0x00000008 /* Writtable file closed */
michael@0 12 #define FAN_CLOSE_NOWRITE 0x00000010 /* Unwrittable file closed */
michael@0 13 #define FAN_OPEN 0x00000020 /* File was opened */
michael@0 14
michael@0 15 #define FAN_Q_OVERFLOW 0x00004000 /* Event queued overflowed */
michael@0 16
michael@0 17 #define FAN_OPEN_PERM 0x00010000 /* File open in perm check */
michael@0 18 #define FAN_ACCESS_PERM 0x00020000 /* File accessed in perm check */
michael@0 19
michael@0 20 #define FAN_ONDIR 0x40000000 /* event occurred against dir */
michael@0 21
michael@0 22 #define FAN_EVENT_ON_CHILD 0x08000000 /* interested in child events */
michael@0 23
michael@0 24 /* helper events */
michael@0 25 #define FAN_CLOSE (FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE) /* close */
michael@0 26
michael@0 27 /* flags used for fanotify_init() */
michael@0 28 #define FAN_CLOEXEC 0x00000001
michael@0 29 #define FAN_NONBLOCK 0x00000002
michael@0 30
michael@0 31 /* These are NOT bitwise flags. Both bits are used togther. */
michael@0 32 #define FAN_CLASS_NOTIF 0x00000000
michael@0 33 #define FAN_CLASS_CONTENT 0x00000004
michael@0 34 #define FAN_CLASS_PRE_CONTENT 0x00000008
michael@0 35 #define FAN_ALL_CLASS_BITS (FAN_CLASS_NOTIF | FAN_CLASS_CONTENT | \
michael@0 36 FAN_CLASS_PRE_CONTENT)
michael@0 37
michael@0 38 #define FAN_UNLIMITED_QUEUE 0x00000010
michael@0 39 #define FAN_UNLIMITED_MARKS 0x00000020
michael@0 40
michael@0 41 #define FAN_ALL_INIT_FLAGS (FAN_CLOEXEC | FAN_NONBLOCK | \
michael@0 42 FAN_ALL_CLASS_BITS | FAN_UNLIMITED_QUEUE |\
michael@0 43 FAN_UNLIMITED_MARKS)
michael@0 44
michael@0 45 /* flags used for fanotify_modify_mark() */
michael@0 46 #define FAN_MARK_ADD 0x00000001
michael@0 47 #define FAN_MARK_REMOVE 0x00000002
michael@0 48 #define FAN_MARK_DONT_FOLLOW 0x00000004
michael@0 49 #define FAN_MARK_ONLYDIR 0x00000008
michael@0 50 #define FAN_MARK_MOUNT 0x00000010
michael@0 51 #define FAN_MARK_IGNORED_MASK 0x00000020
michael@0 52 #define FAN_MARK_IGNORED_SURV_MODIFY 0x00000040
michael@0 53 #define FAN_MARK_FLUSH 0x00000080
michael@0 54
michael@0 55 #define FAN_ALL_MARK_FLAGS (FAN_MARK_ADD |\
michael@0 56 FAN_MARK_REMOVE |\
michael@0 57 FAN_MARK_DONT_FOLLOW |\
michael@0 58 FAN_MARK_ONLYDIR |\
michael@0 59 FAN_MARK_MOUNT |\
michael@0 60 FAN_MARK_IGNORED_MASK |\
michael@0 61 FAN_MARK_IGNORED_SURV_MODIFY |\
michael@0 62 FAN_MARK_FLUSH)
michael@0 63
michael@0 64 /*
michael@0 65 * All of the events - we build the list by hand so that we can add flags in
michael@0 66 * the future and not break backward compatibility. Apps will get only the
michael@0 67 * events that they originally wanted. Be sure to add new events here!
michael@0 68 */
michael@0 69 #define FAN_ALL_EVENTS (FAN_ACCESS |\
michael@0 70 FAN_MODIFY |\
michael@0 71 FAN_CLOSE |\
michael@0 72 FAN_OPEN)
michael@0 73
michael@0 74 /*
michael@0 75 * All events which require a permission response from userspace
michael@0 76 */
michael@0 77 #define FAN_ALL_PERM_EVENTS (FAN_OPEN_PERM |\
michael@0 78 FAN_ACCESS_PERM)
michael@0 79
michael@0 80 #define FAN_ALL_OUTGOING_EVENTS (FAN_ALL_EVENTS |\
michael@0 81 FAN_ALL_PERM_EVENTS |\
michael@0 82 FAN_Q_OVERFLOW)
michael@0 83
michael@0 84 #define FANOTIFY_METADATA_VERSION 3
michael@0 85
michael@0 86 struct fanotify_event_metadata {
michael@0 87 __u32 event_len;
michael@0 88 __u8 vers;
michael@0 89 __u8 reserved;
michael@0 90 __u16 metadata_len;
michael@0 91 __u64 mask;
michael@0 92 __s32 fd;
michael@0 93 __s32 pid;
michael@0 94 };
michael@0 95
michael@0 96 struct fanotify_response {
michael@0 97 __s32 fd;
michael@0 98 __u32 response;
michael@0 99 };
michael@0 100
michael@0 101 /* Legit userspace responses to a _PERM event */
michael@0 102 #define FAN_ALLOW 0x01
michael@0 103 #define FAN_DENY 0x02
michael@0 104 /* No fd set in event */
michael@0 105 #define FAN_NOFD -1
michael@0 106
michael@0 107 /* Helper functions to deal with fanotify_event_metadata buffers */
michael@0 108 #define FAN_EVENT_METADATA_LEN (sizeof(struct fanotify_event_metadata))
michael@0 109
michael@0 110 #define FAN_EVENT_NEXT(meta, len) ((len) -= (meta)->event_len, \
michael@0 111 (struct fanotify_event_metadata*)(((char *)(meta)) + \
michael@0 112 (meta)->event_len))
michael@0 113
michael@0 114 #define FAN_EVENT_OK(meta, len) ((long)(len) >= (long)FAN_EVENT_METADATA_LEN && \
michael@0 115 (long)(meta)->event_len >= (long)FAN_EVENT_METADATA_LEN && \
michael@0 116 (long)(meta)->event_len <= (long)(len))
michael@0 117
michael@0 118 #endif /* _LINUX_FANOTIFY_H */

mercurial