VBoxGuestR3Lib.cpp revision 4faf92053d9cec5599c0ab8577231df0f7d615b3
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync/* $Id$ */
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync/** @file
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, Core.
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync */
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync/*
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * Copyright (C) 2007 Sun Microsystems, Inc.
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync *
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * available from http://www.virtualbox.org. This file is free software;
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * you can redistribute it and/or modify it under the terms of the GNU
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * General Public License (GPL) as published by the Free Software
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync *
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * additional information or have any questions.
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync */
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync/*******************************************************************************
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync* Header Files *
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync*******************************************************************************/
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync#if defined(RT_OS_WINDOWS)
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync# include <Windows.h>
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync
d91dc86210d602f51a4701762488a5e696c80a45vboxsync#elif defined(RT_OS_OS2)
d440eb388d1459ffc6f581ff0c786ef3f048dc39vboxsync# define INCL_BASE
482a222498aae619afda0255a7edf4ebda97268cvboxsync# define INCL_ERRORS
482a222498aae619afda0255a7edf4ebda97268cvboxsync# include <os2.h>
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync#elif defined(RT_OS_FREEBSD) \
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync || defined(RT_OS_LINUX) \
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync || defined(RT_OS_SOLARIS)
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync# include <sys/types.h>
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync# include <sys/stat.h>
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync# if defined(RT_OS_LINUX) /** @todo check this on solaris+freebsd as well. */
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync# include <sys/ioctl.h>
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync# endif
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync# include <errno.h>
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync# include <unistd.h>
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync#endif
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync#include <iprt/assert.h>
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync#include <iprt/asm.h>
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync#include <iprt/file.h>
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync#include <iprt/time.h>
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync#include <iprt/string.h>
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync#include <iprt/thread.h>
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync#include <VBox/log.h>
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync#include "VBGLR3Internal.h"
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync#ifdef VBOX_VBGLR3_XFREE86
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync/* Rather than try to resolve all the header file conflicts, I will just
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync prototype what we need here. */
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync# define XF86_O_RDWR 0x0002
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsynctypedef void *pointer;
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsyncextern "C" int xf86open(const char *, int, ...);
ee5869bb73f07de9c139dc6a608836a7b5767933vboxsyncextern "C" int xf86close(int);
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsyncextern "C" int xf86ioctl(int, unsigned long, pointer);
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync#endif
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync/*******************************************************************************
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync* Global Variables *
ee5869bb73f07de9c139dc6a608836a7b5767933vboxsync*******************************************************************************/
f6dde23cd488aee26203b38ec67220270f5c4273vboxsync/** The VBoxGuest device handle. */
f6dde23cd488aee26203b38ec67220270f5c4273vboxsync#ifdef VBOX_VBGLR3_XFREE86
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsyncstatic int g_File = -1;
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync#elif defined(RT_OS_WINDOWS)
ee5869bb73f07de9c139dc6a608836a7b5767933vboxsyncstatic HANDLE g_hFile = INVALID_HANDLE_VALUE;
ee5869bb73f07de9c139dc6a608836a7b5767933vboxsync#else
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsyncstatic RTFILE g_File = NIL_RTFILE;
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync#endif
ee5869bb73f07de9c139dc6a608836a7b5767933vboxsync/** User counter.
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * A counter of the number of times the library has been initialised, for use with
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * X.org drivers, where the library may be shared by multiple independant modules
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * inside a single process space.
482a222498aae619afda0255a7edf4ebda97268cvboxsync */
482a222498aae619afda0255a7edf4ebda97268cvboxsyncstatic uint32_t volatile g_cInits = 0;
482a222498aae619afda0255a7edf4ebda97268cvboxsync
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync/**
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * Implementation of VbglR3Init and VbglR3InitUser
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync */
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsyncstatic int vbglR3Init(const char *pszDeviceName)
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync{
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync uint32_t cInits = ASMAtomicIncU32(&g_cInits);
d91dc86210d602f51a4701762488a5e696c80a45vboxsync#ifndef VBOX_VBGLR3_XFREE86
d91dc86210d602f51a4701762488a5e696c80a45vboxsync Assert(cInits > 0);
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync#endif
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync if (cInits > 1)
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync {
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync /*
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * This will fail if two (or more) threads race each other calling VbglR3Init.
d91dc86210d602f51a4701762488a5e696c80a45vboxsync * However it will work fine for single threaded or otherwise serialized
d91dc86210d602f51a4701762488a5e696c80a45vboxsync * processed calling us more than once.
d91dc86210d602f51a4701762488a5e696c80a45vboxsync */
d91dc86210d602f51a4701762488a5e696c80a45vboxsync#ifdef RT_OS_WINDOWS
d91dc86210d602f51a4701762488a5e696c80a45vboxsync if (g_hFile == INVALID_HANDLE_VALUE)
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync#elif !defined (VBOX_VBGLR3_XFREE86)
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync if (g_File == NIL_RTFILE)
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync#else
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync if (g_File == -1)
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync#endif
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync return VERR_INTERNAL_ERROR;
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync return VINF_SUCCESS;
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync }
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync#if defined(RT_OS_WINDOWS)
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync if (g_hFile != INVALID_HANDLE_VALUE)
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync#elif !defined(VBOX_VBGLR3_XFREE86)
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync if (g_File != NIL_RTFILE)
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync#else
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync if (g_File != -1)
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync#endif
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync return VERR_INTERNAL_ERROR;
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync#if defined(RT_OS_WINDOWS)
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync /*
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * Have to use CreateFile here as we want to specify FILE_FLAG_OVERLAPPED
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * and possible some other bits not availble thru iprt/file.h.
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync */
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync HANDLE hFile = CreateFile(pszDeviceName,
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync GENERIC_READ | GENERIC_WRITE,
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync FILE_SHARE_READ | FILE_SHARE_WRITE,
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync NULL,
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync OPEN_EXISTING,
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync NULL);
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync if (hFile == INVALID_HANDLE_VALUE)
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync return VERR_OPEN_FAILED;
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync g_hFile = hFile;
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync#elif defined(RT_OS_OS2)
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync /*
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * We might wish to compile this with Watcom, so stick to
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync * the OS/2 APIs all the way. And in any case we have to use
f6dde23cd488aee26203b38ec67220270f5c4273vboxsync * DosDevIOCtl for the requests, why not use Dos* for everything.
f6dde23cd488aee26203b38ec67220270f5c4273vboxsync */
f6dde23cd488aee26203b38ec67220270f5c4273vboxsync HFILE hf = NULLHANDLE;
f6dde23cd488aee26203b38ec67220270f5c4273vboxsync ULONG ulAction = 0;
f6dde23cd488aee26203b38ec67220270f5c4273vboxsync APIRET rc = DosOpen((PCSZ)pszDeviceName, &hf, &ulAction, 0, FILE_NORMAL,
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync OPEN_ACTION_OPEN_IF_EXISTS,
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE,
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync NULL);
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync if (rc)
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync return RTErrConvertFromOS2(rc);
f9cac318205d74ee5b35dabcf2bd39118f6293d7vboxsync
d91dc86210d602f51a4701762488a5e696c80a45vboxsync if (hf < 16)
d91dc86210d602f51a4701762488a5e696c80a45vboxsync {
d91dc86210d602f51a4701762488a5e696c80a45vboxsync HFILE ahfs[16];
d91dc86210d602f51a4701762488a5e696c80a45vboxsync unsigned i;
f9cac318205d74ee5b35dabcf2bd39118f6293d7vboxsync for (i = 0; i < RT_ELEMENTS(ahfs); i++)
f9cac318205d74ee5b35dabcf2bd39118f6293d7vboxsync {
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync ahfs[i] = 0xffffffff;
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync rc = DosDupHandle(hf, &ahfs[i]);
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync if (rc)
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync break;
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync }
8184f68cdef3c26869cdebc6a18829c854d0d17dvboxsync
if (i-- > 1)
{
ULONG fulState = 0;
rc = DosQueryFHState(ahfs[i], &fulState);
if (!rc)
{
fulState |= OPEN_FLAGS_NOINHERIT;
fulState &= OPEN_FLAGS_WRITE_THROUGH | OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_NO_CACHE | OPEN_FLAGS_NOINHERIT; /* Turn off non-participating bits. */
rc = DosSetFHState(ahfs[i], fulState);
}
if (!rc)
{
rc = DosClose(hf);
AssertMsg(!rc, ("%ld\n", rc));
hf = ahfs[i];
}
else
i++;
while (i-- > 0)
DosClose(ahfs[i]);
}
}
g_File = hf;
#elif defined(VBOX_VBGLR3_XFREE86)
int File = xf86open(pszDeviceName, XF86_O_RDWR);
if (File == -1)
return VERR_OPEN_FAILED;
g_File = File;
#else
/* The default implemenation. (linux, solaris, freebsd) */
RTFILE File;
int rc = RTFileOpen(&File, pszDeviceName, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
if (RT_FAILURE(rc))
return rc;
g_File = File;
#endif
/*
* Create release logger
*/
PRTLOGGER pReleaseLogger;
static const char * const s_apszGroups[] = VBOX_LOGGROUP_NAMES;
int rc2 = RTLogCreate(&pReleaseLogger, 0, "all", "VBOX_RELEASE_LOG",
RT_ELEMENTS(s_apszGroups), &s_apszGroups[0],
RTLOGDEST_USER, NULL);
/* This may legitimately fail if we are using the mini-runtime. */
if (RT_SUCCESS(rc2))
RTLogRelSetDefaultInstance(pReleaseLogger);
return VINF_SUCCESS;
}
/**
* Open the VBox R3 Guest Library. This should be called by system daemons
* and processes.
*/
VBGLR3DECL(int) VbglR3Init(void)
{
return vbglR3Init(VBOXGUEST_DEVICE_NAME);
}
/**
* Open the VBox R3 Guest Library. Equivalent to VbglR3Init, but for user
* session processes.
*/
VBGLR3DECL(int) VbglR3InitUser(void)
{
return vbglR3Init(VBOXGUEST_USER_DEVICE_NAME);
}
VBGLR3DECL(void) VbglR3Term(void)
{
/*
* Decrement the reference count and see if we're the last one out.
*/
uint32_t cInits = ASMAtomicDecU32(&g_cInits);
if (cInits > 0)
return;
#if !defined(VBOX_VBGLR3_XFREE86)
AssertReturnVoid(!cInits);
# if defined(RT_OS_WINDOWS)
HANDLE hFile = g_hFile;
g_hFile = INVALID_HANDLE_VALUE;
AssertReturnVoid(hFile != INVALID_HANDLE_VALUE);
BOOL fRc = CloseHandle(hFile);
Assert(fRc); NOREF(fRc);
# elif defined(RT_OS_OS2)
RTFILE File = g_File;
g_File = NIL_RTFILE;
AssertReturnVoid(File != NIL_RTFILE);
APIRET rc = DosClose(File);
AssertMsg(!rc, ("%ld\n", rc));
# else /* The IPRT case. */
RTFILE File = g_File;
g_File = NIL_RTFILE;
AssertReturnVoid(File != NIL_RTFILE);
int rc = RTFileClose(File);
AssertRC(rc);
# endif
#else /* VBOX_VBGLR3_XFREE86 */
int File = g_File;
g_File = -1;
if (File == -1)
return;
xf86close(File);
#endif /* VBOX_VBGLR3_XFREE86 */
}
/**
* Internal wrapper around various OS specific ioctl implemenations.
*
* @returns VBox status code as returned by VBoxGuestCommonIOCtl, or
* an failure returned by the OS specific ioctl APIs.
*
* @param iFunction The requested function.
* @param pvData The input and output data buffer.
* @param cbData The size of the buffer.
*
* @remark Exactly how the VBoxGuestCommonIOCtl is ferried back
* here is OS specific. On BSD and Darwin we can use errno,
* while on OS/2 we use the 2nd buffer of the IOCtl.
*/
int vbglR3DoIOCtl(unsigned iFunction, void *pvData, size_t cbData)
{
#if defined(RT_OS_WINDOWS)
DWORD cbReturned = 0;
if (!DeviceIoControl(g_hFile, iFunction, pvData, (DWORD)cbData, pvData, (DWORD)cbData, &cbReturned, NULL))
{
/** @todo The passing of error codes needs to be tested and fixed (as does *all* the other hosts except for
* OS/2). The idea is that the VBox status codes in ring-0 should be transfered without loss down to
* ring-3. However, it's not vitally important right now (obviously, since the other guys has been
* ignoring it for 1+ years now). On Linux and Solaris the transfer is done, but it is currently not
* lossless, so still needs fixing. */
DWORD LastErr = GetLastError();
return RTErrConvertFromWin32(LastErr);
}
return VINF_SUCCESS;
#elif defined(RT_OS_OS2)
ULONG cbOS2Parm = cbData;
int32_t vrc = VERR_INTERNAL_ERROR;
ULONG cbOS2Data = sizeof(vrc);
APIRET rc = DosDevIOCtl(g_File, VBOXGUEST_IOCTL_CATEGORY, iFunction,
pvData, cbData, &cbOS2Parm,
&vrc, sizeof(vrc), &cbOS2Data);
if (RT_LIKELY(!rc))
return vrc;
return RTErrConvertFromOS2(rc);
#elif defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
VBGLBIGREQ Hdr;
Hdr.u32Magic = VBGLBIGREQ_MAGIC;
Hdr.cbData = cbData;
Hdr.pvDataR3 = pvData;
# if HC_ARCH_BITS == 32
Hdr.u32Padding = 0;
# endif
/** @todo test status code passing! Check that the kernel doesn't do any
* error checks using specific errno values, and just pass an VBox
* error instead of an errno.h one. Alternatively, extend/redefine the
* header with an error code return field (much better alternative
* actually). */
int rc = ioctl((int)g_File, iFunction, &Hdr);
if (rc == -1)
{
rc = errno;
return RTErrConvertFromErrno(rc);
}
return VINF_SUCCESS;
#elif defined(RT_OS_LINUX)
# ifdef VBOX_VBGLR3_XFREE86
int rc = xf86ioctl((int)g_File, iFunction, pvData);
# else
int rc = ioctl((int)g_File, iFunction, pvData);
# endif
if (RT_LIKELY(rc == 0))
return VINF_SUCCESS;
/* Positive values are negated VBox error status codes. */
if (rc > 0)
rc = -rc;
else
# ifdef VBOX_VBGLR3_XFREE86
rc = VERR_FILE_IO_ERROR;
# else
rc = RTErrConvertFromErrno(errno);
# endif
NOREF(cbData);
return rc;
#elif defined(VBOX_VBGLR3_XFREE86)
/* PORTME - This is preferred over the RTFileIOCtl variant below, just be careful with the (int). */
/** @todo test status code passing! */
int rc = xf86ioctl(g_File, iFunction, pvData);
if (rc == -1)
return VERR_FILE_IO_ERROR; /* This is purely legacy stuff, it has to work and no more. */
return VINF_SUCCESS;
#else
/* Default implementation - PORTME: Do not use this without testings that passing errors works! */
/** @todo test status code passing! */
int rc2 = VERR_INTERNAL_ERROR;
int rc = RTFileIoCtl(g_File, (int)iFunction, pvData, cbData, &rc2);
if (RT_SUCCESS(rc))
rc = rc2;
return rc;
#endif
}