Dr Andrew Scott G7VAV

My photo
 
June 2025
Mo Tu We Th Fr Sa Su
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 1 2 3 4 5 6


fanotify.h
001: #ifndef _LINUX_FANOTIFY_H
002: #define _LINUX_FANOTIFY_H
003: 
004: #include <linux/types.h>
005: 
006: /* the following events that user-space can register for */
007: #define FAN_ACCESS              0x00000001      /* File was accessed */
008: #define FAN_MODIFY              0x00000002      /* File was modified */
009: #define FAN_CLOSE_WRITE         0x00000008      /* Writtable file closed */
010: #define FAN_CLOSE_NOWRITE       0x00000010      /* Unwrittable file closed */
011: #define FAN_OPEN                0x00000020      /* File was opened */
012: 
013: #define FAN_Q_OVERFLOW          0x00004000      /* Event queued overflowed */
014: 
015: #define FAN_OPEN_PERM           0x00010000      /* File open in perm check */
016: #define FAN_ACCESS_PERM         0x00020000      /* File accessed in perm check */
017: 
018: #define FAN_ONDIR               0x40000000      /* event occurred against dir */
019: 
020: #define FAN_EVENT_ON_CHILD      0x08000000      /* interested in child events */
021: 
022: /* helper events */
023: #define FAN_CLOSE               (FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE) /* close */
024: 
025: /* flags used for fanotify_init() */
026: #define FAN_CLOEXEC             0x00000001
027: #define FAN_NONBLOCK            0x00000002
028: 
029: /* These are NOT bitwise flags.  Both bits are used togther.  */
030: #define FAN_CLASS_NOTIF         0x00000000
031: #define FAN_CLASS_CONTENT       0x00000004
032: #define FAN_CLASS_PRE_CONTENT   0x00000008
033: #define FAN_ALL_CLASS_BITS      (FAN_CLASS_NOTIF | FAN_CLASS_CONTENT | \
034:                                  FAN_CLASS_PRE_CONTENT)
035: 
036: #define FAN_UNLIMITED_QUEUE     0x00000010
037: #define FAN_UNLIMITED_MARKS     0x00000020
038: 
039: #define FAN_ALL_INIT_FLAGS      (FAN_CLOEXEC | FAN_NONBLOCK | \
040:                                  FAN_ALL_CLASS_BITS | FAN_UNLIMITED_QUEUE |\
041:                                  FAN_UNLIMITED_MARKS)
042: 
043: /* flags used for fanotify_modify_mark() */
044: #define FAN_MARK_ADD            0x00000001
045: #define FAN_MARK_REMOVE         0x00000002
046: #define FAN_MARK_DONT_FOLLOW    0x00000004
047: #define FAN_MARK_ONLYDIR        0x00000008
048: #define FAN_MARK_MOUNT          0x00000010
049: #define FAN_MARK_IGNORED_MASK   0x00000020
050: #define FAN_MARK_IGNORED_SURV_MODIFY    0x00000040
051: #define FAN_MARK_FLUSH          0x00000080
052: 
053: #define FAN_ALL_MARK_FLAGS      (FAN_MARK_ADD |\
054:                                  FAN_MARK_REMOVE |\
055:                                  FAN_MARK_DONT_FOLLOW |\
056:                                  FAN_MARK_ONLYDIR |\
057:                                  FAN_MARK_MOUNT |\
058:                                  FAN_MARK_IGNORED_MASK |\
059:                                  FAN_MARK_IGNORED_SURV_MODIFY |\
060:                                  FAN_MARK_FLUSH)
061: 
062: /*
063:  * All of the events - we build the list by hand so that we can add flags in
064:  * the future and not break backward compatibility.  Apps will get only the
065:  * events that they originally wanted.  Be sure to add new events here!
066:  */
067: #define FAN_ALL_EVENTS (FAN_ACCESS |\
068:                         FAN_MODIFY |\
069:                         FAN_CLOSE |\
070:                         FAN_OPEN)
071: 
072: /*
073:  * All events which require a permission response from userspace
074:  */
075: #define FAN_ALL_PERM_EVENTS (FAN_OPEN_PERM |\
076:                              FAN_ACCESS_PERM)
077: 
078: #define FAN_ALL_OUTGOING_EVENTS (FAN_ALL_EVENTS |\
079:                                  FAN_ALL_PERM_EVENTS |\
080:                                  FAN_Q_OVERFLOW)
081: 
082: #define FANOTIFY_METADATA_VERSION       3
083: 
084: struct fanotify_event_metadata {
085:         __u32 event_len;
086:         __u8 vers;
087:         __u8 reserved;
088:         __u16 metadata_len;
089:         __aligned_u64 mask;
090:         __s32 fd;
091:         __s32 pid;
092: };
093: 
094: struct fanotify_response {
095:         __s32 fd;
096:         __u32 response;
097: };
098: 
099: /* Legit userspace responses to a _PERM event */
100: #define FAN_ALLOW       0x01
101: #define FAN_DENY        0x02
102: /* No fd set in event */
103: #define FAN_NOFD        -1
104: 
105: /* Helper functions to deal with fanotify_event_metadata buffers */
106: #define FAN_EVENT_METADATA_LEN (sizeof(struct fanotify_event_metadata))
107: 
108: #define FAN_EVENT_NEXT(meta, len) ((len) -= (meta)->event_len, \
109:                                    (struct fanotify_event_metadata*)(((char *)(meta)) + \
110:                                    (meta)->event_len))
111: 
112: #define FAN_EVENT_OK(meta, len) ((long)(len) >= (long)FAN_EVENT_METADATA_LEN && \
113:                                 (long)(meta)->event_len >= (long)FAN_EVENT_METADATA_LEN && \
114:                                 (long)(meta)->event_len <= (long)(len))
115: 
116: #endif /* _LINUX_FANOTIFY_H */
117: 


for client (none)
© Andrew Scott 2006 - 2025,
All Rights Reserved
http://www.andrew-scott.uk/
Andrew Scott
http://www.andrew-scott.co.uk/