From: Andries Brouwer <aebr@win.tue.nl>
To: David Woodhouse <dwmw2@infradead.org>
Cc: Bryan Henderson <hbryan@us.ibm.com>,
torvalds@osdl.org, Matthew Wilcox <willy@debian.org>,
Peter Braam <braam@clusterfs.com>,
intermezzo-devel@lists.sourceforge.net,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] remove TCGETS
Date: Tue, 28 Oct 2003 21:52:42 +0100 [thread overview]
Message-ID: <20031028205242.GA10910@win.tue.nl> (raw)
In-Reply-To: <1067356596.15551.448.camel@hades.cambridge.redhat.com>
On Tue, Oct 28, 2003 at 03:56:37PM +0000, David Woodhouse wrote:
> LTP is bitching at me because my file system returns -EINVAL to all
> ioctls instead of -ENOTTY. Do I...
>
> 1. Make my file system return -ENOTTY.
> 2. Make LTP accept -EINVAL instead of -ENOTTY on an invalid ioctl.
> 3. Make LTP accept _either_ -EINVAL or -ENOTTY in that case.
Short answer:
#3.
In the call ioctl(fd, SOMEIOCTL, arg) one should return ENOTTY
is fd is wrong, EINVAL if SOMEIOCTL or arg is wrong.
Long answer:
> > >[ENOTTY]
> > > The fildes argument is not associated with a STREAMS device that
> > > accepts control functions.
But you see that POSIX or SUSv* do not specify ioctl at all, except
insofar as it applies to STREAMS devices:
For non-STREAMS devices, the functions performed by this call are unspecified.
So, if you want to decide what error return is appropriate in the
non-STREAMS case, neither POSIX nor SUSv* will help.
So, there are two sources of inspiration. Actual usage in BSD and
similar operating systems, and the POSIX definitions of the error numbers.
The latter are easy to quote:
[ENOTTY]
Inappropriate I/O control operation. A control function has been attempted
for a file or special file for which the operation is inappropriate.
[EINVAL]
Invalid argument. Some invalid argument was supplied; for example, specifying
an undefined signal in a signal() function or a kill() function.
Since both SOMEIOCTL and arg are arguments to the call ioctl(fd, SOMEIOCTL, arg),
it may not be forbidden to return EINVAL.
The POSIX spec mentions ENOTTY in the pages for ioctl, isatty, sockatmark,
tcdrain, tcflow, tcflush, tcgetattr, tcgetpgrp, tcgetsid, tcsendbreak,
tcsetattr, tcsetpgrp, ttyname. Typically ENOTTY points out that the fd parameter
is not a terminal, is not a controlling terminal, is not a socket.
An interesting text fragment is seen in the Rationale:
[EFTYPE] This error code was proposed in earlier proposals as
``Inappropriate operation for file type'', meaning that the operation
requested is not appropriate for the file specified in the function call.
This code was proposed, although the same idea was covered by [ENOTTY],
because the connotations of the name would be misleading. It was pointed out
that the fcntl( ) function uses the error code [EINVAL] for this notion,
and hence all instances of [EFTYPE] were changed to this code.
(Namely, for fcntl( ) the [EINVAL] description says: "... or fd refers to a file
that does not support locking.")
My conclusion is that failing historical custom that would help choosing
between EINVAL and ENOTTY, we should choose EINVAL in all cases where
the decision to return an error was not based on the properties of fd.
Andries
next prev parent reply other threads:[~2003-10-28 20:53 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-12 21:48 [PATCH] remove TCGETS Matthew Wilcox
2003-08-12 21:59 ` Andreas Dilger
2003-08-13 1:42 ` Peter Braam
2003-08-13 12:12 ` David Woodhouse
2003-08-13 15:35 ` Andreas Dilger
2003-08-14 1:28 ` Peter Braam
2003-08-14 1:43 ` Matthew Wilcox
2003-08-14 15:54 ` Bryan Henderson
2003-10-28 15:56 ` David Woodhouse
2003-10-28 19:41 ` Bryan Henderson
2003-10-28 20:52 ` Andries Brouwer [this message]
2003-10-28 21:07 ` Linus Torvalds
2003-10-28 23:51 ` Andrew Sharp
2003-10-29 1:54 ` Linus Torvalds
2003-10-29 0:46 ` David Woodhouse
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20031028205242.GA10910@win.tue.nl \
--to=aebr@win.tue.nl \
--cc=braam@clusterfs.com \
--cc=dwmw2@infradead.org \
--cc=hbryan@us.ibm.com \
--cc=intermezzo-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=torvalds@osdl.org \
--cc=willy@debian.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.