]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - fs/notify/inotify/inotify_user.c
fsnotify: fsnotify_add_notify_event should return an event
[net-next-2.6.git] / fs / notify / inotify / inotify_user.c
index 7dc940c869b68062fa894ccd3e67c167bae21a40..a4cd227c4c76fd06b65b761f453e7a053ca7c9e4 100644 (file)
@@ -141,6 +141,8 @@ static struct fsnotify_event *get_one_event(struct fsnotify_group *group,
 
        event = fsnotify_peek_notify_event(group);
 
+       pr_debug("%s: group=%p event=%p\n", __func__, group, event);
+
        if (event->name_len)
                event_size += roundup(event->name_len + 1, event_size);
 
@@ -170,6 +172,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
        size_t event_size = sizeof(struct inotify_event);
        size_t name_len = 0;
 
+       pr_debug("%s: group=%p event=%p\n", __func__, group, event);
+
        /* we get the inotify watch descriptor from the event private data */
        spin_lock(&event->lock);
        fsn_priv = fsnotify_remove_priv_from_event(group, event);
@@ -242,6 +246,8 @@ static ssize_t inotify_read(struct file *file, char __user *buf,
                kevent = get_one_event(group, count);
                mutex_unlock(&group->notification_mutex);
 
+               pr_debug("%s: group=%p kevent=%p\n", __func__, group, kevent);
+
                if (kevent) {
                        ret = PTR_ERR(kevent);
                        if (IS_ERR(kevent))
@@ -286,6 +292,8 @@ static int inotify_release(struct inode *ignored, struct file *file)
        struct fsnotify_group *group = file->private_data;
        struct user_struct *user = group->inotify_data.user;
 
+       pr_debug("%s: group=%p\n", __func__, group);
+
        fsnotify_clear_marks_by_group(group);
 
        /* free this group, matching get was inotify_init->fsnotify_obtain_group */
@@ -309,6 +317,8 @@ static long inotify_ioctl(struct file *file, unsigned int cmd,
        group = file->private_data;
        p = (void __user *) arg;
 
+       pr_debug("%s: group=%p cmd=%u\n", __func__, group, cmd);
+
        switch (cmd) {
        case FIONREAD:
                mutex_lock(&group->notification_mutex);
@@ -506,7 +516,7 @@ void inotify_ignored_and_remove_idr(struct fsnotify_mark *fsn_mark,
                                    struct fsnotify_group *group)
 {
        struct inotify_inode_mark *i_mark;
-       struct fsnotify_event *ignored_event;
+       struct fsnotify_event *ignored_event, *notify_event;
        struct inotify_event_private_data *event_priv;
        struct fsnotify_event_private_data *fsn_event_priv;
        int ret;
@@ -528,9 +538,14 @@ void inotify_ignored_and_remove_idr(struct fsnotify_mark *fsn_mark,
        fsn_event_priv->group = group;
        event_priv->wd = i_mark->wd;
 
-       ret = fsnotify_add_notify_event(group, ignored_event, fsn_event_priv, NULL, NULL);
-       if (ret)
+       notify_event = fsnotify_add_notify_event(group, ignored_event, fsn_event_priv, NULL);
+       if (notify_event) {
+               if (IS_ERR(notify_event))
+                       ret = PTR_ERR(notify_event);
+               else
+                       fsnotify_put_event(notify_event);
                inotify_free_event_priv(fsn_event_priv);
+       }
 
 skip_send_ignore: