Subject: Re: ioctl and EOPNOTSUPP
To: None <tech-kern@netbsd.org>
From: Simon Burge <simonb@wasabisystems.com>
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 <david@l8s.co.uk> 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:
[EBADF]
The fildes argument is not a valid open file descriptor.
[ENOTTY]
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.
--
Simon Burge <simonb@wasabisystems.com>
NetBSD Development, Support and Service: http://www.wasabisystems.com/