Subject: Re: ioctl and EOPNOTSUPP
To: None <>
From: Simon Burge <>
List: tech-kern
Date: 06/05/2003 11:34:54
On Thu, Jun 05, 2003 at 01:00:33AM +0200, Klaus Klein wrote:

> David Laight <> writes:
> > There ought to be a note that effect of ioctl() on non-STREAMS fds
> > is 'undefined' (in this case including formating the hard disk!)
> Actually, it is merely 'unspecified'.

The case in point is a posix test suite entry, where it trys isatty()
on /dev/null. isatty() is listed in the spec (I'm pasting from SUSv3)
as only returning:

          The fildes argument is not a valid open file descriptor.
          The fildes argument is not associated with a terminal.

For NetBSD, we use tcgetattr() to implement isatty(), and SUSv3 again
only lists those two errors.  Further, we use ioctl() to implement
tcgetattr().  In SUSv3, neither isatty() nor tcgetattr() care about
STREAMS, only ioctl().

I can think of three choices:

 1- Have ioctl() return ENOTTY and not EOPNOTSUPP.

 2- Have tcgetattr() explicitly check for non-EBADF/ENOTTY error
    codes and set errno to ENOTTY.

 3- Ignore the standard.

I'm tempting towards 2, given the apparent usefulness that a number of
folks have mentioned of ioctl() being able to return EOPNOTSUPP (and
given that ENOTTY seems to be only mandated by SUSv3 for STREAMS fds
we're still in-spec (I think :-)).

Simon Burge                                   <>
NetBSD Development, Support and Service: