[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
|
|
Subscribe / Log in / New account

-EWHICHERROR?

By Jonathan Corbet
June 29, 2011
Users of the Video4Linux2 API know that it is a rather complicated one, involving some 91 different ioctl() commands. The error-reporting side of the API is much simpler, though; if something goes wrong, the application is almost certain to get EINVAL back. That error can be trying to tell user space that the device is in the wrong state, that some parameter was out of range, or, simply, that the requested command has not been implemented. Needless to say, it can be hard for developers to figure out what is really going on.

V4L2 maintainer Mauro Carvalho Chehab recently posted a patch to change the return code to ENOIOCTLCMD in cases where the underlying driver has not actually implemented the requested command. That change would at least distinguish one set of problems - except that the VFS code silently translates ENOIOCTLCMD to EINVAL before returning to user space. So, from the point of view of the application, nothing changes.

Interestingly, the rules for what is supposed to happen in this situation are relatively clear: if an ioctl() command has not been implemented, the kernel should return ENOTTY. Some parts of the kernel follow that convention, while others don't. This is not a new or Linux-specific problem; as Linus put it: "The EINVAL thing goes way back, and is a disaster. It predates Linux itself, as far as I can tell." He has suggested simply changing ENOIOCTLCMD to ENOTTY across the kernel and seeing what happens.

What happens, of course, is that the user-space ABI changes. It is entirely possible that, somewhere out there, some program depends on getting EINVAL for a missing ioctl() function and will break if the return code changes. There is only one way to find out for sure: make the change and see what happens. Mauro reports that making that change within V4L2 does not seem to break things, so chances are good that change will find its way into 3.1. A tree-wide change could have much wider implications; whether somebody will find the courage to try that remains to be seen.

Index entries for this article
KernelDevelopment model/User-space ABI
KernelError codes


to post comments

-EWHICHERROR?

Posted Jun 30, 2011 13:33 UTC (Thu) by stevem (subscriber, #1512) [Link] (6 responses)

*grin*

I have "fond" memories of EINVAL being over-used in the first software I worked on professionally. If you think about it, just about any problem can come down to "you did something wrong" as an error message.

It scarred me so much that I ended up registering einval.com as my personal domain... :-)

-EWHICHERROR?

Posted Jun 30, 2011 15:40 UTC (Thu) by rfunk (subscriber, #4054) [Link] (5 responses)

Yep, it's not just at the kernel level. I was recently working with one of Paypal's APIs. Potentially dozens of parameters to pass, and if one is wrong or missing, always the same error message.

Though come to think of it, EINVAL may actually be more informative and truthful than the error Paypal returns.

-EWHICHERROR?

Posted Jun 30, 2011 18:35 UTC (Thu) by jonabbey (guest, #2736) [Link] (3 responses)

Seeing '3.1' mentioned as the next kernel version in this article caused me to throw a momentary mental EINVAL.

-EWHICHERROR?

Posted Jun 30, 2011 21:15 UTC (Thu) by nix (subscriber, #2304) [Link] (2 responses)

I understand that Linux for Workgroups is coming next year. Linux 95 can't be far behind (and will be universally reviled).

-EWHICHERROR?

Posted Jun 30, 2011 22:24 UTC (Thu) by njs (subscriber, #40338) [Link] (1 responses)

http://www.linuxjournal.com/article/2682

It does seem kind of lacking in features.

-EWHICHERROR?

Posted Jul 1, 2011 9:41 UTC (Fri) by nix (subscriber, #2304) [Link]

Reuse of a version number is no crime.

(I do like the 'Appendix H' reference in there. Brings back lots of obsolete 90s outrage.)

-EWHICHERROR?

Posted Jul 4, 2011 7:12 UTC (Mon) by shane (subscriber, #3335) [Link]

Linux is not totally free of this. If you've ever used sendmsg()/recvmsg() you have probably encountered a similar problem...


Copyright © 2011, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds