]>
Commit | Line | Data |
---|---|---|
e9ce8d39 A |
1 | /* |
2 | * @OSF_COPYRIGHT@ | |
3 | */ | |
4 | /* | |
5 | * Mach Operating System | |
6 | * Copyright (c) 1991,1990,1989 Carnegie Mellon University | |
7 | * All Rights Reserved. | |
8 | * | |
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. | |
14 | * | |
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. | |
18 | * | |
19 | * Carnegie Mellon requests users of this software to return to | |
20 | * | |
21 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
22 | * School of Computer Science | |
23 | * Carnegie Mellon University | |
24 | * Pittsburgh PA 15213-3890 | |
25 | * | |
26 | * any improvements or extensions that they make and grant Carnegie Mellon | |
27 | * the rights to redistribute these changes. | |
28 | */ | |
29 | ||
30 | #include <mach/boolean.h> | |
31 | #include <mach/error.h> | |
32 | #include <mach/mach_error.h> | |
5b2abdfb A |
33 | |
34 | #include "errorlib.h" | |
e9ce8d39 A |
35 | #include "externs.h" |
36 | ||
37 | static void do_compat(mach_error_t *); | |
38 | ||
39 | static void | |
40 | do_compat(mach_error_t *org_err) | |
41 | { | |
42 | mach_error_t err = *org_err; | |
43 | ||
44 | /* | |
45 | * map old error numbers to | |
46 | * to new error sys & subsystem | |
47 | */ | |
48 | ||
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; | |
61 | ||
62 | *org_err = err; | |
63 | } | |
64 | ||
65 | char * | |
66 | mach_error_type(mach_error_t err) | |
67 | { | |
68 | int sub, system; | |
69 | ||
70 | do_compat( &err ); | |
71 | ||
72 | sub = err_get_sub(err); | |
73 | system = err_get_system(err); | |
74 | ||
5b2abdfb | 75 | if (system > err_max_system || sub >= _mach_errors[system].max_sub) |
e9ce8d39 | 76 | return((char *)"(?/?)"); |
5b2abdfb | 77 | return(_mach_errors[system].subsystem[sub].subsys_name); |
e9ce8d39 A |
78 | } |
79 | ||
80 | boolean_t mach_error_full_diag = FALSE; | |
81 | ||
5b2abdfb | 82 | __private_extern__ char * |
e9ce8d39 A |
83 | mach_error_string_int(mach_error_t err, boolean_t *diag) |
84 | { | |
85 | int sub, system, code; | |
86 | ||
87 | do_compat( &err ); | |
88 | ||
89 | sub = err_get_sub(err); | |
90 | system = err_get_system(err); | |
91 | code = err_get_code(err); | |
92 | ||
93 | *diag = TRUE; | |
94 | ||
95 | if (system > err_max_system) | |
96 | return((char *)"(?/?) unknown error system"); | |
5b2abdfb A |
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) | |
e9ce8d39 A |
100 | return ((char *)NO_SUCH_ERROR); |
101 | ||
102 | *diag = mach_error_full_diag; | |
5b2abdfb | 103 | return( _mach_errors[system].subsystem[sub].codes[code] ); |
e9ce8d39 A |
104 | } |
105 | ||
106 | char * | |
107 | mach_error_string(mach_error_t err) | |
108 | { | |
109 | boolean_t diag; | |
110 | ||
111 | return mach_error_string_int( err, &diag ); | |
112 | ||
113 | } |