VirtualBox

Changeset 37596 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Jun 22, 2011 7:30:06 PM (14 years ago)
Author:
vboxsync
Message:

*: RTFILE becomes a pointer, RTFileOpen++ expands it's flags paramter from uint32_t to uint64_t.

Location:
trunk/src/VBox/Devices
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/DrvNAT.cpp

    r35922 r37596  
    55
    66/*
    7  * Copyright (C) 2006-2010 Oracle Corporation
     7 * Copyright (C) 2006-2011 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2828#include <VBox/vmm/pdmnetifs.h>
    2929#include <VBox/vmm/pdmnetinline.h>
     30
    3031#include <iprt/assert.h>
     32#include <iprt/critsect.h>
     33#include <iprt/cidr.h>
    3134#include <iprt/file.h>
    3235#include <iprt/mem.h>
     36#include <iprt/pipe.h>
    3337#include <iprt/string.h>
    34 #include <iprt/critsect.h>
    35 #include <iprt/cidr.h>
    3638#include <iprt/stream.h>
    3739#include <iprt/uuid.h>
     
    163165#ifndef RT_OS_WINDOWS
    164166    /** The write end of the control pipe. */
    165     RTFILE                  PipeWrite;
     167    RTPIPE                  hPipeWrite;
    166168    /** The read end of the control pipe. */
    167     RTFILE                  PipeRead;
     169    RTPIPE                  hPipeRead;
    168170#else
    169171    /** for external notification */
     
    569571#ifndef RT_OS_WINDOWS
    570572    /* kick poll() */
    571     rc = RTFileWrite(pThis->PipeWrite, "", 1, NULL);
     573    size_t cbIgnored;
     574    rc = RTPipeWrite(pThis->hPipeWrite, "", 1, &cbIgnored);
    572575#else
    573576    /* kick WSAWaitForMultipleEvents */
     
    744747        slirp_select_fill(pThis->pNATState, &nFDs, &polls[1]);
    745748
    746         polls[0].fd = pThis->PipeRead;
     749        polls[0].fd = RTPipeToNative(pThis->hPipeRead);
    747750        /* POLLRDBAND usually doesn't used on Linux but seems used on Solaris */
    748         polls[0].events = POLLRDNORM|POLLPRI|POLLRDBAND;
     751        polls[0].events = POLLRDNORM | POLLPRI | POLLRDBAND;
    749752        polls[0].revents = 0;
    750753
     
    770773            if (polls[0].revents & (POLLRDNORM|POLLPRI|POLLRDBAND))
    771774            {
    772                 /* drain the pipe */
    773                 char ch[1];
    774                 size_t cbRead;
    775                 int counter = 0;
    776                 /*
    777                  * drvNATSend decoupled so we don't know how many times
     775                /* drain the pipe
     776                 *
     777                 * Note! drvNATSend decoupled so we don't know how many times
    778778                 * device's thread sends before we've entered multiplex,
    779779                 * so to avoid false alarm drain pipe here to the very end
     
    782782                 * deep pipe has been filed before drain.
    783783                 *
    784                  * XXX:Make it reading exactly we need to drain the pipe.
    785784                 */
    786                 /** @todo use RTPipeCreate + RTPipeRead(,biggerbuffer) here, it's
    787                  *        non-blocking. */
    788                 RTFileRead(pThis->PipeRead, &ch, 1, &cbRead);
     785                /** @todo XXX: Make it reading exactly we need to drain the
     786                 * pipe.*/
     787                char ch;
     788                size_t cbRead;
     789                RTPipeRead(pThis->hPipeRead, &ch, 1, &cbRead);
    789790            }
    790791        }
     
    13451346             * Create the control pipe.
    13461347             */
    1347             int fds[2];
    1348             if (pipe(&fds[0]) != 0) /** @todo RTPipeCreate() or something... */
    1349             {
    1350                 rc = RTErrConvertFromErrno(errno);
    1351                 AssertRC(rc);
    1352                 return rc;
    1353             }
    1354             pThis->PipeRead = fds[0];
    1355             pThis->PipeWrite = fds[1];
     1348            rc = RTPipeCreate(&pThis->hPipeRead, &pThis->hPipeWrite, 0 /*fFlags*/);
     1349            AssertRCReturn(rc, rc);
    13561350#else
    13571351            pThis->hWakeupEvent = CreateEvent(NULL, FALSE, FALSE, NULL); /* auto-reset event */
     
    13621356            rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pSlirpThread, pThis, drvNATAsyncIoThread,
    13631357                                       drvNATAsyncIoWakeup, 128 * _1K, RTTHREADTYPE_IO, "NAT");
    1364             AssertRC(rc);
     1358            AssertRCReturn(rc, rc);
    13651359
    13661360#ifdef VBOX_WITH_SLIRP_MT
    13671361            rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pGuestThread, pThis, drvNATAsyncIoGuest,
    13681362                                       drvNATAsyncIoGuestWakeup, 128 * _1K, RTTHREADTYPE_IO, "NATGUEST");
    1369             AssertRC(rc);
     1363            AssertRCReturn(rc, rc);
    13701364#endif
    13711365
  • trunk/src/VBox/Devices/Network/DrvNetSniffer.cpp

    r37461 r37596  
    6666    char                    szFilename[RTPATH_MAX];
    6767    /** The filehandle. */
    68     RTFILE                  File;
     68    RTFILE                  hFile;
    6969    /** The lock serializing the file access. */
    7070    RTCRITSECT              Lock;
     
    134134    RTCritSectEnter(&pThis->Lock);
    135135    if (!pSgBuf->pvUser)
    136         PcapFileFrame(pThis->File, pThis->StartNanoTS,
     136        PcapFileFrame(pThis->hFile, pThis->StartNanoTS,
    137137                      pSgBuf->aSegs[0].pvSeg,
    138138                      pSgBuf->cbUsed,
    139139                      RT_MIN(pSgBuf->cbUsed, pSgBuf->aSegs[0].cbSeg));
    140140    else
    141         PcapFileGsoFrame(pThis->File, pThis->StartNanoTS, (PCPDMNETWORKGSO)pSgBuf->pvUser,
     141        PcapFileGsoFrame(pThis->hFile, pThis->StartNanoTS, (PCPDMNETWORKGSO)pSgBuf->pvUser,
    142142                         pSgBuf->aSegs[0].pvSeg,
    143143                         pSgBuf->cbUsed,
     
    206206    /* output to sniffer */
    207207    RTCritSectEnter(&pThis->Lock);
    208     PcapFileFrame(pThis->File, pThis->StartNanoTS, pvBuf, cb, cb);
     208    PcapFileFrame(pThis->hFile, pThis->StartNanoTS, pvBuf, cb, cb);
    209209    RTCritSectLeave(&pThis->Lock);
    210210
     
    217217    Hdr.ts_usec = (uint32_t)((u64TS / 1000) % 1000000);
    218218    Hdr.incl_len = 0;
    219     RTFileWrite(pThis->File, &Hdr, sizeof(Hdr), NULL);
     219    RTFileWrite(pThis->hFile, &Hdr, sizeof(Hdr), NULL);
    220220    RTCritSectLeave(&pThis->Lock);
    221221#endif
     
    358358        RTCritSectDelete(&pThis->XmitLock);
    359359
    360     if (pThis->File != NIL_RTFILE)
    361     {
    362         RTFileClose(pThis->File);
    363         pThis->File = NIL_RTFILE;
    364     }
     360    RTFileClose(pThis->hFile);
     361    pThis->hFile = NIL_RTFILE;
    365362}
    366363
     
    380377     */
    381378    pThis->pDrvIns                                  = pDrvIns;
    382     pThis->File                                     = NIL_RTFILE;
     379    pThis->hFile                                    = NIL_RTFILE;
    383380    /* The pcap file *must* start at time offset 0,0. */
    384381    pThis->StartNanoTS                              = RTTimeNanoTS() - RTTimeProgramNanoTS();
     
    483480     * Open output file / pipe.
    484481     */
    485     rc = RTFileOpen(&pThis->File, pThis->szFilename,
     482    rc = RTFileOpen(&pThis->hFile, pThis->szFilename,
    486483                    RTFILE_O_WRITE | RTFILE_O_CREATE_REPLACE | RTFILE_O_DENY_WRITE);
    487484    if (RT_FAILURE(rc))
     
    494491     * current time again.
    495492     */
    496     PcapFileHdr(pThis->File, RTTimeNanoTS());
     493    PcapFileHdr(pThis->hFile, RTTimeNanoTS());
    497494
    498495    return VINF_SUCCESS;
  • trunk/src/VBox/Devices/Network/DrvTAP.cpp

    r35353 r37596  
    3131#include <iprt/mem.h>
    3232#include <iprt/path.h>
     33#include <iprt/pipe.h>
    3334#include <iprt/semaphore.h>
    3435#include <iprt/string.h>
     
    9394    PPDMDRVINS              pDrvIns;
    9495    /** TAP device file handle. */
    95     RTFILE                  FileDevice;
     96    RTFILE                  hFileDevice;
    9697    /** The configured TAP device name. */
    9798    char                   *pszDeviceName;
     
    104105# else
    105106    /** IP device file handle (/dev/udp). */
    106     RTFILE                  IPFileDevice;
     107    int                     iIPFileDes;
    107108# endif
    108109    /** Whether device name is obtained from setup application. */
     
    114115    char                   *pszTerminateApplication;
    115116    /** The write end of the control pipe. */
    116     RTFILE                  PipeWrite;
     117    RTPIPE                  hPipeWrite;
    117118    /** The read end of the control pipe. */
    118     RTFILE                  PipeRead;
     119    RTPIPE                  hPipeRead;
    119120    /** Reader thread. */
    120121    PPDMTHREAD              pThread;
     
    275276              pSgBuf->aSegs[0].pvSeg, pSgBuf->cbUsed, pSgBuf->cbUsed, pSgBuf->aSegs[0].pvSeg));
    276277
    277         rc = RTFileWrite(pThis->FileDevice, pSgBuf->aSegs[0].pvSeg, pSgBuf->cbUsed, NULL);
     278        rc = RTFileWrite(pThis->hFileDevice, pSgBuf->aSegs[0].pvSeg, pSgBuf->cbUsed, NULL);
    278279    }
    279280    else
     
    289290            void *pvSegFrame = PDMNetGsoCarveSegmentQD(pGso, (uint8_t *)pbFrame, pSgBuf->cbUsed, abHdrScratch,
    290291                                                       iSeg, cSegs, &cbSegFrame);
    291             rc = RTFileWrite(pThis->FileDevice, pvSegFrame, cbSegFrame, NULL);
     292            rc = RTFileWrite(pThis->hFileDevice, pvSegFrame, cbSegFrame, NULL);
    292293            if (RT_FAILURE(rc))
    293294                break;
     
    366367         */
    367368        struct pollfd aFDs[2];
    368         aFDs[0].fd      = pThis->FileDevice;
     369        aFDs[0].fd      = RTFileToNative(pThis->hFileDevice);
    369370        aFDs[0].events  = POLLIN | POLLPRI;
    370371        aFDs[0].revents = 0;
    371         aFDs[1].fd      = pThis->PipeRead;
     372        aFDs[1].fd      = RTPipeToNative(pThis->hPipeRead);
    372373        aFDs[1].events  = POLLIN | POLLPRI | POLLERR | POLLHUP;
    373374        aFDs[1].revents = 0;
     
    398399             *        after poll() returned successfully. I don't know why but a second
    399400             *        RTFileRead() operation will return with VERR_TRY_AGAIN in any case. */
    400             rc = RTFileRead(pThis->FileDevice, achBuf, sizeof(achBuf), &cbRead);
     401            rc = RTFileRead(pThis->hFileDevice, achBuf, sizeof(achBuf), &cbRead);
    401402#endif
    402403            if (RT_SUCCESS(rc))
     
    459460            char ch;
    460461            size_t cbRead;
    461             RTFileRead(pThis->PipeRead, &ch, 1, &cbRead);
     462            RTPipeRead(pThis->hPipeRead, &ch, 1, &cbRead);
    462463        }
    463464        else
     
    495496    PDRVTAP pThis = PDMINS_2_DATA(pDrvIns, PDRVTAP);
    496497
    497     int rc = RTFileWrite(pThis->PipeWrite, "", 1, NULL);
     498    size_t cbIgnored;
     499    int rc = RTPipeWrite(pThis->hPipeWrite, "", 1, &cbIgnored);
    498500    AssertRC(rc);
    499501
     
    657659                        if (rc == DLPI_SUCCESS)
    658660                        {
    659                             pThis->FileDevice = g_pfnLibDlpiFd(pThis->pDeviceHandle);
     661                            int fd = g_pfnLibDlpiFd(pThis->pDeviceHandle);
    660662                            if (pThis->FileDevice >= 0)
    661663                            {
    662                                 Log(("SolarisOpenVNIC: %s -> %d\n", pThis->pszDeviceName, pThis->FileDevice));
    663                                 return VINF_SUCCESS;
     664                                rc = RTFileFromNative(&pThis->hFileDevice, fd);
     665                                if (RT_SUCCESS(rc))
     666                                {
     667                                    Log(("SolarisOpenVNIC: %s -> %RTfile\n", pThis->pszDeviceName, pThis->hFileDevice));
     668                                    return VINF_SUCCESS;
     669                                }
    664670                            }
    665 
    666                             rc = PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,
    667                                                      N_("Failed to obtain file descriptor for VNIC"));
     671                            else
     672                                rc = PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_HOSTIF_INIT_FAILED, RT_SRC_POS,
     673                                                         N_("Failed to obtain file descriptor for VNIC"));
    668674                        }
    669675                        else
     
    879885    }
    880886
    881     pThis->FileDevice = (RTFILE)TapFileDes;
    882     pThis->IPFileDevice = (RTFILE)IPFileDes;
     887    int rc = RTFileFromNative(&pThis->hFileDevice, TapFileDes);
     888    AssertLogRelRC(rc);
     889    if (RT_FAILURE(rc)))
     890    {
     891        close(IPFileDes);
     892        close(TapFileDes);
     893    }
     894    pThis->iIPFileDes = IPFileDes;
    883895
    884896    return VINF_SUCCESS;
     
    922934     * Terminate the control pipe.
    923935     */
    924     if (pThis->PipeWrite != NIL_RTFILE)
    925     {
    926         int rc = RTFileClose(pThis->PipeWrite);
    927         AssertRC(rc);
    928         pThis->PipeWrite = NIL_RTFILE;
    929     }
    930     if (pThis->PipeRead != NIL_RTFILE)
    931     {
    932         int rc = RTFileClose(pThis->PipeRead);
    933         AssertRC(rc);
    934         pThis->PipeRead = NIL_RTFILE;
    935     }
     936    int rc;
     937    rc = RTPipeClose(pThis->hPipeWrite); AssertRC(rc);
     938    pThis->hPipeWrite = NIL_RTPIPE;
     939    rc = RTPipeClose(pThis->hPipeRead); AssertRC(rc);
     940    pThis->hPipeRead = NIL_RTPIPE;
    936941
    937942#ifdef RT_OS_SOLARIS
    938943    /** @todo r=bird: This *does* need checking against ConsoleImpl2.cpp if used on non-solaris systems. */
    939     if (pThis->FileDevice != NIL_RTFILE)
    940     {
    941         int rc = RTFileClose(pThis->FileDevice);
     944    if (pThis->hFileDevice != NIL_RTFILE)
     945    {
     946        int rc = RTFileClose(pThis->hFileDevice);
    942947        AssertRC(rc);
    943         pThis->FileDevice = NIL_RTFILE;
     948        pThis->hFileDevice = NIL_RTFILE;
    944949    }
    945950
    946951# ifndef VBOX_WITH_CROSSBOW
    947     if (pThis->IPFileDevice != NIL_RTFILE)
    948     {
    949         int rc = RTFileClose(pThis->IPFileDevice);
    950         AssertRC(rc);
    951         pThis->IPFileDevice = NIL_RTFILE;
     952    if (pThis->iIPFileDes != -1)
     953    {
     954        close(pThis->iIPFileDes);
     955        pThis->iIPFileDes = -1;
    952956    }
    953957# endif
     
    10071011     */
    10081012    pThis->pDrvIns                      = pDrvIns;
    1009     pThis->FileDevice                   = NIL_RTFILE;
     1013    pThis->hFileDevice                  = NIL_RTFILE;
    10101014    pThis->pszDeviceName                = NULL;
    10111015#ifdef RT_OS_SOLARIS
     
    10131017    pThis->pDeviceHandle                = NULL;
    10141018# else
    1015     pThis->IPFileDevice                 = NIL_RTFILE;
     1019    pThis->iIPFileDes                   = -1;
    10161020# endif
    10171021    pThis->fStatic                      = true;
     
    11261130#else /* !RT_OS_SOLARIS */
    11271131
    1128     int32_t iFile;
    1129     rc = CFGMR3QueryS32(pCfg, "FileHandle", &iFile);
     1132    uint64_t u64File;
     1133    rc = CFGMR3QueryU64(pCfg, "FileHandle", &u64File);
    11301134    if (RT_FAILURE(rc))
    11311135        return PDMDRV_SET_ERROR(pDrvIns, rc,
    11321136                                N_("Configuration error: Query for \"FileHandle\" 32-bit signed integer failed"));
    1133     pThis->FileDevice = (RTFILE)iFile;
    1134     if (!RTFileIsValid(pThis->FileDevice))
     1137    pThis->hFileDevice = (RTFILE)(uintptr_t)u64File;
     1138    if (!RTFileIsValid(pThis->hFileDevice))
    11351139        return PDMDrvHlpVMSetError(pDrvIns, VERR_INVALID_HANDLE, RT_SRC_POS,
    1136                                    N_("The TAP file handle %RTfile is not valid"), pThis->FileDevice);
     1140                                   N_("The TAP file handle %RTfile is not valid"), pThis->hFileDevice);
    11371141#endif /* !RT_OS_SOLARIS */
    11381142
     
    11491153     * found any way to do that.
    11501154     */
    1151     if (fcntl(pThis->FileDevice, F_SETFL, O_NONBLOCK) == -1)
     1155    if (fcntl(RTFileToNative(pThis->hFileDevice), F_SETFL, O_NONBLOCK) == -1)
    11521156        return PDMDrvHlpVMSetError(pDrvIns, VERR_HOSTIF_IOCTL, RT_SRC_POS,
    11531157                                   N_("Configuration error: Failed to configure /dev/net/tun. errno=%d"), errno);
    11541158    /** @todo determine device name. This can be done by reading the link /proc/<pid>/fd/<fd> */
    1155     Log(("drvTAPContruct: %d (from fd)\n", pThis->FileDevice));
     1159    Log(("drvTAPContruct: %d (from fd)\n", pThis->hFileDevice));
    11561160    rc = VINF_SUCCESS;
    11571161
     
    11591163     * Create the control pipe.
    11601164     */
    1161     int fds[2];
    1162 #ifdef RT_OS_L4
    1163     /* XXX We need to tell the library which interface we are using */
    1164     fds[0] = vboxrtLinuxFd2VBoxFd(VBOXRT_FT_TAP, 0);
    1165 #endif
    1166     if (pipe(&fds[0]) != 0) /** @todo RTPipeCreate() or something... */
    1167     {
    1168         rc = RTErrConvertFromErrno(errno);
    1169         AssertRC(rc);
    1170         return rc;
    1171     }
    1172     pThis->PipeRead = fds[0];
    1173     pThis->PipeWrite = fds[1];
     1165    rc = RTPipeCreate(&pThis->hPipeRead, &pThis->hPipeWrite, 0 /*fFlags*/);
     1166    AssertRCReturn(rc, rc);
    11741167
    11751168    /*
  • trunk/src/VBox/Devices/Network/DrvVDE.cpp

    r37299 r37596  
    3434#include <iprt/param.h>
    3535#include <iprt/path.h>
     36#include <iprt/pipe.h>
    3637#include <iprt/semaphore.h>
    3738#include <iprt/string.h>
     
    6465    /** Pointer to the driver instance. */
    6566    PPDMDRVINS              pDrvIns;
    66     /** VDE device file handle. */
    67     RTFILE                  FileDevice;
    6867    /** The configured VDE device name. */
    6968    char                   *pszDeviceName;
    7069    /** The write end of the control pipe. */
    71     RTFILE                  PipeWrite;
     70    RTPIPE                  hPipeWrite;
    7271    /** The read end of the control pipe. */
    73     RTFILE                  PipeRead;
     72    RTPIPE                  hPipeRead;
    7473    /** Reader thread. */
    7574    PPDMTHREAD              pThread;
    7675    /** The connection to the VDE switch */
    77     VDECONN                *vdeconn;
     76    VDECONN                *pVdeConn;
    7877
    7978    /** @todo The transmit thread. */
     
    225224
    226225        ssize_t cbSent;
    227         cbSent = vde_send(pThis->vdeconn, pSgBuf->aSegs[0].pvSeg, pSgBuf->cbUsed, 0);
     226        cbSent = vde_send(pThis->pVdeConn, pSgBuf->aSegs[0].pvSeg, pSgBuf->cbUsed, 0);
    228227        rc = cbSent < 0 ? RTErrConvertFromErrno(-cbSent) : VINF_SUCCESS;
    229228    }
     
    241240                                                       iSeg, cSegs, &cbSegFrame);
    242241            ssize_t cbSent;
    243             cbSent = vde_send(pThis->vdeconn, pvSegFrame, cbSegFrame, 0);
     242            cbSent = vde_send(pThis->pVdeConn, pvSegFrame, cbSegFrame, 0);
    244243            rc = cbSent < 0 ? RTErrConvertFromErrno(-cbSent) : VINF_SUCCESS;
    245244            if (RT_FAILURE(rc))
     
    319318         */
    320319        struct pollfd aFDs[2];
    321         aFDs[0].fd      = vde_datafd(pThis->vdeconn);
     320        aFDs[0].fd      = vde_datafd(pThis->pVdeConn);
    322321        aFDs[0].events  = POLLIN | POLLPRI;
    323322        aFDs[0].revents = 0;
    324         aFDs[1].fd      = pThis->PipeRead;
     323        aFDs[1].fd      = RTPipeToNative(pThis->hPipeRead);
    325324        aFDs[1].events  = POLLIN | POLLPRI | POLLERR | POLLHUP;
    326325        aFDs[1].revents = 0;
     
    343342            char achBuf[16384];
    344343            ssize_t cbRead = 0;
    345             cbRead = vde_recv(pThis->vdeconn, achBuf, sizeof(achBuf), 0);
     344            cbRead = vde_recv(pThis->pVdeConn, achBuf, sizeof(achBuf), 0);
    346345            rc = cbRead < 0 ? RTErrConvertFromErrno(-cbRead) : VINF_SUCCESS;
    347346            if (RT_SUCCESS(rc))
     
    404403            char ch;
    405404            size_t cbRead;
    406             RTFileRead(pThis->PipeRead, &ch, 1, &cbRead);
     405            RTPipeRead(pThis->hPipeRead, &ch, 1, &cbRead);
    407406        }
    408407        else
     
    440439    PDRVVDE pThis = PDMINS_2_DATA(pDrvIns, PDRVVDE);
    441440
    442     int rc = RTFileWrite(pThis->PipeWrite, "", 1, NULL);
     441    size_t cbIgnored;
     442    int rc = RTPipeWrite(pThis->hPipeWrite, "", 1, &cbIgnored);
    443443    AssertRC(rc);
    444444
     
    481481     * Terminate the control pipe.
    482482     */
    483     if (pThis->PipeWrite != NIL_RTFILE)
    484     {
    485         int rc = RTFileClose(pThis->PipeWrite);
    486         AssertRC(rc);
    487         pThis->PipeWrite = NIL_RTFILE;
    488     }
    489     if (pThis->PipeRead != NIL_RTFILE)
    490     {
    491         int rc = RTFileClose(pThis->PipeRead);
    492         AssertRC(rc);
    493         pThis->PipeRead = NIL_RTFILE;
    494     }
     483    RTPipeClose(pThis->hPipeWrite);
     484    pThis->hPipeWrite = NIL_RTPIPE;
     485    RTPipeClose(pThis->hPipeRead);
     486    pThis->hPipeRead = NIL_RTPIPE;
    495487
    496488    MMR3HeapFree(pThis->pszDeviceName);
     
    502494        RTCritSectDelete(&pThis->XmitLock);
    503495
    504     vde_close(pThis->vdeconn);
     496    vde_close(pThis->pVdeConn);
     497    pThis->pVdeConn = NULL;
     498
    505499#ifdef VBOX_WITH_STATISTICS
    506500    /*
     
    530524     * Init the static parts.
    531525     */
    532     pThis->pDrvIns                      = pDrvIns;
    533     pThis->FileDevice                   = NIL_RTFILE;
    534     pThis->pszDeviceName                = NULL;
    535     pThis->PipeRead                     = NIL_RTFILE;
    536     pThis->PipeWrite                    = NIL_RTFILE;
     526    pThis->pDrvIns                              = pDrvIns;
     527    pThis->pszDeviceName                        = NULL;
     528    pThis->hPipeRead                            = NIL_RTPIPE;
     529    pThis->hPipeWrite                           = NIL_RTPIPE;
    537530
    538531    /* IBase */
    539     pDrvIns->IBase.pfnQueryInterface    = drvVDEQueryInterface;
     532    pDrvIns->IBase.pfnQueryInterface            = drvVDEQueryInterface;
    540533    /* INetwork */
    541534    pThis->INetworkUp.pfnBeginXmit              = drvVDENetworkUp_BeginXmit;
     
    592585        return PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_HIF_OPEN_FAILED, RT_SRC_POS,
    593586                                   N_("VDEplug library: not found"));
    594     pThis->vdeconn = vde_open(szNetwork, "VirtualBOX", NULL);
    595     if (pThis->vdeconn == NULL)
     587    pThis->pVdeConn = vde_open(szNetwork, "VirtualBOX", NULL);
     588    if (pThis->pVdeConn == NULL)
    596589        return PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_PDM_HIF_OPEN_FAILED, RT_SRC_POS,
    597590                                   N_("Failed to connect to the VDE SWITCH"));
     
    606599     * Create the control pipe.
    607600     */
    608     int fds[2];
    609     if (pipe(&fds[0]) != 0) /** @todo RTPipeCreate() or something... */
    610     {
    611         rc = RTErrConvertFromErrno(errno);
    612         AssertRC(rc);
    613         return rc;
    614     }
    615     pThis->PipeRead = fds[0];
    616     pThis->PipeWrite = fds[1];
     601    rc = RTPipeCreate(&pThis->hPipeRead, &pThis->hPipeWrite, 0 /*fFlags*/);
     602    AssertRCReturn(rc, rc);
    617603
    618604    /*
  • trunk/src/VBox/Devices/Parallel/DrvHostParallel.cpp

    r35353 r37596  
    2727#include <iprt/assert.h>
    2828#include <iprt/file.h>
     29#include <iprt/pipe.h>
    2930#include <iprt/semaphore.h>
    3031#include <iprt/stream.h>
     
    6465    char                         *pszDevicePath;
    6566    /** Device Handle */
    66     RTFILE                        FileDevice;
     67    RTFILE                        hFileDevice;
    6768    /** Thread waiting for interrupts. */
    6869    PPDMTHREAD                    pMonitorThread;
    6970    /** Wakeup pipe read end. */
    70     RTFILE                        WakeupPipeR;
     71    RTPIPE                        hWakeupPipeR;
    7172    /** Wakeup pipe write end. */
    72     RTFILE                        WakeupPipeW;
     73    RTPIPE                        hWakeupPipeW;
    7374} DRVHOSTPARALLEL, *PDRVHOSTPARALLEL;
    7475
     
    102103    LogFlow(("%s: pvBuf=%#p cbWrite=%d\n", __FUNCTION__, pvBuf, *cbWrite));
    103104
    104     ioctl(pThis->FileDevice, PPWDATA, pBuffer);
     105    ioctl(RTFileToNative(pThis->hFileDevice), PPWDATA, pBuffer);
    105106    *cbWrite = 1;
    106107
     
    115116    LogFlow(("%s: pvBuf=%#p cbRead=%d\n", __FUNCTION__, pvBuf, cbRead));
    116117
    117     ioctl(pThis->FileDevice, PPRDATA, pBuffer);
     118    ioctl(RTFileToNative(pThis->hFileDevice), PPRDATA, pBuffer);
    118119    *cbRead = 1;
    119120
     
    140141    }
    141142
    142     ioctl(pThis->FileDevice, PPSETMODE, &ppdev_mode);
     143    ioctl(RTFileToNative(pThis->hFileDevice), PPSETMODE, &ppdev_mode);
    143144
    144145    return VINF_SUCCESS;
     
    150151
    151152    LogFlow(("%s: fReg=%d\n", __FUNCTION__, fReg));
    152 
    153     ioctl(pThis->FileDevice, PPWCONTROL, &fReg);
     153    ioctl(RTFileToNative(pThis->hFileDevice), PPWCONTROL, &fReg);
    154154
    155155    return VINF_SUCCESS;
     
    159159{
    160160    PDRVHOSTPARALLEL pThis = PDMIHOSTPARALLELCONNECTOR_2_DRVHOSTPARALLEL(pInterface);
    161     uint8_t fReg;
    162 
    163     ioctl(pThis->FileDevice, PPRCONTROL, &fReg);
    164 
     161
     162    uint8_t fReg = 0;
     163    ioctl(RTFileToNative(pThis->hFileDevice), PPRCONTROL, &fReg);
    165164    LogFlow(("%s: fReg=%d\n", __FUNCTION__, fReg));
    166 
    167165    *pfReg = fReg;
    168166
     
    173171{
    174172    PDRVHOSTPARALLEL pThis = PDMIHOSTPARALLELCONNECTOR_2_DRVHOSTPARALLEL(pInterface);
    175     uint8_t fReg;
    176 
    177     ioctl(pThis->FileDevice, PPRSTATUS, &fReg);
    178 
     173
     174    uint8_t fReg = 0;
     175    ioctl(RTFileToNative(pThis->hFileDevice), PPRSTATUS, &fReg);
    179176    LogFlow(("%s: fReg=%d\n", __FUNCTION__, fReg));
    180 
    181177    *pfReg = fReg;
    182178
     
    196192        int rc;
    197193
    198         aFDs[0].fd      = pThis->FileDevice;
     194        aFDs[0].fd      = RTFileToNative(pThis->hFileDevice);
    199195        aFDs[0].events  = POLLIN;
    200196        aFDs[0].revents = 0;
    201         aFDs[1].fd      = pThis->WakeupPipeR;
     197        aFDs[1].fd      = RTPipeToNative(pThis->hWakeupPipeR);
    202198        aFDs[1].events  = POLLIN | POLLERR | POLLHUP;
    203199        aFDs[1].revents = 0;
     
    218214            char ch;
    219215            size_t cbRead;
    220             RTFileRead(pThis->WakeupPipeR, &ch, 1, &cbRead);
     216            RTPipeRead(pThis->hWakeupPipeR, &ch, 1, &cbRead);
    221217            continue;
    222218        }
     
    240236{
    241237    PDRVHOSTPARALLEL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTPARALLEL);
    242 
    243     return RTFileWrite(pThis->WakeupPipeW, "", 1, NULL);
     238    size_t cbIgnored;
     239    return RTPipeWrite(pThis->hWakeupPipeW, "", 1, &cbIgnored);
    244240}
    245241
     
    257253    LogFlow(("%s: iInstance=%d\n", __FUNCTION__, pDrvIns->iInstance));
    258254    PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns);
    259 
    260     ioctl(pThis->FileDevice, PPRELEASE);
    261 
    262     if (pThis->WakeupPipeW != NIL_RTFILE)
    263     {
    264         int rc = RTFileClose(pThis->WakeupPipeW);
    265         AssertRC(rc);
    266         pThis->WakeupPipeW = NIL_RTFILE;
    267     }
    268     if (pThis->WakeupPipeR != NIL_RTFILE)
    269     {
    270         int rc = RTFileClose(pThis->WakeupPipeR);
    271         AssertRC(rc);
    272         pThis->WakeupPipeR = NIL_RTFILE;
    273     }
    274     if (pThis->FileDevice != NIL_RTFILE)
    275     {
    276         int rc = RTFileClose(pThis->FileDevice);
    277         AssertRC(rc);
    278         pThis->FileDevice = NIL_RTFILE;
    279     }
     255    int rc;
     256
     257    if (pThis->hFileDevice != NIL_RTFILE)
     258        ioctl(RTFileToNative(pThis->hFileDevice), PPRELEASE);
     259
     260    rc = RTPipeClose(pThis->hWakeupPipeW); AssertRC(rc);
     261    pThis->hWakeupPipeW = NIL_RTPIPE;
     262
     263    rc = RTPipeClose(pThis->hWakeupPipeR); AssertRC(rc);
     264    pThis->hWakeupPipeR = NIL_RTPIPE;
     265
     266    rc = RTFileClose(pThis->hFileDevice); AssertRC(rc);
     267    pThis->hFileDevice = NIL_RTFILE;
     268
    280269    if (pThis->pszDevicePath)
    281270    {
     
    297286
    298287    /*
    299      * Validate the config.
    300      */
    301     if (!CFGMR3AreValuesValid(pCfg, "DevicePath\0"))
    302         return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES,
    303                                 N_("Unknown host parallel configuration option, only supports DevicePath"));
    304 
    305     /*
    306288     * Init basic data members and interfaces.
    307      */
     289     *
     290     * Must be done before returning any failure because we've got a destructor.
     291     */
     292    pThis->hFileDevice  = NIL_RTFILE;
     293    pThis->hWakeupPipeR = NIL_RTPIPE;
     294    pThis->hWakeupPipeW = NIL_RTPIPE;
    308295
    309296    /* IBase. */
     
    318305
    319306    /*
     307     * Validate the config.
     308     */
     309    if (!CFGMR3AreValuesValid(pCfg, "DevicePath\0"))
     310        return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES,
     311                                N_("Unknown host parallel configuration option, only supports DevicePath"));
     312
     313    /*
    320314     * Query configuration.
    321315     */
     
    331325     * Open the device
    332326     */
    333     rc = RTFileOpen(&pThis->FileDevice, pThis->pszDevicePath, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
     327    rc = RTFileOpen(&pThis->hFileDevice, pThis->pszDevicePath, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
    334328    if (RT_FAILURE(rc))
    335329        return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("Parallel#%d could not open '%s'"),
     
    339333     * Try to get exclusive access to parallel port
    340334     */
    341     rc = ioctl(pThis->FileDevice, PPEXCL);
     335    rc = ioctl(RTFileToNative(pThis->hFileDevice), PPEXCL);
    342336    if (rc < 0)
    343337        return PDMDrvHlpVMSetError(pDrvIns, RTErrConvertFromErrno(errno), RT_SRC_POS,
     
    349343     * Claim the parallel port
    350344     */
    351     rc = ioctl(pThis->FileDevice, PPCLAIM);
     345    rc = ioctl(RTFileToNative(pThis->hFileDevice), PPCLAIM);
    352346    if (rc < 0)
    353347        return PDMDrvHlpVMSetError(pDrvIns, RTErrConvertFromErrno(errno), RT_SRC_POS,
     
    367361     * Create wakeup pipe.
    368362     */
    369     int aFDs[2];
    370     if (pipe(aFDs) != 0)
    371     {
    372         rc = RTErrConvertFromErrno(errno);
    373         AssertRC(rc);
    374         return rc;
    375     }
    376     pThis->WakeupPipeR = aFDs[0];
    377     pThis->WakeupPipeW = aFDs[1];
     363    rc = RTPipeCreate(&pThis->hWakeupPipeR, &pThis->hWakeupPipeR, 0 /*fFlags*/);
     364    AssertRCReturn(rc, rc);
    378365
    379366    /*
  • trunk/src/VBox/Devices/Serial/DrvHostSerial.cpp

    r35769 r37596  
    3030#include <iprt/file.h>
    3131#include <iprt/mem.h>
     32#include <iprt/pipe.h>
    3233#include <iprt/semaphore.h>
    3334#include <iprt/uuid.h>
     
    103104#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
    104105    /** the device handle */
    105     RTFILE                      DeviceFile;
     106    RTFILE                      hDeviceFile;
    106107# ifdef RT_OS_DARWIN
    107108    /** The device handle used for reading.
    108109     * Used to prevent the read select from blocking the writes. */
    109     RTFILE                      DeviceFileR;
     110    RTFILE                      hDeviceFileR;
    110111# endif
    111112    /** The read end of the control pipe */
    112     RTFILE                      WakeupPipeR;
     113    RTPIPE                      hWakeupPipeR;
    113114    /** The write end of the control pipe */
    114     RTFILE                      WakeupPipeW;
     115    RTPIPE                      hWakeupPipeW;
    115116# ifndef RT_OS_LINUX
    116117    /** The current line status.
     
    265266#ifdef RT_OS_LINUX
    266267            struct serial_struct serialStruct;
    267             if (ioctl(pThis->DeviceFile, TIOCGSERIAL, &serialStruct) != -1)
     268            if (ioctl(RTFileToNative(pThis->hDeviceFile), TIOCGSERIAL, &serialStruct) != -1)
    268269            {
    269270                serialStruct.custom_divisor = serialStruct.baud_base / Bps;
     
    272273                serialStruct.flags &= ~ASYNC_SPD_MASK;
    273274                serialStruct.flags |= ASYNC_SPD_CUST;
    274                 ioctl(pThis->DeviceFile, TIOCSSERIAL, &serialStruct);
     275                ioctl(RTFileToNative(pThis->hDeviceFile), TIOCSSERIAL, &serialStruct);
    275276                baud_rate = B38400;
    276277            }
     
    328329    termiosSetup->c_lflag &= ~(ICANON | ECHO | ECHOE | ECHONL | ECHOK | ISIG | IEXTEN);
    329330
    330     tcsetattr(pThis->DeviceFile, TCSANOW, termiosSetup);
     331    tcsetattr(RTFileToNative(pThis->hDeviceFile), TCSANOW, termiosSetup);
    331332    RTMemTmpFree(termiosSetup);
    332333
     
    486487
    487488            size_t cbWritten;
    488             rc = RTFileWrite(pThis->DeviceFile, &ch, 1, &cbWritten);
     489            rc = RTFileWrite(pThis->hDeviceFile, &ch, 1, &cbWritten);
    489490            if (rc == VERR_TRY_AGAIN)
    490491                cbWritten = 0;
     
    498499                    fd_set WrSet;
    499500                    FD_ZERO(&WrSet);
    500                     FD_SET(pThis->DeviceFile, &WrSet);
     501                    FD_SET(RTFileToNative(pThis->hDeviceFile), &WrSet);
    501502                    fd_set XcptSet;
    502503                    FD_ZERO(&XcptSet);
    503                     FD_SET(pThis->DeviceFile, &XcptSet);
     504                    FD_SET(RTFileToNative(pThis->hDeviceFile), &XcptSet);
    504505# ifdef DEBUG
    505506                    uint64_t u64Now = RTTimeMilliTS();
    506507# endif
    507                     rc = select(pThis->DeviceFile + 1, NULL, &WrSet, &XcptSet, NULL);
     508                    rc = select(RTFileToNative(pThis->hDeviceFile) + 1, NULL, &WrSet, &XcptSet, NULL);
    508509                    /** @todo check rc? */
    509510
     
    512513# endif
    513514                    /* try write more */
    514                     rc = RTFileWrite(pThis->DeviceFile, &ch, 1, &cbWritten);
     515                    rc = RTFileWrite(pThis->hDeviceFile, &ch, 1, &cbWritten);
    515516                    if (rc == VERR_TRY_AGAIN)
    516517                        cbWritten = 0;
     
    627628            fd_set RdSet;
    628629            FD_ZERO(&RdSet);
    629             FD_SET(pThis->DeviceFileR, &RdSet);
    630             FD_SET(pThis->WakeupPipeR, &RdSet);
     630            FD_SET(RTFileToNative(pThis->hDeviceFileR), &RdSet);
     631            FD_SET(RTPipeToNative(pThis->hWakeupPipeR), &RdSet);
    631632            fd_set XcptSet;
    632633            FD_ZERO(&XcptSet);
    633             FD_SET(pThis->DeviceFileR, &XcptSet);
    634             FD_SET(pThis->WakeupPipeR, &XcptSet);
     634            FD_SET(RTFileToNative(pThis->hDeviceFile), &XcptSet);
     635            FD_SET(RTPipeToNative(pThis->hWakeupPipeR), &XcptSet);
    635636# if 1 /* it seems like this select is blocking the write... */
    636             rc = select(RT_MAX(pThis->WakeupPipeR, pThis->DeviceFileR) + 1, &RdSet, NULL, &XcptSet, NULL);
     637            rc = select(RT_MAX(RTFileToPipe(pThis->hWakeupPipeR), RTFileToNative(pThis->hDeviceFileR)) + 1,
     638                        &RdSet, NULL, &XcptSet, NULL);
    637639# else
    638640            struct timeval tv = { 0, 1000 };
    639             rc = select(RT_MAX(pThis->WakeupPipeR, pThis->DeviceFileR) + 1, &RdSet, NULL, &XcptSet, &tv);
     641            rc = select(RTFileToPipe(pThis->hWakeupPipeR), RTFileToNative(pThis->hDeviceFileR) + 1,
     642                        &RdSet, NULL, &XcptSet, &tv);
    640643# endif
    641644            if (rc == -1)
     
    655658            /* drain the wakeup pipe */
    656659            size_t cbRead;
    657             if (   FD_ISSET(pThis->WakeupPipeR, &RdSet)
    658                 || FD_ISSET(pThis->WakeupPipeR, &XcptSet))
    659             {
    660                 rc = RTFileRead(pThis->WakeupPipeR, abBuffer, 1, &cbRead);
     660            if (   FD_ISSET(RTPipeToNative(pThis->hWakeupPipeR), &RdSet)
     661                || FD_ISSET(pThis->hWakeupPipeR, &XcptSet))
     662            {
     663                rc = RTPipeRead(pThis->hWakeupPipeR, abBuffer, 1, &cbRead);
    661664                if (RT_FAILURE(rc))
    662665                {
     
    669672
    670673            /* read data from the serial port. */
    671             rc = RTFileRead(pThis->DeviceFileR, abBuffer, sizeof(abBuffer), &cbRead);
     674            rc = RTFileRead(pThis->hDeviceFileR, abBuffer, sizeof(abBuffer), &cbRead);
    672675            if (RT_FAILURE(rc))
    673676            {
     
    682685            size_t cbRead;
    683686            struct pollfd aFDs[2];
    684             aFDs[0].fd      = pThis->DeviceFile;
     687            aFDs[0].fd      = RTFileToNative(pThis->hDeviceFile);
    685688            aFDs[0].events  = POLLIN;
    686689            aFDs[0].revents = 0;
    687             aFDs[1].fd      = pThis->WakeupPipeR;
     690            aFDs[1].fd      = RTPipeToNative(pThis->hWakeupPipeR);
    688691            aFDs[1].events  = POLLIN | POLLERR | POLLHUP;
    689692            aFDs[1].revents = 0;
     
    704707                    break;
    705708                /* notification to terminate -- drain the pipe */
    706                 RTFileRead(pThis->WakeupPipeR, &abBuffer, 1, &cbRead);
     709                RTPipeRead(pThis->hWakeupPipeR, &abBuffer, 1, &cbRead);
    707710                continue;
    708711            }
    709             rc = RTFileRead(pThis->DeviceFile, abBuffer, sizeof(abBuffer), &cbRead);
     712            rc = RTFileRead(pThis->hDeviceFile, abBuffer, sizeof(abBuffer), &cbRead);
    710713            if (RT_FAILURE(rc))
    711714            {
     
    844847    PDRVHOSTSERIAL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTSERIAL);
    845848#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
    846     return RTFileWrite(pThis->WakeupPipeW, "", 1, NULL);
     849    size_t cbIgnored;
     850    return RTPipeWrite(pThis->hWakeupPipeW, "", 1, &cbIgnored);
     851
    847852#elif defined(RT_OS_WINDOWS)
    848853    if (!SetEvent(pThis->hHaltEventSem))
     
    883888         * Get the status line state.
    884889         */
    885         rc = ioctl(pThis->DeviceFile, TIOCMGET, &statusLines);
     890        rc = ioctl(RTFileToNative(pThis->hDeviceFile), TIOCMGET, &statusLines);
    886891        if (rc < 0)
    887892        {
     
    916921         * is to send a signal after each tcsetattr.
    917922         */
    918         ioctl(pThis->DeviceFile, TIOCMIWAIT, uStatusLinesToCheck);
     923        ioctl(RTFileToNative(pThis->hDeviceFile), TIOCMIWAIT, uStatusLinesToCheck);
    919924# else
    920925        /* Poll for status line change. */
     
    989994
    990995    if (modemStateSet)
    991         ioctl(pThis->DeviceFile, TIOCMBIS, &modemStateSet);
     996        ioctl(RTFileToNative(pThis->hDeviceFile), TIOCMBIS, &modemStateSet);
    992997
    993998    if (modemStateClear)
    994         ioctl(pThis->DeviceFile, TIOCMBIC, &modemStateClear);
     999        ioctl(RTFileToNative(pThis->hDeviceFile), TIOCMBIC, &modemStateClear);
    9951000
    9961001#elif defined(RT_OS_WINDOWS)
     
    10241029#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
    10251030    if (fBreak)
    1026         ioctl(pThis->DeviceFile, TIOCSBRK);
     1031        ioctl(RTFileToNative(pThis->hDeviceFile), TIOCSBRK);
    10271032    else
    1028         ioctl(pThis->DeviceFile, TIOCCBRK);
     1033        ioctl(RTFileToNative(pThis->hDeviceFile), TIOCCBRK);
    10291034
    10301035#elif defined(RT_OS_WINDOWS)
     
    10581063    pThis->SendSem = NIL_RTSEMEVENT;
    10591064
     1065    int rc;
    10601066#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
    10611067
    1062     if (pThis->WakeupPipeW != NIL_RTFILE)
    1063     {
    1064         int rc = RTFileClose(pThis->WakeupPipeW);
    1065         AssertRC(rc);
    1066         pThis->WakeupPipeW = NIL_RTFILE;
    1067     }
    1068     if (pThis->WakeupPipeR != NIL_RTFILE)
    1069     {
    1070         int rc = RTFileClose(pThis->WakeupPipeR);
    1071         AssertRC(rc);
    1072         pThis->WakeupPipeR = NIL_RTFILE;
    1073     }
     1068    rc = RTPipeClose(pThis->hWakeupPipeW); AssertRC(rc);
     1069    pThis->hWakeupPipeW = NIL_RTPIPE;
     1070    rc = RTPipeClose(pThis->hWakeupPipeR); AssertRC(rc);
     1071    pThis->hWakeupPipeR = NIL_RTPIPE;
     1072
    10741073# if defined(RT_OS_DARWIN)
    1075     if (pThis->DeviceFileR != NIL_RTFILE)
    1076     {
    1077         if (pThis->DeviceFileR != pThis->DeviceFile)
     1074    if (pThis->hDeviceFileR != NIL_RTFILE)
     1075    {
     1076        if (pThis->hDeviceFileR != pThis->hDeviceFile)
    10781077        {
    1079             int rc = RTFileClose(pThis->DeviceFileR);
     1078            rc = RTFileClose(pThis->hDeviceFileR);
    10801079            AssertRC(rc);
    10811080        }
    1082         pThis->DeviceFileR = NIL_RTFILE;
    1083     }
    1084 # endif
    1085     if (pThis->DeviceFile != NIL_RTFILE)
    1086     {
    1087         int rc = RTFileClose(pThis->DeviceFile);
    1088         AssertRC(rc);
    1089         pThis->DeviceFile = NIL_RTFILE;
    1090     }
     1081        pThis->hDeviceFileR = NIL_RTFILE;
     1082    }
     1083# endif
     1084    rc = RTFileClose(pThis->hDeviceFile); AssertRC(rc);
     1085    pThis->hDeviceFile = NIL_RTFILE;
    10911086
    10921087#elif defined(RT_OS_WINDOWS)
    1093 
    10941088    CloseHandle(pThis->hEventRecv);
    10951089    CloseHandle(pThis->hEventSend);
     
    11211115     */
    11221116#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
    1123     pThis->DeviceFile  = NIL_RTFILE;
     1117    pThis->hDeviceFile  = NIL_RTFILE;
    11241118# ifdef RT_OS_DARWIN
    1125     pThis->DeviceFileR = NIL_RTFILE;
    1126 # endif
    1127     pThis->WakeupPipeR = NIL_RTFILE;
    1128     pThis->WakeupPipeW = NIL_RTFILE;
     1119    pThis->hDeviceFileR = NIL_RTFILE;
     1120# endif
     1121    pThis->hWakeupPipeR = NIL_RTPIPE;
     1122    pThis->hWakeupPipeW = NIL_RTPIPE;
     1123#elif defined(RT_OS_WINDOWS)
     1124    pThis->hEventRecv  = INVALID_HANDLE_VALUE;
     1125    pThis->hEventSend  = INVALID_HANDLE_VALUE;
     1126    pThis->hDeviceFile = INVALID_HANDLE_VALUE;
    11291127#endif
    11301128    /* IBase. */
     
    11911189    fOpen |= RTFILE_O_NON_BLOCK;
    11921190# endif
    1193     rc = RTFileOpen(&pThis->DeviceFile, pThis->pszDevicePath, fOpen);
     1191    rc = RTFileOpen(&pThis->hDeviceFile, pThis->pszDevicePath, fOpen);
    11941192# ifdef RT_OS_LINUX
    11951193    /* RTFILE_O_NON_BLOCK not supported? */
    11961194    if (rc == VERR_INVALID_PARAMETER)
    1197         rc = RTFileOpen(&pThis->DeviceFile, pThis->pszDevicePath, fOpen & ~RTFILE_O_NON_BLOCK);
     1195        rc = RTFileOpen(&pThis->hDeviceFile, pThis->pszDevicePath, fOpen & ~RTFILE_O_NON_BLOCK);
    11981196# endif
    11991197# ifdef RT_OS_DARWIN
    12001198    if (RT_SUCCESS(rc))
    1201         rc = RTFileOpen(&pThis->DeviceFileR, pThis->pszDevicePath, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
     1199        rc = RTFileOpen(&pThis->hDeviceFileR, pThis->pszDevicePath, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
    12021200# endif
    12031201
     
    12321230#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
    12331231
    1234     fcntl(pThis->DeviceFile, F_SETFL, O_NONBLOCK);
     1232    fcntl(RTFileToNative(pThis->hDeviceFile), F_SETFL, O_NONBLOCK);
    12351233# ifdef RT_OS_DARWIN
    1236     fcntl(pThis->DeviceFileR, F_SETFL, O_NONBLOCK);
    1237 # endif
    1238     int aFDs[2];
    1239     if (pipe(aFDs) != 0)
    1240     {
    1241         rc = RTErrConvertFromErrno(errno);
    1242         AssertRC(rc);
    1243         return rc;
    1244     }
    1245     pThis->WakeupPipeR = aFDs[0];
    1246     pThis->WakeupPipeW = aFDs[1];
     1234    fcntl(RTFileToNative(pThis->hDeviceFileR), F_SETFL, O_NONBLOCK);
     1235# endif
     1236    rc = RTPipeCreate(&pThis->hWakeupPipeR, &pThis->hWakeupPipeW, 0 /*fFlags*/);
     1237    AssertRCReturn(rc, rc);
    12471238
    12481239#elif defined(RT_OS_WINDOWS)
  • trunk/src/VBox/Devices/Serial/DrvRawFile.cpp

    r35353 r37596  
    6060    char               *pszLocation;
    6161    /** Flag whether VirtualBox represents the server or client side. */
    62     RTFILE              OutputFile;
     62    RTFILE              hOutputFile;
    6363} DRVRAWFILE, *PDRVRAWFILE;
    6464
     
    7575
    7676    Assert(pvBuf);
    77     if (pThis->OutputFile != NIL_RTFILE)
     77    if (pThis->hOutputFile != NIL_RTFILE)
    7878    {
    7979        size_t cbWritten;
    80         rc = RTFileWrite(pThis->OutputFile, pvBuf, *pcbWrite, &cbWritten);
     80        rc = RTFileWrite(pThis->hOutputFile, pvBuf, *pcbWrite, &cbWritten);
    8181#if 0
    8282        /* don't flush here, takes too long and we will loose characters */
    8383        if (RT_SUCCESS(rc))
    84             RTFileFlush(pThis->OutputFile);
     84            RTFileFlush(pThis->hOutputFile);
    8585#endif
    8686        *pcbWrite = cbWritten;
     
    121121    LogFlow(("%s: %s\n", __FUNCTION__, pThis->pszLocation));
    122122
    123     if (pThis->OutputFile != NIL_RTFILE)
    124     {
    125         RTFileClose(pThis->OutputFile);
    126         pThis->OutputFile = NIL_RTFILE;
    127     }
     123    RTFileClose(pThis->hOutputFile);
     124    pThis->hOutputFile = NIL_RTFILE;
    128125}
    129126
     
    146143        MMR3HeapFree(pThis->pszLocation);
    147144
    148     if (pThis->OutputFile != NIL_RTFILE)
    149     {
    150         RTFileClose(pThis->OutputFile);
    151         pThis->OutputFile = NIL_RTFILE;
    152     }
     145    RTFileClose(pThis->hOutputFile);
     146    pThis->hOutputFile = NIL_RTFILE;
    153147}
    154148
     
    169163    pThis->pDrvIns                      = pDrvIns;
    170164    pThis->pszLocation                  = NULL;
    171     pThis->OutputFile                   = NIL_RTFILE;
     165    pThis->hOutputFile                  = NIL_RTFILE;
    172166    /* IBase */
    173167    pDrvIns->IBase.pfnQueryInterface    = drvRawFileQueryInterface;
     
    188182     * Open the raw file.
    189183     */
    190     rc = RTFileOpen(&pThis->OutputFile, pThis->pszLocation, RTFILE_O_WRITE | RTFILE_O_CREATE_REPLACE | RTFILE_O_DENY_NONE);
     184    rc = RTFileOpen(&pThis->hOutputFile, pThis->pszLocation, RTFILE_O_WRITE | RTFILE_O_CREATE_REPLACE | RTFILE_O_DENY_NONE);
    191185    if (RT_FAILURE(rc))
    192186    {
  • trunk/src/VBox/Devices/Storage/DrvHostBase.cpp

    r36797 r37596  
    185185         * Seek and read.
    186186         */
    187         rc = RTFileSeek(pThis->FileDevice, off, RTFILE_SEEK_BEGIN, NULL);
     187        rc = RTFileReadAt(pThis->hFileDevice, off, pvBuf, cbRead, NULL);
    188188        if (RT_SUCCESS(rc))
    189189        {
    190             rc = RTFileRead(pThis->FileDevice, pvBuf, cbRead, NULL);
    191             if (RT_SUCCESS(rc))
    192             {
    193                 Log2(("%s-%d: drvHostBaseRead: off=%#llx cbRead=%#x\n"
    194                       "%16.*Rhxd\n",
    195                       pThis->pDrvIns->pReg->szName, pThis->pDrvIns->iInstance, off, cbRead, cbRead, pvBuf));
    196             }
    197             else
    198                 Log(("%s-%d: drvHostBaseRead: RTFileRead(%d, %p, %#x) -> %Rrc (off=%#llx '%s')\n",
    199                      pThis->pDrvIns->pReg->szName, pThis->pDrvIns->iInstance, pThis->FileDevice,
    200                      pvBuf, cbRead, rc, off, pThis->pszDevice));
     190            Log2(("%s-%d: drvHostBaseRead: off=%#llx cbRead=%#x\n"
     191                  "%16.*Rhxd\n",
     192                  pThis->pDrvIns->pReg->szName, pThis->pDrvIns->iInstance, off, cbRead, cbRead, pvBuf));
    201193        }
    202194        else
    203             Log(("%s-%d: drvHostBaseRead: RTFileSeek(%d,%#llx,) -> %Rrc\n", pThis->pDrvIns->pReg->szName,
    204                  pThis->pDrvIns->iInstance, pThis->FileDevice, off, rc));
     195            Log(("%s-%d: drvHostBaseRead: RTFileReadAt(%RTfile, %#llx, %p, %#x) -> %Rrc ('%s')\n",
     196                 pThis->pDrvIns->pReg->szName, pThis->pDrvIns->iInstance, pThis->hFileDevice,
     197                 off, pvBuf, cbRead, rc, pThis->pszDevice));
    205198#endif
    206199    }
     
    241234             * Seek and write.
    242235             */
    243             rc = RTFileSeek(pThis->FileDevice, off, RTFILE_SEEK_BEGIN, NULL);
    244             if (RT_SUCCESS(rc))
    245             {
    246                 rc = RTFileWrite(pThis->FileDevice, pvBuf, cbWrite, NULL);
    247                 if (RT_FAILURE(rc))
    248                     Log(("%s-%d: drvHostBaseWrite: RTFileWrite(%d, %p, %#x) -> %Rrc (off=%#llx '%s')\n",
    249                          pThis->pDrvIns->pReg->szName, pThis->pDrvIns->iInstance, pThis->FileDevice,
    250                          pvBuf, cbWrite, rc, off, pThis->pszDevice));
    251             }
    252             else
    253                 Log(("%s-%d: drvHostBaseWrite: RTFileSeek(%d,%#llx,) -> %Rrc\n",
    254                      pThis->pDrvIns->pReg->szName, pThis->pDrvIns->iInstance, pThis->FileDevice, off, rc));
     236            rc = RTFileWriteAt(pThis->hFileDevice, off, pvBuf, cbWrite, NULL);
     237            if (RT_FAILURE(rc))
     238                Log(("%s-%d: drvHostBaseWrite: RTFileWriteAt(%RTfile, %#llx, %p, %#x) -> %Rrc ('%s')\n",
     239                     pThis->pDrvIns->pReg->szName, pThis->pDrvIns->iInstance, pThis->hFileDevice,
     240                     off, pvBuf, cbWrite, rc, pThis->pszDevice));
    255241#endif
    256242        }
     
    282268        /** @todo scsi device buffer flush... */
    283269#else
    284         rc = RTFileFlush(pThis->FileDevice);
     270        rc = RTFileFlush(pThis->hFileDevice);
    285271#endif
    286272    }
     
    762748static int drvHostBaseOpen(PDRVHOSTBASE pThis, PRTFILE pFileDevice, bool fReadOnly)
    763749{
    764 #ifdef RT_OS_DARWIN
     750# ifdef RT_OS_DARWIN
    765751    /* Darwin is kind of special... */
    766752    Assert(!pFileDevice); NOREF(pFileDevice);
     
    940926    return rc;
    941927
    942 #elif defined(RT_OS_LINUX)
    943     /** @todo we've got RTFILE_O_NON_BLOCK now. Change the code to use RTFileOpen. */
    944     int FileDevice = open(pThis->pszDeviceOpen, (pThis->fReadOnlyConfig ? O_RDONLY : O_RDWR) | O_NONBLOCK);
    945     if (FileDevice < 0)
    946         return RTErrConvertFromErrno(errno);
    947     *pFileDevice = FileDevice;
    948     return VINF_SUCCESS;
    949 
    950928#elif defined(RT_OS_FREEBSD)
    951     int rc = VINF_SUCCESS;
    952     RTFILE FileDevice;
    953 
    954     rc = RTFileOpen(&FileDevice, pThis->pszDeviceOpen, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
     929    RTFILE hFileDevice;
     930    int rc = RTFileOpen(&hFileDevice, pThis->pszDeviceOpen, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
    955931    if (RT_FAILURE(rc))
    956932        return rc;
     
    964940
    965941    DeviceCCB.ccb_h.func_code = XPT_GDEVLIST;
    966     int rcBSD = ioctl(FileDevice, CAMGETPASSTHRU, &DeviceCCB);
     942    int rcBSD = ioctl(RTFileToNative(hFileDevice), CAMGETPASSTHRU, &DeviceCCB);
    967943    if (!rcBSD)
    968944    {
     
    972948        if (rc >= 0)
    973949        {
    974             RTFILE PassthroughDevice;
    975 
    976             rc = RTFileOpen(&PassthroughDevice, pszPassthroughDevice, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
    977 
     950            RTFILE hPassthroughDevice;
     951            rc = RTFileOpen(&hPassthroughDevice, pszPassthroughDevice, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
    978952            RTStrFree(pszPassthroughDevice);
    979 
    980953            if (RT_SUCCESS(rc))
    981954            {
     
    989962                DeviceCCB.ccb_h.func_code = XPT_GDEVLIST;
    990963
    991                 rcBSD = ioctl(PassthroughDevice, CAMGETPASSTHRU, &DeviceCCB);
     964                rcBSD = ioctl(RTFileToNative(hPassthroughDevice), CAMGETPASSTHRU, &DeviceCCB);
    992965                if (!rcBSD)
    993966                {
     
    997970                        pThis->ScsiTargetID = DeviceCCB.ccb_h.target_id;
    998971                        pThis->ScsiLunID    = DeviceCCB.ccb_h.target_lun;
    999                         *pFileDevice = PassthroughDevice;
     972                        *pFileDevice = hPassthroughDevice;
    1000973                    }
    1001974                    else
     
    1009982
    1010983                if (RT_FAILURE(rc))
    1011                     RTFileClose(PassthroughDevice);
     984                    RTFileClose(hPassthroughDevice);
    1012985            }
    1013986        }
     
    1018991        rc = RTErrConvertFromErrno(errno);
    1019992
    1020     RTFileClose(FileDevice);
     993    RTFileClose(hFileDevice);
    1021994    return rc;
     995
    1022996#else
    1023     return RTFileOpen(pFileDevice, pThis->pszDeviceOpen,
    1024                       (fReadOnly ? RTFILE_O_READ : RTFILE_O_READWRITE) | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
     997    uint32_t fFlags = (fReadOnly ? RTFILE_O_READ : RTFILE_O_READWRITE) | RTFILE_O_OPEN | RTFILE_O_DENY_NONE;
     998# ifdef RT_OS_LINUX
     999    fFlags |= RTFILE_O_NON_BLOCK;
     1000# endif
     1001    return RTFileOpen(pFileDevice, pThis->pszDeviceOpen, fFlags);
    10251002#endif
    10261003}
     
    10721049    LogFlow(("%s-%d: drvHostBaseReopen: '%s'\n", pThis->pDrvIns->pReg->szName, pThis->pDrvIns->iInstance, pThis->pszDeviceOpen));
    10731050
    1074     RTFILE FileDevice;
     1051    RTFILE hFileDevice;
    10751052#ifdef RT_OS_SOLARIS
    1076     if (pThis->FileRawDevice != NIL_RTFILE)
    1077     {
    1078         RTFileClose(pThis->FileRawDevice);
    1079         pThis->FileRawDevice = NIL_RTFILE;
    1080     }
    1081     if (pThis->FileDevice != NIL_RTFILE)
    1082     {
    1083         RTFileClose(pThis->FileDevice);
    1084         pThis->FileDevice = NIL_RTFILE;
    1085     }
    1086     RTFILE FileRawDevice;
    1087     int rc = drvHostBaseOpen(pThis, &FileDevice, &FileRawDevice, pThis->fReadOnlyConfig);
     1053    if (pThis->hFileRawDevice != NIL_RTFILE)
     1054    {
     1055        RTFileClose(pThis->hFileRawDevice);
     1056        pThis->hFileRawDevice = NIL_RTFILE;
     1057    }
     1058    if (pThis->hFileDevice != NIL_RTFILE)
     1059    {
     1060        RTFileClose(pThis->hFileDevice);
     1061        pThis->hFileDevice = NIL_RTFILE;
     1062    }
     1063    RTFILE hFileRawDevice;
     1064    int rc = drvHostBaseOpen(pThis, &hFileDevice, &hFileRawDevice, pThis->fReadOnlyConfig);
    10881065#else
    1089     int rc = drvHostBaseOpen(pThis, &FileDevice, pThis->fReadOnlyConfig);
     1066    int rc = drvHostBaseOpen(pThis, &hFileDevice, pThis->fReadOnlyConfig);
    10901067#endif
    10911068    if (RT_FAILURE(rc))
     
    10951072            LogFlow(("%s-%d: drvHostBaseReopen: '%s' - retry readonly (%Rrc)\n", pThis->pDrvIns->pReg->szName, pThis->pDrvIns->iInstance, pThis->pszDeviceOpen, rc));
    10961073#ifdef RT_OS_SOLARIS
    1097             rc = drvHostBaseOpen(pThis, &FileDevice, &FileRawDevice, false);
     1074            rc = drvHostBaseOpen(pThis, &hFileDevice, &hFileRawDevice, false);
    10981075#else
    1099             rc = drvHostBaseOpen(pThis, &FileDevice, false);
     1076            rc = drvHostBaseOpen(pThis, &hFileDevice, false);
    11001077#endif
    11011078        }
     
    11121089
    11131090#ifdef RT_OS_SOLARIS
    1114     if (pThis->FileRawDevice != NIL_RTFILE)
    1115         RTFileClose(pThis->FileRawDevice);
    1116     pThis->FileRawDevice = FileRawDevice;
    1117 #endif
    1118 
    1119     if (pThis->FileDevice != NIL_RTFILE)
    1120         RTFileClose(pThis->FileDevice);
    1121     pThis->FileDevice = FileDevice;
     1091    if (pThis->hFileRawDevice != NIL_RTFILE)
     1092        RTFileClose(pThis->hFileRawDevice);
     1093    pThis->hFileRawDevice = hFileRawDevice;
     1094#endif
     1095
     1096    if (pThis->hFileDevice != NIL_RTFILE)
     1097        RTFileClose(pThis->hFileDevice);
     1098    pThis->hFileDevice = hFileDevice;
    11221099#endif /* !RT_OS_DARWIN */
    11231100    return VINF_SUCCESS;
     
    11701147     */
    11711148    struct dk_minfo MediaInfo;
    1172     if (ioctl(pThis->FileRawDevice, DKIOCGMEDIAINFO, &MediaInfo) == 0)
     1149    if (ioctl(RTFileToNative(pThis->hFileRawDevice), DKIOCGMEDIAINFO, &MediaInfo) == 0)
    11731150    {
    11741151        *pcb = MediaInfo.dki_capacity * (uint64_t)MediaInfo.dki_lbsize;
    11751152        return VINF_SUCCESS;
    11761153    }
    1177     return RTFileSeek(pThis->FileDevice, 0, RTFILE_SEEK_END, pcb);
     1154    return RTFileSeek(pThis->hFileDevice, 0, RTFILE_SEEK_END, pcb);
    11781155
    11791156#elif defined(RT_OS_WINDOWS)
     
    11811158    IO_STATUS_BLOCK             IoStatusBlock = {0};
    11821159    FILE_FS_SIZE_INFORMATION    FsSize= {0};
    1183     NTSTATUS rcNt = NtQueryVolumeInformationFile((HANDLE)pThis->FileDevice,  &IoStatusBlock,
     1160    NTSTATUS rcNt = NtQueryVolumeInformationFile(RTFileToNative(pThis->hFileDevice),  &IoStatusBlock,
    11841161                                                 &FsSize, sizeof(FsSize), FileFsSizeInformation);
    11851162    int cRetries = 5;
     
    11871164    {
    11881165        RTThreadSleep(10);
    1189         rcNt = NtQueryVolumeInformationFile((HANDLE)pThis->FileDevice,  &IoStatusBlock,
     1166        rcNt = NtQueryVolumeInformationFile(RTFileToNative(pThis->hFileDevice),  &IoStatusBlock,
    11901167                                            &FsSize, sizeof(FsSize), FileFsSizeInformation);
    11911168    }
     
    12071184    return rc;
    12081185#else
    1209     return RTFileSeek(pThis->FileDevice, 0, RTFILE_SEEK_END, pcb);
     1186    return RTFileSeek(pThis->hFileDevice, 0, RTFILE_SEEK_END, pcb);
    12101187#endif
    12111188}
     
    13401317        pDeviceCCB->ccb_h.func_code = XPT_GDEV_TYPE;
    13411318
    1342         rcBSD = ioctl(pThis->FileDevice, CAMIOCOMMAND, pDeviceCCB);
     1319        rcBSD = ioctl(RTFileToNative(pThis->hFileDevice), CAMIOCOMMAND, pDeviceCCB);
    13431320        if (!rcBSD)
    13441321        {
     
    13751352
    13761353        /* Send command */
    1377         rcBSD = ioctl(pThis->FileDevice, CAMIOCOMMAND, pDeviceCCB);
     1354        rcBSD = ioctl(RTFileToNative(pThis->hFileDevice), CAMIOCOMMAND, pDeviceCCB);
    13781355        if (!rcBSD)
    13791356        {
     
    17151692       * (We're currently not unlocking the device after use. See todo in DevATA.cpp.) */
    17161693    if (    pThis->fLocked
    1717         &&  pThis->FileDevice != NIL_RTFILE
     1694        &&  pThis->hFileDevice != NIL_RTFILE
    17181695#endif
    17191696        &&  pThis->pfnDoLock)
     
    17851762    }
    17861763#else
    1787     if (pThis->FileDevice != NIL_RTFILE)
    1788     {
    1789         int rc = RTFileClose(pThis->FileDevice);
     1764    if (pThis->hFileDevice != NIL_RTFILE)
     1765    {
     1766        int rc = RTFileClose(pThis->hFileDevice);
    17901767        AssertRC(rc);
    1791         pThis->FileDevice = NIL_RTFILE;
     1768        pThis->hFileDevice = NIL_RTFILE;
    17921769    }
    17931770#endif
    17941771
    17951772#ifdef RT_OS_SOLARIS
    1796     if (pThis->FileRawDevice != NIL_RTFILE)
    1797     {
    1798         int rc = RTFileClose(pThis->FileRawDevice);
     1773    if (pThis->hFileRawDevice != NIL_RTFILE)
     1774    {
     1775        int rc = RTFileClose(pThis->hFileRawDevice);
    17991776        AssertRC(rc);
    1800         pThis->FileRawDevice = NIL_RTFILE;
     1777        pThis->hFileRawDevice = NIL_RTFILE;
    18011778    }
    18021779
     
    18631840    pThis->pDASession                       = NULL;
    18641841#else
    1865     pThis->FileDevice                       = NIL_RTFILE;
     1842    pThis->hFileDevice                      = NIL_RTFILE;
    18661843#endif
    18671844#ifdef RT_OS_SOLARIS
    1868     pThis->FileRawDevice                    = NIL_RTFILE;
     1845    pThis->hFileRawDevice                   = NIL_RTFILE;
    18691846#endif
    18701847    pThis->enmType                          = enmType;
     
    21102087            && RT_SUCCESS(RTPathReal(pszDevice, szPathReal, sizeof(szPathReal))))
    21112088            pszDevice = szPathReal;
    2112         pThis->FileDevice = NIL_RTFILE;
     2089        pThis->hFileDevice = NIL_RTFILE;
    21132090#endif
    21142091#ifdef RT_OS_SOLARIS
    2115         pThis->FileRawDevice = NIL_RTFILE;
     2092        pThis->hFileRawDevice = NIL_RTFILE;
    21162093#endif
    21172094
  • trunk/src/VBox/Devices/Storage/DrvHostBase.h

    r33540 r37596  
    8383#if !defined(RT_OS_DARWIN)
    8484    /** The filehandle of the device. */
    85     RTFILE                  FileDevice;
     85    RTFILE                  hFileDevice;
    8686#endif
    8787#ifdef RT_OS_SOLARIS
    8888    /** The raw filehandle of the device. */
    89     RTFILE                  FileRawDevice;
     89    RTFILE                  hFileRawDevice;
    9090#endif
    9191
  • trunk/src/VBox/Devices/Storage/DrvHostDVD.cpp

    r35560 r37596  
    156156
    157157#elif defined(RT_OS_LINUX)
    158             rc = ioctl(pThis->FileDevice, CDROMEJECT, 0);
     158            rc = ioctl(RTFileToNative(pThis->hFileDevice), CDROMEJECT, 0);
    159159            if (rc < 0)
    160160            {
     
    168168
    169169#elif defined(RT_OS_SOLARIS)
    170             rc = ioctl(pThis->FileRawDevice, DKIOCEJECT, 0);
     170            rc = ioctl(RTFileToNative(pThis->hFileRawDevice), DKIOCEJECT, 0);
    171171            if (rc < 0)
    172172            {
     
    182182
    183183#elif defined(RT_OS_WINDOWS)
    184             RTFILE FileDevice = pThis->FileDevice;
    185             if (FileDevice == NIL_RTFILE) /* obsolete crap */
    186                 rc = RTFileOpen(&FileDevice, pThis->pszDeviceOpen, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
     184            RTFILE hFileDevice = pThis->hFileDevice;
     185            if (hFileDevice == NIL_RTFILE) /* obsolete crap */
     186                rc = RTFileOpen(&hFileDevice, pThis->pszDeviceOpen, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
    187187            if (RT_SUCCESS(rc))
    188188            {
    189189                /* do ioctl */
    190190                DWORD cbReturned;
    191                 if (DeviceIoControl((HANDLE)FileDevice, IOCTL_STORAGE_EJECT_MEDIA,
     191                if (DeviceIoControl(RTFileToNative(hFileDevice), IOCTL_STORAGE_EJECT_MEDIA,
    192192                                    NULL, 0,
    193193                                    NULL, 0, &cbReturned,
     
    198198
    199199                /* clean up handle */
    200                 if (FileDevice != pThis->FileDevice)
    201                     RTFileClose(FileDevice);
     200                if (hFileDevice != pThis->hFileDevice)
     201                    RTFileClose(hFileDevice);
    202202            }
    203203            else
     
    246246
    247247#elif defined(RT_OS_LINUX)
    248     int rc = ioctl(pThis->FileDevice, CDROM_LOCKDOOR, (int)fLock);
     248    int rc = ioctl(RTFileToNative(pThis->hFileDevice), CDROM_LOCKDOOR, (int)fLock);
    249249    if (rc < 0)
    250250    {
     
    258258
    259259#elif defined(RT_OS_SOLARIS)
    260     int rc = ioctl(pThis->FileRawDevice, fLock ? DKIOCLOCK : DKIOCUNLOCK, 0);
     260    int rc = ioctl(RTFileToNative(pThis->hFileRawDevice), fLock ? DKIOCLOCK : DKIOCUNLOCK, 0);
    261261    if (rc < 0)
    262262    {
     
    274274    DWORD cbReturned;
    275275    int rc;
    276     if (DeviceIoControl((HANDLE)pThis->FileDevice, IOCTL_STORAGE_MEDIA_REMOVAL,
     276    if (DeviceIoControl(RTFileToNative(pThis->hFileDevice), IOCTL_STORAGE_MEDIA_REMOVAL,
    277277                        &PreventMediaRemoval, sizeof(PreventMediaRemoval),
    278278                        NULL, 0, &cbReturned,
     
    309309     */
    310310    /* Clear the media-changed-since-last-call-thingy just to be on the safe side. */
    311     ioctl(pThis->FileDevice, CDROM_MEDIA_CHANGED, CDSL_CURRENT);
    312     return RTFileSeek(pThis->FileDevice, 0, RTFILE_SEEK_END, pcb);
     311    ioctl(RTFileToNative(pThis->hFileDevice), CDROM_MEDIA_CHANGED, CDSL_CURRENT);
     312    return RTFileSeek(pThis->hFileDevice, 0, RTFILE_SEEK_END, pcb);
    313313
    314314}
     
    357357
    358358#elif defined(RT_OS_LINUX)
    359     bool fMediaPresent = ioctl(pThis->FileDevice, CDROM_DRIVE_STATUS, CDSL_CURRENT) == CDS_DISC_OK;
     359    bool fMediaPresent = ioctl(RTFileToNative(pThis->hFileDevice), CDROM_DRIVE_STATUS, CDSL_CURRENT) == CDS_DISC_OK;
    360360
    361361#elif defined(RT_OS_SOLARIS)
     
    366366    static dkio_state s_DeviceState = DKIO_NONE;
    367367    dkio_state PreviousState = s_DeviceState;
    368     int rc2 = ioctl(pThis->FileRawDevice, DKIOCSTATE, &s_DeviceState);
     368    int rc2 = ioctl(RTFileToNative(pThis->hFileRawDevice), DKIOCSTATE, &s_DeviceState);
    369369    if (rc2 == 0)
    370370    {
     
    398398        /* taken care of above. */
    399399#elif defined(RT_OS_LINUX)
    400         bool fMediaChanged = ioctl(pThis->FileDevice, CDROM_MEDIA_CHANGED, CDSL_CURRENT) == 1;
     400        bool fMediaChanged = ioctl(RTFileToNative(pThis->hFileDevice), CDROM_MEDIA_CHANGED, CDSL_CURRENT) == 1;
    401401#else
    402402# error "Unsupported platform."
     
    484484    cgc.quiet = false;
    485485    cgc.timeout = cTimeoutMillies;
    486     rc = ioctl(pThis->FileDevice, CDROM_SEND_PACKET, &cgc);
     486    rc = ioctl(RTFileToNative(pThis->hFileDevice), CDROM_SEND_PACKET, &cgc);
    487487    if (rc < 0)
    488488    {
     
    560560    solarisEnterRootMode(&effUserID); /** @todo check return code when this really works. */
    561561#endif
    562     rc = ioctl(pThis->FileRawDevice, USCSICMD, &usc);
     562    rc = ioctl(RTFileToNative(pThis->hFileRawDevice), USCSICMD, &usc);
    563563#ifdef VBOX_WITH_SUID_WRAPPER
    564564    solarisExitRootMode(&effUserID);
     
    620620    Req.spt.SenseInfoLength = (UCHAR)RT_MIN(sizeof(Req.aSense), cbSense);
    621621    Req.spt.SenseInfoOffset = RT_OFFSETOF(struct _REQ, aSense);
    622     if (DeviceIoControl((HANDLE)pThis->FileDevice, IOCTL_SCSI_PASS_THROUGH_DIRECT,
     622    if (DeviceIoControl(RTFileToNative(pThis->hFileDevice), IOCTL_SCSI_PASS_THROUGH_DIRECT,
    623623                        &Req, sizeof(Req), &Req, sizeof(Req), &cbReturned, NULL))
    624624    {
  • trunk/src/VBox/Devices/Storage/DrvHostFloppy.cpp

    r35353 r37596  
    7373static DECLCALLBACK(int) drvHostFloppyGetMediaSize(PDRVHOSTBASE pThis, uint64_t *pcb)
    7474{
    75     int rc = ioctl(pThis->FileDevice, FDFLUSH);
     75    int rc = ioctl(RTFileToNative(pThis->hFileDevice), FDFLUSH);
    7676    if (rc)
    7777    {
     
    8282
    8383    floppy_drive_struct DrvStat;
    84     rc = ioctl(pThis->FileDevice, FDGETDRVSTAT, &DrvStat);
     84    rc = ioctl(RTFileToNative(pThis->hFileDevice), FDGETDRVSTAT, &DrvStat);
    8585    if (rc)
    8686    {
     
    9191    pThis->fReadOnly = !(DrvStat.flags & FD_DISK_WRITABLE);
    9292
    93     return RTFileSeek(pThis->FileDevice, 0, RTFILE_SEEK_END, pcb);
     93    return RTFileSeek(pThis->hFileDevice, 0, RTFILE_SEEK_END, pcb);
    9494}
    9595#endif /* RT_OS_LINUX */
     
    108108    PDRVHOSTFLOPPY          pThisFloppy = (PDRVHOSTFLOPPY)pThis;
    109109    floppy_drive_struct     DrvStat;
    110     int rc = ioctl(pThis->FileDevice, FDPOLLDRVSTAT, &DrvStat);
     110    int rc = ioctl(RTFileToNative(pThis->hFileDevice), FDPOLLDRVSTAT, &DrvStat);
    111111    if (rc)
    112112        return RTErrConvertFromErrno(errno);
  • trunk/src/VBox/Devices/Storage/DrvMediaISO.cpp

    r35353 r37596  
    6060    char           *pszFilename;
    6161    /** File handle of the ISO file. */
    62     RTFILE          File;
     62    RTFILE          hFile;
    6363} DRVMEDIAISO, *PDRVMEDIAISO;
    6464
     
    7474
    7575    uint64_t cbFile;
    76     int rc = RTFileGetSize(pThis->File, &cbFile);
     76    int rc = RTFileGetSize(pThis->hFile, &cbFile);
    7777    if (RT_SUCCESS(rc))
    7878    {
     
    124124    LogFlow(("drvMediaISORead: off=%#llx pvBuf=%p cbRead=%#x (%s)\n", off, pvBuf, cbRead, pThis->pszFilename));
    125125
    126     Assert(pThis->File);
     126    Assert(pThis->hFile != NIL_RTFILE);
    127127    Assert(pvBuf);
    128128
     
    130130     * Seek to the position and read.
    131131     */
    132     int rc = RTFileSeek(pThis->File, off, RTFILE_SEEK_BEGIN, NULL);
     132    int rc = RTFileReadAt(pThis->hFile, off, pvBuf, cbRead, NULL);
    133133    if (RT_SUCCESS(rc))
    134     {
    135         rc = RTFileRead(pThis->File, pvBuf, cbRead, NULL);
    136         if (RT_SUCCESS(rc))
    137         {
    138             Log2(("drvMediaISORead: off=%#llx pvBuf=%p cbRead=%#x (%s)\n"
    139                   "%16.*Rhxd\n",
    140                   off, pvBuf, cbRead, pThis->pszFilename,
    141                   cbRead, pvBuf));
    142         }
    143         else
    144             AssertMsgFailed(("RTFileRead(%d, %p, %#x) -> %Rrc (off=%#llx '%s')\n",
    145                              pThis->File, pvBuf, cbRead, rc, off, pThis->pszFilename));
    146     }
     134        Log2(("drvMediaISORead: off=%#llx pvBuf=%p cbRead=%#x (%s)\n"
     135              "%16.*Rhxd\n",
     136              off, pvBuf, cbRead, pThis->pszFilename,
     137              cbRead, pvBuf));
    147138    else
    148         AssertMsgFailed(("RTFileSeek(%d,%#llx,) -> %Rrc\n", pThis->File, off, rc));
     139        AssertMsgFailed(("RTFileReadAt(%RTfile, %#llx, %p, %#x) -> %Rrc ('%s')\n",
     140                         pThis->hFile, off, pvBuf, cbRead, rc, pThis->pszFilename));
    149141    LogFlow(("drvMediaISORead: returns %Rrc\n", rc));
    150142    return rc;
     
    212204    PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns);
    213205
    214     if (pThis->File != NIL_RTFILE)
     206    RTFileClose(pThis->hFile);
     207    pThis->hFile = NIL_RTFILE;
     208
     209    if (pThis->pszFilename)
    215210    {
    216         RTFileClose(pThis->File);
    217         pThis->File = NIL_RTFILE;
     211        MMR3HeapFree(pThis->pszFilename);
     212        pThis->pszFilename = NULL;
    218213    }
    219     if (pThis->pszFilename)
    220         MMR3HeapFree(pThis->pszFilename);
    221214}
    222215
     
    236229     */
    237230    pThis->pDrvIns                      = pDrvIns;
    238     pThis->File                         = NIL_RTFILE;
     231    pThis->hFile                        = NIL_RTFILE;
    239232    /* IBase */
    240233    pDrvIns->IBase.pfnQueryInterface    = drvMediaISOQueryInterface;
     
    265258     * Open the image.
    266259     */
    267     rc = RTFileOpen(&pThis->File, pszName,
    268                     RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
     260    rc = RTFileOpen(&pThis->hFile, pszName, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
    269261    if (RT_SUCCESS(rc))
    270262    {
  • trunk/src/VBox/Devices/Storage/DrvRawImage.cpp

    r35353 r37596  
    6161    char           *pszFilename;
    6262    /** File handle of the raw image file. */
    63     RTFILE          File;
     63    RTFILE          hFile;
    6464    /** True if the image is operating in readonly mode. */
    6565    bool            fReadOnly;
     
    7777
    7878    uint64_t cbFile;
    79     int rc = RTFileGetSize(pThis->File, &cbFile);
     79    int rc = RTFileGetSize(pThis->hFile, &cbFile);
    8080    if (RT_SUCCESS(rc))
    8181    {
     
    127127    LogFlow(("drvRawImageRead: off=%#llx pvBuf=%p cbRead=%#x (%s)\n", off, pvBuf, cbRead, pThis->pszFilename));
    128128
    129     Assert(pThis->File);
     129    Assert(pThis->hFile != NIL_RTFILE);
    130130    Assert(pvBuf);
    131131
     
    133133     * Seek to the position and read.
    134134     */
    135     int rc = RTFileSeek(pThis->File, off, RTFILE_SEEK_BEGIN, NULL);
     135    int rc = RTFileSeek(pThis->hFile, off, RTFILE_SEEK_BEGIN, NULL);
    136136    if (RT_SUCCESS(rc))
    137137    {
    138         rc = RTFileRead(pThis->File, pvBuf, cbRead, NULL);
     138        rc = RTFileRead(pThis->hFile, pvBuf, cbRead, NULL);
    139139        if (RT_SUCCESS(rc))
    140140        {
     
    145145        }
    146146        else
    147             AssertMsgFailed(("RTFileRead(%d, %p, %#x) -> %Rrc (off=%#llx '%s')\n",
    148                              pThis->File, pvBuf, cbRead, rc, off, pThis->pszFilename));
     147            AssertMsgFailed(("RTFileRead(%RTfile, %p, %#x) -> %Rrc (off=%#llx '%s')\n",
     148                             pThis->hFile, pvBuf, cbRead, rc, off, pThis->pszFilename));
    149149    }
    150150    else
    151         AssertMsgFailed(("RTFileSeek(%d,%#llx,) -> %Rrc\n", pThis->File, off, rc));
     151        AssertMsgFailed(("RTFileSeek(%RTfile,%#llx,) -> %Rrc\n", pThis->hFile, off, rc));
    152152    LogFlow(("drvRawImageRead: returns %Rrc\n", rc));
    153153    return rc;
     
    161161    LogFlow(("drvRawImageWrite: off=%#llx pvBuf=%p cbWrite=%#x (%s)\n", off, pvBuf, cbWrite, pThis->pszFilename));
    162162
    163     Assert(pThis->File);
     163    Assert(pThis->hFile != NIL_RTFILE);
    164164    Assert(pvBuf);
    165165
     
    167167     * Seek to the position and write.
    168168     */
    169     int rc = RTFileSeek(pThis->File, off, RTFILE_SEEK_BEGIN, NULL);
     169    int rc = RTFileSeek(pThis->hFile, off, RTFILE_SEEK_BEGIN, NULL);
    170170    if (RT_SUCCESS(rc))
    171171    {
    172         rc = RTFileWrite(pThis->File, pvBuf, cbWrite, NULL);
     172        rc = RTFileWrite(pThis->hFile, pvBuf, cbWrite, NULL);
    173173        if (RT_SUCCESS(rc))
    174174        {
     
    179179        }
    180180        else
    181             AssertMsgFailed(("RTFileWrite(%d, %p, %#x) -> %Rrc (off=%#llx '%s')\n",
    182                              pThis->File, pvBuf, cbWrite, rc, off, pThis->pszFilename));
     181            AssertMsgFailed(("RTFileWrite(%RTfile, %p, %#x) -> %Rrc (off=%#llx '%s')\n",
     182                             pThis->hFile, pvBuf, cbWrite, rc, off, pThis->pszFilename));
    183183    }
    184184    else
    185         AssertMsgFailed(("RTFileSeek(%d,%#llx,) -> %Rrc\n", pThis->File, off, rc));
     185        AssertMsgFailed(("RTFileSeek(%RTfile,%#llx,) -> %Rrc\n", pThis->hFile, off, rc));
    186186    LogFlow(("drvRawImageWrite: returns %Rrc\n", rc));
    187187    return rc;
     
    195195    LogFlow(("drvRawImageFlush: (%s)\n", pThis->pszFilename));
    196196
    197     Assert(pThis->File != NIL_RTFILE);
    198     int rc = RTFileFlush(pThis->File);
     197    Assert(pThis->hFile != NIL_RTFILE);
     198    int rc = RTFileFlush(pThis->hFile);
    199199    LogFlow(("drvRawImageFlush: returns %Rrc\n", rc));
    200200    return rc;
     
    249249    PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns);
    250250
    251     if (pThis->File != NIL_RTFILE)
    252     {
    253         RTFileClose(pThis->File);
    254         pThis->File = NIL_RTFILE;
    255     }
     251    RTFileClose(pThis->hFile);
     252    pThis->hFile = NIL_RTFILE;
     253
    256254    if (pThis->pszFilename)
     255    {
    257256        MMR3HeapFree(pThis->pszFilename);
     257        pThis->pszFilename = NULL;
     258    }
    258259}
    259260
     
    273274     */
    274275    pThis->pDrvIns                      = pDrvIns;
    275     pThis->File                         = NIL_RTFILE;
     276    pThis->hFile                        = NIL_RTFILE;
    276277    /* IBase */
    277278    pDrvIns->IBase.pfnQueryInterface    = drvRawImageQueryInterface;
     
    305306     * Open the image.
    306307     */
    307     rc = RTFileOpen(&pThis->File, pszName,
    308                     RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
     308    rc = RTFileOpen(&pThis->hFile, pszName, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
    309309    if (RT_SUCCESS(rc))
    310310    {
     
    315315    else
    316316    {
    317         rc = RTFileOpen(&pThis->File, pszName,
    318                         RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
     317        rc = RTFileOpen(&pThis->hFile, pszName, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
    319318        if (RT_SUCCESS(rc))
    320319        {
  • trunk/src/VBox/Devices/Storage/DrvSCSIHost.cpp

    r35353 r37596  
    5858    char                   *pszDevicePath;
    5959    /** Handle to the device. */
    60     RTFILE                  DeviceFile;
     60    RTFILE                  hDeviceFile;
    6161
    6262    /** The dedicated I/O thread. */
     
    302302        ScsiIoReq.flags  |= SG_FLAG_DIRECT_IO;
    303303
    304         /** Issue command. */
    305         rc = ioctl(pThis->DeviceFile, SG_IO, &ScsiIoReq);
     304        /* Issue command. */
     305        rc = ioctl(RTFileToNative(pThis->hDeviceFile), SG_IO, &ScsiIoReq);
    306306        if (rc < 0)
    307307        {
     
    420420    PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns);
    421421
    422     if (pThis->DeviceFile != NIL_RTFILE)
    423         RTFileClose(pThis->DeviceFile);
     422    RTFileClose(pThis->hDeviceFile);
     423    pThis->hDeviceFile = NIL_RTFILE;
    424424
    425425    if (pThis->pszDevicePath)
     426    {
    426427        MMR3HeapFree(pThis->pszDevicePath);
     428        pThis->pszDevicePath = NULL;
     429    }
    427430
    428431    if (pThis->pQueueRequests)
     
    457460    pDrvIns->IBase.pfnQueryInterface                    = drvscsihostQueryInterface;
    458461    pThis->ISCSIConnector.pfnSCSIRequestSend            = drvscsihostRequestSend;
    459     pThis->pDrvIns    = pDrvIns;
    460     pThis->DeviceFile = NIL_RTFILE;
     462    pThis->pDrvIns     = pDrvIns;
     463    pThis->hDeviceFile = NIL_RTFILE;
    461464
    462465    /* Query the SCSI port interface above. */
     
    474477                                N_("Configuration error: Failed to get the \"DevicePath\" value"));
    475478
    476     rc = RTFileOpen(&pThis->DeviceFile, pThis->pszDevicePath, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
     479    rc = RTFileOpen(&pThis->hDeviceFile, pThis->pszDevicePath, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
    477480    if (RT_FAILURE(rc))
    478481        return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS,
  • trunk/src/VBox/Devices/USB/USBProxyDevice.h

    r33590 r37596  
    207207         * The Linux and Darwin backends are making use of this. */
    208208        void *pv;
    209         RTFILE File;
     209        RTFILE hFile;
    210210        int fd;
    211211        struct vrdp_priv
  • trunk/src/VBox/Devices/USB/freebsd/USBProxyDevice-freebsd.cpp

    r36797 r37596  
    9494{
    9595    /** The open file. */
    96     RTFILE                 File;
     96    RTFILE                 hFile;
    9797    /** Software endpoint structures */
    9898    USBENDPOINTFBSD        aSwEndpoint[USBFBSD_MAXENDPOINTS];
     
    133133    do
    134134    {
    135         rc = ioctl(pDevFBSD->File, iCmd, pvArg);
     135        rc = ioctl(RTFileToNative(pDevFBSD->hFile), iCmd, pvArg);
    136136        if (rc >= 0)
    137137            return VINF_SUCCESS;
     
    369369     * Try open the device node.
    370370     */
    371     RTFILE File;
    372 
    373     rc = RTFileOpen(&File, pszAddress, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
     371    RTFILE hFile;
     372    rc = RTFileOpen(&hFile, pszAddress, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
    374373    if (RT_SUCCESS(rc))
    375374    {
    376375        /*
    377              * Allocate and initialize the linux backend data.
    378              */
    379         PUSBPROXYDEVFBSD pDevFBSD = (PUSBPROXYDEVFBSD)
    380         RTMemAllocZ(sizeof(USBPROXYDEVFBSD));
    381 
     376         * Allocate and initialize the linux backend data.
     377         */
     378        PUSBPROXYDEVFBSD pDevFBSD = (PUSBPROXYDEVFBSD)RTMemAllocZ(sizeof(USBPROXYDEVFBSD));
    382379        if (pDevFBSD)
    383380        {
    384             pDevFBSD->File = File;
     381            pDevFBSD->hFile = hFile;
    385382            pProxyDev->Backend.pv = pDevFBSD;
    386383
     
    388385            if (RT_SUCCESS(rc))
    389386            {
    390                 LogFlow(("usbProxyFreeBSDOpen(%p, %s): returns "
    391                          "successfully File=%d iActiveCfg=%d\n",
    392                          pProxyDev, pszAddress,
    393                          pDevFBSD->File, pProxyDev->iActiveCfg));
     387                LogFlow(("usbProxyFreeBSDOpen(%p, %s): returns successfully hFile=%RTfile iActiveCfg=%d\n",
     388                         pProxyDev, pszAddress, pDevFBSD->hFile, pProxyDev->iActiveCfg));
    394389
    395390                return VINF_SUCCESS;
     
    401396            rc = VERR_NO_MEMORY;
    402397
    403         RTFileClose(File);
     398        RTFileClose(hFile);
    404399    }
    405400    else if (rc == VERR_ACCESS_DENIED)
     
    455450static void usbProxyFreeBSDClose(PUSBPROXYDEV pProxyDev)
    456451{
    457     PUSBPROXYDEVFBSD pDevFBSD = (PUSBPROXYDEVFBSD) pProxyDev->Backend.pv;
     452    PUSBPROXYDEVFBSD pDevFBSD = (PUSBPROXYDEVFBSD)pProxyDev->Backend.pv;
    458453
    459454    LogFlow(("usbProxyFreeBSDClose: pProxyDev=%s\n", pProxyDev->pUsbIns->pszName));
     
    464459    usbProxyFreeBSDFsUnInit(pProxyDev);
    465460
    466     RTFileClose(pDevFBSD->File);
    467 
    468     pDevFBSD->File = NIL_RTFILE;
     461    RTFileClose(pDevFBSD->hFile);
     462    pDevFBSD->hFile = NIL_RTFILE;
    469463
    470464    RTMemFree(pDevFBSD);
    471 
    472465    pProxyDev->Backend.pv = NULL;
    473466
     
    991984    {
    992985        /* Poll for finished transfers */
    993         PollFd.fd = (int)pDevFBSD->File;
     986        PollFd.fd = RTFileToNative(pDevFBSD->hFile);
    994987        PollFd.events = POLLIN | POLLRDNORM;
    995988        PollFd.revents = 0;
  • trunk/src/VBox/Devices/USB/linux/USBProxyDevice-linux.cpp

    r35346 r37596  
    137137{
    138138    /** The open file. */
    139     RTFILE              File;
     139    RTFILE              hFile;
    140140    /** Critical section protecting the two lists. */
    141141    RTCRITSECT          CritSect;
     
    194194        do
    195195        {
    196             rc = ioctl(pDevLnx->File, iCmd, pvArg);
     196            rc = ioctl(RTFileToNative(pDevLnx->hFile), iCmd, pvArg);
    197197            if (rc >= 0)
    198198                return rc;
     
    236236        pUrbLnx = pUrbLnx->pNext;
    237237
    238         ioctl(pDevLnx->File, USBDEVFS_DISCARDURB, &pCur->KUrb); /* not sure if this is required.. */
     238        ioctl(RTFileToNative(pDevLnx->hFile), USBDEVFS_DISCARDURB, &pCur->KUrb); /* not sure if this is required.. */
    239239        if (!pCur->KUrb.status)
    240240            pCur->KUrb.status = -ENODEV;
     
    596596{
    597597    PUSBPROXYDEVLNX pDevLnx = (PUSBPROXYDEVLNX)pProxyDev->Backend.pv;
    598     AssertReturn(pDevLnx->File != NIL_RTFILE, -1);
    599     return pDevLnx->File;
     598    AssertReturn(pDevLnx->hFile != NIL_RTFILE, -1);
     599    return RTFileToNative(pDevLnx->hFile);
    600600}
    601601
     
    653653     * Try open the device node.
    654654     */
    655     RTFILE File;
    656     int rc = RTFileOpen(&File, pszDevNode, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
     655    RTFILE hFile;
     656    int rc = RTFileOpen(&hFile, pszDevNode, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
    657657    if (RT_SUCCESS(rc))
    658658    {
     
    666666            memcpy(&pDevLnx->szPath[0], pszPath, cchPath);
    667667            pDevLnx->szPath[cchPath] = '\0';
    668             pDevLnx->File = File;
     668            pDevLnx->hFile = hFile;
    669669            rc = RTCritSectInit(&pDevLnx->CritSect);
    670670            if (RT_SUCCESS(rc))
     
    672672                pProxyDev->Backend.pv = pDevLnx;
    673673
    674                 LogFlow(("usbProxyLinuxOpen(%p, %s): returns successfully File=%d iActiveCfg=%d\n",
    675                          pProxyDev, pszAddress, pDevLnx->File, pProxyDev->iActiveCfg));
     674                LogFlow(("usbProxyLinuxOpen(%p, %s): returns successfully File=%RTfile iActiveCfg=%d\n",
     675                         pProxyDev, pszAddress, pDevLnx->hFile, pProxyDev->iActiveCfg));
    676676
    677677                return VINF_SUCCESS;
     
    682682        else
    683683            rc = VERR_NO_MEMORY;
    684         RTFileClose(File);
     684        RTFileClose(hFile);
    685685    }
    686686    else if (rc == VERR_ACCESS_DENIED)
     
    812812    }
    813813
    814     RTFileClose(pDevLnx->File);
    815     pDevLnx->File = NIL_RTFILE;
     814    RTFileClose(pDevLnx->hFile);
     815    pDevLnx->hFile = NIL_RTFILE;
    816816
    817817    RTMemFree(pDevLnx);
     
    12781278    unsigned        cTries = 0;
    12791279
    1280     while (ioctl(pDevLnx->File, USBDEVFS_SUBMITURB, &pCur->KUrb))
     1280    while (ioctl(RTFileToNative(pDevLnx->hFile), USBDEVFS_SUBMITURB, &pCur->KUrb))
    12811281    {
    12821282        if (errno == EINTR)
     
    15161516     */
    15171517    cTries = 0;
    1518     while (ioctl(pDevLnx->File, USBDEVFS_SUBMITURB, &pUrbLnx->KUrb))
     1518    while (ioctl(RTFileToNative(pDevLnx->hFile), USBDEVFS_SUBMITURB, &pUrbLnx->KUrb))
    15191519    {
    15201520        if (errno == EINTR)
     
    17601760            {
    17611761                struct pollfd pfd;
    1762                 int rc;
    1763 
    1764                 pfd.fd = pDevLnx->File;
     1762                pfd.fd = RTFileToNative(pDevLnx->hFile);
    17651763                pfd.events = POLLOUT | POLLWRNORM /* completed async */
    17661764                           | POLLERR | POLLHUP    /* disconnected */;
    17671765                pfd.revents = 0;
    1768                 rc = poll(&pfd, 1, cMillies);
     1766                int rc = poll(&pfd, 1, cMillies);
    17691767                Log(("usbProxyLinuxUrbReap: poll rc = %d\n", rc));
    17701768                if (rc >= 1)
     
    17901788        {
    17911789            struct usbdevfs_urb *pKUrb;
    1792             while (ioctl(pDevLnx->File, USBDEVFS_REAPURBNDELAY, &pKUrb))
     1790            while (ioctl(RTFileToNative(pDevLnx->hFile), USBDEVFS_REAPURBNDELAY, &pKUrb))
    17931791                if (errno != EINTR)
    17941792                {
  • trunk/src/VBox/Devices/USB/solaris/USBProxyDevice-solaris.cpp

    r35346 r37596  
    8080    char                          *pszDevicePath;
    8181    /** The connection to the client driver. */
    82     RTFILE                         File;
     82    RTFILE                         hFile;
    8383    /** Pointer to the proxy device instance. */
    8484    PUSBPROXYDEV                   pProxyDev;
     
    196196static void usbProxySolarisCloseFile(PUSBPROXYDEVSOL pDevSol)
    197197{
    198     if (pDevSol->File != NIL_RTFILE)
    199     {
    200         RTFileClose(pDevSol->File);
    201         pDevSol->File = NIL_RTFILE;
    202     }
     198    RTFileClose(pDevSol->hFile);
     199    pDevSol->hFile = NIL_RTFILE;
    203200}
    204201
     
    215212static int usbProxySolarisIOCtl(PUSBPROXYDEVSOL pDevSol, unsigned Function, void *pvData, size_t cbData)
    216213{
    217     if (RT_UNLIKELY(pDevSol->File == NIL_RTFILE))
     214    if (RT_UNLIKELY(pDevSol->hFile == NIL_RTFILE))
    218215    {
    219216        LogFlow((USBPROXY ":usbProxySolarisIOCtl connection to driver gone!\n"));
     
    228225
    229226    int Ret = -1;
    230     int rc = RTFileIoCtl(pDevSol->File, Function, &Req, sizeof(Req), &Ret);
     227    int rc = RTFileIoCtl(pDevSol->hFile, Function, &Req, sizeof(Req), &Ret);
    231228    if (RT_SUCCESS(rc))
    232229    {
     
    327324                         * Open the client driver.
    328325                         */
    329                         RTFILE File;
    330                         rc = RTFileOpen(&File, pDevSol->pszDevicePath, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
     326                        RTFILE hFile;
     327                        rc = RTFileOpen(&hFile, pDevSol->pszDevicePath, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
    331328                        if (RT_SUCCESS(rc))
    332329                        {
    333                             pDevSol->File = File;
     330                            pDevSol->hFile = hFile;
    334331                            pDevSol->pProxyDev = pProxyDev;
    335332
     
    363360                            }
    364361
    365                             RTFileClose(pDevSol->File);
    366                             pDevSol->File = NIL_RTFILE;
     362                            RTFileClose(pDevSol->hFile);
     363                            pDevSol->hFile = NIL_RTFILE;
    367364                            pDevSol->pProxyDev = NULL;
    368365                        }
     
    721718        {
    722719            struct pollfd pfd;
    723             int rc;
    724 
    725             pfd.fd = pDevSol->File;
     720            pfd.fd = RTFileToNative(pDevSol->hFile);
    726721            pfd.events = POLLIN;
    727722            pfd.revents = 0;
    728             rc = poll(&pfd, 1, cMillies);
    729 
     723            int rc = poll(&pfd, 1, cMillies);
    730724            if (rc > 0)
    731725            {
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette