5 * Mach Operating System
6 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
9 * Permission to use, copy, modify and distribute this software and its
10 * documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation.
15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
17 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
19 * Carnegie Mellon requests users of this software to return to
21 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
22 * School of Computer Science
23 * Carnegie Mellon University
24 * Pittsburgh PA 15213-3890
26 * any improvements or extensions that they make and grant Carnegie Mellon
27 * the rights to redistribute these changes.
30 #include <mach/boolean.h>
31 #include <mach/error.h>
32 #include <mach/mach_error.h>
37 static void do_compat(mach_error_t
*);
40 do_compat(mach_error_t
*org_err
)
42 mach_error_t err
= *org_err
;
45 * map old error numbers to
46 * to new error sys & subsystem
49 if ((-200 < err
) && (err
<= -100))
50 err
= -(err
+ 100) | IPC_SEND_MOD
;
51 else if ((-300 < err
) && (err
<= -200))
52 err
= -(err
+ 200) | IPC_RCV_MOD
;
53 else if ((-400 < err
) && (err
<= -300))
54 err
= -(err
+ 300) | MACH_IPC_MIG_MOD
;
55 else if ((1000 <= err
) && (err
< 1100))
56 err
= (err
- 1000) | SERV_NETNAME_MOD
;
57 else if ((1600 <= err
) && (err
< 1700))
58 err
= (err
- 1600) | SERV_ENV_MOD
;
59 else if ((27600 <= err
) && (err
< 27700))
60 err
= (err
- 27600) | SERV_EXECD_MOD
;
66 mach_error_type(mach_error_t err
)
72 sub
= err_get_sub(err
);
73 system
= err_get_system(err
);
75 if (system
> err_max_system
|| sub
>= _mach_errors
[system
].max_sub
)
76 return((char *)"(?/?)");
77 return(_mach_errors
[system
].subsystem
[sub
].subsys_name
);
80 boolean_t mach_error_full_diag
= FALSE
;
82 __private_extern__
char *
83 mach_error_string_int(mach_error_t err
, boolean_t
*diag
)
85 int sub
, system
, code
;
89 sub
= err_get_sub(err
);
90 system
= err_get_system(err
);
91 code
= err_get_code(err
);
95 if (system
> err_max_system
)
96 return((char *)"(?/?) unknown error system");
97 if (sub
>= _mach_errors
[system
].max_sub
)
98 return(_mach_errors
[system
].bad_sub
);
99 if (code
>= _mach_errors
[system
].subsystem
[sub
].max_code
)
100 return ((char *)NO_SUCH_ERROR
);
102 *diag
= mach_error_full_diag
;
103 return( _mach_errors
[system
].subsystem
[sub
].codes
[code
] );
107 mach_error_string(mach_error_t err
)
111 return mach_error_string_int( err
, &diag
);