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);
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to