Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 May 2014 11:15:38 +0000 (UTC)
From:      Aleksandr Rybalko <ray@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r266495 - head/sys/dev/vt
Message-ID:  <201405211115.s4LBFcPw057532@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ray
Date: Wed May 21 11:15:38 2014
New Revision: 266495
URL: http://svnweb.freebsd.org/changeset/base/266495

Log:
  Fix tty locking.
  o Correct expected values for VT_LOCKSWITCH ioctl.
  o Check current window for locked state.
  
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/sys/dev/vt/vt_core.c

Modified: head/sys/dev/vt/vt_core.c
==============================================================================
--- head/sys/dev/vt/vt_core.c	Wed May 21 10:04:51 2014	(r266494)
+++ head/sys/dev/vt/vt_core.c	Wed May 21 11:15:38 2014	(r266495)
@@ -280,12 +280,12 @@ vt_proc_window_switch(struct vt_window *
 	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 @@ skip_thunk:
 		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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201405211115.s4LBFcPw057532>