Index: sys/fs/autofs/autofs_vnops.c =================================================================== --- sys/fs/autofs/autofs_vnops.c +++ sys/fs/autofs/autofs_vnops.c @@ -214,7 +214,7 @@ struct autofs_mount *amp; struct autofs_node *anp, *child; struct componentname *cnp; - int error, lock_flags; + int error; dvp = ap->a_dvp; vpp = ap->a_vpp; @@ -257,23 +257,17 @@ return (error); if (newvp != NULL) { - error = VOP_LOOKUP(newvp, ap->a_vpp, ap->a_cnp); - /* - * Instead of figuring out whether our vnode should - * be locked or not given the error and cnp flags, - * just "copy" the lock status from vnode returned - * by mounted filesystem's VOP_LOOKUP(). Get rid - * of that new vnode afterwards. + * The target filesystem got automounted. Make + * the lookup(9) go around with a new parent vnode + * and the same path component. */ - lock_flags = VOP_ISLOCKED(newvp); - if (lock_flags == 0) { - VOP_UNLOCK(dvp, 0); - vrele(newvp); - } else { - vput(newvp); - } - return (error); + cnp->cn_consume = -(cnp->cn_namelen + 1); + vput(newvp); + vref(dvp); + *vpp = dvp; + + return (0); } } Index: sys/kern/vfs_lookup.c =================================================================== --- sys/kern/vfs_lookup.c +++ sys/kern/vfs_lookup.c @@ -784,7 +784,7 @@ * Take into account any additional components consumed by * the underlying filesystem. */ - if (cnp->cn_consume > 0) { + if (cnp->cn_consume != 0) { cnp->cn_nameptr += cnp->cn_consume; ndp->ni_next += cnp->cn_consume; ndp->ni_pathlen -= cnp->cn_consume;