Lines Matching refs:group

54 static struct fsnotify_event *get_one_event(struct fsnotify_group *group,  in get_one_event()  argument
57 BUG_ON(!mutex_is_locked(&group->notification_mutex)); in get_one_event()
59 pr_debug("%s: group=%p count=%zd\n", __func__, group, count); in get_one_event()
61 if (fsnotify_notify_queue_is_empty(group)) in get_one_event()
69 return fsnotify_remove_first_event(group); in get_one_event()
72 static int create_fd(struct fsnotify_group *group, in create_fd() argument
79 pr_debug("%s: group=%p event=%p\n", __func__, group, event); in create_fd()
81 client_fd = get_unused_fd_flags(group->fanotify_data.f_flags); in create_fd()
93 group->fanotify_data.f_flags | FMODE_NONOTIFY, in create_fd()
114 static int fill_event_metadata(struct fsnotify_group *group, in fill_event_metadata() argument
123 group, metadata, fsn_event); in fill_event_metadata()
136 metadata->fd = create_fd(group, event, file); in fill_event_metadata()
146 struct fsnotify_group *group, int fd) in dequeue_event() argument
150 spin_lock(&group->fanotify_data.access_lock); in dequeue_event()
151 list_for_each_entry(event, &group->fanotify_data.access_list, in dequeue_event()
160 spin_unlock(&group->fanotify_data.access_lock); in dequeue_event()
167 static int process_access_response(struct fsnotify_group *group, in process_access_response() argument
174 pr_debug("%s: group=%p fd=%d response=%d\n", __func__, group, in process_access_response()
192 event = dequeue_event(group, fd); in process_access_response()
197 wake_up(&group->fanotify_data.access_waitq); in process_access_response()
203 static ssize_t copy_event_to_user(struct fsnotify_group *group, in copy_event_to_user() argument
211 pr_debug("%s: group=%p event=%p\n", __func__, group, event); in copy_event_to_user()
213 ret = fill_event_metadata(group, &fanotify_event_metadata, event, &f); in copy_event_to_user()
243 struct fsnotify_group *group = file->private_data; in fanotify_poll() local
246 poll_wait(file, &group->notification_waitq, wait); in fanotify_poll()
247 mutex_lock(&group->notification_mutex); in fanotify_poll()
248 if (!fsnotify_notify_queue_is_empty(group)) in fanotify_poll()
250 mutex_unlock(&group->notification_mutex); in fanotify_poll()
258 struct fsnotify_group *group; in fanotify_read() local
265 group = file->private_data; in fanotify_read()
267 pr_debug("%s: group=%p\n", __func__, group); in fanotify_read()
269 add_wait_queue(&group->notification_waitq, &wait); in fanotify_read()
271 mutex_lock(&group->notification_mutex); in fanotify_read()
272 kevent = get_one_event(group, count); in fanotify_read()
273 mutex_unlock(&group->notification_mutex); in fanotify_read()
296 ret = copy_event_to_user(group, kevent, buf); in fanotify_read()
302 fsnotify_destroy_event(group, kevent); in fanotify_read()
309 wake_up(&group->fanotify_data.access_waitq); in fanotify_read()
312 spin_lock(&group->fanotify_data.access_lock); in fanotify_read()
314 &group->fanotify_data.access_list); in fanotify_read()
315 spin_unlock(&group->fanotify_data.access_lock); in fanotify_read()
321 remove_wait_queue(&group->notification_waitq, &wait); in fanotify_read()
332 struct fsnotify_group *group; in fanotify_write() local
335 group = file->private_data; in fanotify_write()
340 pr_debug("%s: group=%p count=%zu\n", __func__, group, count); in fanotify_write()
345 ret = process_access_response(group, &response); in fanotify_write()
357 struct fsnotify_group *group = file->private_data; in fanotify_release() local
367 spin_lock(&group->fanotify_data.access_lock); in fanotify_release()
369 atomic_inc(&group->fanotify_data.bypass_perm); in fanotify_release()
371 list_for_each_entry_safe(event, next, &group->fanotify_data.access_list, in fanotify_release()
373 pr_debug("%s: found group=%p event=%p\n", __func__, group, in fanotify_release()
379 spin_unlock(&group->fanotify_data.access_lock); in fanotify_release()
388 wake_up(&group->fanotify_data.access_waitq); in fanotify_release()
392 fsnotify_destroy_group(group); in fanotify_release()
399 struct fsnotify_group *group; in fanotify_ioctl() local
405 group = file->private_data; in fanotify_ioctl()
411 mutex_lock(&group->notification_mutex); in fanotify_ioctl()
412 list_for_each_entry(fsn_event, &group->notification_list, list) in fanotify_ioctl()
414 mutex_unlock(&group->notification_mutex); in fanotify_ioctl()
514 static int fanotify_remove_vfsmount_mark(struct fsnotify_group *group, in fanotify_remove_vfsmount_mark() argument
522 mutex_lock(&group->mark_mutex); in fanotify_remove_vfsmount_mark()
523 fsn_mark = fsnotify_find_vfsmount_mark(group, mnt); in fanotify_remove_vfsmount_mark()
525 mutex_unlock(&group->mark_mutex); in fanotify_remove_vfsmount_mark()
532 fsnotify_destroy_mark_locked(fsn_mark, group); in fanotify_remove_vfsmount_mark()
533 mutex_unlock(&group->mark_mutex); in fanotify_remove_vfsmount_mark()
542 static int fanotify_remove_inode_mark(struct fsnotify_group *group, in fanotify_remove_inode_mark() argument
550 mutex_lock(&group->mark_mutex); in fanotify_remove_inode_mark()
551 fsn_mark = fsnotify_find_inode_mark(group, inode); in fanotify_remove_inode_mark()
553 mutex_unlock(&group->mark_mutex); in fanotify_remove_inode_mark()
560 fsnotify_destroy_mark_locked(fsn_mark, group); in fanotify_remove_inode_mark()
561 mutex_unlock(&group->mark_mutex); in fanotify_remove_inode_mark()
600 static struct fsnotify_mark *fanotify_add_new_mark(struct fsnotify_group *group, in fanotify_add_new_mark() argument
607 if (atomic_read(&group->num_marks) > group->fanotify_data.max_marks) in fanotify_add_new_mark()
615 ret = fsnotify_add_mark_locked(mark, group, inode, mnt, 0); in fanotify_add_new_mark()
625 static int fanotify_add_vfsmount_mark(struct fsnotify_group *group, in fanotify_add_vfsmount_mark() argument
632 mutex_lock(&group->mark_mutex); in fanotify_add_vfsmount_mark()
633 fsn_mark = fsnotify_find_vfsmount_mark(group, mnt); in fanotify_add_vfsmount_mark()
635 fsn_mark = fanotify_add_new_mark(group, NULL, mnt); in fanotify_add_vfsmount_mark()
637 mutex_unlock(&group->mark_mutex); in fanotify_add_vfsmount_mark()
642 mutex_unlock(&group->mark_mutex); in fanotify_add_vfsmount_mark()
651 static int fanotify_add_inode_mark(struct fsnotify_group *group, in fanotify_add_inode_mark() argument
658 pr_debug("%s: group=%p inode=%p\n", __func__, group, inode); in fanotify_add_inode_mark()
670 mutex_lock(&group->mark_mutex); in fanotify_add_inode_mark()
671 fsn_mark = fsnotify_find_inode_mark(group, inode); in fanotify_add_inode_mark()
673 fsn_mark = fanotify_add_new_mark(group, inode, NULL); in fanotify_add_inode_mark()
675 mutex_unlock(&group->mark_mutex); in fanotify_add_inode_mark()
680 mutex_unlock(&group->mark_mutex); in fanotify_add_inode_mark()
692 struct fsnotify_group *group; in SYSCALL_DEFINE2() local
731 group = fsnotify_alloc_group(&fanotify_fsnotify_ops); in SYSCALL_DEFINE2()
732 if (IS_ERR(group)) { in SYSCALL_DEFINE2()
734 return PTR_ERR(group); in SYSCALL_DEFINE2()
737 group->fanotify_data.user = user; in SYSCALL_DEFINE2()
745 group->overflow_event = &oevent->fse; in SYSCALL_DEFINE2()
749 group->fanotify_data.f_flags = event_f_flags; in SYSCALL_DEFINE2()
751 spin_lock_init(&group->fanotify_data.access_lock); in SYSCALL_DEFINE2()
752 init_waitqueue_head(&group->fanotify_data.access_waitq); in SYSCALL_DEFINE2()
753 INIT_LIST_HEAD(&group->fanotify_data.access_list); in SYSCALL_DEFINE2()
754 atomic_set(&group->fanotify_data.bypass_perm, 0); in SYSCALL_DEFINE2()
758 group->priority = FS_PRIO_0; in SYSCALL_DEFINE2()
761 group->priority = FS_PRIO_1; in SYSCALL_DEFINE2()
764 group->priority = FS_PRIO_2; in SYSCALL_DEFINE2()
775 group->max_events = UINT_MAX; in SYSCALL_DEFINE2()
777 group->max_events = FANOTIFY_DEFAULT_MAX_EVENTS; in SYSCALL_DEFINE2()
784 group->fanotify_data.max_marks = UINT_MAX; in SYSCALL_DEFINE2()
786 group->fanotify_data.max_marks = FANOTIFY_DEFAULT_MAX_MARKS; in SYSCALL_DEFINE2()
789 fd = anon_inode_getfd("[fanotify]", &fanotify_fops, group, f_flags); in SYSCALL_DEFINE2()
796 fsnotify_destroy_group(group); in SYSCALL_DEFINE2()
806 struct fsnotify_group *group; in SYSCALL_DEFINE5() local
854 group = f.file->private_data; in SYSCALL_DEFINE5()
862 group->priority == FS_PRIO_0) in SYSCALL_DEFINE5()
868 fsnotify_clear_vfsmount_marks_by_group(group); in SYSCALL_DEFINE5()
870 fsnotify_clear_inode_marks_by_group(group); in SYSCALL_DEFINE5()
888 ret = fanotify_add_vfsmount_mark(group, mnt, mask, flags); in SYSCALL_DEFINE5()
890 ret = fanotify_add_inode_mark(group, inode, mask, flags); in SYSCALL_DEFINE5()
894 ret = fanotify_remove_vfsmount_mark(group, mnt, mask, flags); in SYSCALL_DEFINE5()
896 ret = fanotify_remove_inode_mark(group, inode, mask, flags); in SYSCALL_DEFINE5()