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 /fs | |
parent | 8aec08094570562bc305df33b088926d983c3540 (diff) |
[PATCH] new helper - inotify_clone_watch()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/inotify.c | 35 |
1 files changed, 35 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 |