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()
533 mutex_unlock(&group->mark_mutex); in fanotify_remove_vfsmount_mark()
544 static int fanotify_remove_inode_mark(struct fsnotify_group *group, in fanotify_remove_inode_mark() argument
552 mutex_lock(&group->mark_mutex); in fanotify_remove_inode_mark()
553 fsn_mark = fsnotify_find_inode_mark(group, inode); in fanotify_remove_inode_mark()
555 mutex_unlock(&group->mark_mutex); in fanotify_remove_inode_mark()
563 mutex_unlock(&group->mark_mutex); in fanotify_remove_inode_mark()
604 static struct fsnotify_mark *fanotify_add_new_mark(struct fsnotify_group *group, in fanotify_add_new_mark() argument
611 if (atomic_read(&group->num_marks) > group->fanotify_data.max_marks) in fanotify_add_new_mark()
619 ret = fsnotify_add_mark_locked(mark, group, inode, mnt, 0); in fanotify_add_new_mark()
629 static int fanotify_add_vfsmount_mark(struct fsnotify_group *group, in fanotify_add_vfsmount_mark() argument
636 mutex_lock(&group->mark_mutex); in fanotify_add_vfsmount_mark()
637 fsn_mark = fsnotify_find_vfsmount_mark(group, mnt); in fanotify_add_vfsmount_mark()
639 fsn_mark = fanotify_add_new_mark(group, NULL, mnt); in fanotify_add_vfsmount_mark()
641 mutex_unlock(&group->mark_mutex); in fanotify_add_vfsmount_mark()
646 mutex_unlock(&group->mark_mutex); in fanotify_add_vfsmount_mark()
655 static int fanotify_add_inode_mark(struct fsnotify_group *group, in fanotify_add_inode_mark() argument
662 pr_debug("%s: group=%p inode=%p\n", __func__, group, inode); in fanotify_add_inode_mark()
674 mutex_lock(&group->mark_mutex); in fanotify_add_inode_mark()
675 fsn_mark = fsnotify_find_inode_mark(group, inode); in fanotify_add_inode_mark()
677 fsn_mark = fanotify_add_new_mark(group, inode, NULL); in fanotify_add_inode_mark()
679 mutex_unlock(&group->mark_mutex); in fanotify_add_inode_mark()
684 mutex_unlock(&group->mark_mutex); in fanotify_add_inode_mark()
696 struct fsnotify_group *group; in SYSCALL_DEFINE2() local
735 group = fsnotify_alloc_group(&fanotify_fsnotify_ops); in SYSCALL_DEFINE2()
736 if (IS_ERR(group)) { in SYSCALL_DEFINE2()
738 return PTR_ERR(group); in SYSCALL_DEFINE2()
741 group->fanotify_data.user = user; in SYSCALL_DEFINE2()
749 group->overflow_event = &oevent->fse; in SYSCALL_DEFINE2()
753 group->fanotify_data.f_flags = event_f_flags; in SYSCALL_DEFINE2()
755 spin_lock_init(&group->fanotify_data.access_lock); in SYSCALL_DEFINE2()
756 init_waitqueue_head(&group->fanotify_data.access_waitq); in SYSCALL_DEFINE2()
757 INIT_LIST_HEAD(&group->fanotify_data.access_list); in SYSCALL_DEFINE2()
758 atomic_set(&group->fanotify_data.bypass_perm, 0); in SYSCALL_DEFINE2()
762 group->priority = FS_PRIO_0; in SYSCALL_DEFINE2()
765 group->priority = FS_PRIO_1; in SYSCALL_DEFINE2()
768 group->priority = FS_PRIO_2; in SYSCALL_DEFINE2()
779 group->max_events = UINT_MAX; in SYSCALL_DEFINE2()
781 group->max_events = FANOTIFY_DEFAULT_MAX_EVENTS; in SYSCALL_DEFINE2()
788 group->fanotify_data.max_marks = UINT_MAX; in SYSCALL_DEFINE2()
790 group->fanotify_data.max_marks = FANOTIFY_DEFAULT_MAX_MARKS; in SYSCALL_DEFINE2()
793 fd = anon_inode_getfd("[fanotify]", &fanotify_fops, group, f_flags); in SYSCALL_DEFINE2()
800 fsnotify_destroy_group(group); in SYSCALL_DEFINE2()
810 struct fsnotify_group *group; in SYSCALL_DEFINE5() local
858 group = f.file->private_data; in SYSCALL_DEFINE5()
866 group->priority == FS_PRIO_0) in SYSCALL_DEFINE5()
872 fsnotify_clear_vfsmount_marks_by_group(group); in SYSCALL_DEFINE5()
874 fsnotify_clear_inode_marks_by_group(group); in SYSCALL_DEFINE5()
892 ret = fanotify_add_vfsmount_mark(group, mnt, mask, flags); in SYSCALL_DEFINE5()
894 ret = fanotify_add_inode_mark(group, inode, mask, flags); in SYSCALL_DEFINE5()
898 ret = fanotify_remove_vfsmount_mark(group, mnt, mask, flags); in SYSCALL_DEFINE5()
900 ret = fanotify_remove_inode_mark(group, inode, mask, flags); in SYSCALL_DEFINE5()