Subject: Re: ENXIO or ENODEV when r-opening a w-only device?
To: Chapman Flack <nblists@anastigmatix.net>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 01/04/2006 16:47:29
--vOmOzSkFvhd7u8Ms
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Jan 04, 2006 at 05:45:52PM -0500, Chapman Flack wrote:
> What would be the preferable error to return
> on open for reading of a write-only device?
>=20
> >From man 2 intro:
>=20
> 6 ENXIO No such device or address.  Input or output on a special file
>         referred to a device that did not exist, or made a request beyond
>         the limits of the device.  This error may also occur when, for
>         example, a tape drive is not online or no disk pack is loaded on
>         a drive.
>=20
> 19 ENODEV Operation not supported by device.  An attempt was made to
>         apply an inappropriate function to a device, for example, trying
>         to read a write-only device such as a printer.

[snip]

> and SUS also does not list ENODEV as a return for open(2), but
> it does say:
>=20
>  The ERRORS section on each reference page specifies whether
>  an error shall be returned, or whether it may be returned.
>  Implementations shall not generate a different error number
>  from the ones described here for error conditions described
>  in this volume of IEEE Std 1003.1-2001, but may generate
>  additional errors unless explicitly disallowed for a
>  particular function.
>=20
> One way to read that would be that ENODEV would be ok from open,
> as it's not disallowed, none of the errors described for open
> quite matches the situation, and the description for ENODEV
> matches it perfectly. But I hate to do something unprecedented.
> Opinions?

I believe you are correct. We can return ENODEV for errors not mentioned=20
in the standard. I also think this is the right error code.

Take care,

Bill

--vOmOzSkFvhd7u8Ms
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)

iD8DBQFDvGyhWz+3JHUci9cRAoDIAKCJLXNm99GJfzDimGlmWicAVkIKOgCfTTdW
AbDv4B9aYd7EuNiaxdcjngY=
=TZD/
-----END PGP SIGNATURE-----

--vOmOzSkFvhd7u8Ms--