diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2007-06-07 12:21:44 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2007-10-21 02:37:32 -0400 |
commit | b9efe8a234ad874a049460417c54680338f96360 (patch) | |
tree | bf058a173388d825bbc74225fe08f87ad27adcdc | |
parent | 8aec08094570562bc305df33b088926d983c3540 (diff) |
[PATCH] new helper - inotify_clone_watch()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/inotify.c | 35 | ||||
-rw-r--r-- | include/linux/inotify.h | 1 |
2 files changed, 36 insertions, 0 deletions
diff --git a/fs/inotify.c b/fs/inotify.c index 7457501b9565..4b2469bb6554 100644 --- a/fs/inotify.c +++ b/fs/inotify.c | |||
@@ -667,6 +667,41 @@ out: | |||
667 | EXPORT_SYMBOL_GPL(inotify_add_watch); | 667 | EXPORT_SYMBOL_GPL(inotify_add_watch); |
668 | 668 | ||
669 | /** | 669 | /** |
670 | * inotify_clone_watch - put the watch next to existing one | ||
671 | * @old: already installed watch | ||
672 | * @new: new watch | ||
673 | * | ||
674 | * Caller must hold the inotify_mutex of inode we are dealing with; | ||
675 | * it is expected to remove the old watch before unlocking the inode. | ||
676 | */ | ||
677 | s32 inotify_clone_watch(struct inotify_watch *old, struct inotify_watch *new) | ||
678 | { | ||
679 | struct inotify_handle *ih = old->ih; | ||
680 | int ret = 0; | ||
681 | |||
682 | new->mask = old->mask; | ||
683 | new->ih = ih; | ||
684 | |||
685 | mutex_lock(&ih->mutex); | ||
686 | |||
687 | /* Initialize a new watch */ | ||
688 | ret = inotify_handle_get_wd(ih, new); | ||
689 | if (unlikely(ret)) | ||
690 | goto out; | ||
691 | ret = new->wd; | ||
692 | |||
693 | get_inotify_handle(ih); | ||
694 | |||
695 | new->inode = igrab(old->inode); | ||
696 | |||
697 | list_add(&new->h_list, &ih->watches); | ||
698 | list_add(&new->i_list, &old->inode->inotify_watches); | ||
699 | out: | ||
700 | mutex_unlock(&ih->mutex); | ||
701 | return ret; | ||
702 | } | ||
703 | |||
704 | /** | ||
670 | * inotify_rm_wd - remove a watch from an inotify instance | 705 | * inotify_rm_wd - remove a watch from an inotify instance |
671 | * @ih: inotify handle | 706 | * @ih: inotify handle |
672 | * @wd: watch descriptor to remove | 707 | * @wd: watch descriptor to remove |
diff --git a/include/linux/inotify.h b/include/linux/inotify.h index d4f48c6402e6..e76e2272e2ab 100644 --- a/include/linux/inotify.h +++ b/include/linux/inotify.h | |||
@@ -120,6 +120,7 @@ extern __s32 inotify_find_update_watch(struct inotify_handle *, struct inode *, | |||
120 | u32); | 120 | u32); |
121 | extern __s32 inotify_add_watch(struct inotify_handle *, struct inotify_watch *, | 121 | extern __s32 inotify_add_watch(struct inotify_handle *, struct inotify_watch *, |
122 | struct inode *, __u32); | 122 | struct inode *, __u32); |
123 | extern __s32 inotify_clone_watch(struct inotify_watch *, struct inotify_watch *); | ||
123 | extern int inotify_rm_watch(struct inotify_handle *, struct inotify_watch *); | 124 | extern int inotify_rm_watch(struct inotify_handle *, struct inotify_watch *); |
124 | extern int inotify_rm_wd(struct inotify_handle *, __u32); | 125 | extern int inotify_rm_wd(struct inotify_handle *, __u32); |
125 | extern void inotify_remove_watch_locked(struct inotify_handle *, | 126 | extern void inotify_remove_watch_locked(struct inotify_handle *, |