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:51 -0400 |
commit | 3bcf3860a4ff9bbc522820b4b765e65e4deceb3e (patch) | |
tree | 1e235af133559062c6fdee840ff9698f1dee26a6 /fs/notify/notification.c | |
parent | f70ab54cc6c3907b0727ba332b3976f80f3846d0 (diff) |
fsnotify: store struct file not struct path
Al explains that calling dentry_open() with a mnt/dentry pair is only
garunteed to be safe if they are already used in an open struct file. To
make sure this is the case don't store and use a struct path in fsnotify,
always use a struct file.
Signed-off-by: Eric Paris <eparis@redhat.com>
Diffstat (limited to 'fs/notify/notification.c')
-rw-r--r-- | fs/notify/notification.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/fs/notify/notification.c b/fs/notify/notification.c index f39260f8f865..c106cdd7ff5e 100644 --- a/fs/notify/notification.c +++ b/fs/notify/notification.c | |||
@@ -31,6 +31,7 @@ | |||
31 | * allocated and used. | 31 | * allocated and used. |
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <linux/file.h> | ||
34 | #include <linux/fs.h> | 35 | #include <linux/fs.h> |
35 | #include <linux/init.h> | 36 | #include <linux/init.h> |
36 | #include <linux/kernel.h> | 37 | #include <linux/kernel.h> |
@@ -89,8 +90,8 @@ void fsnotify_put_event(struct fsnotify_event *event) | |||
89 | if (atomic_dec_and_test(&event->refcnt)) { | 90 | if (atomic_dec_and_test(&event->refcnt)) { |
90 | pr_debug("%s: event=%p\n", __func__, event); | 91 | pr_debug("%s: event=%p\n", __func__, event); |
91 | 92 | ||
92 | if (event->data_type == FSNOTIFY_EVENT_PATH) | 93 | if (event->data_type == FSNOTIFY_EVENT_FILE) |
93 | path_put(&event->path); | 94 | fput(event->file); |
94 | 95 | ||
95 | BUG_ON(!list_empty(&event->private_data_list)); | 96 | BUG_ON(!list_empty(&event->private_data_list)); |
96 | 97 | ||
@@ -375,8 +376,8 @@ struct fsnotify_event *fsnotify_clone_event(struct fsnotify_event *old_event) | |||
375 | } | 376 | } |
376 | } | 377 | } |
377 | event->tgid = get_pid(old_event->tgid); | 378 | event->tgid = get_pid(old_event->tgid); |
378 | if (event->data_type == FSNOTIFY_EVENT_PATH) | 379 | if (event->data_type == FSNOTIFY_EVENT_FILE) |
379 | path_get(&event->path); | 380 | get_file(event->file); |
380 | 381 | ||
381 | return event; | 382 | return event; |
382 | } | 383 | } |
@@ -423,11 +424,9 @@ struct fsnotify_event *fsnotify_create_event(struct inode *to_tell, __u32 mask, | |||
423 | event->data_type = data_type; | 424 | event->data_type = data_type; |
424 | 425 | ||
425 | switch (data_type) { | 426 | switch (data_type) { |
426 | case FSNOTIFY_EVENT_PATH: { | 427 | case FSNOTIFY_EVENT_FILE: { |
427 | struct path *path = data; | 428 | event->file = data; |
428 | event->path.dentry = path->dentry; | 429 | get_file(event->file); |
429 | event->path.mnt = path->mnt; | ||
430 | path_get(&event->path); | ||
431 | break; | 430 | break; |
432 | } | 431 | } |
433 | case FSNOTIFY_EVENT_INODE: | 432 | case FSNOTIFY_EVENT_INODE: |
@@ -435,8 +434,7 @@ struct fsnotify_event *fsnotify_create_event(struct inode *to_tell, __u32 mask, | |||
435 | break; | 434 | break; |
436 | case FSNOTIFY_EVENT_NONE: | 435 | case FSNOTIFY_EVENT_NONE: |
437 | event->inode = NULL; | 436 | event->inode = NULL; |
438 | event->path.dentry = NULL; | 437 | event->file = NULL; |
439 | event->path.mnt = NULL; | ||
440 | break; | 438 | break; |
441 | default: | 439 | default: |
442 | BUG(); | 440 | BUG(); |