errstring.c 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Mach Operating System
  3. * Copyright (c) 1991,1990,1989 Carnegie Mellon University
  4. * All Rights Reserved.
  5. *
  6. * Permission to use, copy, modify and distribute this software and its
  7. * documentation is hereby granted, provided that both the copyright
  8. * notice and this permission notice appear in all copies of the
  9. * software, derivative works or modified versions, and any portions
  10. * thereof, and that both notices appear in supporting documentation.
  11. *
  12. * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
  13. * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
  14. * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  15. *
  16. * Carnegie Mellon requests users of this software to return to
  17. *
  18. * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
  19. * School of Computer Science
  20. * Carnegie Mellon University
  21. * Pittsburgh PA 15213-3890
  22. *
  23. * any improvements or extensions that they make and grant Carnegie Mellon
  24. * the rights to redistribute these changes.
  25. */
  26. /*
  27. * (pre-GNU) HISTORY
  28. *
  29. * Revision 2.3 92/04/01 19:38:18 rpd
  30. * Updated do_compat for kernel device errors,
  31. * bootstrap file-system errors.
  32. * [92/03/09 rpd]
  33. *
  34. * Revision 2.2 92/02/20 15:58:08 elf
  35. * Created from mach_error.c.
  36. * [92/02/11 rpd]
  37. *
  38. */
  39. #define EXPORT_BOOLEAN
  40. #include <mach/boolean.h>
  41. #include <mach/error.h>
  42. #include <mach_error.h>
  43. #include <errorlib.h>
  44. extern void __mach_error_map_compat (mach_error_t *);
  45. const char *
  46. mach_error_type(mach_error_t err)
  47. {
  48. int sub, system;
  49. __mach_error_map_compat( &err );
  50. sub = err_get_sub(err);
  51. system = err_get_system(err);
  52. if (system > err_max_system
  53. || sub >= errors[system].max_sub ) return( "(?/?)" );
  54. return( errors[system].subsystem[sub].subsys_name );
  55. }
  56. libc_hidden_def (mach_error_type)
  57. boolean_t mach_error_full_diag = FALSE;
  58. const char *
  59. mach_error_string_int(mach_error_t err,
  60. boolean_t * diag)
  61. {
  62. int sub, system, code;
  63. __mach_error_map_compat( &err );
  64. sub = err_get_sub(err);
  65. system = err_get_system(err);
  66. code = err_get_code(err);
  67. *diag = TRUE;
  68. if (system > err_max_system) return( "(?/?) unknown error system" );
  69. if (sub >= errors[system].max_sub) return( errors[system].bad_sub );
  70. if (code >= errors[system].subsystem[sub].max_code) return ( NO_SUCH_ERROR );
  71. *diag = mach_error_full_diag;
  72. return( errors[system].subsystem[sub].codes[code] );
  73. }
  74. const char *
  75. mach_error_string(mach_error_t err)
  76. {
  77. boolean_t diag;
  78. return mach_error_string_int( err, &diag );
  79. }