Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 207653
b: refs/heads/master
c: a12a7dd
h: refs/heads/master
i:
  207651: d6de7dc
v: v3
  • Loading branch information
Eric Paris committed Jul 28, 2010
1 parent 3af7400 commit df459c6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 767cd46c332d1360cdbe46ef18d80c3ade06fdc1
refs/heads/master: a12a7dd3284f5644326af1ea53b35030f205dd29
39 changes: 30 additions & 9 deletions trunk/fs/notify/fanotify/fanotify.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ static bool should_merge(struct fsnotify_event *old, struct fsnotify_event *new)
{
pr_debug("%s: old=%p new=%p\n", __func__, old, new);

if ((old->mask == new->mask) &&
(old->to_tell == new->to_tell) &&
if ((old->to_tell == new->to_tell) &&
(old->data_type == new->data_type)) {
switch (old->data_type) {
case (FSNOTIFY_EVENT_PATH):
Expand All @@ -29,20 +28,42 @@ static bool should_merge(struct fsnotify_event *old, struct fsnotify_event *new)

static int fanotify_merge(struct list_head *list, struct fsnotify_event *event)
{
struct fsnotify_event_holder *holder;
struct fsnotify_event_holder *test_holder;
struct fsnotify_event *test_event;
struct fsnotify_event *new_event;
int ret = 0;

pr_debug("%s: list=%p event=%p\n", __func__, list, event);

/* and the list better be locked by something too! */

list_for_each_entry_reverse(holder, list, event_list) {
test_event = holder->event;
if (should_merge(test_event, event))
return -EEXIST;
list_for_each_entry_reverse(test_holder, list, event_list) {
test_event = test_holder->event;
if (should_merge(test_event, event)) {
ret = -EEXIST;

/* if they are exactly the same we are done */
if (test_event->mask == event->mask)
goto out;

/* can't allocate memory, merge was no possible */
new_event = fsnotify_clone_event(test_event);
if (unlikely(!new_event)) {
ret = 0;
goto out;
}

/* build new event and replace it on the list */
new_event->mask = (test_event->mask | event->mask);
fsnotify_replace_event(test_holder, new_event);
/* match ref from fsnotify_clone_event() */
fsnotify_put_event(new_event);

break;
}
}

return 0;
out:
return ret;
}

static int fanotify_handle_event(struct fsnotify_group *group, struct fsnotify_event *event)
Expand Down

0 comments on commit df459c6

Please sign in to comment.