DrvHostDVD.cpp revision d22a329f1dead5d2ff2f715d6775a109f3db2944
039cd2c4871a00e51af909222a34695d9cec3000vboxsync * DrvHostDVD - Host DVD block driver.
e64031e20c39650a7bc902a3e1aba613b9415deevboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * available from http://www.virtualbox.org. This file is free software;
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * you can redistribute it and/or modify it under the terms of the GNU
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * General Public License (GPL) as published by the Free Software
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
039cd2c4871a00e51af909222a34695d9cec3000vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
12cd783de945853c8fc377095e8d0bbd4c97d8a1vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
27537ffef7291d0bb3a24e459a6b94c65586defevboxsync * additional information or have any questions.
039cd2c4871a00e51af909222a34695d9cec3000vboxsync/*******************************************************************************
039cd2c4871a00e51af909222a34695d9cec3000vboxsync* Header Files *
039cd2c4871a00e51af909222a34695d9cec3000vboxsync*******************************************************************************/
af1bd0025dd5d8be5f1468689d0d77d4839a3be5vboxsync# include <IOKit/storage/IOStorageDeviceCharacteristics.h>
af1bd0025dd5d8be5f1468689d0d77d4839a3be5vboxsync/* nothing (yet). */
3f279f58d7fa1cfb1ef999f80968cf3aefc0680cvboxsync/* All the following crap is apparently not necessary anymore since Linux
ab9c7333d588df5d6959a3b2c96c60321d26c4b0vboxsync * version 2.6.22. Check for 2.6.23 to be in the safe side. */
039cd2c4871a00e51af909222a34695d9cec3000vboxsync/* This is a hack to work around conflicts between these linux kernel headers
039cd2c4871a00e51af909222a34695d9cec3000vboxsync * and the GLIBC tcpip headers. They have different declarations of the 4
039cd2c4871a00e51af909222a34695d9cec3000vboxsync * standard byte order functions. */
e001cafceea8efd540f21109f6ab293f744ebb0bvboxsync/* This is another hack for not bothering with C++ unfriendly byteswap macros. */
ab9c7333d588df5d6959a3b2c96c60321d26c4b0vboxsync/* Those macros that are needed are defined in the header below. */
#include "Builtins.h"
#include "DrvHostBase.h"
#ifdef VBOX_WITH_SUID_WRAPPER
static int solarisCheckUserAuth();
#ifdef RT_OS_DARWIN
if (rc < 0)
if (rc < 0)
rc = RTFileOpen(&FileDevice, pThis->pszDeviceOpen, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
NULL, 0,
NULL))
return rc;
#ifdef RT_OS_DARWIN
if (rc < 0)
if (rc < 0)
int rc;
NULL))
return rc;
#ifdef RT_OS_LINUX
#ifdef USE_MEDIA_POLLING
#ifdef RT_OS_DARWIN
bool fMediaChanged = false;
bool fMediaPresent = false;
int rc2 = DRVHostBaseScsiCmd(pThis, abCmd, 6, PDMBLOCKTXDIR_NONE, NULL, NULL, abSense, sizeof(abSense), 0);
fMediaPresent = true;
fMediaPresent = false;
fMediaChanged = true;
bool fMediaPresent = false;
bool fMediaChanged = false;
if (rc2 == 0)
fMediaChanged = true;
fMediaChanged = true;
if (fMediaPresent)
else if (fMediaPresent)
if (fMediaChanged)
return rc;
int rc;
LogFlow(("%s: cmd[0]=%#04x txdir=%d pcbBuf=%d timeout=%d\n", __FUNCTION__, pbCmd[0], enmTxDir, *pcbBuf, cTimeoutMillies));
#ifdef RT_OS_DARWIN
rc = DRVHostBaseScsiCmd(pThis, pbCmd, 12, PDMBLOCKTXDIR_FROM_DEVICE, pvBuf, pcbBuf, pabSense, cbSense, cTimeoutMillies);
int direction;
switch (enmTxDir)
case PDMBLOCKTXDIR_NONE:
case PDMBLOCKTXDIR_TO_DEVICE:
if (rc < 0)
switch (enmTxDir)
switch (enmTxDir)
case PDMBLOCKTXDIR_NONE:
case PDMBLOCKTXDIR_TO_DEVICE:
#ifdef VBOX_WITH_SUID_WRAPPER
#ifdef VBOX_WITH_SUID_WRAPPER
if (rc < 0)
return VERR_PERMISSION_DENIED;
Log2(("%s: after ioctl: residual buflen=%d original buflen=%d\n", __FUNCTION__, usc.uscsi_resid, usc.uscsi_buflen));
int direction;
struct _REQ
} Req;
switch (enmTxDir)
case PDMBLOCKTXDIR_NONE:
case PDMBLOCKTXDIR_TO_DEVICE:
Log2(("%s: scsistatus=%d bytes returned=%d tlength=%d\n", __FUNCTION__, Req.spt.ScsiStatus, cbReturned, Req.spt.DataTransferLength));
return rc;
#ifdef VBOX_WITH_SUID_WRAPPER
# ifdef RT_OS_SOLARIS
static int solarisCheckUserAuth()
return VERR_PERMISSION_DENIED;
return VINF_SUCCESS;
if (*pEffUserID != 0)
if (seteuid(0) == 0)
*pEffUserID = 0;
return VINF_SUCCESS;
return VERR_PERMISSION_DENIED;
return VINF_SUCCESS;
if (*pEffUserID == 0)
return VINF_SUCCESS;
return VERR_PERMISSION_DENIED;
return VINF_SUCCESS;
#ifdef RT_OS_LINUX
if (!CFGMR3AreValuesValid(pCfgHandle, "Path\0Interval\0Locked\0BIOSVisible\0AttachFailError\0Passthrough\0"))
#ifdef RT_OS_LINUX
return VERR_NO_MEMORY;
bool fPassthrough;
return rc;
#ifdef USE_MEDIA_POLLING
if (!fPassthrough)
#ifdef RT_OS_LINUX
return rc;
sizeof(DRVHOSTBASE),
NULL,
NULL,
NULL,
NULL,
NULL,