mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
fsnotify: make fasync generic for both inotify and fanotify
inotify is supposed to support async signal notification when information is available on the inotify fd. This patch moves that support to generic fsnotify functions so it can be used by all notification mechanisms. Signed-off-by: Eric Paris <[email protected]>
This commit is contained in:
parent
6960b0d909
commit
0a6b6bd591
5 changed files with 20 additions and 10 deletions
|
|
@ -414,6 +414,10 @@ static int fanotify_release(struct inode *ignored, struct file *file)
|
|||
|
||||
wake_up(&group->fanotify_data.access_waitq);
|
||||
#endif
|
||||
|
||||
if (file->f_flags & FASYNC)
|
||||
fsnotify_fasync(-1, file, 0);
|
||||
|
||||
/* matches the fanotify_init->fsnotify_alloc_group */
|
||||
fsnotify_destroy_group(group);
|
||||
|
||||
|
|
|
|||
|
|
@ -102,3 +102,10 @@ struct fsnotify_group *fsnotify_alloc_group(const struct fsnotify_ops *ops)
|
|||
|
||||
return group;
|
||||
}
|
||||
|
||||
int fsnotify_fasync(int fd, struct file *file, int on)
|
||||
{
|
||||
struct fsnotify_group *group = file->private_data;
|
||||
|
||||
return fasync_helper(fd, file, on, &group->fsn_fa) >= 0 ? 0 : -EIO;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -280,19 +280,15 @@ static ssize_t inotify_read(struct file *file, char __user *buf,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int inotify_fasync(int fd, struct file *file, int on)
|
||||
{
|
||||
struct fsnotify_group *group = file->private_data;
|
||||
|
||||
return fasync_helper(fd, file, on, &group->inotify_data.fa) >= 0 ? 0 : -EIO;
|
||||
}
|
||||
|
||||
static int inotify_release(struct inode *ignored, struct file *file)
|
||||
{
|
||||
struct fsnotify_group *group = file->private_data;
|
||||
|
||||
pr_debug("%s: group=%p\n", __func__, group);
|
||||
|
||||
if (file->f_flags & FASYNC)
|
||||
fsnotify_fasync(-1, file, 0);
|
||||
|
||||
/* free this group, matching get was inotify_init->fsnotify_obtain_group */
|
||||
fsnotify_destroy_group(group);
|
||||
|
||||
|
|
@ -335,7 +331,7 @@ static long inotify_ioctl(struct file *file, unsigned int cmd,
|
|||
static const struct file_operations inotify_fops = {
|
||||
.poll = inotify_poll,
|
||||
.read = inotify_read,
|
||||
.fasync = inotify_fasync,
|
||||
.fasync = fsnotify_fasync,
|
||||
.release = inotify_release,
|
||||
.unlocked_ioctl = inotify_ioctl,
|
||||
.compat_ioctl = inotify_ioctl,
|
||||
|
|
@ -706,7 +702,6 @@ static struct fsnotify_group *inotify_new_group(unsigned int max_events)
|
|||
spin_lock_init(&group->inotify_data.idr_lock);
|
||||
idr_init(&group->inotify_data.idr);
|
||||
group->inotify_data.last_wd = 0;
|
||||
group->inotify_data.fa = NULL;
|
||||
group->inotify_data.user = get_current_user();
|
||||
|
||||
if (atomic_inc_return(&group->inotify_data.user->inotify_devs) >
|
||||
|
|
|
|||
|
|
@ -225,6 +225,7 @@ alloc_holder:
|
|||
mutex_unlock(&group->notification_mutex);
|
||||
|
||||
wake_up(&group->notification_waitq);
|
||||
kill_fasync(&group->fsn_fa, SIGIO, POLL_IN);
|
||||
return return_event;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue