Fix tty locking.

o Correct expected values for VT_LOCKSWITCH ioctl.
o Check current window for locked state.

Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Aleksandr Rybalko 2014-05-21 11:15:38 +00:00
parent c4f55e08be
commit 7ee92f6e08

View File

@ -280,12 +280,12 @@ vt_proc_window_switch(struct vt_window *vw)
struct vt_device *vd;
int ret;
if (vw->vw_flags & VWF_VTYLOCK)
return (EBUSY);
vd = vw->vw_device;
curvw = vd->vd_curwindow;
if (curvw->vw_flags & VWF_VTYLOCK)
return (EBUSY);
/* Ask current process permitions to switch away. */
if (curvw->vw_smode.mode == VT_PROCESS) {
DPRINTF(30, "%s: VT_PROCESS ", __func__);
@ -1814,10 +1814,12 @@ vtterm_ioctl(struct terminal *tm, u_long cmd, caddr_t data,
return (0);
case VT_LOCKSWITCH:
/* TODO: Check current state, switching can be in progress. */
if ((*(int *)data) & 0x01)
if ((*(int *)data) == 0x01)
vw->vw_flags &= ~VWF_VTYLOCK;
else if ((*(int *)data) == 0x02)
vw->vw_flags |= VWF_VTYLOCK;
else
vw->vw_flags &= ~VWF_VTYLOCK;
return (EINVAL);
return (0);
case VT_OPENQRY:
VT_LOCK(vd);