Kbase P10188: How to determine the meaning of errno on Unix or GNU/Linux?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  16/10/2008 |
|
Status: Verified
GOAL:
How to determine the meaning of errno on Unix or GNU/Linux?
GOAL:
What are errno codes on Unix or GNU/Linux?
GOAL:
Where is the errno.h file on a Unix or GNU/Linux operating systems?
GOAL:
What does the errno for UNIX mean
GOAL:
What does the error code mean on UNIX
FACT(s) (Environment):
UNIX
FIX:
So-called "errnos" are symptoms of operating system errors. These errors are produced as the result of failed operating system operations (syscalls).
Unix errnos are identified by a name in upper case starting with the letter E, such as EINVAL. The meaning of each name is about the same on all flavors of Unix; the mapping between code and meaning is given below. However, the numerical value for each errno identifier is often different on each flavor of Unix.
To find the error code from the error number, it is necessary to look up the number in the file errno.h. The standard location for this file is /usr/include/sys/errno.h. However, often this file makes reference to a file in another location for the actual definitions of error codes. To access the complete list, it is therefore necessary to look in different locations depending on the Unix flavor:
On AIX: /usr/include/errno.h
On Solaris or HP-UX: /usr/include/sys/errno.h
On GNU/Linux: depends on the distribution. Known locations are:
/usr/include/asm/errno.h
/usr/include/asm-generic/errno-base.h
/usr/include/asm-generic/errno.h
/usr/lib/bcc/include/linux/errno.h
/usr/include/sys/errno.h
/usr/include/asm-i386/errno.h
To look up the error code, use the 'grep' command as follows:
grep 'define.*<code>' <location of errno.h>
For example:
grep 'define.*15' /usr/include/sys/errno.h
This command yields:
#define ENOTBLK 15 /* Block device required */