| .. | .. |
|---|
| 7 | 7 | /* the following events that user-space can register for */ |
|---|
| 8 | 8 | #define FAN_ACCESS 0x00000001 /* File was accessed */ |
|---|
| 9 | 9 | #define FAN_MODIFY 0x00000002 /* File was modified */ |
|---|
| 10 | +#define FAN_ATTRIB 0x00000004 /* Metadata changed */ |
|---|
| 10 | 11 | #define FAN_CLOSE_WRITE 0x00000008 /* Writtable file closed */ |
|---|
| 11 | 12 | #define FAN_CLOSE_NOWRITE 0x00000010 /* Unwrittable file closed */ |
|---|
| 12 | 13 | #define FAN_OPEN 0x00000020 /* File was opened */ |
|---|
| 14 | +#define FAN_MOVED_FROM 0x00000040 /* File was moved from X */ |
|---|
| 15 | +#define FAN_MOVED_TO 0x00000080 /* File was moved to Y */ |
|---|
| 16 | +#define FAN_CREATE 0x00000100 /* Subfile was created */ |
|---|
| 17 | +#define FAN_DELETE 0x00000200 /* Subfile was deleted */ |
|---|
| 18 | +#define FAN_DELETE_SELF 0x00000400 /* Self was deleted */ |
|---|
| 19 | +#define FAN_MOVE_SELF 0x00000800 /* Self was moved */ |
|---|
| 20 | +#define FAN_OPEN_EXEC 0x00001000 /* File was opened for exec */ |
|---|
| 13 | 21 | |
|---|
| 14 | 22 | #define FAN_Q_OVERFLOW 0x00004000 /* Event queued overflowed */ |
|---|
| 15 | 23 | |
|---|
| 16 | 24 | #define FAN_OPEN_PERM 0x00010000 /* File open in perm check */ |
|---|
| 17 | 25 | #define FAN_ACCESS_PERM 0x00020000 /* File accessed in perm check */ |
|---|
| 26 | +#define FAN_OPEN_EXEC_PERM 0x00040000 /* File open/exec in perm check */ |
|---|
| 18 | 27 | |
|---|
| 19 | | -#define FAN_ONDIR 0x40000000 /* event occurred against dir */ |
|---|
| 28 | +#define FAN_EVENT_ON_CHILD 0x08000000 /* Interested in child events */ |
|---|
| 20 | 29 | |
|---|
| 21 | | -#define FAN_EVENT_ON_CHILD 0x08000000 /* interested in child events */ |
|---|
| 30 | +#define FAN_ONDIR 0x40000000 /* Event occurred against dir */ |
|---|
| 22 | 31 | |
|---|
| 23 | 32 | /* helper events */ |
|---|
| 24 | 33 | #define FAN_CLOSE (FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE) /* close */ |
|---|
| 34 | +#define FAN_MOVE (FAN_MOVED_FROM | FAN_MOVED_TO) /* moves */ |
|---|
| 25 | 35 | |
|---|
| 26 | 36 | /* flags used for fanotify_init() */ |
|---|
| 27 | 37 | #define FAN_CLOEXEC 0x00000001 |
|---|
| 28 | 38 | #define FAN_NONBLOCK 0x00000002 |
|---|
| 29 | 39 | |
|---|
| 30 | | -/* These are NOT bitwise flags. Both bits are used togther. */ |
|---|
| 40 | +/* These are NOT bitwise flags. Both bits are used together. */ |
|---|
| 31 | 41 | #define FAN_CLASS_NOTIF 0x00000000 |
|---|
| 32 | 42 | #define FAN_CLASS_CONTENT 0x00000004 |
|---|
| 33 | 43 | #define FAN_CLASS_PRE_CONTENT 0x00000008 |
|---|
| 44 | + |
|---|
| 45 | +/* Deprecated - do not use this in programs and do not add new flags here! */ |
|---|
| 34 | 46 | #define FAN_ALL_CLASS_BITS (FAN_CLASS_NOTIF | FAN_CLASS_CONTENT | \ |
|---|
| 35 | 47 | FAN_CLASS_PRE_CONTENT) |
|---|
| 36 | 48 | |
|---|
| .. | .. |
|---|
| 38 | 50 | #define FAN_UNLIMITED_MARKS 0x00000020 |
|---|
| 39 | 51 | #define FAN_ENABLE_AUDIT 0x00000040 |
|---|
| 40 | 52 | |
|---|
| 53 | +/* Flags to determine fanotify event format */ |
|---|
| 54 | +#define FAN_REPORT_TID 0x00000100 /* event->pid is thread id */ |
|---|
| 55 | +#define FAN_REPORT_FID 0x00000200 /* Report unique file id */ |
|---|
| 56 | +#define FAN_REPORT_DIR_FID 0x00000400 /* Report unique directory id */ |
|---|
| 57 | +#define FAN_REPORT_NAME 0x00000800 /* Report events with name */ |
|---|
| 58 | + |
|---|
| 59 | +/* Convenience macro - FAN_REPORT_NAME requires FAN_REPORT_DIR_FID */ |
|---|
| 60 | +#define FAN_REPORT_DFID_NAME (FAN_REPORT_DIR_FID | FAN_REPORT_NAME) |
|---|
| 61 | + |
|---|
| 62 | +/* Deprecated - do not use this in programs and do not add new flags here! */ |
|---|
| 41 | 63 | #define FAN_ALL_INIT_FLAGS (FAN_CLOEXEC | FAN_NONBLOCK | \ |
|---|
| 42 | 64 | FAN_ALL_CLASS_BITS | FAN_UNLIMITED_QUEUE |\ |
|---|
| 43 | 65 | FAN_UNLIMITED_MARKS) |
|---|
| .. | .. |
|---|
| 47 | 69 | #define FAN_MARK_REMOVE 0x00000002 |
|---|
| 48 | 70 | #define FAN_MARK_DONT_FOLLOW 0x00000004 |
|---|
| 49 | 71 | #define FAN_MARK_ONLYDIR 0x00000008 |
|---|
| 50 | | -#define FAN_MARK_MOUNT 0x00000010 |
|---|
| 72 | +/* FAN_MARK_MOUNT is 0x00000010 */ |
|---|
| 51 | 73 | #define FAN_MARK_IGNORED_MASK 0x00000020 |
|---|
| 52 | 74 | #define FAN_MARK_IGNORED_SURV_MODIFY 0x00000040 |
|---|
| 53 | 75 | #define FAN_MARK_FLUSH 0x00000080 |
|---|
| 76 | +/* FAN_MARK_FILESYSTEM is 0x00000100 */ |
|---|
| 54 | 77 | |
|---|
| 78 | +/* These are NOT bitwise flags. Both bits can be used togther. */ |
|---|
| 79 | +#define FAN_MARK_INODE 0x00000000 |
|---|
| 80 | +#define FAN_MARK_MOUNT 0x00000010 |
|---|
| 81 | +#define FAN_MARK_FILESYSTEM 0x00000100 |
|---|
| 82 | + |
|---|
| 83 | +/* Deprecated - do not use this in programs and do not add new flags here! */ |
|---|
| 55 | 84 | #define FAN_ALL_MARK_FLAGS (FAN_MARK_ADD |\ |
|---|
| 56 | 85 | FAN_MARK_REMOVE |\ |
|---|
| 57 | 86 | FAN_MARK_DONT_FOLLOW |\ |
|---|
| .. | .. |
|---|
| 61 | 90 | FAN_MARK_IGNORED_SURV_MODIFY |\ |
|---|
| 62 | 91 | FAN_MARK_FLUSH) |
|---|
| 63 | 92 | |
|---|
| 64 | | -/* |
|---|
| 65 | | - * All of the events - we build the list by hand so that we can add flags in |
|---|
| 66 | | - * the future and not break backward compatibility. Apps will get only the |
|---|
| 67 | | - * events that they originally wanted. Be sure to add new events here! |
|---|
| 68 | | - */ |
|---|
| 93 | +/* Deprecated - do not use this in programs and do not add new flags here! */ |
|---|
| 69 | 94 | #define FAN_ALL_EVENTS (FAN_ACCESS |\ |
|---|
| 70 | 95 | FAN_MODIFY |\ |
|---|
| 71 | 96 | FAN_CLOSE |\ |
|---|
| .. | .. |
|---|
| 74 | 99 | /* |
|---|
| 75 | 100 | * All events which require a permission response from userspace |
|---|
| 76 | 101 | */ |
|---|
| 102 | +/* Deprecated - do not use this in programs and do not add new flags here! */ |
|---|
| 77 | 103 | #define FAN_ALL_PERM_EVENTS (FAN_OPEN_PERM |\ |
|---|
| 78 | 104 | FAN_ACCESS_PERM) |
|---|
| 79 | 105 | |
|---|
| 106 | +/* Deprecated - do not use this in programs and do not add new flags here! */ |
|---|
| 80 | 107 | #define FAN_ALL_OUTGOING_EVENTS (FAN_ALL_EVENTS |\ |
|---|
| 81 | 108 | FAN_ALL_PERM_EVENTS |\ |
|---|
| 82 | 109 | FAN_Q_OVERFLOW) |
|---|
| .. | .. |
|---|
| 93 | 120 | __s32 pid; |
|---|
| 94 | 121 | }; |
|---|
| 95 | 122 | |
|---|
| 123 | +#define FAN_EVENT_INFO_TYPE_FID 1 |
|---|
| 124 | +#define FAN_EVENT_INFO_TYPE_DFID_NAME 2 |
|---|
| 125 | +#define FAN_EVENT_INFO_TYPE_DFID 3 |
|---|
| 126 | + |
|---|
| 127 | +/* Variable length info record following event metadata */ |
|---|
| 128 | +struct fanotify_event_info_header { |
|---|
| 129 | + __u8 info_type; |
|---|
| 130 | + __u8 pad; |
|---|
| 131 | + __u16 len; |
|---|
| 132 | +}; |
|---|
| 133 | + |
|---|
| 134 | +/* |
|---|
| 135 | + * Unique file identifier info record. |
|---|
| 136 | + * This structure is used for records of types FAN_EVENT_INFO_TYPE_FID, |
|---|
| 137 | + * FAN_EVENT_INFO_TYPE_DFID and FAN_EVENT_INFO_TYPE_DFID_NAME. |
|---|
| 138 | + * For FAN_EVENT_INFO_TYPE_DFID_NAME there is additionally a null terminated |
|---|
| 139 | + * name immediately after the file handle. |
|---|
| 140 | + */ |
|---|
| 141 | +struct fanotify_event_info_fid { |
|---|
| 142 | + struct fanotify_event_info_header hdr; |
|---|
| 143 | + __kernel_fsid_t fsid; |
|---|
| 144 | + /* |
|---|
| 145 | + * Following is an opaque struct file_handle that can be passed as |
|---|
| 146 | + * an argument to open_by_handle_at(2). |
|---|
| 147 | + */ |
|---|
| 148 | + unsigned char handle[0]; |
|---|
| 149 | +}; |
|---|
| 150 | + |
|---|
| 96 | 151 | struct fanotify_response { |
|---|
| 97 | 152 | __s32 fd; |
|---|
| 98 | 153 | __u32 response; |
|---|