lockmgr(&sysctl_lock, LK_RELEASE, NULL, p);
lockmgr(&sysctl_lock, LK_RELEASE, NULL);
sys___sysctl(p, v, retval)	struct proc *p;	void *v;	register_t *retval;{	register struct sys___sysctl_args /* {		syscallarg(int *) name;		syscallarg(u_int) namelen;		syscallarg(void *) old;		syscallarg(size_t *) oldlenp;		syscallarg(void *) new;		syscallarg(size_t) newlen;	} */ *uap = v;	int error, dolock = 1;	size_t savelen = 0, oldlen = 0;	sysctlfn *fn;	int name[CTL_MAXNAME];	if (SCARG(uap, new) != NULL &&	    (error = suser(p, 0)))		return (error);	/*	 * all top-level sysctl names are non-terminal	 */	if (SCARG(uap, namelen) > CTL_MAXNAME || SCARG(uap, namelen) < 2)		return (EINVAL);	error = copyin(SCARG(uap, name), name,		       SCARG(uap, namelen) * sizeof(int));	if (error)		return (error);	switch (name[0]) {	case CTL_KERN:		fn = kern_sysctl;		if (name[1] == KERN_VNODE)	/* XXX */			dolock = 0;		break;	case CTL_HW:		fn = hw_sysctl;		break;	case CTL_VM:		fn = uvm_sysctl;		break;	case CTL_NET:		fn = net_sysctl;		break;	case CTL_FS:		fn = fs_sysctl;		break;	case CTL_VFS:		fn = vfs_sysctl;		break;	case CTL_MACHDEP:		fn = cpu_sysctl;		break;#ifdef DEBUG	case CTL_DEBUG:		fn = debug_sysctl;		break;#endif#ifdef DDB	case CTL_DDB:		fn = ddb_sysctl;		break;#endif	default:		return (EOPNOTSUPP);	}	if (SCARG(uap, oldlenp) &&	    (error = copyin(SCARG(uap, oldlenp), &oldlen, sizeof(oldlen))))		return (error);	if (SCARG(uap, old) != NULL) {		if ((error = lockmgr(&sysctl_lock, LK_EXCLUSIVE, NULL, p)) != 0)			return (error);		if (dolock) {			error = uvm_vslock(p, SCARG(uap, old), oldlen,			    VM_PROT_READ|VM_PROT_WRITE);			if (error) {				lockmgr(&sysctl_lock, LK_RELEASE, NULL, p);				return (error);			}		}		savelen = oldlen;	}	error = (*fn)(&name[1], SCARG(uap, namelen) - 1, SCARG(uap, old),	    &oldlen, SCARG(uap, new), SCARG(uap, newlen), p);	if (SCARG(uap, old) != NULL) {		if (dolock)			uvm_vsunlock(p, SCARG(uap, old), savelen);		lockmgr(&sysctl_lock, LK_RELEASE, NULL, p);	}	if (error)		return (error);	if (SCARG(uap, oldlenp))		error = copyout(&oldlen, SCARG(uap, oldlenp), sizeof(oldlen));	return (error);}