diff options
author | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2011-07-09 10:42:26 -0400 |
---|---|---|
committer | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2011-07-16 01:24:31 -0400 |
commit | d873d794235efa590ab3c94d5ee22bb1fab19ac4 (patch) | |
tree | 6d65b61937517c475318b332b6e62f074df04d9b /drivers/firewire/core-cdev.c | |
parent | 9f426173e54a4f0882f9516c226f3165a3bd5474 (diff) |
firewire: cdev: return -ENOTTY for unimplemented ioctls, not -EINVAL
On Jun 27 Linus Torvalds wrote:
> The correct error code for "I don't understand this ioctl" is ENOTTY.
> The naming may be odd, but you should think of that error value as a
> "unrecognized ioctl number, you're feeding me random numbers that I
> don't understand and I assume for historical reasons that you tried to
> do some tty operation on me".
[...]
> The EINVAL thing goes way back, and is a disaster. It predates Linux
> itself, as far as I can tell. You'll find lots of man-pages that have
> this line in it:
>
> EINVAL Request or argp is not valid.
>
> and it shows up in POSIX etc. And sadly, it generally shows up
> _before_ the line that says
>
> ENOTTY The specified request does not apply to the kind of object
> that the descriptor d references.
>
> so a lot of people get to the EINVAL, and never even notice the ENOTTY.
[...]
> At least glibc (and hopefully other C libraries) use a _string_ that
> makes much more sense: strerror(ENOTTY) is "Inappropriate ioctl for
> device"
So let's correct this in the <linux/firewire-cdev.h> ABI while it is
still young, relative to distributor adoption.
Side note: We return -ENOTTY not only on _IOC_TYPE or _IOC_NR mismatch,
but also on _IOC_SIZE mismatch. An ioctl with an unsupported size of
argument structure can be seen as an unsupported version of that ioctl.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Cc: <stable@kernel.org>
Diffstat (limited to 'drivers/firewire/core-cdev.c')
-rw-r--r-- | drivers/firewire/core-cdev.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index b1c11775839c..9b5915ebeb35 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c | |||
@@ -1583,7 +1583,7 @@ static int dispatch_ioctl(struct client *client, | |||
1583 | if (_IOC_TYPE(cmd) != '#' || | 1583 | if (_IOC_TYPE(cmd) != '#' || |
1584 | _IOC_NR(cmd) >= ARRAY_SIZE(ioctl_handlers) || | 1584 | _IOC_NR(cmd) >= ARRAY_SIZE(ioctl_handlers) || |
1585 | _IOC_SIZE(cmd) > sizeof(buffer)) | 1585 | _IOC_SIZE(cmd) > sizeof(buffer)) |
1586 | return -EINVAL; | 1586 | return -ENOTTY; |
1587 | 1587 | ||
1588 | if (_IOC_DIR(cmd) == _IOC_READ) | 1588 | if (_IOC_DIR(cmd) == _IOC_READ) |
1589 | memset(&buffer, 0, _IOC_SIZE(cmd)); | 1589 | memset(&buffer, 0, _IOC_SIZE(cmd)); |