Does the kernel have strerror like functionality? I could not find it, so my thought is not, but more importantly, are there any discussions about this? I would think that this can shorten the troubleshooting time, since you do not have to look for error codes (which not everyone remembers) and, possibly, simplify the work of system administrators and ordinary users throughout the day (via dmesg ).
I wanted to ask here before posting LKML. My thoughts were about a dual mechanism, one for the name of the error (e.g. EINVAL ) and the other for the description. In addition, the %m glibc extension can be added to printk, except that it will need to read the error code since the glibc extension reads errno . Maybe %m can print the name of the error, and %m can print the description of the error?
In any case, if it is added, it should be the .config parameter, since it inflates the size of the text. You can reduce the size by simply storing the error names (from 1 to 133 at present) in one line with a zero terminator between each line and only a slow strerror (forced to iterate over the line and count the null terminators), since the speed of this should not matter. Internal errors 512-529 must be on a separate line. Then a direct pointer to a string with a terminating zero can be returned, without having to copy anything. According to my calculations, this will take approximately 1322 bytes for error names and 3540 bytes for descriptions (depending on what is now in the comments after each error #define and adding "no description" for those that are currently missing).
Then, when config-disabled, printk %m can simply be interpreted as %d , and %m may just not print anything (or some).
Daniel Santos
source share