diff options
author | Eric Paris <eparis@redhat.com> | 2010-07-28 10:18:37 -0400 |
---|---|---|
committer | Eric Paris <eparis@redhat.com> | 2010-07-28 10:18:50 -0400 |
commit | f70ab54cc6c3907b0727ba332b3976f80f3846d0 (patch) | |
tree | 2a22097325a668a0d08d4ea3354d0e6c95fddd86 /fs/notify/inotify | |
parent | 5ba08e2eeb06355f66ed62ae97bb87d145973a9a (diff) |
fsnotify: fsnotify_add_notify_event should return an event
Rather than the horrific void ** argument and such just to pass the
fanotify_merge event back to the caller of fsnotify_add_notify_event() have
those things return an event if it was different than the event suggusted to
be added.
Signed-off-by: Eric Paris <eparis@redhat.com>
Diffstat (limited to 'fs/notify/inotify')
-rw-r--r-- | fs/notify/inotify/inotify_fsnotify.c | 28 | ||||
-rw-r--r-- | fs/notify/inotify/inotify_user.c | 11 |
2 files changed, 22 insertions, 17 deletions
diff --git a/fs/notify/inotify/inotify_fsnotify.c b/fs/notify/inotify/inotify_fsnotify.c index 906b72761b17..73a1106b3542 100644 --- a/fs/notify/inotify/inotify_fsnotify.c +++ b/fs/notify/inotify/inotify_fsnotify.c | |||
@@ -68,13 +68,11 @@ static bool event_compare(struct fsnotify_event *old, struct fsnotify_event *new | |||
68 | return false; | 68 | return false; |
69 | } | 69 | } |
70 | 70 | ||
71 | static int inotify_merge(struct list_head *list, | 71 | static struct fsnotify_event *inotify_merge(struct list_head *list, |
72 | struct fsnotify_event *event, | 72 | struct fsnotify_event *event) |
73 | void **arg) | ||
74 | { | 73 | { |
75 | struct fsnotify_event_holder *last_holder; | 74 | struct fsnotify_event_holder *last_holder; |
76 | struct fsnotify_event *last_event; | 75 | struct fsnotify_event *last_event; |
77 | int ret = 0; | ||
78 | 76 | ||
79 | /* and the list better be locked by something too */ | 77 | /* and the list better be locked by something too */ |
80 | spin_lock(&event->lock); | 78 | spin_lock(&event->lock); |
@@ -82,11 +80,13 @@ static int inotify_merge(struct list_head *list, | |||
82 | last_holder = list_entry(list->prev, struct fsnotify_event_holder, event_list); | 80 | last_holder = list_entry(list->prev, struct fsnotify_event_holder, event_list); |
83 | last_event = last_holder->event; | 81 | last_event = last_holder->event; |
84 | if (event_compare(last_event, event)) | 82 | if (event_compare(last_event, event)) |
85 | ret = -EEXIST; | 83 | fsnotify_get_event(last_event); |
84 | else | ||
85 | last_event = NULL; | ||
86 | 86 | ||
87 | spin_unlock(&event->lock); | 87 | spin_unlock(&event->lock); |
88 | 88 | ||
89 | return ret; | 89 | return last_event; |
90 | } | 90 | } |
91 | 91 | ||
92 | static int inotify_handle_event(struct fsnotify_group *group, struct fsnotify_event *event) | 92 | static int inotify_handle_event(struct fsnotify_group *group, struct fsnotify_event *event) |
@@ -96,7 +96,8 @@ static int inotify_handle_event(struct fsnotify_group *group, struct fsnotify_ev | |||
96 | struct inode *to_tell; | 96 | struct inode *to_tell; |
97 | struct inotify_event_private_data *event_priv; | 97 | struct inotify_event_private_data *event_priv; |
98 | struct fsnotify_event_private_data *fsn_event_priv; | 98 | struct fsnotify_event_private_data *fsn_event_priv; |
99 | int wd, ret; | 99 | struct fsnotify_event *added_event; |
100 | int wd, ret = 0; | ||
100 | 101 | ||
101 | pr_debug("%s: group=%p event=%p to_tell=%p mask=%x\n", __func__, group, | 102 | pr_debug("%s: group=%p event=%p to_tell=%p mask=%x\n", __func__, group, |
102 | event, event->to_tell, event->mask); | 103 | event, event->to_tell, event->mask); |
@@ -120,14 +121,13 @@ static int inotify_handle_event(struct fsnotify_group *group, struct fsnotify_ev | |||
120 | fsn_event_priv->group = group; | 121 | fsn_event_priv->group = group; |
121 | event_priv->wd = wd; | 122 | event_priv->wd = wd; |
122 | 123 | ||
123 | ret = fsnotify_add_notify_event(group, event, fsn_event_priv, inotify_merge, NULL); | 124 | added_event = fsnotify_add_notify_event(group, event, fsn_event_priv, inotify_merge); |
124 | if (ret) { | 125 | if (added_event) { |
125 | inotify_free_event_priv(fsn_event_priv); | 126 | inotify_free_event_priv(fsn_event_priv); |
126 | /* EEXIST says we tail matched, EOVERFLOW isn't something | 127 | if (!IS_ERR(added_event)) |
127 | * to report up the stack. */ | 128 | fsnotify_put_event(added_event); |
128 | if ((ret == -EEXIST) || | 129 | else |
129 | (ret == -EOVERFLOW)) | 130 | ret = PTR_ERR(added_event); |
130 | ret = 0; | ||
131 | } | 131 | } |
132 | 132 | ||
133 | if (fsn_mark->mask & IN_ONESHOT) | 133 | if (fsn_mark->mask & IN_ONESHOT) |
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c index 1068e1ca9cb0..a4cd227c4c76 100644 --- a/fs/notify/inotify/inotify_user.c +++ b/fs/notify/inotify/inotify_user.c | |||
@@ -516,7 +516,7 @@ void inotify_ignored_and_remove_idr(struct fsnotify_mark *fsn_mark, | |||
516 | struct fsnotify_group *group) | 516 | struct fsnotify_group *group) |
517 | { | 517 | { |
518 | struct inotify_inode_mark *i_mark; | 518 | struct inotify_inode_mark *i_mark; |
519 | struct fsnotify_event *ignored_event; | 519 | struct fsnotify_event *ignored_event, *notify_event; |
520 | struct inotify_event_private_data *event_priv; | 520 | struct inotify_event_private_data *event_priv; |
521 | struct fsnotify_event_private_data *fsn_event_priv; | 521 | struct fsnotify_event_private_data *fsn_event_priv; |
522 | int ret; | 522 | int ret; |
@@ -538,9 +538,14 @@ void inotify_ignored_and_remove_idr(struct fsnotify_mark *fsn_mark, | |||
538 | fsn_event_priv->group = group; | 538 | fsn_event_priv->group = group; |
539 | event_priv->wd = i_mark->wd; | 539 | event_priv->wd = i_mark->wd; |
540 | 540 | ||
541 | ret = fsnotify_add_notify_event(group, ignored_event, fsn_event_priv, NULL, NULL); | 541 | notify_event = fsnotify_add_notify_event(group, ignored_event, fsn_event_priv, NULL); |
542 | if (ret) | 542 | if (notify_event) { |
543 | if (IS_ERR(notify_event)) | ||
544 | ret = PTR_ERR(notify_event); | ||
545 | else | ||
546 | fsnotify_put_event(notify_event); | ||
543 | inotify_free_event_priv(fsn_event_priv); | 547 | inotify_free_event_priv(fsn_event_priv); |
548 | } | ||
544 | 549 | ||
545 | skip_send_ignore: | 550 | skip_send_ignore: |
546 | 551 | ||