diff options
author | Eric Paris <eparis@redhat.com> | 2009-05-21 17:01:50 -0400 |
---|---|---|
committer | Eric Paris <eparis@redhat.com> | 2009-06-11 14:57:54 -0400 |
commit | e4aff117368cfdd3567ee41844d216d079b55173 (patch) | |
tree | c467bc38edc7ba3154bbf6875dca635b855e1c8c /include | |
parent | 47882c6f51e8ef41fbbe2bbb746a1ea3228dd7ca (diff) |
fsnotify: allow groups to add private data to events
inotify needs per group information attached to events. This patch allows
groups to attach private information and implements a callback so that
information can be freed when an event is being destroyed.
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 'include')
-rw-r--r-- | include/linux/fsnotify_backend.h | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h index b78b5573d227..efdf9e442d86 100644 --- a/include/linux/fsnotify_backend.h +++ b/include/linux/fsnotify_backend.h | |||
@@ -63,6 +63,7 @@ | |||
63 | struct fsnotify_group; | 63 | struct fsnotify_group; |
64 | struct fsnotify_event; | 64 | struct fsnotify_event; |
65 | struct fsnotify_mark_entry; | 65 | struct fsnotify_mark_entry; |
66 | struct fsnotify_event_private_data; | ||
66 | 67 | ||
67 | /* | 68 | /* |
68 | * Each group much define these ops. The fsnotify infrastructure will call | 69 | * Each group much define these ops. The fsnotify infrastructure will call |
@@ -81,6 +82,7 @@ struct fsnotify_ops { | |||
81 | int (*handle_event)(struct fsnotify_group *group, struct fsnotify_event *event); | 82 | int (*handle_event)(struct fsnotify_group *group, struct fsnotify_event *event); |
82 | void (*free_group_priv)(struct fsnotify_group *group); | 83 | void (*free_group_priv)(struct fsnotify_group *group); |
83 | void (*freeing_mark)(struct fsnotify_mark_entry *entry, struct fsnotify_group *group); | 84 | void (*freeing_mark)(struct fsnotify_mark_entry *entry, struct fsnotify_group *group); |
85 | void (*free_event_priv)(struct fsnotify_event_private_data *priv); | ||
84 | }; | 86 | }; |
85 | 87 | ||
86 | /* | 88 | /* |
@@ -158,6 +160,15 @@ struct fsnotify_event_holder { | |||
158 | }; | 160 | }; |
159 | 161 | ||
160 | /* | 162 | /* |
163 | * Inotify needs to tack data onto an event. This struct lets us later find the | ||
164 | * correct private data of the correct group. | ||
165 | */ | ||
166 | struct fsnotify_event_private_data { | ||
167 | struct fsnotify_group *group; | ||
168 | struct list_head event_list; | ||
169 | }; | ||
170 | |||
171 | /* | ||
161 | * all of the information about the original object we want to now send to | 172 | * all of the information about the original object we want to now send to |
162 | * a group. If you want to carry more info from the accessing task to the | 173 | * a group. If you want to carry more info from the accessing task to the |
163 | * listener this structure is where you need to be adding fields. | 174 | * listener this structure is where you need to be adding fields. |
@@ -196,6 +207,8 @@ struct fsnotify_event { | |||
196 | u32 sync_cookie; /* used to corrolate events, namely inotify mv events */ | 207 | u32 sync_cookie; /* used to corrolate events, namely inotify mv events */ |
197 | char *file_name; | 208 | char *file_name; |
198 | size_t name_len; | 209 | size_t name_len; |
210 | |||
211 | struct list_head private_data_list; /* groups can store private data here */ | ||
199 | }; | 212 | }; |
200 | 213 | ||
201 | /* | 214 | /* |
@@ -294,17 +307,18 @@ extern void fsnotify_put_group(struct fsnotify_group *group); | |||
294 | /* take a reference to an event */ | 307 | /* take a reference to an event */ |
295 | extern void fsnotify_get_event(struct fsnotify_event *event); | 308 | extern void fsnotify_get_event(struct fsnotify_event *event); |
296 | extern void fsnotify_put_event(struct fsnotify_event *event); | 309 | extern void fsnotify_put_event(struct fsnotify_event *event); |
297 | /* find private data previously attached to an event */ | 310 | /* find private data previously attached to an event and unlink it */ |
298 | extern struct fsnotify_event_private_data *fsnotify_get_priv_from_event(struct fsnotify_group *group, | 311 | extern struct fsnotify_event_private_data *fsnotify_remove_priv_from_event(struct fsnotify_group *group, |
299 | struct fsnotify_event *event); | 312 | struct fsnotify_event *event); |
300 | 313 | ||
301 | /* attach the event to the group notification queue */ | 314 | /* attach the event to the group notification queue */ |
302 | extern int fsnotify_add_notify_event(struct fsnotify_group *group, struct fsnotify_event *event); | 315 | extern int fsnotify_add_notify_event(struct fsnotify_group *group, struct fsnotify_event *event, |
316 | struct fsnotify_event_private_data *priv); | ||
303 | /* true if the group notification queue is empty */ | 317 | /* true if the group notification queue is empty */ |
304 | extern bool fsnotify_notify_queue_is_empty(struct fsnotify_group *group); | 318 | extern bool fsnotify_notify_queue_is_empty(struct fsnotify_group *group); |
305 | /* return, but do not dequeue the first event on the notification queue */ | 319 | /* return, but do not dequeue the first event on the notification queue */ |
306 | extern struct fsnotify_event *fsnotify_peek_notify_event(struct fsnotify_group *group); | 320 | extern struct fsnotify_event *fsnotify_peek_notify_event(struct fsnotify_group *group); |
307 | /* reutnr AND dequeue the first event on the notification queue */ | 321 | /* return AND dequeue the first event on the notification queue */ |
308 | extern struct fsnotify_event *fsnotify_remove_notify_event(struct fsnotify_group *group); | 322 | extern struct fsnotify_event *fsnotify_remove_notify_event(struct fsnotify_group *group); |
309 | 323 | ||
310 | /* functions used to manipulate the marks attached to inodes */ | 324 | /* functions used to manipulate the marks attached to inodes */ |