1 | /* $Id $ */
|
---|
2 | /** @file
|
---|
3 | * innotek Portable Runtime - Convert Darwin Mach returns codes to iprt status codes.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License as published by the Free Software Foundation,
|
---|
13 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
14 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
15 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * If you received this file as part of a commercial VirtualBox
|
---|
18 | * distribution, then only the terms of your commercial VirtualBox
|
---|
19 | * license agreement apply instead of the previous paragraph.
|
---|
20 | */
|
---|
21 |
|
---|
22 | /*******************************************************************************
|
---|
23 | * Header Files *
|
---|
24 | *******************************************************************************/
|
---|
25 | #include <mach/kern_return.h>
|
---|
26 |
|
---|
27 | #include <iprt/err.h>
|
---|
28 | #include <iprt/assert.h>
|
---|
29 |
|
---|
30 |
|
---|
31 | RTDECL(int) RTErrConvertFromDarwinKern(int iNativeCode)
|
---|
32 | {
|
---|
33 | /*
|
---|
34 | * 'optimzied' success case.
|
---|
35 | */
|
---|
36 | if (iNativeCode == KERN_SUCCESS)
|
---|
37 | return VINF_SUCCESS;
|
---|
38 |
|
---|
39 | switch (iNativeCode)
|
---|
40 | {
|
---|
41 | case KERN_INVALID_ADDRESS: return VERR_INVALID_POINTER;
|
---|
42 | //case KERN_PROTECTION_FAILURE:
|
---|
43 | //case KERN_NO_SPACE:
|
---|
44 | case KERN_INVALID_ARGUMENT: return VERR_INVALID_PARAMETER;
|
---|
45 | //case KERN_FAILURE:
|
---|
46 | //case KERN_RESOURCE_SHORTAGE:
|
---|
47 | //case KERN_NOT_RECEIVER:
|
---|
48 | case KERN_NO_ACCESS: return VERR_ACCESS_DENIED;
|
---|
49 | //case KERN_MEMORY_FAILURE:
|
---|
50 | //case KERN_MEMORY_ERROR:
|
---|
51 | //case KERN_ALREADY_IN_SET:
|
---|
52 | //case KERN_NOT_IN_SET:
|
---|
53 | //case KERN_NAME_EXISTS:
|
---|
54 | //case KERN_ABORTED:
|
---|
55 | //case KERN_INVALID_NAME:
|
---|
56 | //case KERN_INVALID_TASK:
|
---|
57 | //case KERN_INVALID_RIGHT:
|
---|
58 | //case KERN_INVALID_VALUE:
|
---|
59 | //case KERN_UREFS_OVERFLOW:
|
---|
60 | //case KERN_INVALID_CAPABILITY:
|
---|
61 | //case KERN_RIGHT_EXISTS:
|
---|
62 | //case KERN_INVALID_HOST:
|
---|
63 | //case KERN_MEMORY_PRESENT:
|
---|
64 | //case KERN_MEMORY_DATA_MOVED:
|
---|
65 | //case KERN_MEMORY_RESTART_COPY:
|
---|
66 | //case KERN_INVALID_PROCESSOR_SET:
|
---|
67 | //case KERN_POLICY_LIMIT:
|
---|
68 | //case KERN_INVALID_POLICY:
|
---|
69 | //case KERN_INVALID_OBJECT:
|
---|
70 | //case KERN_ALREADY_WAITING:
|
---|
71 | //case KERN_DEFAULT_SET:
|
---|
72 | //case KERN_EXCEPTION_PROTECTED:
|
---|
73 | //case KERN_INVALID_LEDGER:
|
---|
74 | //case KERN_INVALID_MEMORY_CONTROL:
|
---|
75 | //case KERN_INVALID_SECURITY:
|
---|
76 | //case KERN_NOT_DEPRESSED:
|
---|
77 | //case KERN_TERMINATED:
|
---|
78 | //case KERN_LOCK_SET_DESTROYED:
|
---|
79 | //case KERN_LOCK_UNSTABLE:
|
---|
80 | case KERN_LOCK_OWNED: return VERR_SEM_BUSY;
|
---|
81 | //case KERN_LOCK_OWNED_SELF:
|
---|
82 | case KERN_SEMAPHORE_DESTROYED: return VERR_SEM_DESTROYED;
|
---|
83 | //case KERN_RPC_SERVER_TERMINATED:
|
---|
84 | //case KERN_RPC_TERMINATE_ORPHAN:
|
---|
85 | //case KERN_RPC_CONTINUE_ORPHAN:
|
---|
86 | case KERN_NOT_SUPPORTED: return VERR_NOT_SUPPORTED;
|
---|
87 | //case KERN_NODE_DOWN:
|
---|
88 | //case KERN_NOT_WAITING:
|
---|
89 | case KERN_OPERATION_TIMED_OUT: return VERR_TIMEOUT;
|
---|
90 | }
|
---|
91 |
|
---|
92 | /* unknown error. */
|
---|
93 | AssertMsgFailed(("Unhandled error %#x\n", iNativeCode));
|
---|
94 | return VERR_UNRESOLVED_ERROR;
|
---|
95 | }
|
---|
96 |
|
---|
97 |
|
---|