summaryrefslogtreecommitdiffstats
path: root/src/VBox/Runtime/common/err
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/VBox/Runtime/common/err/Makefile.kup0
-rw-r--r--src/VBox/Runtime/common/err/RTErrConvertFromErrno.cpp457
-rw-r--r--src/VBox/Runtime/common/err/RTErrConvertToErrno.cpp451
-rw-r--r--src/VBox/Runtime/common/err/errinfo-alloc.cpp70
-rw-r--r--src/VBox/Runtime/common/err/errinfo.cpp127
-rw-r--r--src/VBox/Runtime/common/err/errinfolog.cpp185
-rw-r--r--src/VBox/Runtime/common/err/errmsg.cpp115
-rw-r--r--src/VBox/Runtime/common/err/errmsg.sed88
-rw-r--r--src/VBox/Runtime/common/err/errmsgcom.sed66
-rw-r--r--src/VBox/Runtime/common/err/errmsgxpcom.cpp154
10 files changed, 1713 insertions, 0 deletions
diff --git a/src/VBox/Runtime/common/err/Makefile.kup b/src/VBox/Runtime/common/err/Makefile.kup
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/VBox/Runtime/common/err/Makefile.kup
diff --git a/src/VBox/Runtime/common/err/RTErrConvertFromErrno.cpp b/src/VBox/Runtime/common/err/RTErrConvertFromErrno.cpp
new file mode 100644
index 00000000..302e6bf8
--- /dev/null
+++ b/src/VBox/Runtime/common/err/RTErrConvertFromErrno.cpp
@@ -0,0 +1,457 @@
+/* $Id: RTErrConvertFromErrno.cpp $ */
+/** @file
+ * IPRT - Convert errno to iprt status codes.
+ */
+
+/*
+ * Copyright (C) 2006-2019 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
+#include <iprt/err.h>
+#include "internal/iprt.h"
+
+#include <iprt/log.h>
+#include <iprt/assert.h>
+#include <iprt/errno.h>
+
+
+RTDECL(int) RTErrConvertFromErrno(unsigned uNativeCode)
+{
+ /* very fast check for no error. */
+ if (uNativeCode == 0)
+ return VINF_SUCCESS;
+
+ /*
+ * Process error codes.
+ *
+ * (Use a switch and not a table since the numbers vary among compilers
+ * and OSes. So we let the compiler switch optimizer handle speed issues.)
+ *
+ * This switch is arranged like the Linux i386 errno.h! This switch is mirrored
+ * by RTErrConvertToErrno.
+ */
+ switch (uNativeCode)
+ { /* Linux number */
+#ifdef EPERM
+ case EPERM: return VERR_ACCESS_DENIED; /* 1 */
+#endif
+#ifdef ENOENT
+ case ENOENT: return VERR_FILE_NOT_FOUND;
+#endif
+#ifdef ESRCH
+ case ESRCH: return VERR_PROCESS_NOT_FOUND;
+#endif
+#ifdef EINTR
+ case EINTR: return VERR_INTERRUPTED;
+#endif
+#ifdef EIO
+ case EIO: return VERR_DEV_IO_ERROR;
+#endif
+#ifdef ENXIO
+ case ENXIO: return VERR_DEV_IO_ERROR; /** @todo fix this duplicate error */
+#endif
+#ifdef E2BIG
+ case E2BIG: return VERR_TOO_MUCH_DATA;
+#endif
+#ifdef ENOEXEC
+ case ENOEXEC: return VERR_BAD_EXE_FORMAT;
+#endif
+#ifdef EBADF
+ case EBADF: return VERR_INVALID_HANDLE;
+#endif
+#ifdef ECHILD
+ case ECHILD: return VERR_PROCESS_NOT_FOUND; /* 10 */ /** @todo fix duplicate error */
+#endif
+#ifdef EAGAIN
+ case EAGAIN: return VERR_TRY_AGAIN;
+#endif
+#ifdef ENOMEM
+ case ENOMEM: return VERR_NO_MEMORY;
+#endif
+#ifdef EACCES
+ case EACCES: return VERR_ACCESS_DENIED; /** @todo fix duplicate error */
+#endif
+#ifdef EFAULT
+ case EFAULT: return VERR_INVALID_POINTER;
+#endif
+#ifdef ENOTBLK
+ //case ENOTBLK: return VERR_;
+#endif
+#ifdef EBUSY
+ case EBUSY: return VERR_RESOURCE_BUSY;
+#endif
+#ifdef EEXIST
+ case EEXIST: return VERR_ALREADY_EXISTS;
+#endif
+#ifdef EXDEV
+ case EXDEV: return VERR_NOT_SAME_DEVICE;
+#endif
+#ifdef ENODEV
+ case ENODEV: return VERR_NOT_SUPPORTED; /** @todo fix duplicate error */
+#endif
+#ifdef ENOTDIR
+ case ENOTDIR: return VERR_PATH_NOT_FOUND; /* 20 */
+#endif
+#ifdef EISDIR
+ case EISDIR: return VERR_IS_A_DIRECTORY;
+#endif
+#ifdef EINVAL
+ case EINVAL: return VERR_INVALID_PARAMETER;
+#endif
+#ifdef ENFILE
+ case ENFILE: return VERR_TOO_MANY_OPEN_FILES; /** @todo fix duplicate error */
+#endif
+#ifdef EMFILE
+ case EMFILE: return VERR_TOO_MANY_OPEN_FILES;
+#endif
+#ifdef ENOTTY
+ case ENOTTY: return VERR_INVALID_FUNCTION;
+#endif
+#ifdef ETXTBSY
+ case ETXTBSY: return VERR_SHARING_VIOLATION;
+#endif
+#ifdef EFBIG
+ case EFBIG: return VERR_FILE_TOO_BIG;
+#endif
+#ifdef ENOSPC
+ case ENOSPC: return VERR_DISK_FULL;
+#endif
+#ifdef ESPIPE
+ case ESPIPE: return VERR_SEEK_ON_DEVICE;
+#endif
+#ifdef EROFS
+ case EROFS: return VERR_WRITE_PROTECT; /* 30 */
+#endif
+#ifdef EMLINK
+ //case EMLINK:
+#endif
+#ifdef EPIPE
+ case EPIPE: return VERR_BROKEN_PIPE;
+#endif
+#ifdef EDOM
+ case EDOM: return VERR_INVALID_PARAMETER; /** @todo fix duplicate error */
+#endif
+#ifdef ERANGE
+ case ERANGE: return VERR_INVALID_PARAMETER; /** @todo fix duplicate error */
+#endif
+#ifdef EDEADLK
+ case EDEADLK: return VERR_DEADLOCK;
+#endif
+#ifdef ENAMETOOLONG
+ case ENAMETOOLONG: return VERR_FILENAME_TOO_LONG;
+#endif
+#ifdef ENOLCK
+ case ENOLCK: return VERR_FILE_LOCK_FAILED;
+#endif
+#ifdef ENOSYS /** @todo map this differently on solaris. */
+ case ENOSYS: return VERR_NOT_SUPPORTED;
+#endif
+#ifdef ENOTEMPTY
+ case ENOTEMPTY: return VERR_DIR_NOT_EMPTY;
+#endif
+#ifdef ELOOP
+ case ELOOP: return VERR_TOO_MANY_SYMLINKS; /* 40 */
+#endif
+ //41??
+#ifdef ENOMSG
+ //case ENOMSG 42 /* No message of desired type */
+#endif
+#ifdef EIDRM
+ //case EIDRM 43 /* Identifier removed */
+#endif
+#ifdef ECHRNG
+ //case ECHRNG 44 /* Channel number out of range */
+#endif
+#ifdef EL2NSYNC
+ //case EL2NSYNC 45 /* Level 2 not synchronized */
+#endif
+#ifdef EL3HLT
+ //case EL3HLT 46 /* Level 3 halted */
+#endif
+#ifdef EL3RST
+ //case EL3RST 47 /* Level 3 reset */
+#endif
+#ifdef ELNRNG
+ //case ELNRNG 48 /* Link number out of range */
+#endif
+#ifdef EUNATCH
+ //case EUNATCH 49 /* Protocol driver not attached */
+#endif
+#ifdef ENOCSI
+ //case ENOCSI 50 /* No CSI structure available */
+#endif
+#ifdef EL2HLT
+ //case EL2HLT 51 /* Level 2 halted */
+#endif
+#ifdef EBADE
+ //case EBADE 52 /* Invalid exchange */
+#endif
+#ifdef EBADR
+ //case EBADR 53 /* Invalid request descriptor */
+#endif
+#ifdef EXFULL
+ //case EXFULL 54 /* Exchange full */
+#endif
+#ifdef ENOANO
+ //case ENOANO 55 /* No anode */
+#endif
+#ifdef EBADRQC
+ //case EBADRQC 56 /* Invalid request code */
+#endif
+#ifdef EBADSLT
+ //case EBADSLT 57 /* Invalid slot */
+#endif
+ //case 58:
+#ifdef EBFONT
+ //case EBFONT 59 /* Bad font file format */
+#endif
+#ifdef ENOSTR
+ //case ENOSTR 60 /* Device not a stream */
+#endif
+#ifdef ENODATA
+ case ENODATA: return VERR_NO_DATA;
+#endif
+#ifdef ETIME
+ //case ETIME 62 /* Timer expired */
+#endif
+#ifdef ENOSR
+ //case ENOSR 63 /* Out of streams resources */
+#endif
+#ifdef ENONET
+ case ENONET: return VERR_NET_NO_NETWORK;
+#endif
+#ifdef ENOPKG
+ //case ENOPKG 65 /* Package not installed */
+#endif
+#ifdef EREMOTE
+ //case EREMOTE 66 /* Object is remote */
+#endif
+#ifdef ENOLINK
+ //case ENOLINK 67 /* Link has been severed */
+#endif
+#ifdef EADV
+ //case EADV 68 /* Advertise error */
+#endif
+#ifdef ESRMNT
+ //case ESRMNT 69 /* Srmount error */
+#endif
+#ifdef ECOMM
+ //case ECOMM 70 /* Communication error on send */
+#endif
+#ifdef EPROTO
+ case EPROTO: return VERR_NET_PROTOCOL_ERROR;
+#endif
+#ifdef EMULTIHOP
+ //case EMULTIHOP 72 /* Multihop attempted */
+#endif
+#ifdef EDOTDOT
+ //case EDOTDOT 73 /* RFS specific error */
+#endif
+#ifdef EBADMSG
+ //case EBADMSG 74 /* Not a data message */
+#endif
+#ifdef EOVERFLOW
+ case EOVERFLOW: return VERR_TOO_MUCH_DATA; /** @todo fix duplicate error */
+#endif
+#ifdef ENOTUNIQ
+ case ENOTUNIQ: return VERR_NET_NOT_UNIQUE_NAME;
+#endif
+#ifdef EBADFD
+ case EBADFD: return VERR_INVALID_HANDLE; /** @todo fix duplicate error? */
+#endif
+#ifdef EREMCHG
+ //case EREMCHG 78 /* Remote address changed */
+#endif
+#ifdef ELIBACC
+ //case ELIBACC 79 /* Can not access a needed shared library */
+#endif
+#ifdef ELIBBAD
+ //case ELIBBAD 80 /* Accessing a corrupted shared library */
+#endif
+#ifdef ELIBSCN
+ //case ELIBSCN 81 /* .lib section in a.out corrupted */
+#endif
+#ifdef ELIBMAX
+ //case ELIBMAX 82 /* Attempting to link in too many shared libraries */
+#endif
+#ifdef ELIBEXEC
+ //case ELIBEXEC 83 /* Cannot exec a shared library directly */
+#endif
+#ifdef EILSEQ
+ case EILSEQ: return VERR_NO_TRANSLATION;
+#endif
+#ifdef ERESTART
+ case ERESTART: return VERR_INTERRUPTED;/** @todo fix duplicate error?*/
+#endif
+#ifdef ESTRPIPE
+ //case ESTRPIPE 86 /* Streams pipe error */
+#endif
+#ifdef EUSERS
+ //case EUSERS 87 /* Too many users */
+#endif
+#ifdef ENOTSOCK
+ case ENOTSOCK: return VERR_NET_NOT_SOCKET;
+#endif
+#ifdef EDESTADDRREQ
+ case EDESTADDRREQ: return VERR_NET_DEST_ADDRESS_REQUIRED;
+#endif
+#ifdef EMSGSIZE
+ case EMSGSIZE: return VERR_NET_MSG_SIZE;
+#endif
+#ifdef EPROTOTYPE
+ case EPROTOTYPE: return VERR_NET_PROTOCOL_TYPE;
+#endif
+#ifdef ENOPROTOOPT
+ case ENOPROTOOPT: return VERR_NET_PROTOCOL_NOT_AVAILABLE;
+#endif
+#ifdef EPROTONOSUPPORT
+ case EPROTONOSUPPORT: return VERR_NET_PROTOCOL_NOT_SUPPORTED;
+#endif
+#ifdef ESOCKTNOSUPPORT
+ case ESOCKTNOSUPPORT: return VERR_NET_SOCKET_TYPE_NOT_SUPPORTED;
+#endif
+#ifdef EOPNOTSUPP /** @todo map this differently on solaris. */
+ case EOPNOTSUPP: return VERR_NET_OPERATION_NOT_SUPPORTED;
+#endif
+#ifdef EPFNOSUPPORT
+ case EPFNOSUPPORT: return VERR_NET_PROTOCOL_FAMILY_NOT_SUPPORTED;
+#endif
+#ifdef EAFNOSUPPORT
+ case EAFNOSUPPORT: return VERR_NET_ADDRESS_FAMILY_NOT_SUPPORTED;
+#endif
+#ifdef EADDRINUSE
+ case EADDRINUSE: return VERR_NET_ADDRESS_IN_USE;
+#endif
+#ifdef EADDRNOTAVAIL
+ case EADDRNOTAVAIL: return VERR_NET_ADDRESS_NOT_AVAILABLE;
+#endif
+#ifdef ENETDOWN
+ case ENETDOWN: return VERR_NET_DOWN;
+#endif
+#ifdef ENETUNREACH
+ case ENETUNREACH: return VERR_NET_UNREACHABLE;
+#endif
+#ifdef ENETRESET
+ case ENETRESET: return VERR_NET_CONNECTION_RESET;
+#endif
+#ifdef ECONNABORTED
+ case ECONNABORTED: return VERR_NET_CONNECTION_ABORTED;
+#endif
+#ifdef ECONNRESET
+ case ECONNRESET: return VERR_NET_CONNECTION_RESET_BY_PEER;
+#endif
+#ifdef ENOBUFS
+ case ENOBUFS: return VERR_NET_NO_BUFFER_SPACE;
+#endif
+#ifdef EISCONN
+ case EISCONN: return VERR_NET_ALREADY_CONNECTED;
+#endif
+#ifdef ENOTCONN
+ case ENOTCONN: return VERR_NET_NOT_CONNECTED;
+#endif
+#ifdef ESHUTDOWN
+ case ESHUTDOWN: return VERR_NET_SHUTDOWN;
+#endif
+#ifdef ETOOMANYREFS
+ case ETOOMANYREFS: return VERR_NET_TOO_MANY_REFERENCES;
+#endif
+#ifdef ETIMEDOUT
+ case ETIMEDOUT: return VERR_TIMEOUT;
+#endif
+#ifdef ECONNREFUSED
+ case ECONNREFUSED: return VERR_NET_CONNECTION_REFUSED;
+#endif
+#ifdef EHOSTDOWN
+ case EHOSTDOWN: return VERR_NET_HOST_DOWN;
+#endif
+#ifdef EHOSTUNREACH
+ case EHOSTUNREACH: return VERR_NET_HOST_UNREACHABLE;
+#endif
+#ifdef EALREADY
+# if !defined(ENOLCK) || (EALREADY != ENOLCK)
+ case EALREADY: return VERR_NET_ALREADY_IN_PROGRESS;
+# endif
+#endif
+#ifdef EINPROGRESS
+# if !defined(ENODEV) || (EINPROGRESS != ENODEV)
+ case EINPROGRESS: return VERR_NET_IN_PROGRESS;
+# endif
+#endif
+#ifdef ESTALE
+ //case ESTALE 116 /* Stale NFS file handle */
+#endif
+#ifdef EUCLEAN
+ //case EUCLEAN 117 /* Structure needs cleaning */
+#endif
+#ifdef ENOTNAM
+ //case ENOTNAM 118 /* Not a XENIX named type file */
+#endif
+#ifdef ENAVAIL
+ //case ENAVAIL 119 /* No XENIX semaphores available */
+#endif
+#ifdef EISNAM
+ //case EISNAM 120 /* Is a named type file */
+#endif
+#ifdef EREMOTEIO
+ //case EREMOTEIO 121 /* Remote I/O error */
+#endif
+#ifdef EDQUOT
+ case EDQUOT: return VERR_DISK_FULL; /** @todo fix duplicate error */
+#endif
+#ifdef ENOMEDIUM
+ case ENOMEDIUM: return VERR_MEDIA_NOT_PRESENT;
+#endif
+#ifdef EMEDIUMTYPE
+ case EMEDIUMTYPE: return VERR_MEDIA_NOT_RECOGNIZED;
+#endif
+#if defined(EWOULDBLOCK) && (EWOULDBLOCK != EAGAIN)
+ case EWOULDBLOCK: return VERR_TRY_AGAIN;
+#endif
+
+ /* Non-linux */
+
+#ifdef EPROCLIM
+ case EPROCLIM: return VERR_MAX_PROCS_REACHED;
+#endif
+#ifdef EDOOFUS
+# if EDOOFUS != EINVAL
+ case EDOOFUS: return VERR_INTERNAL_ERROR;
+# endif
+#endif
+#ifdef ENOTSUP
+# ifndef EOPNOTSUPP
+ case ENOTSUP: return VERR_NOT_SUPPORTED;
+# else
+# if ENOTSUP != EOPNOTSUPP
+ case ENOTSUP: return VERR_NOT_SUPPORTED;
+# endif
+# endif
+#endif
+ default:
+ AssertLogRelMsgFailed(("Unhandled error code %d\n", uNativeCode));
+ return VERR_UNRESOLVED_ERROR;
+ }
+}
+RT_EXPORT_SYMBOL(RTErrConvertFromErrno);
+
diff --git a/src/VBox/Runtime/common/err/RTErrConvertToErrno.cpp b/src/VBox/Runtime/common/err/RTErrConvertToErrno.cpp
new file mode 100644
index 00000000..3faf1ee5
--- /dev/null
+++ b/src/VBox/Runtime/common/err/RTErrConvertToErrno.cpp
@@ -0,0 +1,451 @@
+/* $Id: RTErrConvertToErrno.cpp $ */
+/** @file
+ * IPRT - Convert iprt status codes to errno.
+ */
+
+/*
+ * Copyright (C) 2007-2019 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
+#include <iprt/err.h>
+#include "internal/iprt.h"
+
+#include <iprt/assert.h>
+#include <iprt/err.h>
+#include <iprt/errno.h>
+
+
+RTDECL(int) RTErrConvertToErrno(int iErr)
+{
+ /* very fast check for no error. */
+ if (RT_SUCCESS(iErr))
+ return 0;
+
+ /*
+ * Process error codes.
+ *
+ * (Use a switch and not a table since the numbers vary among compilers
+ * and OSes. So we let the compiler switch optimizer handle speed issues.)
+ *
+ * This switch is arranged like the Linux i386 errno.h! It also mirrors the
+ * conversions performed by RTErrConvertFromErrno with a few extra case since
+ * there are far more IPRT status codes than Unix ones.
+ */
+ switch (iErr)
+ {
+#ifdef EPERM
+ case VERR_ACCESS_DENIED: return EPERM;
+#endif
+#ifdef ENOENT
+ case VERR_FILE_NOT_FOUND: return ENOENT;
+#endif
+#ifdef ESRCH
+ case VERR_PROCESS_NOT_FOUND: return ESRCH;
+#endif
+#ifdef EINTR
+ case VERR_INTERRUPTED: return EINTR;
+#endif
+#ifdef EIO
+ case VERR_DEV_IO_ERROR: return EIO;
+#endif
+#ifdef ENXIO
+ //case VERR_DEV_IO_ERROR: return ENXIO;
+#endif
+#ifdef E2BIG
+ case VERR_TOO_MUCH_DATA: return E2BIG;
+#endif
+#ifdef ENOEXEC
+ case VERR_BAD_EXE_FORMAT: return ENOEXEC;
+#endif
+#ifdef EBADF
+ case VERR_INVALID_HANDLE: return EBADF;
+#endif
+#ifdef ECHILD
+ //case VERR_PROCESS_NOT_FOUND: return ECHILD;
+#endif
+#ifdef EAGAIN
+ case VERR_TRY_AGAIN: return EAGAIN;
+#endif
+#ifdef ENOMEM
+ case VERR_NO_MEMORY: return ENOMEM;
+#endif
+#ifdef EACCES
+ //case VERR_ACCESS_DENIED: return EACCES;
+#endif
+#ifdef EFAULT
+ case VERR_INVALID_POINTER: return EFAULT;
+#endif
+#ifdef ENOTBLK
+ //case ENOTBLK: return VERR_;
+#endif
+#ifdef EBUSY
+ case VERR_RESOURCE_BUSY: return EBUSY;
+#endif
+#ifdef EEXIST
+ case VERR_ALREADY_EXISTS: return EEXIST;
+#endif
+#ifdef EXDEV
+ case VERR_NOT_SAME_DEVICE: return EXDEV;
+#endif
+#ifdef ENODEV
+ //case VERR_NOT_SUPPORTED: return ENODEV;
+#endif
+#ifdef ENOTDIR
+ case VERR_NOT_A_DIRECTORY:
+ case VERR_PATH_NOT_FOUND: return ENOTDIR;
+#endif
+#ifdef EISDIR
+ case VERR_IS_A_DIRECTORY: return EISDIR;
+#endif
+#ifdef EINVAL
+ case VERR_INVALID_PARAMETER: return EINVAL;
+#endif
+#ifdef ENFILE
+ case VERR_TOO_MANY_OPEN_FILES: return ENFILE;
+#endif
+#ifdef EMFILE
+ //case VERR_TOO_MANY_OPEN_FILES: return EMFILE;
+#endif
+#ifdef ENOTTY
+ case VERR_INVALID_FUNCTION: return ENOTTY;
+#endif
+#ifdef ETXTBSY
+ case VERR_SHARING_VIOLATION: return ETXTBSY;
+#endif
+#ifdef EFBIG
+ case VERR_FILE_TOO_BIG: return EFBIG;
+#endif
+#ifdef ENOSPC
+ case VERR_DISK_FULL: return ENOSPC;
+#endif
+#ifdef ESPIPE
+ case VERR_SEEK_ON_DEVICE: return ESPIPE;
+#endif
+#ifdef EROFS
+ case VERR_WRITE_PROTECT: return EROFS;
+#endif
+#ifdef EMLINK
+ //case EMLINK:
+#endif
+#ifdef EPIPE
+ case VERR_BROKEN_PIPE: return EPIPE;
+#endif
+#ifdef EDOM
+ //case VERR_INVALID_PARAMETER: return EDOM;
+#endif
+#ifdef ERANGE
+ //case VERR_INVALID_PARAMETER: return ERANGE;
+#endif
+#ifdef EDEADLK
+ case VERR_DEADLOCK: return EDEADLK;
+#endif
+#ifdef ENAMETOOLONG
+ case VERR_FILENAME_TOO_LONG: return ENAMETOOLONG;
+#endif
+#ifdef ENOLCK
+ case VERR_FILE_LOCK_FAILED: return ENOLCK;
+#endif
+#ifdef ENOSYS
+ case VERR_NOT_IMPLEMENTED:
+ case VERR_NOT_SUPPORTED: return ENOSYS;
+#endif
+#ifdef ENOTEMPTY
+ case VERR_DIR_NOT_EMPTY: return ENOTEMPTY;
+#endif
+#ifdef ELOOP
+ case VERR_TOO_MANY_SYMLINKS: return ELOOP;
+#endif
+ //41??
+#ifdef ENOMSG
+ //case ENOMSG 42 /* No message of desired type */
+#endif
+#ifdef EIDRM
+ //case EIDRM 43 /* Identifier removed */
+#endif
+#ifdef ECHRNG
+ //case ECHRNG 44 /* Channel number out of range */
+#endif
+#ifdef EL2NSYNC
+ //case EL2NSYNC 45 /* Level 2 not synchronized */
+#endif
+#ifdef EL3HLT
+ //case EL3HLT 46 /* Level 3 halted */
+#endif
+#ifdef EL3RST
+ //case EL3RST 47 /* Level 3 reset */
+#endif
+#ifdef ELNRNG
+ //case ELNRNG 48 /* Link number out of range */
+#endif
+#ifdef EUNATCH
+ //case EUNATCH 49 /* Protocol driver not attached */
+#endif
+#ifdef ENOCSI
+ //case ENOCSI 50 /* No CSI structure available */
+#endif
+#ifdef EL2HLT
+ //case EL2HLT 51 /* Level 2 halted */
+#endif
+#ifdef EBADE
+ //case EBADE 52 /* Invalid exchange */
+#endif
+#ifdef EBADR
+ //case EBADR 53 /* Invalid request descriptor */
+#endif
+#ifdef EXFULL
+ //case EXFULL 54 /* Exchange full */
+#endif
+#ifdef ENOANO
+ //case ENOANO 55 /* No anode */
+#endif
+#ifdef EBADRQC
+ //case EBADRQC 56 /* Invalid request code */
+#endif
+#ifdef EBADSLT
+ //case EBADSLT 57 /* Invalid slot */
+#endif
+ //case 58:
+#ifdef EBFONT
+ //case EBFONT 59 /* Bad font file format */
+#endif
+#ifdef ENOSTR
+ //case ENOSTR 60 /* Device not a stream */
+#endif
+#ifdef ENODATA
+ case VERR_NO_DATA: return ENODATA;
+#endif
+#ifdef ETIME
+ //case ETIME 62 /* Timer expired */
+#endif
+#ifdef ENOSR
+ //case ENOSR 63 /* Out of streams resources */
+#endif
+#ifdef ENONET
+ case VERR_NET_NO_NETWORK: return ENONET;
+#endif
+#ifdef ENOPKG
+ //case ENOPKG 65 /* Package not installed */
+#endif
+#ifdef EREMOTE
+ //case EREMOTE 66 /* Object is remote */
+#endif
+#ifdef ENOLINK
+ //case ENOLINK 67 /* Link has been severed */
+#endif
+#ifdef EADV
+ //case EADV 68 /* Advertise error */
+#endif
+#ifdef ESRMNT
+ //case ESRMNT 69 /* Srmount error */
+#endif
+#ifdef ECOMM
+ //case ECOMM 70 /* Communication error on send */
+#endif
+#ifdef EPROTO
+ //case EPROTO 71 /* Protocol error */
+#endif
+#ifdef EMULTIHOP
+ //case EMULTIHOP 72 /* Multihop attempted */
+#endif
+#ifdef EDOTDOT
+ //case EDOTDOT 73 /* RFS specific error */
+#endif
+#ifdef EBADMSG
+ //case EBADMSG 74 /* Not a data message */
+#endif
+#ifdef EOVERFLOW
+ //case VERR_TOO_MUCH_DATA: return EOVERFLOW;
+#endif
+#ifdef ENOTUNIQ
+ case VERR_NET_NOT_UNIQUE_NAME: return ENOTUNIQ;
+#endif
+#ifdef EBADFD
+ //case VERR_INVALID_HANDLE: return EBADFD;
+#endif
+#ifdef EREMCHG
+ //case EREMCHG 78 /* Remote address changed */
+#endif
+#ifdef ELIBACC
+ //case ELIBACC 79 /* Can not access a needed shared library */
+#endif
+#ifdef ELIBBAD
+ //case ELIBBAD 80 /* Accessing a corrupted shared library */
+#endif
+#ifdef ELIBSCN
+ //case ELIBSCN 81 /* .lib section in a.out corrupted */
+#endif
+#ifdef ELIBMAX
+ //case ELIBMAX 82 /* Attempting to link in too many shared libraries */
+#endif
+#ifdef ELIBEXEC
+ //case ELIBEXEC 83 /* Cannot exec a shared library directly */
+#endif
+#ifdef EILSEQ
+ case VERR_NO_TRANSLATION: return EILSEQ;
+#endif
+#ifdef ERESTART
+ //case VERR_INTERRUPTED: return ERESTART;
+#endif
+#ifdef ESTRPIPE
+ //case ESTRPIPE 86 /* Streams pipe error */
+#endif
+#ifdef EUSERS
+ //case EUSERS 87 /* Too many users */
+#endif
+#ifdef ENOTSOCK
+ case VERR_NET_NOT_SOCKET: return ENOTSOCK;
+#endif
+#ifdef EDESTADDRREQ
+ case VERR_NET_DEST_ADDRESS_REQUIRED: return EDESTADDRREQ;
+#endif
+#ifdef EMSGSIZE
+ case VERR_NET_MSG_SIZE: return EMSGSIZE;
+#endif
+#ifdef EPROTOTYPE
+ case VERR_NET_PROTOCOL_TYPE: return EPROTOTYPE;
+#endif
+#ifdef ENOPROTOOPT
+ case VERR_NET_PROTOCOL_NOT_AVAILABLE: return ENOPROTOOPT;
+#endif
+#ifdef EPROTONOSUPPORT
+ case VERR_NET_PROTOCOL_NOT_SUPPORTED: return EPROTONOSUPPORT;
+#endif
+#ifdef ESOCKTNOSUPPORT
+ case VERR_NET_SOCKET_TYPE_NOT_SUPPORTED: return ESOCKTNOSUPPORT;
+#endif
+#ifdef EOPNOTSUPP
+ case VERR_NET_OPERATION_NOT_SUPPORTED: return EOPNOTSUPP;
+#endif
+#ifdef EPFNOSUPPORT
+ case VERR_NET_PROTOCOL_FAMILY_NOT_SUPPORTED: return EPFNOSUPPORT;
+#endif
+#ifdef EAFNOSUPPORT
+ case VERR_NET_ADDRESS_FAMILY_NOT_SUPPORTED: return EAFNOSUPPORT;
+#endif
+#ifdef EADDRINUSE
+ case VERR_NET_ADDRESS_IN_USE: return EADDRINUSE;
+#endif
+#ifdef EADDRNOTAVAIL
+ case VERR_NET_ADDRESS_NOT_AVAILABLE: return EADDRNOTAVAIL;
+#endif
+#ifdef ENETDOWN
+ case VERR_NET_DOWN: return ENETDOWN;
+#endif
+#ifdef ENETUNREACH
+ case VERR_NET_UNREACHABLE: return ENETUNREACH;
+#endif
+#ifdef ENETRESET
+ case VERR_NET_CONNECTION_RESET: return ENETRESET;
+#endif
+#ifdef ECONNABORTED
+ case VERR_NET_CONNECTION_ABORTED: return ECONNABORTED;
+#endif
+#ifdef ECONNRESET
+ case VERR_NET_CONNECTION_RESET_BY_PEER: return ECONNRESET;
+#endif
+#ifdef ENOBUFS
+ case VERR_NET_NO_BUFFER_SPACE: return ENOBUFS;
+#endif
+#ifdef EISCONN
+ case VERR_NET_ALREADY_CONNECTED: return EISCONN;
+#endif
+#ifdef ENOTCONN
+ case VERR_NET_NOT_CONNECTED: return ENOTCONN;
+#endif
+#ifdef ESHUTDOWN
+ case VERR_NET_SHUTDOWN: return ESHUTDOWN;
+#endif
+#ifdef ETOOMANYREFS
+ case VERR_NET_TOO_MANY_REFERENCES: return ETOOMANYREFS;
+#endif
+#ifdef ETIMEDOUT
+ case VERR_TIMEOUT: return ETIMEDOUT;
+#endif
+#ifdef ECONNREFUSED
+ case VERR_NET_CONNECTION_REFUSED: return ECONNREFUSED;
+#endif
+#ifdef EHOSTDOWN
+ case VERR_NET_HOST_DOWN: return EHOSTDOWN;
+#endif
+#ifdef EHOSTUNREACH
+ case VERR_NET_HOST_UNREACHABLE: return EHOSTUNREACH;
+#endif
+#ifdef EALREADY
+ case VERR_NET_ALREADY_IN_PROGRESS: return EALREADY;
+#endif
+#ifdef EINPROGRESS
+ case VERR_NET_IN_PROGRESS: return EINPROGRESS;
+#endif
+#ifdef ESTALE
+ //case ESTALE 116 /* Stale NFS file handle */
+#endif
+#ifdef EUCLEAN
+ //case EUCLEAN 117 /* Structure needs cleaning */
+#endif
+#ifdef ENOTNAM
+ //case ENOTNAM 118 /* Not a XENIX named type file */
+#endif
+#ifdef ENAVAIL
+ //case ENAVAIL 119 /* No XENIX semaphores available */
+#endif
+#ifdef EISNAM
+ //case EISNAM 120 /* Is a named type file */
+#endif
+#ifdef EREMOTEIO
+ //case EREMOTEIO 121 /* Remote I/O error */
+#endif
+#ifdef EDQUOT
+ //case VERR_DISK_FULL: return EDQUOT;
+#endif
+#ifdef ENOMEDIUM
+ case VERR_MEDIA_NOT_PRESENT: return ENOMEDIUM;
+#endif
+#ifdef EMEDIUMTYPE
+ case VERR_MEDIA_NOT_RECOGNIZED: return EMEDIUMTYPE;
+#endif
+
+ /* Non-linux */
+
+#ifdef EPROCLIM
+ case VERR_MAX_PROCS_REACHED: return EPROCLIM;
+#endif
+#ifdef EDOOFUS
+ case VERR_INTERNAL_ERROR:
+ case VERR_INTERNAL_ERROR_2:
+ case VERR_INTERNAL_ERROR_3: return EDOOFUS;
+#endif
+
+ default:
+ /* The idea here is that if you hit this, you will have to
+ translate the status code yourself. */
+ AssertMsgFailed(("Unhandled error code %Rrc\n", iErr));
+#ifdef EPROTO
+ return EPROTO;
+#else
+ return EINVAL;
+#endif
+ }
+}
+RT_EXPORT_SYMBOL(RTErrConvertToErrno);
+
diff --git a/src/VBox/Runtime/common/err/errinfo-alloc.cpp b/src/VBox/Runtime/common/err/errinfo-alloc.cpp
new file mode 100644
index 00000000..d95caeaa
--- /dev/null
+++ b/src/VBox/Runtime/common/err/errinfo-alloc.cpp
@@ -0,0 +1,70 @@
+/* $Id: errinfo-alloc.cpp $ */
+/** @file
+ * IPRT - Error Info, Allocators.
+ */
+
+/*
+ * Copyright (C) 2010-2019 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
+#include "internal/iprt.h"
+#include <iprt/err.h>
+
+#include <iprt/assert.h>
+#include <iprt/mem.h>
+#include <iprt/string.h>
+
+
+
+RTDECL(PRTERRINFO) RTErrInfoAlloc(size_t cbMsg)
+{
+ PRTERRINFO pErrInfo;
+ RTErrInfoAllocEx(cbMsg, &pErrInfo);
+ return pErrInfo;
+}
+
+
+RTDECL(int) RTErrInfoAllocEx(size_t cbMsg, PRTERRINFO *ppErrInfo)
+{
+ if (cbMsg == 0)
+ cbMsg = _4K;
+ else
+ cbMsg = RT_ALIGN_Z(cbMsg, 256);
+
+ PRTERRINFO pErrInfo;
+ *ppErrInfo = pErrInfo = (PRTERRINFO)RTMemTmpAlloc(sizeof(*pErrInfo) + cbMsg);
+ if (RT_UNLIKELY(!pErrInfo))
+ return VERR_NO_TMP_MEMORY;
+
+ RTErrInfoInit(pErrInfo, (char *)(pErrInfo + 1), cbMsg);
+ pErrInfo->fFlags = RTERRINFO_FLAGS_T_ALLOC | RTERRINFO_FLAGS_MAGIC;
+ return VINF_SUCCESS;
+}
+
+
+RTDECL(void) RTErrInfoFree(PRTERRINFO pErrInfo)
+{
+ RTMemTmpFree(pErrInfo);
+}
+
diff --git a/src/VBox/Runtime/common/err/errinfo.cpp b/src/VBox/Runtime/common/err/errinfo.cpp
new file mode 100644
index 00000000..a4b0c08c
--- /dev/null
+++ b/src/VBox/Runtime/common/err/errinfo.cpp
@@ -0,0 +1,127 @@
+/* $Id: errinfo.cpp $ */
+/** @file
+ * IPRT - Error Info, Setters.
+ */
+
+/*
+ * Copyright (C) 2010-2019 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
+#include "internal/iprt.h"
+#include <iprt/errcore.h>
+
+#include <iprt/assert.h>
+#include <iprt/string.h>
+
+
+RTDECL(int) RTErrInfoSet(PRTERRINFO pErrInfo, int rc, const char *pszMsg)
+{
+ if (pErrInfo)
+ {
+ AssertPtr(pErrInfo);
+ Assert((pErrInfo->fFlags & RTERRINFO_FLAGS_MAGIC_MASK) == RTERRINFO_FLAGS_MAGIC);
+
+ RTStrCopy(pErrInfo->pszMsg, pErrInfo->cbMsg, pszMsg);
+ pErrInfo->rc = rc;
+ pErrInfo->fFlags |= RTERRINFO_FLAGS_SET;
+ }
+ return rc;
+}
+
+
+RTDECL(int) RTErrInfoSetF(PRTERRINFO pErrInfo, int rc, const char *pszFormat, ...)
+{
+ va_list va;
+ va_start(va, pszFormat);
+ RTErrInfoSetV(pErrInfo, rc, pszFormat, va);
+ va_end(va);
+ return rc;
+}
+
+
+RTDECL(int) RTErrInfoSetV(PRTERRINFO pErrInfo, int rc, const char *pszFormat, va_list va)
+{
+ if (pErrInfo)
+ {
+ AssertPtr(pErrInfo);
+ Assert((pErrInfo->fFlags & RTERRINFO_FLAGS_MAGIC_MASK) == RTERRINFO_FLAGS_MAGIC);
+
+ RTStrPrintfV(pErrInfo->pszMsg, pErrInfo->cbMsg, pszFormat, va);
+ pErrInfo->rc = rc;
+ pErrInfo->fFlags |= RTERRINFO_FLAGS_SET;
+ }
+ return rc;
+}
+
+
+RTDECL(int) RTErrInfoAdd(PRTERRINFO pErrInfo, int rc, const char *pszMsg)
+{
+ if (pErrInfo)
+ {
+ AssertPtr(pErrInfo);
+ if (pErrInfo->fFlags & RTERRINFO_FLAGS_SET)
+ RTStrCat(pErrInfo->pszMsg, pErrInfo->cbMsg, pszMsg);
+ else
+ {
+ while (*pszMsg == ' ')
+ pszMsg++;
+ return RTErrInfoSet(pErrInfo, rc, pszMsg);
+ }
+ }
+ return rc;
+}
+
+
+RTDECL(int) RTErrInfoAddF(PRTERRINFO pErrInfo, int rc, const char *pszFormat, ...)
+{
+ va_list va;
+ va_start(va, pszFormat);
+ RTErrInfoAddV(pErrInfo, rc, pszFormat, va);
+ va_end(va);
+ return rc;
+}
+
+
+RTDECL(int) RTErrInfoAddV(PRTERRINFO pErrInfo, int rc, const char *pszFormat, va_list va)
+{
+ if (pErrInfo)
+ {
+ AssertPtr(pErrInfo);
+ Assert((pErrInfo->fFlags & RTERRINFO_FLAGS_MAGIC_MASK) == RTERRINFO_FLAGS_MAGIC);
+ if (pErrInfo->fFlags & RTERRINFO_FLAGS_SET)
+ {
+ char *pszOut = (char *)memchr(pErrInfo->pszMsg, '\0', pErrInfo->cbMsg - 2);
+ if (pszOut)
+ RTStrPrintfV(pszOut, &pErrInfo->pszMsg[pErrInfo->cbMsg] - pszOut, pszFormat, va);
+ }
+ else
+ {
+ while (*pszFormat == ' ')
+ pszFormat++;
+ return RTErrInfoSetV(pErrInfo, rc, pszFormat, va);
+ }
+ }
+ return rc;
+}
+
diff --git a/src/VBox/Runtime/common/err/errinfolog.cpp b/src/VBox/Runtime/common/err/errinfolog.cpp
new file mode 100644
index 00000000..adad6cb3
--- /dev/null
+++ b/src/VBox/Runtime/common/err/errinfolog.cpp
@@ -0,0 +1,185 @@
+/* $Id: errinfolog.cpp $ */
+/** @file
+ * IPRT - Error Info, Setters with logging.
+ */
+
+/*
+ * Copyright (C) 2010-2019 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
+#include "internal/iprt.h"
+#include <iprt/errcore.h>
+
+#include <iprt/assert.h>
+#include <iprt/string.h>
+#include <iprt/log.h>
+
+
+RTDECL(int) RTErrInfoLogAndSet(PRTERRINFO pErrInfo, int rc, uint32_t iLogGroup, uint32_t fFlags, const char *pszMsg)
+{
+ /* The logging: */
+ if (fFlags & RTERRINFO_LOG_F_RELEASE)
+ {
+ PRTLOGGER pLogger = RTLogRelGetDefaultInstanceEx(RT_MAKE_U32(RTLOGGRPFLAGS_LEVEL_1, iLogGroup));
+ if (pLogger)
+ RTLogLoggerEx(pLogger, RTLOGGRPFLAGS_LEVEL_1, iLogGroup, "RTErrInfoSet(%Rrc): %s\n", rc, pszMsg);
+ }
+
+ PRTLOGGER pLogger = RTLogGetDefaultInstanceEx(RT_MAKE_U32(RTLOGGRPFLAGS_LEVEL_1, iLogGroup));
+ if (pLogger)
+ RTLogLoggerEx(pLogger, RTLOGGRPFLAGS_LEVEL_1, iLogGroup, "RTErrInfoSet(%Rrc): %s\n", rc, pszMsg);
+
+ /* The setting: */
+ if (pErrInfo)
+ {
+ AssertPtr(pErrInfo);
+ Assert((pErrInfo->fFlags & RTERRINFO_FLAGS_MAGIC_MASK) == RTERRINFO_FLAGS_MAGIC);
+
+ RTStrCopy(pErrInfo->pszMsg, pErrInfo->cbMsg, pszMsg);
+ pErrInfo->rc = rc;
+ pErrInfo->fFlags |= RTERRINFO_FLAGS_SET;
+ }
+ return rc;
+}
+
+
+RTDECL(int) RTErrInfoLogAndSetF(PRTERRINFO pErrInfo, int rc, uint32_t iLogGroup, uint32_t fFlags, const char *pszFormat, ...)
+{
+ va_list va;
+ va_start(va, pszFormat);
+ RTErrInfoLogAndSetV(pErrInfo, rc, iLogGroup, fFlags, pszFormat, va);
+ va_end(va);
+ return rc;
+}
+
+
+RTDECL(int) RTErrInfoLogAndSetV(PRTERRINFO pErrInfo, int rc, uint32_t iLogGroup, uint32_t fFlags, const char *pszFormat, va_list va)
+{
+ /* The logging: */
+ if (fFlags & RTERRINFO_LOG_F_RELEASE)
+ {
+ PRTLOGGER pLogger = RTLogRelGetDefaultInstanceEx(RT_MAKE_U32(RTLOGGRPFLAGS_LEVEL_1, iLogGroup));
+ if (pLogger)
+ RTLogLoggerEx(pLogger, RTLOGGRPFLAGS_LEVEL_1, iLogGroup, "RTErrInfoSet(%Rrc): %N\n", rc, pszFormat, &va);
+ }
+
+ PRTLOGGER pLogger = RTLogGetDefaultInstanceEx(RT_MAKE_U32(RTLOGGRPFLAGS_LEVEL_1, iLogGroup));
+ if (pLogger)
+ RTLogLoggerEx(pLogger, RTLOGGRPFLAGS_LEVEL_1, iLogGroup, "RTErrInfoSet(%Rrc): %N\n", rc, pszFormat, &va);
+
+ /* The setting: */
+ if (pErrInfo)
+ {
+ AssertPtr(pErrInfo);
+ Assert((pErrInfo->fFlags & RTERRINFO_FLAGS_MAGIC_MASK) == RTERRINFO_FLAGS_MAGIC);
+
+ RTStrPrintfV(pErrInfo->pszMsg, pErrInfo->cbMsg, pszFormat, va);
+ pErrInfo->rc = rc;
+ pErrInfo->fFlags |= RTERRINFO_FLAGS_SET;
+ }
+ return rc;
+}
+
+
+RTDECL(int) RTErrInfoLogAndAdd(PRTERRINFO pErrInfo, int rc, uint32_t iLogGroup, uint32_t fFlags, const char *pszMsg)
+{
+ if (pErrInfo)
+ {
+ AssertPtr(pErrInfo);
+ if (pErrInfo->fFlags & RTERRINFO_FLAGS_SET)
+ RTStrCat(pErrInfo->pszMsg, pErrInfo->cbMsg, pszMsg);
+ else
+ {
+ while (*pszMsg == ' ')
+ pszMsg++;
+ return RTErrInfoSet(pErrInfo, rc, pszMsg);
+ }
+ }
+
+ /* The logging: */
+ if (fFlags & RTERRINFO_LOG_F_RELEASE)
+ {
+ PRTLOGGER pLogger = RTLogRelGetDefaultInstanceEx(RT_MAKE_U32(RTLOGGRPFLAGS_LEVEL_1, iLogGroup));
+ if (pLogger)
+ RTLogLoggerEx(pLogger, RTLOGGRPFLAGS_LEVEL_1, iLogGroup, "RTErrInfoAdd(%Rrc): %s\n", rc, pszMsg);
+ }
+
+ PRTLOGGER pLogger = RTLogGetDefaultInstanceEx(RT_MAKE_U32(RTLOGGRPFLAGS_LEVEL_1, iLogGroup));
+ if (pLogger)
+ RTLogLoggerEx(pLogger, RTLOGGRPFLAGS_LEVEL_1, iLogGroup, "RTErrInfoAdd(%Rrc): %s\n", rc, pszMsg);
+
+ return rc;
+}
+
+
+RTDECL(int) RTErrInfoLogAndAddF(PRTERRINFO pErrInfo, int rc, uint32_t iLogGroup, uint32_t fFlags, const char *pszFormat, ...)
+{
+ va_list va;
+ va_start(va, pszFormat);
+ RTErrInfoLogAndAddV(pErrInfo, rc, iLogGroup, fFlags, pszFormat, va);
+ va_end(va);
+ return rc;
+}
+
+
+RTDECL(int) RTErrInfoLogAndAddV(PRTERRINFO pErrInfo, int rc, uint32_t iLogGroup, uint32_t fFlags, const char *pszFormat, va_list va)
+{
+ if (pErrInfo)
+ {
+ AssertPtr(pErrInfo);
+ Assert((pErrInfo->fFlags & RTERRINFO_FLAGS_MAGIC_MASK) == RTERRINFO_FLAGS_MAGIC);
+ if (pErrInfo->fFlags & RTERRINFO_FLAGS_SET)
+ {
+ char *pszOut = (char *)memchr(pErrInfo->pszMsg, '\0', pErrInfo->cbMsg - 2);
+ if (pszOut)
+ {
+ va_list va2;
+ va_copy(va2, va);
+ RTStrPrintfV(pszOut, &pErrInfo->pszMsg[pErrInfo->cbMsg] - pszOut, pszFormat, va2);
+ va_end(va2);
+ }
+ }
+ else
+ {
+ while (*pszFormat == ' ')
+ pszFormat++;
+ return RTErrInfoSetV(pErrInfo, rc, pszFormat, va);
+ }
+ }
+
+ /* The logging: */
+ if (fFlags & RTERRINFO_LOG_F_RELEASE)
+ {
+ PRTLOGGER pLogger = RTLogRelGetDefaultInstanceEx(RT_MAKE_U32(RTLOGGRPFLAGS_LEVEL_1, iLogGroup));
+ if (pLogger)
+ RTLogLoggerEx(pLogger, RTLOGGRPFLAGS_LEVEL_1, iLogGroup, "RTErrInfoAdd(%Rrc): %N\n", rc, pszFormat, &va);
+ }
+
+ PRTLOGGER pLogger = RTLogGetDefaultInstanceEx(RT_MAKE_U32(RTLOGGRPFLAGS_LEVEL_1, iLogGroup));
+ if (pLogger)
+ RTLogLoggerEx(pLogger, RTLOGGRPFLAGS_LEVEL_1, iLogGroup, "RTErrInfoAdd(%Rrc): %N\n", rc, pszFormat, &va);
+
+ return rc;
+}
+
diff --git a/src/VBox/Runtime/common/err/errmsg.cpp b/src/VBox/Runtime/common/err/errmsg.cpp
new file mode 100644
index 00000000..3ce2b106
--- /dev/null
+++ b/src/VBox/Runtime/common/err/errmsg.cpp
@@ -0,0 +1,115 @@
+/* $Id: errmsg.cpp $ */
+/** @file
+ * IPRT - Status code messages.
+ */
+
+/*
+ * Copyright (C) 2006-2019 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
+#include <iprt/err.h>
+#include "internal/iprt.h"
+
+#include <iprt/asm.h>
+#include <iprt/string.h>
+#include <iprt/err.h>
+#include <VBox/err.h>
+
+
+/*********************************************************************************************************************************
+* Global Variables *
+*********************************************************************************************************************************/
+/** Array of messages.
+ * The data is generated by a sed script.
+ */
+static const RTSTATUSMSG g_aStatusMsgs[] =
+{
+#if !defined(IPRT_NO_ERROR_DATA) && !defined(DOXYGEN_RUNNING)
+# include "errmsgdata.h"
+#else
+ { "Success.", "Success.", "VINF_SUCCESS", 0 },
+#endif
+ { NULL, NULL, NULL, 0 }
+};
+
+
+/** Temporary buffers to format unknown messages in.
+ * @{
+ */
+static char g_aszUnknownStr[4][64];
+static RTSTATUSMSG g_aUnknownMsgs[4] =
+{
+ { &g_aszUnknownStr[0][0], &g_aszUnknownStr[0][0], &g_aszUnknownStr[0][0], 0 },
+ { &g_aszUnknownStr[1][0], &g_aszUnknownStr[1][0], &g_aszUnknownStr[1][0], 0 },
+ { &g_aszUnknownStr[2][0], &g_aszUnknownStr[2][0], &g_aszUnknownStr[2][0], 0 },
+ { &g_aszUnknownStr[3][0], &g_aszUnknownStr[3][0], &g_aszUnknownStr[3][0], 0 }
+};
+/** Last used index in g_aUnknownMsgs. */
+static volatile uint32_t g_iUnknownMsgs;
+/** @} */
+
+
+/**
+ * Get the message corresponding to a given status code.
+ *
+ * @returns Pointer to read-only message description.
+ * @param rc The status code.
+ */
+RTDECL(PCRTSTATUSMSG) RTErrGet(int rc)
+{
+ unsigned iFound = ~0U;
+ unsigned i;
+ for (i = 0; i < RT_ELEMENTS(g_aStatusMsgs) - 1; i++)
+ {
+ if (g_aStatusMsgs[i].iCode == rc)
+ {
+ /*
+ * Found a match.
+ * Since this isn't a unique key, we must check that it's not
+ * one of those start/end #defines before we return.
+ */
+#define STR_ENDS_WITH(a_psz, a_cch, a_sz) \
+ ( (a_cch) >= sizeof(a_sz) && !strncmp((a_psz) + (a_cch) - sizeof(a_sz) + 1, RT_STR_TUPLE(a_sz)) )
+ size_t const cchDefine = strlen(g_aStatusMsgs[i].pszDefine);
+ if ( !STR_ENDS_WITH(g_aStatusMsgs[i].pszDefine, cchDefine, "_FIRST")
+ && !STR_ENDS_WITH(g_aStatusMsgs[i].pszDefine, cchDefine, "_LAST")
+ && !STR_ENDS_WITH(g_aStatusMsgs[i].pszDefine, cchDefine, "_LOWEST")
+ && !STR_ENDS_WITH(g_aStatusMsgs[i].pszDefine, cchDefine, "_HIGHEST")
+ )
+ return &g_aStatusMsgs[i];
+ iFound = i;
+ }
+ }
+ if (iFound != ~0U)
+ return &g_aStatusMsgs[iFound];
+
+ /*
+ * Need to use the temporary stuff.
+ */
+ int iMsg = ASMAtomicXchgU32(&g_iUnknownMsgs, (g_iUnknownMsgs + 1) % RT_ELEMENTS(g_aUnknownMsgs));
+ RTStrPrintf(&g_aszUnknownStr[iMsg][0], sizeof(g_aszUnknownStr[iMsg]), "Unknown Status %d (%#x)", rc, rc);
+ return &g_aUnknownMsgs[iMsg];
+}
+RT_EXPORT_SYMBOL(RTErrGet);
+
diff --git a/src/VBox/Runtime/common/err/errmsg.sed b/src/VBox/Runtime/common/err/errmsg.sed
new file mode 100644
index 00000000..cf7a8c7b
--- /dev/null
+++ b/src/VBox/Runtime/common/err/errmsg.sed
@@ -0,0 +1,88 @@
+# $Id: errmsg.sed $
+## @file
+# IPRT - SED script for converting */err.h.
+#
+
+#
+# Copyright (C) 2006-2019 Oracle Corporation
+#
+# This file is part of VirtualBox Open Source Edition (OSE), as
+# available from http://www.virtualbox.org. This file is free software;
+# you can redistribute it and/or modify it under the terms of the GNU
+# General Public License (GPL) as published by the Free Software
+# Foundation, in version 2 as it comes in the "COPYING" file of the
+# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+#
+# The contents of this file may alternatively be used under the terms
+# of the Common Development and Distribution License Version 1.0
+# (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+# VirtualBox OSE distribution, in which case the provisions of the
+# CDDL are applicable instead of those of the GPL.
+#
+# You may elect to license modified versions of this file under the
+# terms and conditions of either the GPL or the CDDL or both.
+#
+
+# Handle text inside the markers.
+/SED-START/,/SED-END/{
+
+# if (#define) goto defines
+/^[[:space:]]*#[[:space:]]*define/b defines
+
+# if (/**) goto description
+/\/\*\*/b description
+
+}
+
+# Everything else is deleted!
+d
+b end
+
+
+##
+# Convert the defines
+:defines
+s/^[[:space:]]*#[[:space:]]*define[[:space:]]*\([[:alnum:]_]*\)[[:space:]]*\(.*\)[[:space:]]*$/ "\1",\n \1 }, /
+b end
+
+##
+# Convert descriptive comments. /** desc */
+:description
+
+# Read all the lines belonging to the comment into the buffer.
+:look-for-end-of-comment
+/\*\//bend-of-comment
+N
+blook-for-end-of-comment
+:end-of-comment
+
+# anything with @{ and @} is skipped
+/@[\{\}]/d
+
+# Fix double spaces
+s/[[:space:]][[:space:]]/ /g
+
+# Fix \# sequences (doxygen needs them, we don't).
+s/\\#/#/g
+
+# insert punctuation.
+s/\([^.[:space:]]\)[[:space:]]*\*\//\1. \*\//
+
+# convert /** short. more
+s/[[:space:]]*\/\*\*[[:space:]]*/ { NULL, \"/
+s/ { NULL, \"\([^.!?"]*[.!?][.!?]*\)/ { \"\1\",\n \"\1/
+
+# terminate the string
+s/[[:space:]]*\*\//\"\,/
+
+# translate empty lines into new-lines (only one, please).
+s/[[:space:]]*[[:space:]]\*[[:space:]][[:space:]]*\*[[:space:]][[:space:]]*/\\n/g
+
+# remove asterics.
+s/[[:space:]]*[[:space:]]\*[[:space:]][[:space:]]*/ /g
+b end
+
+
+# next expression
+:end
diff --git a/src/VBox/Runtime/common/err/errmsgcom.sed b/src/VBox/Runtime/common/err/errmsgcom.sed
new file mode 100644
index 00000000..da8519fa
--- /dev/null
+++ b/src/VBox/Runtime/common/err/errmsgcom.sed
@@ -0,0 +1,66 @@
+# $Id: errmsgcom.sed $
+## @file
+# IPRT - SED script for converting COM errors
+#
+
+#
+# Copyright (C) 2006-2019 Oracle Corporation
+#
+# This file is part of VirtualBox Open Source Edition (OSE), as
+# available from http://www.virtualbox.org. This file is free software;
+# you can redistribute it and/or modify it under the terms of the GNU
+# General Public License (GPL) as published by the Free Software
+# Foundation, in version 2 as it comes in the "COPYING" file of the
+# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+#
+# The contents of this file may alternatively be used under the terms
+# of the Common Development and Distribution License Version 1.0
+# (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+# VirtualBox OSE distribution, in which case the provisions of the
+# CDDL are applicable instead of those of the GPL.
+#
+# You may elect to license modified versions of this file under the
+# terms and conditions of either the GPL or the CDDL or both.
+#
+
+# we only care about message definitions
+/No symbolic name defined/b skip_it
+\/\/ MessageId: /b messageid
+d
+b end
+
+
+# Everything else is deleted!
+:skip_it
+d
+b end
+
+
+#
+# A message ID we care about
+#
+:messageid
+# concatenate the next four lines to the string
+N
+N
+N
+N
+{
+ # remove DOS <CR>.
+ s/\r//g
+ # remove the message ID
+ s/\/\/ MessageId: //g
+ # remove the stuff in between
+ s/\/\/\n\/\/ MessageText:\n\/\/\n\/\/ *//g
+ # backslashes have to be escaped
+ s/\\/\\\\/g
+ # double quotes have to be escaped, too
+ s/"/\\"/g
+ # output C array entry
+ s/\([[:alnum:]_]*\)[\t ]*\n\(.*\)[\t ]*$/{ "\2", "\1", \1 }, /
+}
+b end
+
+# next expression
+:end
diff --git a/src/VBox/Runtime/common/err/errmsgxpcom.cpp b/src/VBox/Runtime/common/err/errmsgxpcom.cpp
new file mode 100644
index 00000000..01824aee
--- /dev/null
+++ b/src/VBox/Runtime/common/err/errmsgxpcom.cpp
@@ -0,0 +1,154 @@
+/* $Id: errmsgxpcom.cpp $ */
+/** @file
+ * IPRT - Status code messages for XPCOM.
+ */
+
+/*
+ * Copyright (C) 2006-2019 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+
+/*********************************************************************************************************************************
+* Header Files *
+*********************************************************************************************************************************/
+#include <iprt/errcore.h>
+#include "internal/iprt.h"
+
+#include <iprt/asm.h>
+#include <iprt/string.h>
+#include <iprt/errcore.h>
+
+
+/*********************************************************************************************************************************
+* Global Variables *
+*********************************************************************************************************************************/
+/** Array of messages.
+ * The data is generated by a sed script.
+ */
+static const RTCOMERRMSG g_aStatusMsgs[] =
+{
+#define MY_ERR(_def, _desc, _val) { _desc, _def, _val }
+
+ MY_ERR("NS_OK", "Success", UINT32_C(0x00000000)),
+ MY_ERR("NS_ERROR_NOT_IMPLEMENTED", "Not implemented", UINT32_C(0x80004001)),
+ MY_ERR("NS_ERROR_NO_INTERFACE", "Interface not supported", UINT32_C(0x80004002)),
+ MY_ERR("NS_ERROR_INVALID_POINTER", "Invalid pointer value", UINT32_C(0x80004003)),
+ MY_ERR("NS_ERROR_ABORT", "Operation aborted", UINT32_C(0x80004004)),
+ MY_ERR("NS_ERROR_FAILURE", "Operation failed", UINT32_C(0x80004005)),
+ MY_ERR("NS_ERROR_CALL_FAILED", "Call to remote object failed", UINT32_C(0x800706be)),
+ MY_ERR("NS_ERROR_UNEXPECTED", "Unexpected error", UINT32_C(0x8000ffff)),
+
+ MY_ERR("NS_ERROR_CANNOT_CONVERT_DATA", "Cannot convert data", UINT32_C(0x80010001)),
+ MY_ERR("NS_ERROR_OBJECT_IS_IMMUTABLE", "Object is immutable", UINT32_C(0x80010002)),
+ MY_ERR("NS_ERROR_LOSS_OF_SIGNIFICANT_DATA", "Loss of significant data", UINT32_C(0x80010003)),
+ MY_ERR("NS_ERROR_PROXY_INVALID_IN_PARAMETER", "Cannot proxy an IN parameter", UINT32_C(0x80010010)),
+ MY_ERR("NS_ERROR_PROXY_INVALID_OUT_PARAMETER", "Cannot proxy an OUT parameter", UINT32_C(0x80010011)),
+ MY_ERR("NS_SUCCESS_LOSS_OF_INSIGNIFICANT_DATA", "Loss of insignificant data", UINT32_C(0x00010001)),
+
+ MY_ERR("E_ACCESSDENIED", "Access denied", UINT32_C(0x80070005)), /* VirtualBox addition */
+ MY_ERR("NS_ERROR_OUT_OF_MEMORY", "Memory allocation failed", UINT32_C(0x8007000e)),
+ MY_ERR("NS_ERROR_INVALID_ARG", "Invalid argument value", UINT32_C(0x80070057)),
+
+ MY_ERR("NS_ERROR_NO_AGGREGATION", "Class does not allow aggregation", UINT32_C(0x80040110)),
+ MY_ERR("NS_ERROR_NOT_AVAILABLE", "Resource not available", UINT32_C(0x80040111)),
+ MY_ERR("NS_ERROR_FACTORY_NOT_REGISTERED", "Class not registered", UINT32_C(0x80040154)),
+ MY_ERR("NS_ERROR_FACTORY_REGISTER_AGAIN", "Cannot be registered, try again later", UINT32_C(0x80040155)),
+ MY_ERR("NS_ERROR_FACTORY_NOT_LOADED", "Dynamically loaded factory cannot be found", UINT32_C(0x800401f8)),
+ MY_ERR("NS_ERROR_FACTORY_EXISTS", "Factory already exists", UINT32_C(0xc1f30100)),
+ MY_ERR("NS_ERROR_FACTORY_NO_SIGNATURE_SUPPORT", "Factory does not support signatures", UINT32_C(0xc1f30101)),
+ MY_ERR("NS_ERROR_NOT_INITIALIZED", "Instance not initialized", UINT32_C(0xc1f30001)),
+ MY_ERR("NS_ERROR_ALREADY_INITIALIZED", "Instance already initialized", UINT32_C(0xc1f30002)),
+
+ MY_ERR("NS_BASE_STREAM_CLOSED", "Stream closed", UINT32_C(0x80470002)),
+ MY_ERR("NS_BASE_STREAM_OSERROR", "Operative system stream error", UINT32_C(0x80470003)),
+ MY_ERR("NS_BASE_STREAM_ILLEGAL_ARGS", "Illegal argument to stream method", UINT32_C(0x80470004)),
+ MY_ERR("NS_BASE_STREAM_NO_CONVERTER", "No stream converter", UINT32_C(0x80470005)),
+ MY_ERR("NS_BASE_STREAM_BAD_CONVERSION", "Badstream conversion", UINT32_C(0x80470006)),
+ MY_ERR("NS_BASE_STREAM_WOULD_BLOCK", "Stream operation would block", UINT32_C(0x80470007)),
+
+ MY_ERR("NS_ERROR_FILE_UNRECOGNIZED_PATH", "Unrecognized path", UINT32_C(0x80520001)),
+ MY_ERR("NS_ERROR_FILE_UNRESOLVABLE_SYMLINK", "NS_ERROR_FILE_UNRESOLVABLE_SYMLINK", UINT32_C(0x80520002)),
+ MY_ERR("NS_ERROR_FILE_EXECUTION_FAILED", "NS_ERROR_FILE_EXECUTION_FAILED", UINT32_C(0x80520003)),
+ MY_ERR("NS_ERROR_FILE_UNKNOWN_TYPE", "NS_ERROR_FILE_UNKNOWN_TYPE", UINT32_C(0x80520004)),
+ MY_ERR("NS_ERROR_FILE_DESTINATION_NOT_DIR", "NS_ERROR_FILE_DESTINATION_NOT_DIR", UINT32_C(0x80520005)),
+ MY_ERR("NS_ERROR_FILE_TARGET_DOES_NOT_EXIST", "NS_ERROR_FILE_TARGET_DOES_NOT_EXIST", UINT32_C(0x80520006)),
+ MY_ERR("NS_ERROR_FILE_COPY_OR_MOVE_FAILED", "NS_ERROR_FILE_COPY_OR_MOVE_FAILED", UINT32_C(0x80520007)),
+ MY_ERR("NS_ERROR_FILE_ALREADY_EXISTS", "NS_ERROR_FILE_ALREADY_EXISTS", UINT32_C(0x80520008)),
+ MY_ERR("NS_ERROR_FILE_INVALID_PATH", "NS_ERROR_FILE_INVALID_PATH", UINT32_C(0x80520009)),
+ MY_ERR("NS_ERROR_FILE_DISK_FULL", "NS_ERROR_FILE_DISK_FULL", UINT32_C(0x8052000a)),
+ MY_ERR("NS_ERROR_FILE_CORRUPTED", "NS_ERROR_FILE_CORRUPTED", UINT32_C(0x8052000b)),
+ MY_ERR("NS_ERROR_FILE_NOT_DIRECTORY", "NS_ERROR_FILE_NOT_DIRECTORY", UINT32_C(0x8052000c)),
+ MY_ERR("NS_ERROR_FILE_IS_DIRECTORY", "NS_ERROR_FILE_IS_DIRECTORY", UINT32_C(0x8052000d)),
+ MY_ERR("NS_ERROR_FILE_IS_LOCKED", "NS_ERROR_FILE_IS_LOCKED", UINT32_C(0x8052000e)),
+ MY_ERR("NS_ERROR_FILE_TOO_BIG", "NS_ERROR_FILE_TOO_BIG", UINT32_C(0x8052000f)),
+ MY_ERR("NS_ERROR_FILE_NO_DEVICE_SPACE", "NS_ERROR_FILE_NO_DEVICE_SPACE", UINT32_C(0x80520010)),
+ MY_ERR("NS_ERROR_FILE_NAME_TOO_LONG", "NS_ERROR_FILE_NAME_TOO_LONG", UINT32_C(0x80520011)),
+ MY_ERR("NS_ERROR_FILE_NOT_FOUND", "NS_ERROR_FILE_NOT_FOUND", UINT32_C(0x80520012)),
+ MY_ERR("NS_ERROR_FILE_READ_ONLY", "NS_ERROR_FILE_READ_ONLY", UINT32_C(0x80520013)),
+ MY_ERR("NS_ERROR_FILE_DIR_NOT_EMPTY", "NS_ERROR_FILE_DIR_NOT_EMPTY", UINT32_C(0x80520014)),
+ MY_ERR("NS_ERROR_FILE_ACCESS_DENIED", "NS_ERROR_FILE_ACCESS_DENIED", UINT32_C(0x80520015)),
+ MY_ERR("NS_SUCCESS_FILE_DIRECTORY_EMPTY", "NS_SUCCESS_FILE_DIRECTORY_EMPTY", UINT32_C(0x00520001)),
+ MY_ERR("NS_ERROR_SOCKET_FAIL", "IPC daemon socket error", UINT32_C(0xc1f30200)), /* new XPCOM error code */
+
+#if defined(VBOX) && !defined(IN_GUEST) && !defined(DOXYGEN_RUNNING)
+# include "errmsgvboxcomdata.h"
+#endif
+
+ { NULL, NULL, 0 }
+#undef MY_ERR
+};
+
+
+/** Temporary buffers to format unknown messages in.
+ * @{
+ */
+static char g_aszUnknownStr[8][64];
+static RTCOMERRMSG g_aUnknownMsgs[8] =
+{
+ { &g_aszUnknownStr[0][0], &g_aszUnknownStr[0][0], 0 },
+ { &g_aszUnknownStr[1][0], &g_aszUnknownStr[1][0], 0 },
+ { &g_aszUnknownStr[2][0], &g_aszUnknownStr[2][0], 0 },
+ { &g_aszUnknownStr[3][0], &g_aszUnknownStr[3][0], 0 },
+ { &g_aszUnknownStr[4][0], &g_aszUnknownStr[4][0], 0 },
+ { &g_aszUnknownStr[5][0], &g_aszUnknownStr[5][0], 0 },
+ { &g_aszUnknownStr[6][0], &g_aszUnknownStr[6][0], 0 },
+ { &g_aszUnknownStr[7][0], &g_aszUnknownStr[7][0], 0 }
+};
+/** Last used index in g_aUnknownMsgs. */
+static volatile uint32_t g_iUnknownMsgs;
+/** @} */
+
+
+RTDECL(PCRTCOMERRMSG) RTErrCOMGet(uint32_t rc)
+{
+ unsigned i;
+ for (i = 0; i < RT_ELEMENTS(g_aStatusMsgs) - 1; i++)
+ if (g_aStatusMsgs[i].iCode == rc)
+ return &g_aStatusMsgs[i];
+
+ /*
+ * Need to use the temporary stuff.
+ */
+ int32_t iMsg = (ASMAtomicIncU32(&g_iUnknownMsgs) - 1) % RT_ELEMENTS(g_aUnknownMsgs);
+ RTStrPrintf(&g_aszUnknownStr[iMsg][0], sizeof(g_aszUnknownStr[iMsg]), "Unknown Status 0x%X", rc);
+ return &g_aUnknownMsgs[iMsg];
+}
+RT_EXPORT_SYMBOL(RTErrCOMGet);
+