diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-11-30 21:41:06 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-11-30 21:41:06 +0000 |
commit | 116b060cf4dba89b6c66be82029f24526198d4bb (patch) | |
tree | 42e0f059b84d8f70c6bacecf27e972373fb77adc | |
parent | 850508827a6abe22b9653b81bc36aaa3f0df9912 (diff) |
fix TIOCGPGRP in sunos emulation
-rw-r--r-- | sys/compat/sunos/sunos_ioctl.c | 23 | ||||
-rw-r--r-- | sys/kern/tty_pty.c | 15 |
2 files changed, 33 insertions, 5 deletions
diff --git a/sys/compat/sunos/sunos_ioctl.c b/sys/compat/sunos/sunos_ioctl.c index c3f775191ef..e52a1d3066e 100644 --- a/sys/compat/sunos/sunos_ioctl.c +++ b/sys/compat/sunos/sunos_ioctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sunos_ioctl.c,v 1.4 1996/04/18 21:21:44 niklas Exp $ */ +/* $OpenBSD: sunos_ioctl.c,v 1.5 1997/11/30 21:41:05 deraadt Exp $ */ /* $NetBSD: sunos_ioctl.c,v 1.23 1996/03/14 19:33:46 christos Exp $ */ /* @@ -476,12 +476,27 @@ sunos_sys_ioctl(p, v, retval) return copyout ((caddr_t)&ss, SCARG(uap, data), sizeof (ss)); } - case _IOW('t', 130, int): + case _IOW('t', 130, int): /* TIOCSETPGRP: posix variant */ SCARG(uap, com) = TIOCSPGRP; break; case _IOR('t', 131, int): - SCARG(uap, com) = TIOCGPGRP; - break; + { + /* + * sigh, must do error translation on pty devices + * (see also kern/tty_pty.c) + */ + int pgrp; + struct vnode *vp; + error = (*ctl)(fp, TIOCGPGRP, (caddr_t)&pgrp, p); + if (error) { + vp = (struct vnode *)fp->f_data; + if (error == EIO && vp != NULL && + vp->v_type == VCHR && major(vp->v_rdev) == 21) + error = ENOTTY; + return (error); + } + return copyout((caddr_t)&pgrp, SCARG(uap, data), sizeof(pgrp)); + } case _IO('t', 132): SCARG(uap, com) = TIOCSCTTY; break; diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c index bc1b1c8604a..7b37313b565 100644 --- a/sys/kern/tty_pty.c +++ b/sys/kern/tty_pty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty_pty.c,v 1.6 1997/11/13 03:11:17 millert Exp $ */ +/* $OpenBSD: tty_pty.c,v 1.7 1997/11/30 21:41:03 deraadt Exp $ */ /* $NetBSD: tty_pty.c,v 1.33.4.1 1996/06/02 09:08:11 mrg Exp $ */ /* @@ -616,6 +616,19 @@ ptyioctl(dev, cmd, data, flag, p) switch (cmd) { case TIOCGPGRP: +#ifdef COMPAT_SUNOS + { + /* + * I'm not sure about SunOS TIOCGPGRP semantics + * on PTYs, but it's something like this: + */ + extern struct emul emul_sunos; + if (p->p_emul == &emul_sunos && tp->t_pgrp == 0) + return (EIO); + *(int *)data = tp->t_pgrp->pg_id; + return (0); + } +#endif /* * We aviod calling ttioctl on the controller since, * in that case, tp must be the controlling terminal. |