aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/tty.c
diff options
context:
space:
mode:
authorPeter Holm <pho@FreeBSD.org>2012-06-18 07:34:38 +0000
committerPeter Holm <pho@FreeBSD.org>2012-06-18 07:34:38 +0000
commite84a11e7ff58c3e8c2d2e932c55c54249ef3fc1c (patch)
tree27c833177cccfff2a3e52b545b9cec7acc615af7 /sys/kern/tty.c
parent8a3860d5b4974d6e5d007a310ca0a806194fac77 (diff)
downloadsrc-e84a11e7ff58c3e8c2d2e932c55c54249ef3fc1c.tar.gz
src-e84a11e7ff58c3e8c2d2e932c55c54249ef3fc1c.zip
Notes
Diffstat (limited to 'sys/kern/tty.c')
-rw-r--r--sys/kern/tty.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index 7ddcb0bc390f..e9c0fb6fe554 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -219,9 +219,15 @@ ttydev_leave(struct tty *tp)
static int
ttydev_open(struct cdev *dev, int oflags, int devtype, struct thread *td)
{
- struct tty *tp = dev->si_drv1;
+ struct tty *tp;
int error = 0;
+ while ((tp = dev->si_drv1) == NULL) {
+ error = tsleep(&dev->si_drv1, PCATCH, "ttdrv1", 1);
+ if (error != EWOULDBLOCK)
+ return (error);
+ }
+
tty_lock(tp);
if (tty_gone(tp)) {
/* Device is already gone. */
@@ -738,9 +744,14 @@ static struct cdevsw ttydev_cdevsw = {
static int
ttyil_open(struct cdev *dev, int oflags, int devtype, struct thread *td)
{
- struct tty *tp = dev->si_drv1;
+ struct tty *tp;
int error = 0;
+ while ((tp = dev->si_drv1) == NULL) {
+ error = tsleep(&dev->si_drv1, PCATCH, "ttdrv1", 1);
+ if (error != EWOULDBLOCK)
+ return (error);
+ }
tty_lock(tp);
if (tty_gone(tp))
error = ENODEV;
@@ -1203,6 +1214,7 @@ tty_makedev(struct tty *tp, struct ucred *cred, const char *fmt, ...)
dev = make_dev_cred(&ttydev_cdevsw, 0, cred,
uid, gid, mode, "%s%s", prefix, name);
dev->si_drv1 = tp;
+ wakeup(&dev->si_drv1);
tp->t_dev = dev;
/* Slave call-in devices. */
@@ -1211,12 +1223,14 @@ tty_makedev(struct tty *tp, struct ucred *cred, const char *fmt, ...)
uid, gid, mode, "%s%s.init", prefix, name);
dev_depends(tp->t_dev, dev);
dev->si_drv1 = tp;
+ wakeup(&dev->si_drv1);
dev->si_drv2 = &tp->t_termios_init_in;
dev = make_dev_cred(&ttyil_cdevsw, TTYUNIT_LOCK, cred,
uid, gid, mode, "%s%s.lock", prefix, name);
dev_depends(tp->t_dev, dev);
dev->si_drv1 = tp;
+ wakeup(&dev->si_drv1);
dev->si_drv2 = &tp->t_termios_lock_in;
}
@@ -1226,6 +1240,7 @@ tty_makedev(struct tty *tp, struct ucred *cred, const char *fmt, ...)
UID_UUCP, GID_DIALER, 0660, "cua%s", name);
dev_depends(tp->t_dev, dev);
dev->si_drv1 = tp;
+ wakeup(&dev->si_drv1);
/* Slave call-out devices. */
if (tp->t_flags & TF_INITLOCK) {
@@ -1234,6 +1249,7 @@ tty_makedev(struct tty *tp, struct ucred *cred, const char *fmt, ...)
UID_UUCP, GID_DIALER, 0660, "cua%s.init", name);
dev_depends(tp->t_dev, dev);
dev->si_drv1 = tp;
+ wakeup(&dev->si_drv1);
dev->si_drv2 = &tp->t_termios_init_out;
dev = make_dev_cred(&ttyil_cdevsw,
@@ -1241,6 +1257,7 @@ tty_makedev(struct tty *tp, struct ucred *cred, const char *fmt, ...)
UID_UUCP, GID_DIALER, 0660, "cua%s.lock", name);
dev_depends(tp->t_dev, dev);
dev->si_drv1 = tp;
+ wakeup(&dev->si_drv1);
dev->si_drv2 = &tp->t_termios_lock_out;
}
}