VBoxGuestR3Lib.cpp revision 999b9efb1c9a95fee642550c525ca0cf7c6f07b5
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, Core.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Copyright (C) 2007 Sun Microsystems, Inc.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * This file is part of VirtualBox Open Source Edition (OSE), as
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * available from http://www.virtualbox.org. This file is free software;
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * you can redistribute it and/or modify it under the terms of the GNU
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * General Public License (GPL) as published by the Free Software
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Foundation, in version 2 as it comes in the "COPYING" file of the
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Clara, CA 95054 USA or visit http://www.sun.com if you need
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * additional information or have any questions.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis/*******************************************************************************
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis* Header Files *
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis*******************************************************************************/
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis#elif defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis/* Rather than try to resolve all the header file conflicts, I will just
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis prototype what we need here. */
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtisextern "C" int xf86open(const char*, int,...);
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtisextern "C" int xf86ioctl(int, unsigned long, pointer);
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis/*******************************************************************************
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis* Global Variables *
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis*******************************************************************************/
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis/** The VBoxGuest device handle. */
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis/** User counter.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * A counter of the number of times the library has been initialised, for use with
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * X.org drivers, where the library may be shared by multiple independant modules
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * inside a single process space.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis uint32_t cInits = ASMAtomicIncU32(&g_cInits);
#ifndef VBOX_VBGLR3_XFREE86
return VERR_INTERNAL_ERROR;
return VINF_SUCCESS;
#ifndef VBOX_VBGLR3_XFREE86
return VERR_INTERNAL_ERROR;
#if defined(RT_OS_OS2)
NULL);
if (rc)
if (rc)
if (!rc)
fulState &= OPEN_FLAGS_WRITE_THROUGH | OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_NO_CACHE | OPEN_FLAGS_NOINHERIT; /* Turn off non-participating bits. */
if (!rc)
return VERR_OPEN_FAILED;
#if defined(VBOX_VBGLR3_XFREE86)
int File = 0;
int rc;
#if defined(VBOX_VBGLR3_XFREE86)
if (File >= 0)
#if defined(VBOX_VBGLR3_XFREE86)
return VERR_OPEN_FAILED;
return rc;
int rc = RTFileOpen(&File, VBOXGUEST_DEVICE_NAME, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
return rc;
return VINF_SUCCESS;
if (cInits > 0)
#ifndef VBOX_VBGLR3_XFREE86
#if defined(RT_OS_OS2)
#ifdef RT_OS_OS2
return vrc;
return VINF_SUCCESS;
/* PORTME - This is preferred over the RTFileIOCtl variant below, just be careful with the (int). */
return VINF_SUCCESS;
return rc;