aboutsummaryrefslogtreecommitdiffstats
path: root/fs/notify/inotify
diff options
context:
space:
mode:
authorEric Paris <eparis@redhat.com>2011-10-14 17:43:39 -0400
committerEric Paris <eparis@redhat.com>2012-12-11 13:44:36 -0500
commit0a6b6bd5919a65030b557ec8fe81f6fb3e93744a (patch)
tree940e38b5cc9d7fdb5804748842b555af554ed32f /fs/notify/inotify
parent6960b0d909cde5bdff49e4e5c1250edd10be7ebd (diff)
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 <eparis@redhat.com>
Diffstat (limited to 'fs/notify/inotify')
-rw-r--r--fs/notify/inotify/inotify_user.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index 00ff82ff7c9f..68f7bec1e664 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -280,19 +280,15 @@ static ssize_t inotify_read(struct file *file, char __user *buf,
280 return ret; 280 return ret;
281} 281}
282 282
283static int inotify_fasync(int fd, struct file *file, int on)
284{
285 struct fsnotify_group *group = file->private_data;
286
287 return fasync_helper(fd, file, on, &group->inotify_data.fa) >= 0 ? 0 : -EIO;
288}
289
290static int inotify_release(struct inode *ignored, struct file *file) 283static int inotify_release(struct inode *ignored, struct file *file)
291{ 284{
292 struct fsnotify_group *group = file->private_data; 285 struct fsnotify_group *group = file->private_data;
293 286
294 pr_debug("%s: group=%p\n", __func__, group); 287 pr_debug("%s: group=%p\n", __func__, group);
295 288
289 if (file->f_flags & FASYNC)
290 fsnotify_fasync(-1, file, 0);
291
296 /* free this group, matching get was inotify_init->fsnotify_obtain_group */ 292 /* free this group, matching get was inotify_init->fsnotify_obtain_group */
297 fsnotify_destroy_group(group); 293 fsnotify_destroy_group(group);
298 294
@@ -335,7 +331,7 @@ static long inotify_ioctl(struct file *file, unsigned int cmd,
335static const struct file_operations inotify_fops = { 331static const struct file_operations inotify_fops = {
336 .poll = inotify_poll, 332 .poll = inotify_poll,
337 .read = inotify_read, 333 .read = inotify_read,
338 .fasync = inotify_fasync, 334 .fasync = fsnotify_fasync,
339 .release = inotify_release, 335 .release = inotify_release,
340 .unlocked_ioctl = inotify_ioctl, 336 .unlocked_ioctl = inotify_ioctl,
341 .compat_ioctl = inotify_ioctl, 337 .compat_ioctl = inotify_ioctl,
@@ -706,7 +702,6 @@ static struct fsnotify_group *inotify_new_group(unsigned int max_events)
706 spin_lock_init(&group->inotify_data.idr_lock); 702 spin_lock_init(&group->inotify_data.idr_lock);
707 idr_init(&group->inotify_data.idr); 703 idr_init(&group->inotify_data.idr);
708 group->inotify_data.last_wd = 0; 704 group->inotify_data.last_wd = 0;
709 group->inotify_data.fa = NULL;
710 group->inotify_data.user = get_current_user(); 705 group->inotify_data.user = get_current_user();
711 706
712 if (atomic_inc_return(&group->inotify_data.user->inotify_devs) > 707 if (atomic_inc_return(&group->inotify_data.user->inotify_devs) >