Lines Matching refs:group
54 static struct fsnotify_event *get_one_event(struct fsnotify_group *group, in get_one_event() argument
57 assert_spin_locked(&group->notification_lock); 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->notification_lock); in dequeue_event()
151 list_for_each_entry(event, &group->fanotify_data.access_list, in dequeue_event()
160 spin_unlock(&group->notification_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 spin_lock(&group->notification_lock); in fanotify_poll()
248 if (!fsnotify_notify_queue_is_empty(group)) in fanotify_poll()
250 spin_unlock(&group->notification_lock); 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 spin_lock(&group->notification_lock); in fanotify_read()
272 kevent = get_one_event(group, count); in fanotify_read()
273 spin_unlock(&group->notification_lock); in fanotify_read()
296 ret = copy_event_to_user(group, kevent, buf); in fanotify_read()
312 fsnotify_destroy_event(group, kevent); in fanotify_read()
317 wake_up(&group->fanotify_data.access_waitq); in fanotify_read()
319 spin_lock(&group->notification_lock); in fanotify_read()
321 &group->fanotify_data.access_list); in fanotify_read()
322 spin_unlock(&group->notification_lock); in fanotify_read()
331 remove_wait_queue(&group->notification_waitq, &wait); in fanotify_read()
342 struct fsnotify_group *group; in fanotify_write() local
345 group = file->private_data; in fanotify_write()
350 pr_debug("%s: group=%p count=%zu\n", __func__, group, count); in fanotify_write()
355 ret = process_access_response(group, &response); in fanotify_write()
367 struct fsnotify_group *group = file->private_data; in fanotify_release() local
378 fsnotify_group_stop_queueing(group); in fanotify_release()
384 spin_lock(&group->notification_lock); in fanotify_release()
385 list_for_each_entry_safe(event, next, &group->fanotify_data.access_list, in fanotify_release()
387 pr_debug("%s: found group=%p event=%p\n", __func__, group, in fanotify_release()
399 while (!fsnotify_notify_queue_is_empty(group)) { in fanotify_release()
400 fsn_event = fsnotify_remove_first_event(group); in fanotify_release()
402 spin_unlock(&group->notification_lock); in fanotify_release()
403 fsnotify_destroy_event(group, fsn_event); in fanotify_release()
404 spin_lock(&group->notification_lock); in fanotify_release()
408 spin_unlock(&group->notification_lock); in fanotify_release()
411 wake_up(&group->fanotify_data.access_waitq); in fanotify_release()
415 fsnotify_destroy_group(group); in fanotify_release()
422 struct fsnotify_group *group; in fanotify_ioctl() local
428 group = file->private_data; in fanotify_ioctl()
434 spin_lock(&group->notification_lock); in fanotify_ioctl()
435 list_for_each_entry(fsn_event, &group->notification_list, list) in fanotify_ioctl()
437 spin_unlock(&group->notification_lock); in fanotify_ioctl()
537 static int fanotify_remove_vfsmount_mark(struct fsnotify_group *group, in fanotify_remove_vfsmount_mark() argument
545 mutex_lock(&group->mark_mutex); in fanotify_remove_vfsmount_mark()
546 fsn_mark = fsnotify_find_vfsmount_mark(group, mnt); in fanotify_remove_vfsmount_mark()
548 mutex_unlock(&group->mark_mutex); in fanotify_remove_vfsmount_mark()
556 mutex_unlock(&group->mark_mutex); in fanotify_remove_vfsmount_mark()
567 static int fanotify_remove_inode_mark(struct fsnotify_group *group, in fanotify_remove_inode_mark() argument
575 mutex_lock(&group->mark_mutex); in fanotify_remove_inode_mark()
576 fsn_mark = fsnotify_find_inode_mark(group, inode); in fanotify_remove_inode_mark()
578 mutex_unlock(&group->mark_mutex); in fanotify_remove_inode_mark()
586 mutex_unlock(&group->mark_mutex); in fanotify_remove_inode_mark()
627 static struct fsnotify_mark *fanotify_add_new_mark(struct fsnotify_group *group, in fanotify_add_new_mark() argument
634 if (atomic_read(&group->num_marks) > group->fanotify_data.max_marks) in fanotify_add_new_mark()
642 ret = fsnotify_add_mark_locked(mark, group, inode, mnt, 0); in fanotify_add_new_mark()
652 static int fanotify_add_vfsmount_mark(struct fsnotify_group *group, in fanotify_add_vfsmount_mark() argument
659 mutex_lock(&group->mark_mutex); in fanotify_add_vfsmount_mark()
660 fsn_mark = fsnotify_find_vfsmount_mark(group, mnt); in fanotify_add_vfsmount_mark()
662 fsn_mark = fanotify_add_new_mark(group, NULL, mnt); in fanotify_add_vfsmount_mark()
664 mutex_unlock(&group->mark_mutex); in fanotify_add_vfsmount_mark()
669 mutex_unlock(&group->mark_mutex); in fanotify_add_vfsmount_mark()
678 static int fanotify_add_inode_mark(struct fsnotify_group *group, in fanotify_add_inode_mark() argument
685 pr_debug("%s: group=%p inode=%p\n", __func__, group, inode); in fanotify_add_inode_mark()
697 mutex_lock(&group->mark_mutex); in fanotify_add_inode_mark()
698 fsn_mark = fsnotify_find_inode_mark(group, inode); in fanotify_add_inode_mark()
700 fsn_mark = fanotify_add_new_mark(group, inode, NULL); in fanotify_add_inode_mark()
702 mutex_unlock(&group->mark_mutex); in fanotify_add_inode_mark()
707 mutex_unlock(&group->mark_mutex); in fanotify_add_inode_mark()
719 struct fsnotify_group *group; in SYSCALL_DEFINE2() local
758 group = fsnotify_alloc_group(&fanotify_fsnotify_ops); in SYSCALL_DEFINE2()
759 if (IS_ERR(group)) { in SYSCALL_DEFINE2()
761 return PTR_ERR(group); in SYSCALL_DEFINE2()
764 group->fanotify_data.user = user; in SYSCALL_DEFINE2()
772 group->overflow_event = &oevent->fse; in SYSCALL_DEFINE2()
776 group->fanotify_data.f_flags = event_f_flags; in SYSCALL_DEFINE2()
778 init_waitqueue_head(&group->fanotify_data.access_waitq); in SYSCALL_DEFINE2()
779 INIT_LIST_HEAD(&group->fanotify_data.access_list); in SYSCALL_DEFINE2()
783 group->priority = FS_PRIO_0; in SYSCALL_DEFINE2()
786 group->priority = FS_PRIO_1; in SYSCALL_DEFINE2()
789 group->priority = FS_PRIO_2; in SYSCALL_DEFINE2()
800 group->max_events = UINT_MAX; in SYSCALL_DEFINE2()
802 group->max_events = FANOTIFY_DEFAULT_MAX_EVENTS; in SYSCALL_DEFINE2()
809 group->fanotify_data.max_marks = UINT_MAX; in SYSCALL_DEFINE2()
811 group->fanotify_data.max_marks = FANOTIFY_DEFAULT_MAX_MARKS; in SYSCALL_DEFINE2()
814 fd = anon_inode_getfd("[fanotify]", &fanotify_fops, group, f_flags); in SYSCALL_DEFINE2()
821 fsnotify_destroy_group(group); in SYSCALL_DEFINE2()
831 struct fsnotify_group *group; in SYSCALL_DEFINE5() local
879 group = f.file->private_data; in SYSCALL_DEFINE5()
887 group->priority == FS_PRIO_0) in SYSCALL_DEFINE5()
893 fsnotify_clear_vfsmount_marks_by_group(group); in SYSCALL_DEFINE5()
895 fsnotify_clear_inode_marks_by_group(group); in SYSCALL_DEFINE5()
913 ret = fanotify_add_vfsmount_mark(group, mnt, mask, flags); in SYSCALL_DEFINE5()
915 ret = fanotify_add_inode_mark(group, inode, mask, flags); in SYSCALL_DEFINE5()
919 ret = fanotify_remove_vfsmount_mark(group, mnt, mask, flags); in SYSCALL_DEFINE5()
921 ret = fanotify_remove_inode_mark(group, inode, mask, flags); in SYSCALL_DEFINE5()