VirtualBox

source: vbox/trunk/src/VBox/Runtime/darwin/RTErrConvertFromDarwin.cpp@ 98859

Last change on this file since 98859 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 5.0 KB
Line 
1/* $Id: RTErrConvertFromDarwin.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * IPRT - Convert Darwin Mach returns codes to iprt status codes.
4 */
5
6/*
7 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37
38/*********************************************************************************************************************************
39* Header Files *
40*********************************************************************************************************************************/
41#include <mach/kern_return.h>
42#include <IOKit/IOReturn.h>
43
44#include <iprt/err.h>
45#include <iprt/log.h>
46#include <iprt/assert.h>
47
48
49RTDECL(int) RTErrConvertFromDarwin(int iNativeCode)
50{
51 /*
52 * 'optimized' success case.
53 */
54 if (iNativeCode == KERN_SUCCESS)
55 return VINF_SUCCESS;
56
57 switch (iNativeCode)
58 {
59 /*
60 * Mach.
61 */
62 case KERN_INVALID_ADDRESS: return VERR_INVALID_POINTER;
63 case KERN_PROTECTION_FAILURE: return VERR_PERMISSION_DENIED;
64 //case KERN_NO_SPACE:
65 case KERN_INVALID_ARGUMENT: return VERR_INVALID_PARAMETER;
66 //case KERN_FAILURE:
67 //case KERN_RESOURCE_SHORTAGE:
68 //case KERN_NOT_RECEIVER:
69 case KERN_NO_ACCESS: return VERR_ACCESS_DENIED;
70 //case KERN_MEMORY_FAILURE:
71 //case KERN_MEMORY_ERROR:
72 //case KERN_ALREADY_IN_SET:
73 //case KERN_NOT_IN_SET:
74 //case KERN_NAME_EXISTS:
75 //case KERN_ABORTED:
76 //case KERN_INVALID_NAME:
77 //case KERN_INVALID_TASK:
78 //case KERN_INVALID_RIGHT:
79 //case KERN_INVALID_VALUE:
80 //case KERN_UREFS_OVERFLOW:
81 //case KERN_INVALID_CAPABILITY:
82 //case KERN_RIGHT_EXISTS:
83 //case KERN_INVALID_HOST:
84 //case KERN_MEMORY_PRESENT:
85 //case KERN_MEMORY_DATA_MOVED:
86 //case KERN_MEMORY_RESTART_COPY:
87 //case KERN_INVALID_PROCESSOR_SET:
88 //case KERN_POLICY_LIMIT:
89 //case KERN_INVALID_POLICY:
90 //case KERN_INVALID_OBJECT:
91 //case KERN_ALREADY_WAITING:
92 //case KERN_DEFAULT_SET:
93 //case KERN_EXCEPTION_PROTECTED:
94 //case KERN_INVALID_LEDGER:
95 //case KERN_INVALID_MEMORY_CONTROL:
96 //case KERN_INVALID_SECURITY:
97 //case KERN_NOT_DEPRESSED:
98 //case KERN_TERMINATED:
99 //case KERN_LOCK_SET_DESTROYED:
100 //case KERN_LOCK_UNSTABLE:
101 case KERN_LOCK_OWNED: return VERR_SEM_BUSY;
102 //case KERN_LOCK_OWNED_SELF:
103 case KERN_SEMAPHORE_DESTROYED: return VERR_SEM_DESTROYED;
104 //case KERN_RPC_SERVER_TERMINATED:
105 //case KERN_RPC_TERMINATE_ORPHAN:
106 //case KERN_RPC_CONTINUE_ORPHAN:
107 case KERN_NOT_SUPPORTED: return VERR_NOT_SUPPORTED;
108 //case KERN_NODE_DOWN:
109 //case KERN_NOT_WAITING:
110 case KERN_OPERATION_TIMED_OUT: return VERR_TIMEOUT;
111
112
113 /*
114 * I/O Kit.
115 */
116 case kIOReturnNoDevice: return VERR_IO_BAD_UNIT;
117 case kIOReturnUnsupported: return VERR_NOT_SUPPORTED;
118 case kIOReturnInternalError: return VERR_INTERNAL_ERROR;
119 case kIOReturnNoResources: return VERR_OUT_OF_RESOURCES;
120 case kIOReturnBadArgument: return VERR_INVALID_PARAMETER;
121 case kIOReturnCannotWire: return VERR_LOCK_FAILED;
122
123#ifdef IN_RING3
124 /*
125 * CoreFoundation COM (may overlap with I/O Kit and Mach).
126 */
127 default:
128 if ( (unsigned)iNativeCode >= 0x80000000U
129 && (unsigned)iNativeCode <= 0x8000FFFFU)
130 return RTErrConvertFromDarwinCOM(iNativeCode);
131 break;
132#endif /* IN_RING3 */
133 }
134
135 /* unknown error. */
136 AssertLogRelMsgFailed(("Unhandled error %#x\n", iNativeCode));
137 return VERR_UNRESOLVED_ERROR;
138}
139
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette