diff options
Diffstat (limited to 'fs/inotify.c')
-rw-r--r-- | fs/inotify.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/fs/inotify.c b/fs/inotify.c index 7457501b9565..2c5b92152876 100644 --- a/fs/inotify.c +++ b/fs/inotify.c | |||
@@ -667,6 +667,49 @@ 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 | void inotify_evict_watch(struct inotify_watch *watch) | ||
705 | { | ||
706 | get_inotify_watch(watch); | ||
707 | mutex_lock(&watch->ih->mutex); | ||
708 | inotify_remove_watch_locked(watch->ih, watch); | ||
709 | mutex_unlock(&watch->ih->mutex); | ||
710 | } | ||
711 | |||
712 | /** | ||
670 | * inotify_rm_wd - remove a watch from an inotify instance | 713 | * inotify_rm_wd - remove a watch from an inotify instance |
671 | * @ih: inotify handle | 714 | * @ih: inotify handle |
672 | * @wd: watch descriptor to remove | 715 | * @wd: watch descriptor to remove |