From 394739140cd780cd7417ddfc4ba69019ec57f7d6 Mon Sep 17 00:00:00 2001 From: Don Lewis Date: Thu, 19 Sep 2002 13:34:50 +0000 Subject: [PATCH] The file vnode passed to VOP_LINK() should now be locked before the call. --- share/man/man9/VOP_LINK.9 | 36 +++++++----------------------------- 1 file changed, 7 insertions(+), 29 deletions(-) diff --git a/share/man/man9/VOP_LINK.9 b/share/man/man9/VOP_LINK.9 index e87ee530ddd..7c355ddbc2b 100644 --- a/share/man/man9/VOP_LINK.9 +++ b/share/man/man9/VOP_LINK.9 @@ -56,15 +56,9 @@ The pathname info should NOT be released on exit because it is done by the caller. The directory and file vnodes should NOT be released on exit. .Sh LOCKS -The directory, -.Fa dvp -is locked on entry and should remain locked on return. -The file -.Fa vp -is not locked on entry and should remain that way on return. -If your VOP code locks -.Fa vp , -it must be sure to unlock prior to returning. +.Xr VOP_LINK 9 +expects the directory and file vnodes to be locked on entry and will leave +the vnodes locked on return. .Sh RETURN VALUES Zero is returned if the file was linked successfully, otherwise an error is returned. @@ -77,23 +71,12 @@ vop_link(struct vnode *dvp, struct vnode *vp, struct componentname *cnp) if (vp->v_mount != dvp->v_mount) return (EXDEV); - if (vp != dvp && (error = VOP_LOCK(vp))) { - goto out2; - } - /* - * now that we've locked vp, we have to use out1 instead of out2 - */ + if (vp would have too many links) + return (EMLINK); - if (vp would have too many links) { - error = EMLINK; - goto out1; - } - - if (vp is immutable) { - error = EPERM; - goto out1; - } + if (vp is immutable) + return (EPERM); /* * Increment link count of vp and write back the on-disc version of it. @@ -107,11 +90,6 @@ vop_link(struct vnode *dvp, struct vnode *vp, struct componentname *cnp) ...; } -out1: - if (vp != dvp) - VOP_UNLOCK(vp); -out2: - return error; } .Ed