Re: ioctls,verify_area,ENOTTY

Tim Wright (timw@sequent.com)
Tue, 23 Apr 1996 17:48:47 PDT


In message <199604191534.LAA29271@krakatoa.ccs.neu.edu>,Albert Cahalan writes:
> > I would like to bring to your attention that POSIX.1 expects
> > certain errno values for certain situations. In the kernel source
> >
> > ENODEV is often used instead of ENXIO
> > EINVAL is often used instead of ENOTTY
>
> POSIX is broken.
>

In your opinion.

It does however allow people to write portable programs that work with a
minimum of fuss on many platforms. That alone should be sufficient reason
to make the kernel return the errno specified by POSIX.1.

In fact, ENODEV goes back a *long* way. It is there from the old days of
bdevsw[]/cdevsw[] where you might have a devwrite(), but no devread(). In
that case, devread() would be set to nodev() which returned ENODEV.

So, even historically, ENXIO is quite different to ENODEV. ENODEV doesn't mean
no such device, it means no valid entry in the devsw table (yes, the name
is poorly chosen). ENXIO means a bad major/minor number.

The ENOTTY is a bit gross. It's there because (at least in SVR3), it's returned
if you try to do an ioctl to link and xt or sxt device to a tty and the thing
you're linking to isn't a tty. They don't return EINVAL since that signifies
a different error. This was probably overkill, especially since the xt/sxt
drivers never worked correctly, but POSIX embraced it (probably at gunpoint !).

t

--
Tim Wright, Worldwide Technical Services,         |  Email: timw@sequent.com
Sequent Computer Systems Inc., 15450,             |
SW Koll Parkway, Beaverton, Oregon 97006          |  Phone: +1-503-578-3822
"Nobody ever said I was charming, they said "Rimmer, you're a git!"" RD VI