USBLib-solaris.cpp revision de980107a6bd30a0e3da84211655dc0b9336708d
/** $Id$ */
/** @file
* USBLib - Library for wrapping up the VBoxUSB functionality, Solaris flavor.
*/
/*
* Copyright (C) 2008 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* 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.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
# include <errno.h>
# include <unistd.h>
# include <string.h>
# include <limits.h>
# include <strings.h>
/** -XXX- Remove this hackery eventually */
#ifdef DEBUG_ramshankar
#endif
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
/** Logging class. */
#define USBLIBR3 "USBLibR3"
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/** Reference counter. */
/** VBoxUSB Device handle. */
/** List of tasks handled by the USB helper. */
typedef enum USBHELPER_OP
{
ADD_ALIAS = 0,
};
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
USBLIB_DECL(int) USBLibInit(void)
{
/*
* Already open?
* This isn't properly serialized, but we'll be fine with the current usage.
*/
if (g_cUsers)
{
return VINF_SUCCESS;
}
int rc = RTFileOpen(&File, VBOXUSB_DEVICE_NAME, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
if (RT_FAILURE(rc))
{
return rc;
}
/*
* Check the USBMonitor version.
*/
if (RT_SUCCESS(rc))
{
{
g_File = NIL_RTFILE;
return rc;
}
}
else
{
g_File = NIL_RTFILE;
return rc;
}
return VINF_SUCCESS;
}
USBLIB_DECL(int) USBLibTerm(void)
{
if (!g_cUsers)
return VERR_WRONG_ORDER;
if (ASMAtomicDecU32(&g_cUsers) != 0)
return VINF_SUCCESS;
/*
* We're the last guy, close down the connection.
*/
g_File = NIL_RTFILE;
if (File == NIL_RTFILE)
return VERR_INTERNAL_ERROR;
return rc;
}
{
if (RT_SUCCESS(rc))
return NULL;
}
{
if (RT_SUCCESS(rc))
return;
}
{
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
return VINF_SUCCESS;
LogRel((USBLIBR3 ":USBLibGetClientInfo RTStrDupEx failed! rc=%Rrc szClientPath=%s\n", rc, Req.szClientPath));
}
else
return rc;
}
{
if (RT_UNLIKELY(!pReq))
return VERR_NO_MEMORY;
if (RT_FAILURE(rc))
return rc;
}
{
if (g_File == NIL_RTFILE)
{
return VERR_FILE_NOT_FOUND;
}
if (rc < 0)
{
return RTErrConvertFromErrno(rc);
}
return rc;
}