You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

errno.c 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include "etherboot.h"
  2. #include "errno.h"
  3. #include "vsprintf.h"
  4. /** @file
  5. *
  6. * Error codes and descriptions.
  7. *
  8. * This file provides the global variable errno
  9. *
  10. */
  11. /**
  12. * Global "last error" number.
  13. *
  14. * This is valid only when a function has just returned indicating a
  15. * failure.
  16. *
  17. */
  18. int errno;
  19. static struct errortab errortab_start[0] __table_start(errortab);
  20. static struct errortab errortab_end[0] __table_end(errortab);
  21. /**
  22. * Retrieve string representation of error number.
  23. *
  24. * @v errno Error number
  25. * @ret strerror Pointer to error text
  26. *
  27. * If the error is not found in the linked-in error tables, generates
  28. * a generic "Error 0x0000" message.
  29. *
  30. * The pointer returned by strerror() is valid only until the next
  31. * call to strerror().
  32. *
  33. */
  34. const char * strerror ( int errno ) {
  35. static char *generic_message = "Error 0x0000";
  36. struct errortab *errortab;
  37. for ( errortab = errortab_start ; errortab < errortab_end ;
  38. errortab++ ) {
  39. if ( errortab->errno == errno )
  40. return errortab->text;
  41. }
  42. sprintf ( generic_message + 8, "%hx", errno );
  43. return generic_message;
  44. }