2006-12-20 04:49:36 +01:00
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
2006-12-20 06:33:12 +01:00
|
|
|
#include <vsprintf.h>
|
2006-12-20 04:49:36 +01:00
|
|
|
#include <gpxe/errortab.h>
|
|
|
|
|
|
|
|
/** @file
|
|
|
|
*
|
|
|
|
* Error descriptions.
|
|
|
|
*
|
|
|
|
* The error numbers used by Etherboot are a superset of those defined
|
|
|
|
* by the PXE specification version 2.1. See errno.h for a listing of
|
|
|
|
* the error values.
|
|
|
|
*
|
|
|
|
* To save space in ROM images, error string tables are optional. Use
|
|
|
|
* the ERRORMSG_XXX options in config.h to select which error string
|
|
|
|
* tables you want to include. If an error string table is omitted,
|
|
|
|
* strerror() will simply return the text "Error 0x<errno>".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-01-10 05:22:09 +01:00
|
|
|
static struct errortab errortab_start[0]
|
|
|
|
__table_start ( struct errortab, errortab );
|
|
|
|
static struct errortab errortab_end[0]
|
|
|
|
__table_end ( struct errortab, errortab );
|
2006-12-20 04:49:36 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieve string representation of error number.
|
|
|
|
*
|
|
|
|
* @v errno Error number
|
|
|
|
* @ret strerror Pointer to error text
|
|
|
|
*
|
|
|
|
* If the error is not found in the linked-in error tables, generates
|
|
|
|
* a generic "Error 0x<errno>" message.
|
|
|
|
*
|
|
|
|
* The pointer returned by strerror() is valid only until the next
|
|
|
|
* call to strerror().
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
const char * strerror ( int errno ) {
|
|
|
|
static char *generic_message = "Error 0x0000";
|
|
|
|
struct errortab *errortab;
|
|
|
|
|
2006-12-20 04:54:20 +01:00
|
|
|
/* Allow for strerror(rc) as well as strerror(errno) */
|
|
|
|
if ( errno < 0 )
|
|
|
|
errno = -errno;
|
|
|
|
|
2006-12-20 04:49:36 +01:00
|
|
|
for ( errortab = errortab_start ; errortab < errortab_end ;
|
|
|
|
errortab++ ) {
|
|
|
|
if ( errortab->errno == errno )
|
|
|
|
return errortab->text;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf ( generic_message + 8, "%hx", errno );
|
|
|
|
return generic_message;
|
|
|
|
}
|
2006-12-20 04:54:20 +01:00
|
|
|
|
|
|
|
/** The most common errors */
|
2007-01-11 05:01:31 +01:00
|
|
|
struct errortab enoerr __errortab = { 0, "No error" };
|
2006-12-20 08:57:40 +01:00
|
|
|
struct errortab enoem __errortab = { ENOMEM, "Out of memory" };
|
|
|
|
struct errortab einval __errortab = { EINVAL, "Invalid argument" };
|
|
|
|
struct errortab enospc __errortab = { ENOSPC, "No space left on device" };
|
|
|
|
struct errortab eio __errortab = { EIO, "Input/output error" };
|
2006-12-21 17:16:24 +01:00
|
|
|
struct errortab eacces __errortab = { EACCES, "Permission denied" };
|
2007-01-12 20:14:01 +01:00
|
|
|
struct errortab enoent __errortab = { ENOENT, "File not found" };
|