Squash some small bugs in pts(4).

- Don't return a negative errno when using an unknown ioctl() on a
  pseudo-terminal master device. Be sure to convert ENOIOCTL to ENOTTY,
  just like the TTY layer does.

- Even though we should return st_rdev of the master device node when
  emulating pty(4) devices, FIODGNAME should still return the name of
  the slave device. Otherwise ptsname(3) and ttyname(3) return an
  invalid device name.
This commit is contained in:
Ed Schouten 2009-02-19 17:54:42 +00:00
parent 24a07b5b23
commit 40d05103d8

View File

@ -290,12 +290,7 @@ ptsdev_ioctl(struct file *fp, u_long cmd, void *data,
/* Reverse device name lookups, for ptsname() and ttyname(). */
fgn = data;
#ifdef PTS_EXTERNAL
if (psc->pts_cdev != NULL)
p = devtoname(psc->pts_cdev);
else
#endif /* PTS_EXTERNAL */
p = tty_devname(tp);
p = tty_devname(tp);
i = strlen(p) + 1;
if (i > fgn->len)
return (EINVAL);
@ -385,6 +380,8 @@ ptsdev_ioctl(struct file *fp, u_long cmd, void *data,
tty_lock(tp);
error = tty_ioctl(tp, cmd, data, td);
tty_unlock(tp);
if (error == ENOIOCTL)
error = ENOTTY;
return (error);
}