From 162ce1a75f68a8b2b1c107fe4a8a30973c8ad0ba Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Sat, 4 Nov 2006 23:59:51 +0000 Subject: [PATCH] When the source and destination objects for VOP_RENAME() are the same, POSIX advice to just ignore the operation and return 0. We already handle this case in kern_rename(), but don't give bad example - the source is not removed. --- share/man/man9/VOP_RENAME.9 | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/share/man/man9/VOP_RENAME.9 b/share/man/man9/VOP_RENAME.9 index 2d8b4508bc85..4c2e58a65a3c 100644 --- a/share/man/man9/VOP_RENAME.9 +++ b/share/man/man9/VOP_RENAME.9 @@ -104,34 +104,13 @@ vop_rename(struct vnode *fdvp, struct vnode *fvp, struct componentname *fcnp, } /* - * Check if just deleting a link name. + * POSIX: "If the old argument and the new argument + * both refer to links to the same existing file, + * the rename() function shall return successfully + * and perform no other action." + * The upper layers already handle this case. */ - if (fvp == tvp) { - if (fvp->v_type == VDIR) { - error = EINVAL; - goto abortit; - } - - /* - * Release destination. - */ - vput(tdvp); - vput(tvp); - - /* - * Delete source. Pretty bizarre stuff. - */ - vrele(fdvp); - vrele(fvp); - fcnp->cn_flags &= ~MODMASK; - fcnp->cn_flags |= LOCKPARENT | LOCKLEAF; - fcnp->cn_nameiop = DELETE; - VREF(fdvp); - error = relookup(fdvp, &fvp, fcnp); - if (error == 0) - vrele(fdvp); - return VOP_REMOVE(fdvp, fvp, fcnp); - } + KASSERT(fvp != tvp, ("vop_rename: source and destination are the same")); if (fvp is immutable) { error = EPERM;