diff options
-rw-r--r-- | fs/notify/notification.c | 29 | ||||
-rw-r--r-- | include/linux/fsnotify_backend.h | 3 |
2 files changed, 28 insertions, 4 deletions
diff --git a/fs/notify/notification.c b/fs/notify/notification.c index 6dc96b35e4a7..bc9470c7ece7 100644 --- a/fs/notify/notification.c +++ b/fs/notify/notification.c | |||
@@ -284,11 +284,33 @@ static void initialize_event(struct fsnotify_event *event) | |||
284 | 284 | ||
285 | spin_lock_init(&event->lock); | 285 | spin_lock_init(&event->lock); |
286 | 286 | ||
287 | event->data_type = FSNOTIFY_EVENT_NONE; | ||
288 | |||
289 | INIT_LIST_HEAD(&event->private_data_list); | 287 | INIT_LIST_HEAD(&event->private_data_list); |
290 | } | 288 | } |
291 | 289 | ||
290 | struct fsnotify_event *fsnotify_clone_event(struct fsnotify_event *old_event) | ||
291 | { | ||
292 | struct fsnotify_event *event; | ||
293 | |||
294 | event = kmem_cache_alloc(fsnotify_event_cachep, GFP_KERNEL); | ||
295 | if (!event) | ||
296 | return NULL; | ||
297 | |||
298 | memcpy(event, old_event, sizeof(*event)); | ||
299 | initialize_event(event); | ||
300 | |||
301 | if (event->name_len) { | ||
302 | event->file_name = kstrdup(old_event->file_name, GFP_KERNEL); | ||
303 | if (!event->file_name) { | ||
304 | kmem_cache_free(fsnotify_event_cachep, event); | ||
305 | return NULL; | ||
306 | } | ||
307 | } | ||
308 | if (event->data_type == FSNOTIFY_EVENT_PATH) | ||
309 | path_get(&event->path); | ||
310 | |||
311 | return event; | ||
312 | } | ||
313 | |||
292 | /* | 314 | /* |
293 | * fsnotify_create_event - Allocate a new event which will be sent to each | 315 | * fsnotify_create_event - Allocate a new event which will be sent to each |
294 | * group's handle_event function if the group was interested in this | 316 | * group's handle_event function if the group was interested in this |
@@ -324,6 +346,7 @@ struct fsnotify_event *fsnotify_create_event(struct inode *to_tell, __u32 mask, | |||
324 | 346 | ||
325 | event->sync_cookie = cookie; | 347 | event->sync_cookie = cookie; |
326 | event->to_tell = to_tell; | 348 | event->to_tell = to_tell; |
349 | event->data_type = data_type; | ||
327 | 350 | ||
328 | switch (data_type) { | 351 | switch (data_type) { |
329 | case FSNOTIFY_EVENT_FILE: { | 352 | case FSNOTIFY_EVENT_FILE: { |
@@ -340,12 +363,10 @@ struct fsnotify_event *fsnotify_create_event(struct inode *to_tell, __u32 mask, | |||
340 | event->path.dentry = path->dentry; | 363 | event->path.dentry = path->dentry; |
341 | event->path.mnt = path->mnt; | 364 | event->path.mnt = path->mnt; |
342 | path_get(&event->path); | 365 | path_get(&event->path); |
343 | event->data_type = FSNOTIFY_EVENT_PATH; | ||
344 | break; | 366 | break; |
345 | } | 367 | } |
346 | case FSNOTIFY_EVENT_INODE: | 368 | case FSNOTIFY_EVENT_INODE: |
347 | event->inode = data; | 369 | event->inode = data; |
348 | event->data_type = FSNOTIFY_EVENT_INODE; | ||
349 | break; | 370 | break; |
350 | case FSNOTIFY_EVENT_NONE: | 371 | case FSNOTIFY_EVENT_NONE: |
351 | event->inode = NULL; | 372 | event->inode = NULL; |
diff --git a/include/linux/fsnotify_backend.h b/include/linux/fsnotify_backend.h index 25789d45fad8..3a7fff235539 100644 --- a/include/linux/fsnotify_backend.h +++ b/include/linux/fsnotify_backend.h | |||
@@ -363,6 +363,9 @@ extern struct fsnotify_event *fsnotify_create_event(struct inode *to_tell, __u32 | |||
363 | void *data, int data_is, const char *name, | 363 | void *data, int data_is, const char *name, |
364 | u32 cookie, gfp_t gfp); | 364 | u32 cookie, gfp_t gfp); |
365 | 365 | ||
366 | /* fanotify likes to change events after they are on lists... */ | ||
367 | extern struct fsnotify_event *fsnotify_clone_event(struct fsnotify_event *old_event); | ||
368 | |||
366 | #else | 369 | #else |
367 | 370 | ||
368 | static inline void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is, | 371 | static inline void fsnotify(struct inode *to_tell, __u32 mask, void *data, int data_is, |