The library is not quite a drop-in replacement for strerror, but it comes close. Each system call has a dedicated libexplain function, for example
fd = open(path, flags, mode); if (fd < 0) { fprintf(stderr, "%s\n", explain_open(path, flags, mode)); exit(EXIT_FAILURE); }
‘I think it's totally awesome, in the category of “why hasn't this existed for n years” awesome.’ — Parker san |
open(pathname = "no-such-dir/some-file", flags = O_RDONLY) failed, No such file or directory (2, ENOENT) because there is no "no-such-dir" directory in the current directory
The good news is that for each of these functions there is a wrapper function, in this case explain_open_or_die(3), that includes the above code fragment. Adding good error reporting is as simple as using a different, but similarly named, function. The library also provides thread safe variants of each explanation function.
The coverage for system calls is being improved all the time, as you can see from this documentation page generated from the source code. Coverage includes 221 system calls and 547 ioctl requests.
“pmiller read the kernel source so you don't have to” — Rob Weir |
Master Sources The following files are available for download from this web site:
|
|||||||||
Sourceforge Downloads
|
|||||||||
Ubuntu Packages If you use Ubuntu Linux, there are pre-built packages available for installation using the normal sudo apt-get install method, from this package archive (PPA). Instructions are available there for how to manually add the PPA to your /etc/apt/sources.list file, but the following commands are sufficient on recent versions of Ubuntu: sudo add-apt-repository ppa:pmiller-opensource/ppa sudo apt-get update sudo apt-get install libexplain-dev
|
|||||||||
Debian Packages
|
|||||||||
Aegis
|
Libexplain is written and owned by Peter Miller <pmiller@opensource.org.au> and is freely distributable under the terms and conditions of the GNU LGPL, so you may use libexplain with proprietary programs. | There is more Software by Peter Miller at his home page. |