Node:Usual file name errors, Next:Opening files at a low level, Previous:Low-level file routines, Up:Low-level file routines
Most low-level file functions return some kind of error flag if they
cannot perform the action you request, for example, if they cannot parse
the file name or find the file. However, to discover which error
or what kind of error has occurred, you must frequently refer to the
system variable errno
. This is an integer specifying the most recent
error that has occurred. Macros for values of errno
are listed below.
They are all defined in the GNU C Library.
The word component below refers to part of a full file name. For
example, in the file name /home/fred/snozzberry.txt
, fred
is a component that designates a subdirectory of the directory
/home
, and snozzberry.txt
is the name of the file proper.
Most functions that accept file name arguments can detect the following
error conditions. These are known as the usual file name errors.
The names of the errors, such as EACCES
, are compounded of
E
for "error" and a term indicating the type of error, such as
ACCES
for "access".
EACCES
ENAMETOOLONG
ENOENT
ENOTDIR
ELOOP
You can display English text for each of these errors with the m
conversion specifier of the printf
function, as in the following
short example.
errno = EACCES; printf ("errno string (EACCES): %m\n");
This example prints the following string:
errno string (EACCES): Permission denied
See Formatted output conversion specifiers, for more information
on the m
conversion specifier.