This source file includes following definitions.
- fanotify_fid_fh
- fanotify_fid_equal
- fanotify_event_has_path
- fanotify_event_has_fid
- fanotify_event_has_ext_fh
- fanotify_event_fh
- FANOTIFY_PE
- fanotify_is_perm_event
- FANOTIFY_E
1
2 #include <linux/fsnotify_backend.h>
3 #include <linux/path.h>
4 #include <linux/slab.h>
5 #include <linux/exportfs.h>
6
7 extern struct kmem_cache *fanotify_mark_cache;
8 extern struct kmem_cache *fanotify_event_cachep;
9 extern struct kmem_cache *fanotify_perm_event_cachep;
10
11
12 enum {
13 FAN_EVENT_INIT,
14 FAN_EVENT_REPORTED,
15 FAN_EVENT_ANSWERED,
16 FAN_EVENT_CANCELED,
17 };
18
19
20
21
22
23
24
25
26 #if BITS_PER_LONG == 32
27 #define FANOTIFY_INLINE_FH_LEN (3 << 2)
28 #else
29 #define FANOTIFY_INLINE_FH_LEN (4 << 2)
30 #endif
31
32 struct fanotify_fid {
33 __kernel_fsid_t fsid;
34 union {
35 unsigned char fh[FANOTIFY_INLINE_FH_LEN];
36 unsigned char *ext_fh;
37 };
38 };
39
40 static inline void *fanotify_fid_fh(struct fanotify_fid *fid,
41 unsigned int fh_len)
42 {
43 return fh_len <= FANOTIFY_INLINE_FH_LEN ? fid->fh : fid->ext_fh;
44 }
45
46 static inline bool fanotify_fid_equal(struct fanotify_fid *fid1,
47 struct fanotify_fid *fid2,
48 unsigned int fh_len)
49 {
50 return fid1->fsid.val[0] == fid2->fsid.val[0] &&
51 fid1->fsid.val[1] == fid2->fsid.val[1] &&
52 !memcmp(fanotify_fid_fh(fid1, fh_len),
53 fanotify_fid_fh(fid2, fh_len), fh_len);
54 }
55
56
57
58
59
60
61 struct fanotify_event {
62 struct fsnotify_event fse;
63 u32 mask;
64
65
66
67
68
69
70 u8 fh_type;
71 u8 fh_len;
72 u16 pad;
73 union {
74
75
76
77
78 struct path path;
79
80
81
82
83
84 struct fanotify_fid fid;
85 };
86 struct pid *pid;
87 };
88
89 static inline bool fanotify_event_has_path(struct fanotify_event *event)
90 {
91 return event->fh_type == FILEID_ROOT;
92 }
93
94 static inline bool fanotify_event_has_fid(struct fanotify_event *event)
95 {
96 return event->fh_type != FILEID_ROOT &&
97 event->fh_type != FILEID_INVALID;
98 }
99
100 static inline bool fanotify_event_has_ext_fh(struct fanotify_event *event)
101 {
102 return fanotify_event_has_fid(event) &&
103 event->fh_len > FANOTIFY_INLINE_FH_LEN;
104 }
105
106 static inline void *fanotify_event_fh(struct fanotify_event *event)
107 {
108 return fanotify_fid_fh(&event->fid, event->fh_len);
109 }
110
111
112
113
114
115
116
117
118 struct fanotify_perm_event {
119 struct fanotify_event fae;
120 unsigned short response;
121 unsigned short state;
122 int fd;
123 };
124
125 static inline struct fanotify_perm_event *
126 FANOTIFY_PE(struct fsnotify_event *fse)
127 {
128 return container_of(fse, struct fanotify_perm_event, fae.fse);
129 }
130
131 static inline bool fanotify_is_perm_event(u32 mask)
132 {
133 return IS_ENABLED(CONFIG_FANOTIFY_ACCESS_PERMISSIONS) &&
134 mask & FANOTIFY_PERM_EVENTS;
135 }
136
137 static inline struct fanotify_event *FANOTIFY_E(struct fsnotify_event *fse)
138 {
139 return container_of(fse, struct fanotify_event, fse);
140 }
141
142 struct fanotify_event *fanotify_alloc_event(struct fsnotify_group *group,
143 struct inode *inode, u32 mask,
144 const void *data, int data_type,
145 __kernel_fsid_t *fsid);