diff options
author | kib <kib@FreeBSD.org> | 2016-05-02 13:13:32 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2016-05-02 13:13:32 +0000 |
commit | 5bc5df16639fd16299b315b38cdba281bf17a539 (patch) | |
tree | 77b99af90f8fbc7629d62d4ee5b4ca64ea7b8391 /sys/kern | |
parent | 0e2c2a615d6758c383ba050a494d83f9f1967482 (diff) | |
download | FreeBSD-src-5bc5df16639fd16299b315b38cdba281bf17a539.zip FreeBSD-src-5bc5df16639fd16299b315b38cdba281bf17a539.tar.gz |
Fix reporting of NOTE_LINK when directory link count changes due to
rename removing or adding subdirectory entry.
Discussed with and tested by: Vladimir Kondratyev <wulf@cicgroup.ru>
NetBSD PR: 48958 (http://gnats.netbsd.org/48958)
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/vfs_subr.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index a81fce3..e1711ea 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -4650,10 +4650,26 @@ void vop_rename_post(void *ap, int rc) { struct vop_rename_args *a = ap; + long hint; if (!rc) { - VFS_KNOTE_UNLOCKED(a->a_fdvp, NOTE_WRITE); - VFS_KNOTE_UNLOCKED(a->a_tdvp, NOTE_WRITE); + hint = NOTE_WRITE; + if (a->a_fdvp == a->a_tdvp) { + if (a->a_tvp != NULL && a->a_tvp->v_type == VDIR) + hint |= NOTE_LINK; + VFS_KNOTE_UNLOCKED(a->a_fdvp, hint); + VFS_KNOTE_UNLOCKED(a->a_tdvp, hint); + } else { + if (a->a_fvp->v_type == VDIR) + hint |= NOTE_LINK; + VFS_KNOTE_UNLOCKED(a->a_fdvp, hint); + + if (a->a_fvp->v_type == VDIR && a->a_tvp != NULL && + a->a_tvp->v_type == VDIR) + hint &= ~NOTE_LINK; + VFS_KNOTE_UNLOCKED(a->a_tdvp, hint); + } + VFS_KNOTE_UNLOCKED(a->a_fvp, NOTE_RENAME); if (a->a_tvp) VFS_KNOTE_UNLOCKED(a->a_tvp, NOTE_DELETE); |