Lines Matching +full:event +full:- +full:name

1 /* SPDX-License-Identifier: GPL-2.0 */
13 /* Possible states of the permission event */
39 /* Variable size struct for dir file handle + child file handle + name */
53 * name starts at buf[dir_fh_totlen + dir2_fh_totlen + file_fh_totlen]
56 #define FANOTIFY_DIR_FH_SIZE(info) ((info)->dir_fh_totlen)
57 #define FANOTIFY_DIR2_FH_SIZE(info) ((info)->dir2_fh_totlen)
58 #define FANOTIFY_FILE_FH_SIZE(info) ((info)->file_fh_totlen)
59 #define FANOTIFY_NAME_SIZE(info) ((info)->name_len + 1)
60 #define FANOTIFY_NAME2_SIZE(info) ((info)->name2_len + 1)
73 ((info)->buf + FANOTIFY_DIR_FH_OFFSET(info))
75 ((info)->buf + FANOTIFY_DIR2_FH_OFFSET(info))
77 ((info)->buf + FANOTIFY_FILE_FH_OFFSET(info))
79 ((info)->buf + FANOTIFY_NAME_OFFSET(info))
81 ((info)->buf + FANOTIFY_NAME2_OFFSET(info))
86 return (fh->flags & FANOTIFY_FH_FLAG_EXT_BUF); in fanotify_fh_has_ext_buf()
92 BUILD_BUG_ON(__alignof__(char *) - 4 + sizeof(char *) > in fanotify_fh_ext_buf_ptr()
94 return (char **)ALIGN((unsigned long)(fh->buf), __alignof__(char *)); in fanotify_fh_ext_buf_ptr()
104 return fanotify_fh_has_ext_buf(fh) ? fanotify_fh_ext_buf(fh) : fh->buf; in fanotify_fh_buf()
109 if (!info->dir_fh_totlen || in fanotify_info_dir_fh_len()
110 WARN_ON_ONCE(info->dir_fh_totlen < FANOTIFY_FH_HDR_LEN)) in fanotify_info_dir_fh_len()
113 return info->dir_fh_totlen - FANOTIFY_FH_HDR_LEN; in fanotify_info_dir_fh_len()
125 if (!info->dir2_fh_totlen || in fanotify_info_dir2_fh_len()
126 WARN_ON_ONCE(info->dir2_fh_totlen < FANOTIFY_FH_HDR_LEN)) in fanotify_info_dir2_fh_len()
129 return info->dir2_fh_totlen - FANOTIFY_FH_HDR_LEN; in fanotify_info_dir2_fh_len()
139 if (!info->file_fh_totlen || in fanotify_info_file_fh_len()
140 WARN_ON_ONCE(info->file_fh_totlen < FANOTIFY_FH_HDR_LEN)) in fanotify_info_file_fh_len()
143 return info->file_fh_totlen - FANOTIFY_FH_HDR_LEN; in fanotify_info_file_fh_len()
153 if (!info->name_len) in fanotify_info_name()
161 if (!info->name2_len) in fanotify_info_name2()
172 info->dir_fh_totlen = 0; in fanotify_info_init()
173 info->dir2_fh_totlen = 0; in fanotify_info_init()
174 info->file_fh_totlen = 0; in fanotify_info_init()
175 info->name_len = 0; in fanotify_info_init()
176 info->name2_len = 0; in fanotify_info_init()
183 if (WARN_ON_ONCE(info->dir2_fh_totlen > 0) || in fanotify_info_set_dir_fh()
184 WARN_ON_ONCE(info->file_fh_totlen > 0) || in fanotify_info_set_dir_fh()
185 WARN_ON_ONCE(info->name_len > 0) || in fanotify_info_set_dir_fh()
186 WARN_ON_ONCE(info->name2_len > 0)) in fanotify_info_set_dir_fh()
189 info->dir_fh_totlen = totlen; in fanotify_info_set_dir_fh()
195 if (WARN_ON_ONCE(info->file_fh_totlen > 0) || in fanotify_info_set_dir2_fh()
196 WARN_ON_ONCE(info->name_len > 0) || in fanotify_info_set_dir2_fh()
197 WARN_ON_ONCE(info->name2_len > 0)) in fanotify_info_set_dir2_fh()
200 info->dir2_fh_totlen = totlen; in fanotify_info_set_dir2_fh()
206 if (WARN_ON_ONCE(info->name_len > 0) || in fanotify_info_set_file_fh()
207 WARN_ON_ONCE(info->name2_len > 0)) in fanotify_info_set_file_fh()
210 info->file_fh_totlen = totlen; in fanotify_info_set_file_fh()
214 const struct qstr *name) in fanotify_info_copy_name() argument
216 if (WARN_ON_ONCE(name->len > NAME_MAX) || in fanotify_info_copy_name()
217 WARN_ON_ONCE(info->name2_len > 0)) in fanotify_info_copy_name()
220 info->name_len = name->len; in fanotify_info_copy_name()
221 strcpy(fanotify_info_name(info), name->name); in fanotify_info_copy_name()
225 const struct qstr *name) in fanotify_info_copy_name2() argument
227 if (WARN_ON_ONCE(name->len > NAME_MAX)) in fanotify_info_copy_name2()
230 info->name2_len = name->len; in fanotify_info_copy_name2()
231 strcpy(fanotify_info_name2(info), name->name); in fanotify_info_copy_name2()
237 * userspace. The type of event determines how it was allocated, how it will
251 (ilog2(__FANOTIFY_EVENT_TYPE_NUM - 1) + 1)
253 (32 - FANOTIFY_EVENT_TYPE_BITS)
266 static inline void fanotify_init_event(struct fanotify_event *event, in fanotify_init_event() argument
269 fsnotify_init_event(&event->fse); in fanotify_init_event()
270 INIT_HLIST_NODE(&event->merge_list); in fanotify_init_event()
271 event->hash = hash; in fanotify_init_event()
272 event->mask = mask; in fanotify_init_event()
273 event->pid = NULL; in fanotify_init_event()
276 #define FANOTIFY_INLINE_FH(name, size) \ argument
278 struct fanotify_fh (name); \
279 /* Space for object_fh.buf[] - access with fanotify_fh_buf() */ \
291 FANOTIFY_FE(struct fanotify_event *event) in FANOTIFY_FE() argument
293 return container_of(event, struct fanotify_fid_event, fae); in FANOTIFY_FE()
303 FANOTIFY_NE(struct fanotify_event *event) in FANOTIFY_NE() argument
305 return container_of(event, struct fanotify_name_event, fae); in FANOTIFY_NE()
319 FANOTIFY_EE(struct fanotify_event *event) in FANOTIFY_EE() argument
321 return container_of(event, struct fanotify_error_event, fae); in FANOTIFY_EE()
324 static inline __kernel_fsid_t *fanotify_event_fsid(struct fanotify_event *event) in fanotify_event_fsid() argument
326 if (event->type == FANOTIFY_EVENT_TYPE_FID) in fanotify_event_fsid()
327 return &FANOTIFY_FE(event)->fsid; in fanotify_event_fsid()
328 else if (event->type == FANOTIFY_EVENT_TYPE_FID_NAME) in fanotify_event_fsid()
329 return &FANOTIFY_NE(event)->fsid; in fanotify_event_fsid()
330 else if (event->type == FANOTIFY_EVENT_TYPE_FS_ERROR) in fanotify_event_fsid()
331 return &FANOTIFY_EE(event)->fsid; in fanotify_event_fsid()
337 struct fanotify_event *event) in fanotify_event_object_fh() argument
339 if (event->type == FANOTIFY_EVENT_TYPE_FID) in fanotify_event_object_fh()
340 return &FANOTIFY_FE(event)->object_fh; in fanotify_event_object_fh()
341 else if (event->type == FANOTIFY_EVENT_TYPE_FID_NAME) in fanotify_event_object_fh()
342 return fanotify_info_file_fh(&FANOTIFY_NE(event)->info); in fanotify_event_object_fh()
343 else if (event->type == FANOTIFY_EVENT_TYPE_FS_ERROR) in fanotify_event_object_fh()
344 return &FANOTIFY_EE(event)->object_fh; in fanotify_event_object_fh()
350 struct fanotify_event *event) in fanotify_event_info() argument
352 if (event->type == FANOTIFY_EVENT_TYPE_FID_NAME) in fanotify_event_info()
353 return &FANOTIFY_NE(event)->info; in fanotify_event_info()
358 static inline int fanotify_event_object_fh_len(struct fanotify_event *event) in fanotify_event_object_fh_len() argument
360 struct fanotify_info *info = fanotify_event_info(event); in fanotify_event_object_fh_len()
361 struct fanotify_fh *fh = fanotify_event_object_fh(event); in fanotify_event_object_fh_len()
364 return info->file_fh_totlen ? fh->len : 0; in fanotify_event_object_fh_len()
366 return fh ? fh->len : 0; in fanotify_event_object_fh_len()
369 static inline int fanotify_event_dir_fh_len(struct fanotify_event *event) in fanotify_event_dir_fh_len() argument
371 struct fanotify_info *info = fanotify_event_info(event); in fanotify_event_dir_fh_len()
376 static inline int fanotify_event_dir2_fh_len(struct fanotify_event *event) in fanotify_event_dir2_fh_len() argument
378 struct fanotify_info *info = fanotify_event_info(event); in fanotify_event_dir2_fh_len()
383 static inline bool fanotify_event_has_object_fh(struct fanotify_event *event) in fanotify_event_has_object_fh() argument
386 if (event->type == FANOTIFY_EVENT_TYPE_FS_ERROR) in fanotify_event_has_object_fh()
388 return fanotify_event_object_fh_len(event) > 0; in fanotify_event_has_object_fh()
391 static inline bool fanotify_event_has_dir_fh(struct fanotify_event *event) in fanotify_event_has_dir_fh() argument
393 return fanotify_event_dir_fh_len(event) > 0; in fanotify_event_has_dir_fh()
396 static inline bool fanotify_event_has_dir2_fh(struct fanotify_event *event) in fanotify_event_has_dir2_fh() argument
398 return fanotify_event_dir2_fh_len(event) > 0; in fanotify_event_has_dir2_fh()
401 static inline bool fanotify_event_has_any_dir_fh(struct fanotify_event *event) in fanotify_event_has_any_dir_fh() argument
403 return fanotify_event_has_dir_fh(event) || in fanotify_event_has_any_dir_fh()
404 fanotify_event_has_dir2_fh(event); in fanotify_event_has_any_dir_fh()
413 FANOTIFY_PE(struct fanotify_event *event) in FANOTIFY_PE() argument
415 return container_of(event, struct fanotify_path_event, fae); in FANOTIFY_PE()
422 * group->notification_list to group->fanotify_data.access_list to wait for
428 u32 response; /* userspace answer to the event */
429 unsigned short state; /* state of the event */
430 int fd; /* fd we passed to userspace for this event */
438 FANOTIFY_PERM(struct fanotify_event *event) in FANOTIFY_PERM() argument
440 return container_of(event, struct fanotify_perm_event, fae); in FANOTIFY_PERM()
459 static inline const struct path *fanotify_event_path(struct fanotify_event *event) in fanotify_event_path() argument
461 if (event->type == FANOTIFY_EVENT_TYPE_PATH) in fanotify_event_path()
462 return &FANOTIFY_PE(event)->path; in fanotify_event_path()
463 else if (event->type == FANOTIFY_EVENT_TYPE_PATH_PERM) in fanotify_event_path()
464 return &FANOTIFY_PERM(event)->path; in fanotify_event_path()
474 #define FANOTIFY_HTABLE_MASK (FANOTIFY_HTABLE_SIZE - 1)
477 * Permission events and overflow event do not get merged - don't hash them.
487 struct fanotify_event *event) in fanotify_event_hash_bucket() argument
489 return event->hash & FANOTIFY_HTABLE_MASK; in fanotify_event_hash_bucket()
496 if (mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY) in fanotify_mark_user_flags()
498 if (mark->flags & FSNOTIFY_MARK_FLAG_NO_IREF) in fanotify_mark_user_flags()
500 if (mark->flags & FSNOTIFY_MARK_FLAG_HAS_IGNORE_FLAGS) in fanotify_mark_user_flags()