Lines Matching refs:group

80 		 * With group flag FAN_REPORT_NAME, if name was not recorded in
98 static struct fanotify_event *get_one_event(struct fsnotify_group *group,
103 unsigned int fid_mode = FAN_GROUP_FLAG(group, FANOTIFY_FID_BITS);
105 pr_debug("%s: group=%p count=%zd\n", __func__, group, count);
107 spin_lock(&group->notification_lock);
108 if (fsnotify_notify_queue_is_empty(group))
113 FANOTIFY_E(fsnotify_peek_first_event(group)));
120 event = FANOTIFY_E(fsnotify_remove_first_event(group));
124 spin_unlock(&group->notification_lock);
128 static int create_fd(struct fsnotify_group *group, struct path *path,
134 client_fd = get_unused_fd_flags(group->fanotify_data.f_flags);
143 group->fanotify_data.f_flags | FMODE_NONOTIFY,
164 * drop group->notification_lock.
166 static void finish_permission_event(struct fsnotify_group *group,
169 __releases(&group->notification_lock)
173 assert_spin_locked(&group->notification_lock);
179 spin_unlock(&group->notification_lock);
181 fsnotify_destroy_event(group, &event->fae.fse);
184 static int process_access_response(struct fsnotify_group *group,
191 pr_debug("%s: group=%p fd=%d response=%d\n", __func__, group,
209 if ((response & FAN_AUDIT) && !FAN_GROUP_FLAG(group, FAN_ENABLE_AUDIT))
212 spin_lock(&group->notification_lock);
213 list_for_each_entry(event, &group->fanotify_data.access_list,
219 finish_permission_event(group, event, response);
220 wake_up(&group->fanotify_data.access_waitq);
223 spin_unlock(&group->notification_lock);
323 static ssize_t copy_event_to_user(struct fsnotify_group *group,
330 unsigned int fid_mode = FAN_GROUP_FLAG(group, FANOTIFY_FID_BITS);
335 pr_debug("%s: group=%p event=%p\n", __func__, group, event);
346 fd = create_fd(group, path, &f);
390 * With only group flag FAN_REPORT_FID only type FID is
397 * With group flag FAN_REPORT_NAME, if name was not
407 * With group flag FAN_REPORT_DIR_FID, a single info
414 * With group flags FAN_REPORT_DIR_FID|FAN_REPORT_FID,
448 struct fsnotify_group *group = file->private_data;
451 poll_wait(file, &group->notification_waitq, wait);
452 spin_lock(&group->notification_lock);
453 if (!fsnotify_notify_queue_is_empty(group))
455 spin_unlock(&group->notification_lock);
463 struct fsnotify_group *group;
470 group = file->private_data;
472 pr_debug("%s: group=%p\n", __func__, group);
474 add_wait_queue(&group->notification_waitq, &wait);
481 event = get_one_event(group, count);
503 ret = copy_event_to_user(group, event, buf, count);
519 fsnotify_destroy_event(group, &event->fse);
522 spin_lock(&group->notification_lock);
523 finish_permission_event(group,
525 wake_up(&group->fanotify_data.access_waitq);
527 spin_lock(&group->notification_lock);
529 &group->fanotify_data.access_list);
530 spin_unlock(&group->notification_lock);
538 remove_wait_queue(&group->notification_waitq, &wait);
548 struct fsnotify_group *group;
554 group = file->private_data;
561 pr_debug("%s: group=%p count=%zu\n", __func__, group, count);
566 ret = process_access_response(group, &response);
575 struct fsnotify_group *group = file->private_data;
582 fsnotify_group_stop_queueing(group);
588 spin_lock(&group->notification_lock);
589 while (!list_empty(&group->fanotify_data.access_list)) {
592 event = list_first_entry(&group->fanotify_data.access_list,
595 finish_permission_event(group, event, FAN_ALLOW);
596 spin_lock(&group->notification_lock);
604 while (!fsnotify_notify_queue_is_empty(group)) {
607 event = FANOTIFY_E(fsnotify_remove_first_event(group));
609 spin_unlock(&group->notification_lock);
610 fsnotify_destroy_event(group, &event->fse);
612 finish_permission_event(group, FANOTIFY_PERM(event),
615 spin_lock(&group->notification_lock);
617 spin_unlock(&group->notification_lock);
620 wake_up(&group->fanotify_data.access_waitq);
623 fsnotify_destroy_group(group);
630 struct fsnotify_group *group;
636 group = file->private_data;
642 spin_lock(&group->notification_lock);
643 list_for_each_entry(fsn_event, &group->notification_list, list)
645 spin_unlock(&group->notification_lock);
746 static int fanotify_remove_mark(struct fsnotify_group *group,
754 mutex_lock(&group->mark_mutex);
755 fsn_mark = fsnotify_find_mark(connp, group);
757 mutex_unlock(&group->mark_mutex);
767 mutex_unlock(&group->mark_mutex);
776 static int fanotify_remove_vfsmount_mark(struct fsnotify_group *group,
780 return fanotify_remove_mark(group, &real_mount(mnt)->mnt_fsnotify_marks,
784 static int fanotify_remove_sb_mark(struct fsnotify_group *group,
788 return fanotify_remove_mark(group, &sb->s_fsnotify_marks, mask,
792 static int fanotify_remove_inode_mark(struct fsnotify_group *group,
796 return fanotify_remove_mark(group, &inode->i_fsnotify_marks, mask,
820 static struct fsnotify_mark *fanotify_add_new_mark(struct fsnotify_group *group,
828 if (atomic_read(&group->num_marks) > group->fanotify_data.max_marks)
835 fsnotify_init_mark(mark, group);
846 static int fanotify_add_mark(struct fsnotify_group *group,
854 mutex_lock(&group->mark_mutex);
855 fsn_mark = fsnotify_find_mark(connp, group);
857 fsn_mark = fanotify_add_new_mark(group, connp, type, fsid);
859 mutex_unlock(&group->mark_mutex);
866 mutex_unlock(&group->mark_mutex);
872 static int fanotify_add_vfsmount_mark(struct fsnotify_group *group,
876 return fanotify_add_mark(group, &real_mount(mnt)->mnt_fsnotify_marks,
880 static int fanotify_add_sb_mark(struct fsnotify_group *group,
884 return fanotify_add_mark(group, &sb->s_fsnotify_marks,
888 static int fanotify_add_inode_mark(struct fsnotify_group *group,
892 pr_debug("%s: group=%p inode=%p\n", __func__, group, inode);
904 return fanotify_add_mark(group, &inode->i_fsnotify_marks,
925 struct fsnotify_group *group;
979 group = fsnotify_alloc_group(&fanotify_fsnotify_ops);
980 if (IS_ERR(group)) {
982 return PTR_ERR(group);
985 group->fanotify_data.user = user;
986 group->fanotify_data.flags = flags;
988 group->memcg = get_mem_cgroup_from_mm(current->mm);
990 group->overflow_event = fanotify_alloc_overflow_event();
991 if (unlikely(!group->overflow_event)) {
998 group->fanotify_data.f_flags = event_f_flags;
999 init_waitqueue_head(&group->fanotify_data.access_waitq);
1000 INIT_LIST_HEAD(&group->fanotify_data.access_list);
1003 group->priority = FS_PRIO_0;
1006 group->priority = FS_PRIO_1;
1009 group->priority = FS_PRIO_2;
1020 group->max_events = UINT_MAX;
1022 group->max_events = FANOTIFY_DEFAULT_MAX_EVENTS;
1029 group->fanotify_data.max_marks = UINT_MAX;
1031 group->fanotify_data.max_marks = FANOTIFY_DEFAULT_MAX_MARKS;
1040 fd = anon_inode_getfd("[fanotify]", &fanotify_fops, group, f_flags);
1047 fsnotify_destroy_group(group);
1132 struct fsnotify_group *group;
1199 group = f.file->private_data;
1202 * group->priority == FS_PRIO_0 == FAN_CLASS_NOTIF. These are not
1207 group->priority == FS_PRIO_0)
1213 * group supports reporting fid.
1217 fid_mode = FAN_GROUP_FLAG(group, FANOTIFY_FID_BITS);
1225 fsnotify_clear_vfsmount_marks_by_group(group);
1227 fsnotify_clear_sb_marks_by_group(group);
1229 fsnotify_clear_inode_marks_by_group(group);
1252 /* inode held in place by reference to path; group by fget on fd */
1263 * If group needs to report parent fid, register for getting
1275 ret = fanotify_add_vfsmount_mark(group, mnt, mask,
1278 ret = fanotify_add_sb_mark(group, mnt->mnt_sb, mask,
1281 ret = fanotify_add_inode_mark(group, inode, mask,
1286 ret = fanotify_remove_vfsmount_mark(group, mnt, mask,
1289 ret = fanotify_remove_sb_mark(group, mnt->mnt_sb, mask,
1292 ret = fanotify_remove_inode_mark(group, inode, mask,