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>
33 #include <mach/errorlib.h>
36 static void do_compat(mach_error_t
*);
39 do_compat(mach_error_t
*org_err
)
41 mach_error_t err
= *org_err
;
44 * map old error numbers to
45 * to new error sys & subsystem
48 if ((-200 < err
) && (err
<= -100))
49 err
= -(err
+ 100) | IPC_SEND_MOD
;
50 else if ((-300 < err
) && (err
<= -200))
51 err
= -(err
+ 200) | IPC_RCV_MOD
;
52 else if ((-400 < err
) && (err
<= -300))
53 err
= -(err
+ 300) | MACH_IPC_MIG_MOD
;
54 else if ((1000 <= err
) && (err
< 1100))
55 err
= (err
- 1000) | SERV_NETNAME_MOD
;
56 else if ((1600 <= err
) && (err
< 1700))
57 err
= (err
- 1600) | SERV_ENV_MOD
;
58 else if ((27600 <= err
) && (err
< 27700))
59 err
= (err
- 27600) | SERV_EXECD_MOD
;
65 mach_error_type(mach_error_t err
)
71 sub
= err_get_sub(err
);
72 system
= err_get_system(err
);
74 if (system
> err_max_system
|| sub
>= errors
[system
].max_sub
)
75 return((char *)"(?/?)");
76 return(errors
[system
].subsystem
[sub
].subsys_name
);
79 boolean_t mach_error_full_diag
= FALSE
;
82 mach_error_string_int(mach_error_t err
, boolean_t
*diag
)
84 int sub
, system
, code
;
88 sub
= err_get_sub(err
);
89 system
= err_get_system(err
);
90 code
= err_get_code(err
);
94 if (system
> err_max_system
)
95 return((char *)"(?/?) unknown error system");
96 if (sub
>= errors
[system
].max_sub
)
97 return(errors
[system
].bad_sub
);
98 if (code
>= errors
[system
].subsystem
[sub
].max_code
)
99 return ((char *)NO_SUCH_ERROR
);
101 *diag
= mach_error_full_diag
;
102 return( errors
[system
].subsystem
[sub
].codes
[code
] );
106 mach_error_string(mach_error_t err
)
110 return mach_error_string_int( err
, &diag
);