Changeset View
Changeset View
Standalone View
Standalone View
sys/fs/devfs/devfs_vnops.c
Show First 20 Lines • Show All 590 Lines • ▼ Show 20 Lines | devfs_close(struct vop_close_args *ap) | ||||
* plus the session), release the reference from the session. | * plus the session), release the reference from the session. | ||||
*/ | */ | ||||
if (td != NULL) { | if (td != NULL) { | ||||
p = td->td_proc; | p = td->td_proc; | ||||
PROC_LOCK(p); | PROC_LOCK(p); | ||||
if (vp == p->p_session->s_ttyvp) { | if (vp == p->p_session->s_ttyvp) { | ||||
PROC_UNLOCK(p); | PROC_UNLOCK(p); | ||||
oldvp = NULL; | oldvp = NULL; | ||||
sx_xlock(&proctree_lock); | sx_xlock(&V_proctree_lock); | ||||
if (vp == p->p_session->s_ttyvp) { | if (vp == p->p_session->s_ttyvp) { | ||||
SESS_LOCK(p->p_session); | SESS_LOCK(p->p_session); | ||||
VI_LOCK(vp); | VI_LOCK(vp); | ||||
if (count_dev(dev) == 2 && | if (count_dev(dev) == 2 && | ||||
(vp->v_iflag & VI_DOOMED) == 0) { | (vp->v_iflag & VI_DOOMED) == 0) { | ||||
p->p_session->s_ttyvp = NULL; | p->p_session->s_ttyvp = NULL; | ||||
p->p_session->s_ttydp = NULL; | p->p_session->s_ttydp = NULL; | ||||
oldvp = vp; | oldvp = vp; | ||||
} | } | ||||
VI_UNLOCK(vp); | VI_UNLOCK(vp); | ||||
SESS_UNLOCK(p->p_session); | SESS_UNLOCK(p->p_session); | ||||
} | } | ||||
sx_xunlock(&proctree_lock); | sx_xunlock(&V_proctree_lock); | ||||
if (oldvp != NULL) | if (oldvp != NULL) | ||||
vrele(oldvp); | vrele(oldvp); | ||||
} else | } else | ||||
PROC_UNLOCK(p); | PROC_UNLOCK(p); | ||||
} | } | ||||
/* | /* | ||||
* We do not want to really close the device if it | * We do not want to really close the device if it | ||||
* is still in use unless we are trying to close it | * is still in use unless we are trying to close it | ||||
▲ Show 20 Lines • Show All 187 Lines • ▼ Show 20 Lines | |||||
out: | out: | ||||
dev_relthread(dev, ref); | dev_relthread(dev, ref); | ||||
if (error == ENOIOCTL) | if (error == ENOIOCTL) | ||||
error = ENOTTY; | error = ENOTTY; | ||||
if (error == 0 && com == TIOCSCTTY) { | if (error == 0 && com == TIOCSCTTY) { | ||||
/* Do nothing if reassigning same control tty */ | /* Do nothing if reassigning same control tty */ | ||||
sx_slock(&proctree_lock); | sx_slock(&V_proctree_lock); | ||||
if (td->td_proc->p_session->s_ttyvp == vp) { | if (td->td_proc->p_session->s_ttyvp == vp) { | ||||
sx_sunlock(&proctree_lock); | sx_sunlock(&V_proctree_lock); | ||||
return (0); | return (0); | ||||
} | } | ||||
vpold = td->td_proc->p_session->s_ttyvp; | vpold = td->td_proc->p_session->s_ttyvp; | ||||
VREF(vp); | VREF(vp); | ||||
SESS_LOCK(td->td_proc->p_session); | SESS_LOCK(td->td_proc->p_session); | ||||
td->td_proc->p_session->s_ttyvp = vp; | td->td_proc->p_session->s_ttyvp = vp; | ||||
td->td_proc->p_session->s_ttydp = cdev2priv(dev); | td->td_proc->p_session->s_ttydp = cdev2priv(dev); | ||||
SESS_UNLOCK(td->td_proc->p_session); | SESS_UNLOCK(td->td_proc->p_session); | ||||
sx_sunlock(&proctree_lock); | sx_sunlock(&V_proctree_lock); | ||||
/* Get rid of reference to old control tty */ | /* Get rid of reference to old control tty */ | ||||
if (vpold) | if (vpold) | ||||
vrele(vpold); | vrele(vpold); | ||||
} | } | ||||
return (error); | return (error); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,129 Lines • Show Last 20 Lines |