Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 Oct 2001 16:14:14 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Warner Losh <imp@harmony.village.org>
Cc:        Yar Tikhiy <yar@FreeBSD.ORG>, <net@FreeBSD.ORG>, <hackers@FreeBSD.ORG>
Subject:   Re: Some thoughts on if_ioctl() 
Message-ID:  <20011009155802.A23072-100000@delplex.bde.org>
In-Reply-To: <200110081503.f98F3s759159@harmony.village.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 8 Oct 2001, Warner Losh wrote:

> In message <20011008113214.A68390@snark.rinet.ru> Yar Tikhiy writes:
> : First, the current implementation of the utility function
> : ether_ioctl(), which can do good job common to ethernet drivers,
> : won't indicate the situation when an ioctl command is unsupported
> : by it. It will return 0 in this case. Wouldn't it be better to
> : return EINVAL so the driver can do something about that?
> : Now each driver using ether_ioctl() has to maintain painfully the
> : list of the ioctl commands that may be passed to ether_ioctl(), or
> : the kernel will be likely to panic in copyout() dereferencing a
> : NULL pointer.
>
> Actaully, it should return ENOTTY rather than EINVAL.  ENOTTY means
> that the ioctl isn't understood.  I've had to fix several drivers at
> work that didn't follow this convention due to ignorance on the part
> of the driver writer.

Actually, it should return ENOIOCTL rather than ENOTTY or EINVAL.
ENOTTY means that the ioctl _is_ understood by the current layer, but
the operation is not supported for the current device type.  ENOIOCTL
means that current layer doesn't handle this ioctl at all, at least for
the current device type.  I introduced this error code to disambiguate
it from ERESTART.  It is only currently used for disk and tty ioctls
AFAIK.  In 4.4BSD, it was hard-coded as -1 and used only for tty ioctls
AFAIK.  -1 conflicted with ERESTART, and the conflict caused breakage
for at least disk ioctls.

Bruce


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011009155802.A23072-100000>