diff options
author | Eric Paris <eparis@redhat.com> | 2009-05-21 17:01:43 -0400 |
---|---|---|
committer | Eric Paris <eparis@redhat.com> | 2009-06-11 14:57:53 -0400 |
commit | 62ffe5dfba056f7ba81d710fee9f28c58a42fdd6 (patch) | |
tree | ac0d4afc641bdc8ff76779545fde9c6ae539bdaf /fs/notify | |
parent | a2d8bc6cb4a3024661baf877242f123787d0c054 (diff) |
fsnotify: include pathnames with entries when possible
When inotify wants to send events to a directory about a child it includes
the name of the original file. This patch collects that filename and makes
it available for notification.
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'fs/notify')
-rw-r--r-- | fs/notify/fsnotify.c | 7 | ||||
-rw-r--r-- | fs/notify/notification.c | 16 |
2 files changed, 19 insertions, 4 deletions
diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c index 7fc760067a6..675129fa9fd 100644 --- a/fs/notify/fsnotify.c +++ b/fs/notify/fsnotify.c | |||
@@ -114,7 +114,8 @@ void __fsnotify_parent(struct dentry *dentry, __u32 mask) | |||
114 | * specifies these are events which came from a child. */ | 114 | * specifies these are events which came from a child. */ |
115 | mask |= FS_EVENT_ON_CHILD; | 115 | mask |= FS_EVENT_ON_CHILD; |
116 | 116 | ||
117 | fsnotify(p_inode, mask, dentry->d_inode, FSNOTIFY_EVENT_INODE); | 117 | fsnotify(p_inode, mask, dentry->d_inode, FSNOTIFY_EVENT_INODE, |
118 | dentry->d_name.name); | ||
118 | dput(parent); | 119 | dput(parent); |
119 | } | 120 | } |
120 | 121 | ||
@@ -131,7 +132,7 @@ EXPORT_SYMBOL_GPL(__fsnotify_parent); | |||
131 | * out to all of the registered fsnotify_group. Those groups can then use the | 132 | * out to all of the registered fsnotify_group. Those groups can then use the |
132 | * notification event in whatever means they feel necessary. | 133 | * notification event in whatever means they feel necessary. |
133 | */ | 134 | */ |
134 | void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is) | 135 | void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is, const char *file_name) |
135 | { | 136 | { |
136 | struct fsnotify_group *group; | 137 | struct fsnotify_group *group; |
137 | struct fsnotify_event *event = NULL; | 138 | struct fsnotify_event *event = NULL; |
@@ -156,7 +157,7 @@ void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is) | |||
156 | if (!group->ops->should_send_event(group, to_tell, mask)) | 157 | if (!group->ops->should_send_event(group, to_tell, mask)) |
157 | continue; | 158 | continue; |
158 | if (!event) { | 159 | if (!event) { |
159 | event = fsnotify_create_event(to_tell, mask, data, data_is); | 160 | event = fsnotify_create_event(to_tell, mask, data, data_is, file_name); |
160 | /* shit, we OOM'd and now we can't tell, maybe | 161 | /* shit, we OOM'd and now we can't tell, maybe |
161 | * someday someone else will want to do something | 162 | * someday someone else will want to do something |
162 | * here */ | 163 | * here */ |
diff --git a/fs/notify/notification.c b/fs/notify/notification.c index dddecc74e63..c69b18b9aba 100644 --- a/fs/notify/notification.c +++ b/fs/notify/notification.c | |||
@@ -78,6 +78,7 @@ void fsnotify_put_event(struct fsnotify_event *event) | |||
78 | if (event->data_type == FSNOTIFY_EVENT_PATH) | 78 | if (event->data_type == FSNOTIFY_EVENT_PATH) |
79 | path_put(&event->path); | 79 | path_put(&event->path); |
80 | 80 | ||
81 | kfree(event->file_name); | ||
81 | kmem_cache_free(fsnotify_event_cachep, event); | 82 | kmem_cache_free(fsnotify_event_cachep, event); |
82 | } | 83 | } |
83 | } | 84 | } |
@@ -262,6 +263,9 @@ static void initialize_event(struct fsnotify_event *event) | |||
262 | event->data_type = FSNOTIFY_EVENT_NONE; | 263 | event->data_type = FSNOTIFY_EVENT_NONE; |
263 | 264 | ||
264 | event->to_tell = NULL; | 265 | event->to_tell = NULL; |
266 | |||
267 | event->file_name = NULL; | ||
268 | event->name_len = 0; | ||
265 | } | 269 | } |
266 | 270 | ||
267 | /* | 271 | /* |
@@ -274,9 +278,10 @@ static void initialize_event(struct fsnotify_event *event) | |||
274 | * @mask what actually happened. | 278 | * @mask what actually happened. |
275 | * @data pointer to the object which was actually affected | 279 | * @data pointer to the object which was actually affected |
276 | * @data_type flag indication if the data is a file, path, inode, nothing... | 280 | * @data_type flag indication if the data is a file, path, inode, nothing... |
281 | * @name the filename, if available | ||
277 | */ | 282 | */ |
278 | struct fsnotify_event *fsnotify_create_event(struct inode *to_tell, __u32 mask, | 283 | struct fsnotify_event *fsnotify_create_event(struct inode *to_tell, __u32 mask, |
279 | void *data, int data_type) | 284 | void *data, int data_type, const char *name) |
280 | { | 285 | { |
281 | struct fsnotify_event *event; | 286 | struct fsnotify_event *event; |
282 | 287 | ||
@@ -285,6 +290,15 @@ struct fsnotify_event *fsnotify_create_event(struct inode *to_tell, __u32 mask, | |||
285 | return NULL; | 290 | return NULL; |
286 | 291 | ||
287 | initialize_event(event); | 292 | initialize_event(event); |
293 | |||
294 | if (name) { | ||
295 | event->file_name = kstrdup(name, GFP_KERNEL); | ||
296 | if (!event->file_name) { | ||
297 | kmem_cache_free(fsnotify_event_cachep, event); | ||
298 | return NULL; | ||
299 | } | ||
300 | event->name_len = strlen(event->file_name); | ||
301 | } | ||
288 | event->to_tell = to_tell; | 302 | event->to_tell = to_tell; |
289 | 303 | ||
290 | switch (data_type) { | 304 | switch (data_type) { |