Is there any strerror
-like functionality currently in the kernel? I haven't been able to find one so my thought is no, but more importantly, has their been any discussion about this? I would think it could reduce troubleshooting time, since you wont have to look up error codes (which not everybody has memorized) and possibly make things a bit easier for system administrators and normal ever-day users (via dmesg
).
I wanted to ask here before mailing the LKML. My thoughts were for a dual mechanism, one for the error name (e.g., EINVAL
) and another for the description. Further, the %m
glibc extension could be added to printk, except that it would have to read a error code since the glibc extension reads errno
. Perhaps %m
could print the error name while %M
could print the error description?
Anyway, if it is added, it should be a .config option since it will bloat the text size. The size can be shrunk by just storing the error names (1 through 133 currently) in a single string with a null terminator between each string and just a slow strerror
(forced to iterate through the string and count null-terminators), since the speed of this shouldn't matter. Internal errors 512-529 would have to be in a separate string. Then, a direct pointer to the null-terminated string could be returned with no need to copy anything. By my calculations, this would take roughly 1322 bytes for the error names and 3540 bytes for the descriptions (based upon what are now in comments after each error's #define and adding "no description" for those that are currently missing one).
Then, when config-disabled, the printk %m
could just be interpreted as %d
and %M
could just print nothing (or some such).