VirtualBox

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

Last change on this file since 81106 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 4.7 KB
Line 
1/* $Id: RTErrConvertFromDarwin.cpp 76553 2019-01-01 01:45:53Z vboxsync $ */
2/** @file
3 * IPRT - Convert Darwin Mach returns codes to iprt status codes.
4 */
5
6/*
7 * Copyright (C) 2006-2019 Oracle Corporation
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 (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27
28/*********************************************************************************************************************************
29* Header Files *
30*********************************************************************************************************************************/
31#include <mach/kern_return.h>
32#include <IOKit/IOReturn.h>
33
34#include <iprt/err.h>
35#include <iprt/log.h>
36#include <iprt/assert.h>
37
38
39RTDECL(int) RTErrConvertFromDarwin(int iNativeCode)
40{
41 /*
42 * 'optimized' success case.
43 */
44 if (iNativeCode == KERN_SUCCESS)
45 return VINF_SUCCESS;
46
47 switch (iNativeCode)
48 {
49 /*
50 * Mach.
51 */
52 case KERN_INVALID_ADDRESS: return VERR_INVALID_POINTER;
53 case KERN_PROTECTION_FAILURE: return VERR_PERMISSION_DENIED;
54 //case KERN_NO_SPACE:
55 case KERN_INVALID_ARGUMENT: return VERR_INVALID_PARAMETER;
56 //case KERN_FAILURE:
57 //case KERN_RESOURCE_SHORTAGE:
58 //case KERN_NOT_RECEIVER:
59 case KERN_NO_ACCESS: return VERR_ACCESS_DENIED;
60 //case KERN_MEMORY_FAILURE:
61 //case KERN_MEMORY_ERROR:
62 //case KERN_ALREADY_IN_SET:
63 //case KERN_NOT_IN_SET:
64 //case KERN_NAME_EXISTS:
65 //case KERN_ABORTED:
66 //case KERN_INVALID_NAME:
67 //case KERN_INVALID_TASK:
68 //case KERN_INVALID_RIGHT:
69 //case KERN_INVALID_VALUE:
70 //case KERN_UREFS_OVERFLOW:
71 //case KERN_INVALID_CAPABILITY:
72 //case KERN_RIGHT_EXISTS:
73 //case KERN_INVALID_HOST:
74 //case KERN_MEMORY_PRESENT:
75 //case KERN_MEMORY_DATA_MOVED:
76 //case KERN_MEMORY_RESTART_COPY:
77 //case KERN_INVALID_PROCESSOR_SET:
78 //case KERN_POLICY_LIMIT:
79 //case KERN_INVALID_POLICY:
80 //case KERN_INVALID_OBJECT:
81 //case KERN_ALREADY_WAITING:
82 //case KERN_DEFAULT_SET:
83 //case KERN_EXCEPTION_PROTECTED:
84 //case KERN_INVALID_LEDGER:
85 //case KERN_INVALID_MEMORY_CONTROL:
86 //case KERN_INVALID_SECURITY:
87 //case KERN_NOT_DEPRESSED:
88 //case KERN_TERMINATED:
89 //case KERN_LOCK_SET_DESTROYED:
90 //case KERN_LOCK_UNSTABLE:
91 case KERN_LOCK_OWNED: return VERR_SEM_BUSY;
92 //case KERN_LOCK_OWNED_SELF:
93 case KERN_SEMAPHORE_DESTROYED: return VERR_SEM_DESTROYED;
94 //case KERN_RPC_SERVER_TERMINATED:
95 //case KERN_RPC_TERMINATE_ORPHAN:
96 //case KERN_RPC_CONTINUE_ORPHAN:
97 case KERN_NOT_SUPPORTED: return VERR_NOT_SUPPORTED;
98 //case KERN_NODE_DOWN:
99 //case KERN_NOT_WAITING:
100 case KERN_OPERATION_TIMED_OUT: return VERR_TIMEOUT;
101
102
103 /*
104 * I/O Kit.
105 */
106 case kIOReturnNoDevice: return VERR_IO_BAD_UNIT;
107 case kIOReturnUnsupported: return VERR_NOT_SUPPORTED;
108 case kIOReturnInternalError: return VERR_INTERNAL_ERROR;
109 case kIOReturnNoResources: return VERR_OUT_OF_RESOURCES;
110 case kIOReturnBadArgument: return VERR_INVALID_PARAMETER;
111 case kIOReturnCannotWire: return VERR_LOCK_FAILED;
112
113#ifdef IN_RING3
114 /*
115 * CoreFoundation COM (may overlap with I/O Kit and Mach).
116 */
117 default:
118 if ( (unsigned)iNativeCode >= 0x80000000U
119 && (unsigned)iNativeCode <= 0x8000FFFFU)
120 return RTErrConvertFromDarwinCOM(iNativeCode);
121 break;
122#endif /* IN_RING3 */
123 }
124
125 /* unknown error. */
126 AssertLogRelMsgFailed(("Unhandled error %#x\n", iNativeCode));
127 return VERR_UNRESOLVED_ERROR;
128}
129
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