-EWHICHERROR?
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 | |
---|---|
Kernel | Development model/User-space ABI |
Kernel | Error codes |
Posted Jun 30, 2011 13:33 UTC (Thu)
by stevem (subscriber, #1512)
[Link] (6 responses)
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... :-)
Posted Jun 30, 2011 15:40 UTC (Thu)
by rfunk (subscriber, #4054)
[Link] (5 responses)
Though come to think of it, EINVAL may actually be more informative and truthful than the error Paypal returns.
Posted Jun 30, 2011 18:35 UTC (Thu)
by jonabbey (guest, #2736)
[Link] (3 responses)
Posted Jun 30, 2011 21:15 UTC (Thu)
by nix (subscriber, #2304)
[Link] (2 responses)
Posted Jun 30, 2011 22:24 UTC (Thu)
by njs (subscriber, #40338)
[Link] (1 responses)
Posted Jul 1, 2011 9:41 UTC (Fri)
by nix (subscriber, #2304)
[Link]
(I do like the 'Appendix H' reference in there. Brings back lots of obsolete 90s outrage.)
Posted Jul 4, 2011 7:12 UTC (Mon)
by shane (subscriber, #3335)
[Link]
-EWHICHERROR?
-EWHICHERROR?
-EWHICHERROR?
-EWHICHERROR?
-EWHICHERROR?
-EWHICHERROR?
-EWHICHERROR?