aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2009-10-18 19:45:44 +0000
committerEd Schouten <ed@FreeBSD.org>2009-10-18 19:45:44 +0000
commit99087885be1051d788b71bd67f1cdf5fa146a352 (patch)
tree759b70ca7082727ef2289f526d88b6097a344142
parentc7e1669396026eb0e379681cd3d9f0c2c4f4eaf8 (diff)
downloadsrc-99087885be1051d788b71bd67f1cdf5fa146a352.tar.gz
src-99087885be1051d788b71bd67f1cdf5fa146a352.zip
Make lock devices work properly.
It turned out I did add the code to use the init state devices to set the termios structure when opening the device, but it seems I totally forgot to add the bits required to force the actual locking of flags through the lock state devices. Reported by: ru MFC after: 1 week (to be discussed)
Notes
Notes: svn path=/head/; revision=198213
-rw-r--r--sys/kern/tty.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index 6990b8ff94fe..25908df8acc1 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -523,6 +523,34 @@ ttydev_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag,
goto done;
}
+ if (cmd == TIOCSETA || cmd == TIOCSETAW || cmd == TIOCSETAF) {
+ struct termios *old = &tp->t_termios;
+ struct termios *new = (struct termios *)data;
+ struct termios *lock = TTY_CALLOUT(tp, dev) ?
+ &tp->t_termios_lock_out : &tp->t_termios_lock_in;
+ int cc;
+
+ /*
+ * Lock state devices. Just overwrite the values of the
+ * commands that are currently in use.
+ */
+ new->c_iflag = (old->c_iflag & lock->c_iflag) |
+ (new->c_iflag & ~lock->c_iflag);
+ new->c_oflag = (old->c_oflag & lock->c_oflag) |
+ (new->c_oflag & ~lock->c_oflag);
+ new->c_cflag = (old->c_cflag & lock->c_cflag) |
+ (new->c_cflag & ~lock->c_cflag);
+ new->c_lflag = (old->c_lflag & lock->c_lflag) |
+ (new->c_lflag & ~lock->c_lflag);
+ for (cc = 0; cc < NCCS; ++cc)
+ if (lock->c_cc[cc])
+ new->c_cc[cc] = old->c_cc[cc];
+ if (lock->c_ispeed)
+ new->c_ispeed = old->c_ispeed;
+ if (lock->c_ospeed)
+ new->c_ospeed = old->c_ospeed;
+ }
+
error = tty_ioctl(tp, cmd, data, td);
done: tty_unlock(tp);