List of error messages available for a command in Unix

documentationexit-status

Is it possible to find out what error messages a command includes?
For example I want to see the list of error messages that mkfs.ext3 command will print in different error situations.
Shall I look into the source code or are there other ways to achieve this?

Best Answer

Source code is going to be your best bet. You can in a pinch use the command strings to get some basic ideas about a binary and text that it may contain.

Example

Here are the first 20 lines of the output. These are the lines that contain the string "error" in them.

$ strings /usr/sbin/mkfs.ext3 | grep -i error | head -20
Syntax error in mke2fs config file (%s, line #%d)
Couldn't init profile successfully (error: %ld).
Error while enabling multiple mount protection feature.
MMP error info: last update: %s node: %s device: %s
Syntax error in profile section header
Syntax error in profile relation
[ERROR] %s:%d:%s:: Unable to allocate dquot
[ERROR] %s:%d:%s:: Cannot initialize io on quotafile
[ERROR] %s:%d:%s:: Cannot finish IO on new quotafile: %s
[ERROR] %s:%d:%s:: Unable to allocate quota handle
[ERROR] %s:%d:%s:: Failed to allocate quota context
[ERROR] %s:%d:%s:: Failed to allocate dictionary
[ERROR] %s:%d:%s:: while opening inode scan. ret=%ld
[ERROR] %s:%d:%s:: while getting next inode. ret=%ld
[ERROR] %s:%d:%s:: Open quota file failed
[ERROR] %s:%d:%s:: Error scanning dquots
[ERROR] %s:%d:%s:: ext2fs_file_llseek failed: %ld
[ERROR] %s:%d:%s:: ext2fs_file_read failed: %ld
[ERROR] %s:%d:%s:: ext2fs_file_write failed: %ld
[ERROR] %s:%d:%s:: ext2fs_file_open failed: %s
Related Question