VirtualBox

Changeset 37596 in vbox for trunk/src/VBox


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
Files:
59 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3Lib.cpp

    r36408 r37596  
    188188        }
    189189    }
    190     g_File = hf;
     190    g_File = (RTFILE)hf;
    191191
    192192#elif defined(VBOX_VBGLR3_XFREE86)
     
    267267    g_File = NIL_RTFILE;
    268268    AssertReturnVoid(File != NIL_RTFILE);
    269     APIRET rc = DosClose(File);
     269    APIRET rc = DosClose((uintptr_t)File);
    270270    AssertMsg(!rc, ("%ld\n", rc));
    271271
     
    323323    int32_t vrc = VERR_INTERNAL_ERROR;
    324324    ULONG cbOS2Data = sizeof(vrc);
    325     APIRET rc = DosDevIOCtl(g_File, VBOXGUEST_IOCTL_CATEGORY, iFunction,
     325    APIRET rc = DosDevIOCtl((uintptr_t)g_File, VBOXGUEST_IOCTL_CATEGORY, iFunction,
    326326                            pvData, cbData, &cbOS2Parm,
    327327                            &vrc, sizeof(vrc), &cbOS2Data);
     
    344344 *        header with an error code return field (much better alternative
    345345 *        actually). */
    346     int rc = ioctl((int)g_File, iFunction, &Hdr);
     346    int rc = ioctl(RTFileToNative(g_File), iFunction, &Hdr);
    347347    if (rc == -1)
    348348    {
     
    356356    int rc = xf86ioctl((int)g_File, iFunction, pvData);
    357357# else
    358     int rc = ioctl((int)g_File, iFunction, pvData);
     358    int rc = ioctl(RTFileToNative(g_File), iFunction, pvData);
    359359# endif
    360360    if (RT_LIKELY(rc == 0))
  • 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            {
  • trunk/src/VBox/Frontends/VBoxBFE/VBoxBFE.cpp

    r37418 r37596  
    17031703                        strcpy(IfReq.ifr_name, "tun%d");
    17041704                    IfReq.ifr_flags = IFF_TAP | IFF_NO_PI;
    1705                     rc = ioctl(tapFD, TUNSETIFF, &IfReq);
     1705                    rc = ioctl(RTFileToNative(tapFD), TUNSETIFF, &IfReq);
    17061706                    if (rc)
    17071707                    {
     
    17121712                    }
    17131713
    1714                     rc = fcntl(tapFD, F_SETFL, O_NONBLOCK);
     1714                    rc = fcntl(RTFileToNative(tapFD), F_SETFL, O_NONBLOCK);
    17151715                    if (rc)
    17161716                    {
     
    17221722
    17231723                    rc = CFGMR3InsertString(pCfg, "Device", g_aNetDevs[ulInstance].pszName);        UPDATE_RC();
    1724                     rc = CFGMR3InsertInteger(pCfg, "FileHandle", (RTFILE)tapFD);                    UPDATE_RC();
     1724                    rc = CFGMR3InsertInteger(pCfg, "FileHandle", (uintptr_t)tapFD);                 UPDATE_RC();
    17251725
    17261726#elif defined(RT_OS_SOLARIS)
  • trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp

    r36527 r37596  
    864864        return errorSyntax(USAGE_LISTPARTITIONS, "Mandatory parameter -rawdisk missing");
    865865
    866     RTFILE RawFile;
    867     int vrc = RTFileOpen(&RawFile, rawdisk.c_str(), RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
     866    RTFILE hRawFile;
     867    int vrc = RTFileOpen(&hRawFile, rawdisk.c_str(), RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
    868868    if (RT_FAILURE(vrc))
    869869    {
     
    873873
    874874    HOSTPARTITIONS partitions;
    875     vrc = partRead(RawFile, &partitions);
     875    vrc = partRead(hRawFile, &partitions);
    876876    /* Don't bail out on errors, print the table and return the result code. */
    877877
     
    989989    fRelative = true;
    990990#endif /* RT_OS_DARWIN */
    991     RTFILE RawFile;
    992     int vrc = RTFileOpen(&RawFile, rawdisk.c_str(), RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
     991    RTFILE hRawFile;
     992    int vrc = RTFileOpen(&hRawFile, rawdisk.c_str(), RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
    993993    if (RT_FAILURE(vrc))
    994994    {
     
    10081008    DISK_GEOMETRY DriveGeo;
    10091009    DWORD cbDriveGeo;
    1010     if (DeviceIoControl((HANDLE)RawFile,
     1010    if (DeviceIoControl((HANDLE)RTFileToNative(hRawFile),
    10111011                        IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0,
    10121012                        &DriveGeo, sizeof(DriveGeo), &cbDriveGeo, NULL))
     
    10291029        GET_LENGTH_INFORMATION DiskLenInfo;
    10301030        DWORD junk;
    1031         if (DeviceIoControl((HANDLE)RawFile,
     1031        if (DeviceIoControl((HANDLE)RTFileToNative(hRawFile),
    10321032                            IOCTL_DISK_GET_LENGTH_INFO, NULL, 0,
    10331033                            &DiskLenInfo, sizeof(DiskLenInfo), &junk, (LPOVERLAPPED)NULL))
     
    10451045#elif defined(RT_OS_LINUX)
    10461046    struct stat DevStat;
    1047     if (!fstat(RawFile, &DevStat) && S_ISBLK(DevStat.st_mode))
     1047    if (!fstat(RTFileToNative(hRawFile), &DevStat) && S_ISBLK(DevStat.st_mode))
    10481048    {
    10491049#ifdef BLKGETSIZE64
     
    10561056        {
    10571057            uint64_t cbBlk;
    1058             if (!ioctl(RawFile, BLKGETSIZE64, &cbBlk))
     1058            if (!ioctl(RTFileToNative(hRawFile), BLKGETSIZE64, &cbBlk))
    10591059                cbSize = cbBlk;
    10601060        }
     
    10631063        {
    10641064            long cBlocks;
    1065             if (!ioctl(RawFile, BLKGETSIZE, &cBlocks))
     1065            if (!ioctl(RTFileToNative(hRawFile), BLKGETSIZE, &cBlocks))
    10661066                cbSize = (uint64_t)cBlocks << 9;
    10671067            else
     
    10811081#elif defined(RT_OS_DARWIN)
    10821082    struct stat DevStat;
    1083     if (!fstat(RawFile, &DevStat) && S_ISBLK(DevStat.st_mode))
     1083    if (!fstat(RTFileToNative(hRawFile), &DevStat) && S_ISBLK(DevStat.st_mode))
    10841084    {
    10851085        uint64_t cBlocks;
    10861086        uint32_t cbBlock;
    1087         if (!ioctl(RawFile, DKIOCGETBLOCKCOUNT, &cBlocks))
    1088         {
    1089             if (!ioctl(RawFile, DKIOCGETBLOCKSIZE, &cbBlock))
     1087        if (!ioctl(RTFileToNative(hRawFile), DKIOCGETBLOCKCOUNT, &cBlocks))
     1088        {
     1089            if (!ioctl(RTFileToNative(hRawFile), DKIOCGETBLOCKSIZE, &cbBlock))
    10901090                cbSize = cBlocks * cbBlock;
    10911091            else
     
    11111111#elif defined(RT_OS_SOLARIS)
    11121112    struct stat DevStat;
    1113     if (!fstat(RawFile, &DevStat) && (   S_ISBLK(DevStat.st_mode)
     1113    if (!fstat(RTFileToNative(hRawFile), &DevStat) && (   S_ISBLK(DevStat.st_mode)
    11141114                                      || S_ISCHR(DevStat.st_mode)))
    11151115    {
    11161116        struct dk_minfo mediainfo;
    1117         if (!ioctl(RawFile, DKIOCGMEDIAINFO, &mediainfo))
     1117        if (!ioctl(RTFileToNative(hRawFile), DKIOCGMEDIAINFO, &mediainfo))
    11181118            cbSize = mediainfo.dki_capacity * mediainfo.dki_lbsize;
    11191119        else
     
    11321132#elif defined(RT_OS_FREEBSD)
    11331133    struct stat DevStat;
    1134     if (!fstat(RawFile, &DevStat) && S_ISCHR(DevStat.st_mode))
     1134    if (!fstat(RTFileToNative(hRawFile), &DevStat) && S_ISCHR(DevStat.st_mode))
    11351135    {
    11361136        off_t cbMedia = 0;
    1137         if (!ioctl(RawFile, DIOCGMEDIASIZE, &cbMedia))
     1137        if (!ioctl(RTFileToNative(hRawFile), DIOCGMEDIASIZE, &cbMedia))
    11381138        {
    11391139            cbSize = cbMedia;
     
    11551155    /* Hopefully this works on all other hosts. If it doesn't, it'll just fail
    11561156     * creating the VMDK, so no real harm done. */
    1157     vrc = RTFileGetSize(RawFile, &cbSize);
     1157    vrc = RTFileGetSize(hRawFile, &cbSize);
    11581158    if (RT_FAILURE(vrc))
    11591159    {
     
    12131213
    12141214        HOSTPARTITIONS partitions;
    1215         vrc = partRead(RawFile, &partitions);
     1215        vrc = partRead(hRawFile, &partitions);
    12161216        if (RT_FAILURE(vrc))
    12171217        {
     
    12681268                    goto out;
    12691269                }
    1270                 vrc = RTFileReadAt(RawFile, partitions.aPartitions[i].uPartDataStart * 512,
     1270                vrc = RTFileReadAt(hRawFile, partitions.aPartitions[i].uPartDataStart * 512,
    12711271                                   pPartData, (size_t)pPartDesc->cbData, NULL);
    12721272                if (RT_FAILURE(vrc))
     
    14151415    }
    14161416
    1417     RTFileClose(RawFile);
     1417    RTFileClose(hRawFile);
    14181418
    14191419#ifdef DEBUG_klaus
     
    16381638    vrc = VINF_SUCCESS;
    16391639    if (fWriteToStdOut)
    1640         outFile = 1;
     1640        vrc = RTFileFromNative(&outFile, 1);
    16411641    else
    16421642        vrc = RTFileOpen(&outFile, dst.c_str(), RTFILE_O_WRITE | RTFILE_O_CREATE | RTFILE_O_DENY_ALL);
  • trunk/src/VBox/HostDrivers/Support/SUPLib.cpp

    r37410 r37596  
    9797SUPLIBDATA                      g_supLibData =
    9898{
    99     NIL_RTFILE
     99    SUP_HDEVICE_NIL
    100100#if   defined(RT_OS_DARWIN)
    101101    , NULL
     
    185185        return VERR_INVALID_MAGIC;
    186186    if (    !(fFlags & SUPSECMAIN_FLAGS_DONT_OPEN_DEV)
    187         &&  pPreInitData->Data.hDevice == NIL_RTFILE)
     187        &&  pPreInitData->Data.hDevice == SUP_HDEVICE_NIL)
    188188        return VERR_INVALID_HANDLE;
    189189    if (    (fFlags & SUPSECMAIN_FLAGS_DONT_OPEN_DEV)
    190         &&  pPreInitData->Data.hDevice != NIL_RTFILE)
     190        &&  pPreInitData->Data.hDevice != SUP_HDEVICE_NIL)
    191191        return VERR_INVALID_PARAMETER;
    192192
  • trunk/src/VBox/HostDrivers/Support/SUPLibInternal.h

    r35188 r37596  
    185185{
    186186    /** The device handle. */
    187     RTFILE              hDevice;
     187#if defined(RT_OS_WINDOWS)
     188    void               *hDevice;
     189#else
     190    int                 hDevice;
     191#endif
    188192#if   defined(RT_OS_DARWIN)
    189193    /** The connection to the VBoxSupDrv service. */
     
    203207/** Pointer to const pre-init data. */
    204208typedef SUPLIBDATA const *PCSUPLIBDATA;
     209
     210/** The NIL value of SUPLIBDATA::hDevice. */
     211#if defined(RT_OS_WINDOWS)
     212# define SUP_HDEVICE_NIL NULL
     213#else
     214# define SUP_HDEVICE_NIL (-1)
     215#endif
    205216
    206217
  • trunk/src/VBox/HostDrivers/Support/SUPR3HardenedMain.cpp

    r35311 r37596  
    10191019     */
    10201020    g_pszSupLibHardenedProgName = pszProgName;
    1021     g_SupPreInitData.u32Magic = SUPPREINITDATA_MAGIC;
    1022     g_SupPreInitData.Data.hDevice = NIL_RTFILE;
    1023     g_SupPreInitData.u32EndMagic = SUPPREINITDATA_MAGIC;
     1021    g_SupPreInitData.u32Magic     = SUPPREINITDATA_MAGIC;
     1022    g_SupPreInitData.Data.hDevice = SUP_HDEVICE_NIL;
     1023    g_SupPreInitData.u32EndMagic  = SUPPREINITDATA_MAGIC;
    10241024
    10251025#ifdef SUP_HARDENED_SUID
  • trunk/src/VBox/HostDrivers/Support/darwin/SUPLib-darwin.cpp

    r33540 r37596  
    194194     * Do the job.
    195195     */
    196     Assert(pThis->hDevice == NIL_RTFILE);
     196    Assert(pThis->hDevice == (intptr_t)NIL_RTFILE);
    197197    int rc = suplibDarwinOpenService(pThis);
    198198    if (RT_SUCCESS(rc))
     
    237237     * Check if we're inited at all.
    238238     */
    239     if (pThis->hDevice != NIL_RTFILE)
     239    if (pThis->hDevice != (intptr_t)NIL_RTFILE)
    240240    {
    241241        if (close(pThis->hDevice))
    242242            AssertFailed();
    243         pThis->hDevice = NIL_RTFILE;
     243        pThis->hDevice = (intptr_t)NIL_RTFILE;
    244244    }
    245245
  • trunk/src/VBox/HostDrivers/Support/freebsd/SUPLib-freebsd.cpp

    r33540 r37596  
    133133     * Check if we're inited at all.
    134134     */
    135     if (pThis->hDevice != NIL_RTFILE)
     135    if (pThis->hDevice != (intptr_t)NIL_RTFILE)
    136136    {
    137137        if (close(pThis->hDevice))
    138138            AssertFailed();
    139         pThis->hDevice = NIL_RTFILE;
     139        pThis->hDevice = (intptr_t)NIL_RTFILE;
    140140    }
    141141    return VINF_SUCCESS;
  • trunk/src/VBox/HostDrivers/Support/linux/SUPLib-linux.cpp

    r37556 r37596  
    7979    if (fPreInited)
    8080        return VINF_SUCCESS;
    81     Assert(pThis->hDevice == NIL_RTFILE);
     81    Assert(pThis->hDevice == (intptr_t)NIL_RTFILE);
    8282
    8383    /*
     
    145145     * Close the device if it's actually open.
    146146     */
    147     if (pThis->hDevice != NIL_RTFILE)
     147    if (pThis->hDevice != (intptr_t)NIL_RTFILE)
    148148    {
    149149        if (close(pThis->hDevice))
    150150            AssertFailed();
    151         pThis->hDevice = NIL_RTFILE;
     151        pThis->hDevice = (intptr_t)NIL_RTFILE;
    152152    }
    153153
     
    172172int suplibOsIOCtl(PSUPLIBDATA pThis, uintptr_t uFunction, void *pvReq, size_t cbReq)
    173173{
    174     AssertMsg(pThis->hDevice != NIL_RTFILE, ("SUPLIB not initiated successfully!\n"));
     174    AssertMsg(pThis->hDevice != (intptr_t)NIL_RTFILE, ("SUPLIB not initiated successfully!\n"));
    175175
    176176    /*
  • trunk/src/VBox/HostDrivers/Support/os2/SUPLib-os2.cpp

    r33540 r37596  
    100100    }
    101101
    102     pThis->hDevice = (RTFILE)hDevice;
     102    pThis->hDevice = hDevice;
    103103    return VINF_SUCCESS;
    104104}
     
    112112     * Check if we're inited at all.
    113113     */
    114     if (pThis->hDevice != NIL_RTFILE)
     114    if (pThis->hDevice != (intptr_t)NIL_RTFILE)
    115115    {
    116116        APIRET rc = DosClose((HFILE)pThis->hDevice);
    117117        AssertMsg(rc == NO_ERROR, ("%d\n", rc)); NOREF(rc);
    118         pThis->hDevice = NIL_RTFILE;
     118        pThis->hDevice = (intptr_t)NIL_RTFILE;
    119119    }
    120120
  • trunk/src/VBox/HostDrivers/Support/solaris/SUPLib-solaris.cpp

    r28800 r37596  
    162162        if (close(pThis->hDevice))
    163163            AssertFailed();
    164         pThis->hDevice = NIL_RTFILE;
     164        pThis->hDevice = (intptr_t)NIL_RTFILE;
    165165    }
    166166
  • trunk/src/VBox/HostDrivers/Support/win/SUPLib-win.cpp

    r33540 r37596  
    139139     * We're done.
    140140     */
    141     pThis->hDevice = (RTFILE)hDevice;
     141    pThis->hDevice = hDevice;
    142142    return VINF_SUCCESS;
    143143}
     
    475475     * Check if we're inited at all.
    476476     */
    477     if (pThis->hDevice != NIL_RTFILE)
     477    if (pThis->hDevice != NULL)
    478478    {
    479479        if (!CloseHandle((HANDLE)pThis->hDevice))
    480480            AssertFailed();
    481         pThis->hDevice = NIL_RTFILE;
     481        pThis->hDevice = NIL_RTFILE; /* yes, that's right */
    482482    }
    483483
  • trunk/src/VBox/Main/include/USBProxyService.h

    r36993 r37596  
    256256private:
    257257    /** File handle to the '/proc/bus/usb/devices' file. */
    258     RTFILE mFile;
     258    RTFILE mhFile;
    259259    /** Pipe used to interrupt wait(), the read end. */
    260     RTFILE mWakeupPipeR;
     260    RTPIPE mhWakeupPipeR;
    261261    /** Pipe used to interrupt wait(), the write end. */
    262     RTFILE mWakeupPipeW;
     262    RTPIPE mhWakeupPipeW;
    263263    /** The root of usbfs. */
    264264    Utf8Str mDevicesRoot;
  • trunk/src/VBox/Main/src-server/linux/USBProxyServiceLinux.cpp

    r36997 r37596  
    3939#include <iprt/param.h>
    4040#include <iprt/path.h>
     41#include <iprt/pipe.h>
    4142#include <iprt/stream.h>
    4243#include <iprt/linux/sysfs.h>
     
    6061 */
    6162USBProxyServiceLinux::USBProxyServiceLinux(Host *aHost)
    62     : USBProxyService(aHost), mFile(NIL_RTFILE), mWakeupPipeR(NIL_RTFILE),
    63       mWakeupPipeW(NIL_RTFILE), mUsingUsbfsDevices(true /* see init */),
     63    : USBProxyService(aHost), mhFile(NIL_RTFILE), mhWakeupPipeR(NIL_RTPIPE),
     64      mhWakeupPipeW(NIL_RTPIPE), mUsingUsbfsDevices(true /* see init */),
    6465      mUdevPolls(0), mpWaiter(NULL)
    6566#ifdef UNIT_TEST
     
    209210    if (pszDevices)
    210211    {
    211         rc = RTFileOpen(&mFile, pszDevices, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
     212        rc = RTFileOpen(&mhFile, pszDevices, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
    212213        if (RT_SUCCESS(rc))
    213214        {
    214             int pipes[2];
    215             if (!pipe(pipes))
     215            rc = RTPipeCreate(&mhWakeupPipeR, &mhWakeupPipeW, 0 /*fFlags*/);
     216            if (RT_SUCCESS(rc))
    216217            {
    217                 /* Set close on exec (race here!) */
    218                 if (   fcntl(pipes[0], F_SETFD, FD_CLOEXEC) >= 0
    219                     && fcntl(pipes[1], F_SETFD, FD_CLOEXEC) >= 0)
     218                /*
     219                 * Start the poller thread.
     220                 */
     221                rc = start();
     222                if (RT_SUCCESS(rc))
    220223                {
    221                     mWakeupPipeR = pipes[0];
    222                     mWakeupPipeW = pipes[1];
    223                     /*
    224                      * Start the poller thread.
    225                      */
    226                     rc = start();
    227                     if (RT_SUCCESS(rc))
    228                     {
    229                         RTStrFree(pszDevices);
    230                         LogFlowThisFunc(("returns successfully - mWakeupPipeR/W=%d/%d\n",
    231                                          mWakeupPipeR, mWakeupPipeW));
    232                         return VINF_SUCCESS;
    233                     }
    234 
    235                     RTFileClose(mWakeupPipeR);
    236                     RTFileClose(mWakeupPipeW);
    237                     mWakeupPipeW = mWakeupPipeR = NIL_RTFILE;
     224                    RTStrFree(pszDevices);
     225                    LogFlowThisFunc(("returns successfully\n"));
     226                    return VINF_SUCCESS;
    238227                }
    239                 else
    240                 {
    241                     rc = RTErrConvertFromErrno(errno);
    242                     Log(("USBProxyServiceLinux::USBProxyServiceLinux: fcntl failed, errno=%d\n", errno));
    243                     close(pipes[0]);
    244                     close(pipes[1]);
    245                 }
     228
     229                RTPipeClose(mhWakeupPipeR);
     230                RTPipeClose(mhWakeupPipeW);
     231                mhWakeupPipeW = mhWakeupPipeR = NIL_RTPIPE;
    246232            }
    247233            else
    248             {
    249                 rc = RTErrConvertFromErrno(errno);
    250                 Log(("USBProxyServiceLinux::USBProxyServiceLinux: pipe failed, errno=%d\n", errno));
    251             }
    252             RTFileClose(mFile);
     234                Log(("USBProxyServiceLinux::USBProxyServiceLinux: RTFilePipe failed with rc=%Rrc\n", rc));
     235            RTFileClose(mhFile);
    253236        }
    254237
     
    332315     * Free resources.
    333316     */
    334     if (mFile != NIL_RTFILE)
    335     {
    336         RTFileClose(mFile);
    337         mFile = NIL_RTFILE;
    338     }
    339 
    340     if (mWakeupPipeR != NIL_RTFILE)
    341         RTFileClose(mWakeupPipeR);
    342     if (mWakeupPipeW != NIL_RTFILE)
    343         RTFileClose(mWakeupPipeW);
    344     mWakeupPipeW = mWakeupPipeR = NIL_RTFILE;
     317    RTFileClose(mhFile);
     318    mhFile = NIL_RTFILE;
     319
     320    RTPipeClose(mhWakeupPipeR);
     321    RTPipeClose(mhWakeupPipeW);
     322    mhWakeupPipeW = mhWakeupPipeR = NIL_RTPIPE;
    345323}
    346324
     
    434412
    435413    memset(&PollFds, 0, sizeof(PollFds));
    436     PollFds[0].fd        = mFile;
     414    PollFds[0].fd        = RTFileToNative(mhFile);
    437415    PollFds[0].events    = POLLIN;
    438     PollFds[1].fd        = mWakeupPipeR;
     416    PollFds[1].fd        = RTPipeToNative(mhWakeupPipeR);
    439417    PollFds[1].events    = POLLIN | POLLERR | POLLHUP;
    440418
     
    448426        {
    449427            char szBuf[WAKE_UP_STRING_LEN];
    450             rc = RTFileRead(mWakeupPipeR, szBuf, sizeof(szBuf), NULL);
     428            rc = RTPipeReadBlocking(mhWakeupPipeR, szBuf, sizeof(szBuf), NULL);
    451429            AssertRC(rc);
    452430        }
     
    484462    }
    485463#endif /* VBOX_USB_WITH_SYSFS */
    486     int rc = RTFileWrite(mWakeupPipeW, WAKE_UP_STRING, WAKE_UP_STRING_LEN, NULL);
     464    int rc = RTPipeWriteBlocking(mhWakeupPipeW, WAKE_UP_STRING, WAKE_UP_STRING_LEN, NULL);
    487465    if (RT_SUCCESS(rc))
    488         RTFileFlush(mWakeupPipeW);
     466        RTPipeFlush(mhWakeupPipeW);
    489467    LogFlowFunc(("returning %Rrc\n", rc));
    490468    return rc;
  • trunk/src/VBox/NetworkServices/NAT/VBoxNetNAT.cpp

    r36470 r37596  
    3535#include <iprt/path.h>
    3636#include <iprt/param.h>
     37#include <iprt/pipe.h>
    3738#include <iprt/getopt.h>
    3839#include <iprt/string.h>
     
    9091    HANDLE m_hWakeupEvent;
    9192#else
    92     RTFILE m_PipeWrite;
    93     RTFILE m_PipeRead;
     93    RTPIPE m_hPipeWrite;
     94    RTPIPE m_hPipeRead;
    9495#endif
    9596    /** Queue for NAT-thread-external events. */
     
    126127#ifndef RT_OS_WINDOWS
    127128    /* kick select() */
    128     rc = RTFileWrite(g_pNAT->m_PipeWrite, "", 1, NULL);
     129    size_t cbIgnored;
     130    rc = RTPipeWrite(g_pNAT->m_hPipeWrite, "", 1, &cbIgnored);
    129131#else
    130132    /* kick WSAWaitForMultipleEvents */
     
    170172     * Create the control pipe.
    171173     */
    172     int fds[2];
    173     if (pipe(&fds[0]) != 0) /** @todo RTPipeCreate() or something... */
    174     {
    175         rc = RTErrConvertFromErrno(errno);
    176         AssertReleaseRC(rc);
    177         return;
    178     }
    179     m_PipeRead = fds[0];
    180     m_PipeWrite = fds[1];
     174    rc = RTPipeCreate(&m_hPipeRead, &m_hPipeWrite, 0 /*fFlags*/);
     175    AssertReleaseRC(rc);
    181176#else
    182177    m_hWakeupEvent = CreateEvent(NULL, FALSE, FALSE, NULL); /* auto-reset event */
     178    AssertReleaseRC(m_hWakeupEvent != NULL);
    183179    slirp_register_external_event(m_pNATState, m_hWakeupEvent, VBOX_WAKEUP_EVENT_INDEX);
    184180#endif
     
    299295#ifndef RT_OS_WINDOWS
    300296                /* kick select() */
    301                 rc = RTFileWrite(m_PipeWrite, "", 1, NULL);
     297                size_t cbIgnored;
     298                rc = RTPipeWrite(m_hPipeWrite, "", 1, &cbIgnored);
    302299                AssertRC(rc);
    303300#else
     
    468465        unsigned int cMsTimeout = slirp_get_timeout_ms(pThis->m_pNATState);
    469466
    470         polls[0].fd = pThis->m_PipeRead;
     467        polls[0].fd = RTPipeToNative(pThis->m_hPipeRead);
    471468        /* POLLRDBAND usually doesn't used on Linux but seems used on Solaris */
    472469        polls[0].events = POLLRDNORM|POLLPRI|POLLRDBAND;
     
    494491            if (polls[0].revents & (POLLRDNORM|POLLPRI|POLLRDBAND))
    495492            {
    496                 /* drain the pipe */
    497                 char ch[1];
    498                 size_t cbRead;
    499                 int counter = 0;
    500                 /*
     493                /* drain the pipe
     494                 *
     495                 * Note!
    501496                 * drvNATSend decoupled so we don't know how many times
    502497                 * device's thread sends before we've entered multiplex,
     
    506501                 * deep pipe has been filed before drain.
    507502                 *
    508                  * XXX:Make it reading exactly we need to drain the pipe.
    509503                 */
    510                 RTFileRead(pThis->m_PipeRead, &ch, 1, &cbRead);
     504                 /** @todo XXX: Make it reading exactly we need to drain the
     505                  *  pipe.  */
     506                char    ch;
     507                size_t  cbRead;
     508                RTPipeRead(pThis->m_hPipeRead, &ch, 1, &cbRead);
    511509            }
    512510        }
  • trunk/src/VBox/Runtime/common/ldr/ldr.cpp

    r28800 r37596  
    3939#include <iprt/log.h>
    4040#include "internal/ldr.h"
    41 
    42 
    43 /*******************************************************************************
    44 *   Structures and Typedefs                                                    *
    45 *******************************************************************************/
    46 typedef struct RTLDRREADERFILE
    47 {
    48     /** The core. */
    49     RTLDRREADER     Core;
    50     /** The file. */
    51     RTFILE          File;
    52     /** The file size. */
    53     RTFOFF          cbFile;
    54     /** The current offset. */
    55     RTFOFF          off;
    56     /** The filename (variable size). */
    57     char            szFilename[1];
    58 } RTLDRREADERFILE, *PRTLDRREADERFILE;
    59 
    6041
    6142
  • trunk/src/VBox/Runtime/common/ldr/ldrFile.cpp

    r28800 r37596  
    5555    RTLDRREADER     Core;
    5656    /** The file. */
    57     RTFILE          File;
     57    RTFILE          hFile;
    5858    /** The file size. */
    5959    RTFOFF          cbFile;
     
    7979    if (pFileReader->off != off)
    8080    {
    81         int rc = RTFileSeek(pFileReader->File, off, RTFILE_SEEK_BEGIN, NULL);
     81        int rc = RTFileSeek(pFileReader->hFile, off, RTFILE_SEEK_BEGIN, NULL);
    8282        if (RT_FAILURE(rc))
    8383        {
     
    9191     * Read.
    9292     */
    93     int rc = RTFileRead(pFileReader->File, pvBuf, cb, NULL);
     93    int rc = RTFileRead(pFileReader->hFile, pvBuf, cb, NULL);
    9494    if (RT_SUCCESS(rc))
    9595        pFileReader->off += cb;
     
    185185    int rc = VINF_SUCCESS;
    186186    PRTLDRREADERFILE pFileReader = (PRTLDRREADERFILE)pReader;
    187     if (pFileReader->File != NIL_RTFILE)
    188     {
    189         rc = RTFileClose(pFileReader->File);
     187    if (pFileReader->hFile != NIL_RTFILE)
     188    {
     189        rc = RTFileClose(pFileReader->hFile);
    190190        AssertRC(rc);
    191         pFileReader->File = NIL_RTFILE;
     191        pFileReader->hFile = NIL_RTFILE;
    192192    }
    193193    RTMemFree(pFileReader);
     
    211211    {
    212212        memcpy(pFileReader->szFilename, pszFilename, cchFilename + 1);
    213         rc = RTFileOpen(&pFileReader->File, pszFilename, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
     213        rc = RTFileOpen(&pFileReader->hFile, pszFilename, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
    214214        if (RT_SUCCESS(rc))
    215215        {
    216             rc = RTFileGetSize(pFileReader->File, (uint64_t *)&pFileReader->cbFile);
     216            rc = RTFileGetSize(pFileReader->hFile, (uint64_t *)&pFileReader->cbFile);
    217217            if (RT_SUCCESS(rc))
    218218            {
     
    230230                return VINF_SUCCESS;
    231231            }
    232             RTFileClose(pFileReader->File);
     232
     233            RTFileClose(pFileReader->hFile);
    233234        }
    234235        RTMemFree(pFileReader);
  • trunk/src/VBox/Runtime/common/log/log.cpp

    r37593 r37596  
    129129
    130130    /** Handle to log file (if open). */
    131     union
    132     {
    133         RTFILE              hFile;
    134         RTHCUINTPTR         uPaddingForNewRTFILE;
    135     } u;
     131    RTFILE                  hFile;
    136132    /** Log file history settings: maximum amount of data to put in a file. */
    137133    uint64_t                cbHistoryFileMax;
     
    157153/** The size of the RTLOGGERINTERNAL structure in ring-0.  */
    158154# define RTLOGGERINTERNAL_R0_SIZE       RT_OFFSETOF(RTLOGGERINTERNAL, pfnPhase)
    159 AssertCompileMemberAlignment(RTLOGGERINTERNAL, u.hFile, sizeof(void *));
     155AssertCompileMemberAlignment(RTLOGGERINTERNAL, hFile, sizeof(void *));
    160156AssertCompileMemberAlignment(RTLOGGERINTERNAL, cbHistoryFileMax, sizeof(uint64_t));
    161157#endif
     
    341337{
    342338    PRTLOGGER pLogger = (PRTLOGGER)pvArg;
    343     RTFileWrite(pLogger->pInt->u.hFile, pachChars, cbChars, NULL);
     339    RTFileWrite(pLogger->pInt->hFile, pachChars, cbChars, NULL);
    344340    return cbChars;
    345341}
     
    479475# ifdef IN_RING3
    480476        pLogger->pInt->pfnPhase                 = pfnPhase;
    481         pLogger->pInt->u.hFile                  = NIL_RTFILE;
     477        pLogger->pInt->hFile                    = NIL_RTFILE;
    482478        pLogger->pInt->cHistory                 = cHistory;
    483479        if (cbHistoryFileMax == 0)
     
    596592
    597593                    /* If the file is not open then rotation is not set up. */
    598                     if (pLogger->pInt->u.hFile == NIL_RTFILE)
     594                    if (pLogger->pInt->hFile == NIL_RTFILE)
    599595                    {
    600596                        pLogger->pInt->cbHistoryFileWritten = 0;
     
    638634            }
    639635# ifdef IN_RING3
    640             RTFileClose(pLogger->pInt->u.hFile);
     636            RTFileClose(pLogger->pInt->hFile);
    641637# endif
    642638# if defined(LOG_USE_C99) && defined(RT_WITHOUT_EXEC_ALLOC)
     
    736732     */
    737733    if (   (pLogger->fDestFlags & RTLOGDEST_FILE)
    738         && pLogger->pInt->u.hFile != NIL_RTFILE)
     734        && pLogger->pInt->hFile != NIL_RTFILE)
    739735        pLogger->pInt->pfnPhase(pLogger, RTLOGPHASE_END, rtlogPhaseMsgLocked);
    740736
     
    742738     * Close output stuffs.
    743739     */
    744     if (pLogger->pInt->u.hFile != NIL_RTFILE)
    745     {
    746         int rc2 = RTFileClose(pLogger->pInt->u.hFile);
     740    if (pLogger->pInt->hFile != NIL_RTFILE)
     741    {
     742        int rc2 = RTFileClose(pLogger->pInt->hFile);
    747743        AssertRC(rc2);
    748744        if (RT_FAILURE(rc2) && RT_SUCCESS(rc))
    749745            rc = rc2;
    750         pLogger->pInt->u.hFile = NIL_RTFILE;
     746        pLogger->pInt->hFile = NIL_RTFILE;
    751747    }
    752748# endif
     
    25582554        fOpen |= RTFILE_O_WRITE_THROUGH;
    25592555
    2560     int rc = RTFileOpen(&pLogger->pInt->u.hFile, pLogger->pInt->szFilename, fOpen);
     2556    int rc = RTFileOpen(&pLogger->pInt->hFile, pLogger->pInt->szFilename, fOpen);
    25612557    if (RT_FAILURE(rc))
    25622558    {
    2563         pLogger->pInt->u.hFile = NIL_RTFILE;
     2559        pLogger->pInt->hFile = NIL_RTFILE;
    25642560        if (pszErrorMsg)
    25652561            RTStrPrintf(pszErrorMsg, cchErrorMsg, N_("could not open file '%s' (fOpen=%#x)"), pLogger->pInt->szFilename, fOpen);
     
    25672563    else
    25682564    {
    2569         rc = RTFileGetSize(pLogger->pInt->u.hFile, &pLogger->pInt->cbHistoryFileWritten);
     2565        rc = RTFileGetSize(pLogger->pInt->hFile, &pLogger->pInt->cbHistoryFileWritten);
    25702566        if (RT_FAILURE(rc))
    25712567        {
     
    26192615     * Close the old log file.
    26202616     */
    2621     if (pLogger->pInt->u.hFile != NIL_RTFILE)
     2617    if (pLogger->pInt->hFile != NIL_RTFILE)
    26222618    {
    26232619        /* Use the callback to generate some final log contents, but only if
     
    26312627            pLogger->fDestFlags = fODestFlags;
    26322628        }
    2633         RTFileClose(pLogger->pInt->u.hFile);
    2634         pLogger->pInt->u.hFile = NIL_RTFILE;
     2629        RTFileClose(pLogger->pInt->hFile);
     2630        pLogger->pInt->hFile = NIL_RTFILE;
    26352631    }
    26362632
     
    27172713    if (pLogger->fDestFlags & RTLOGDEST_FILE)
    27182714    {
    2719         if (pLogger->pInt->u.hFile != NIL_RTFILE)
    2720         {
    2721             RTFileWrite(pLogger->pInt->u.hFile, pLogger->achScratch, pLogger->offScratch, NULL);
     2715        if (pLogger->pInt->hFile != NIL_RTFILE)
     2716        {
     2717            RTFileWrite(pLogger->pInt->hFile, pLogger->achScratch, pLogger->offScratch, NULL);
    27222718            if (pLogger->fFlags & RTLOGFLAGS_FLUSH)
    2723                 RTFileFlush(pLogger->pInt->u.hFile);
     2719                RTFileFlush(pLogger->pInt->hFile);
    27242720        }
    27252721        if (pLogger->pInt->cHistory)
  • trunk/src/VBox/Runtime/common/misc/RTFileOpenF.cpp

    r28800 r37596  
    3333
    3434
    35 RTR3DECL(int) RTFileOpenF(PRTFILE pFile, uint32_t fOpen, const char *pszFilenameFmt, ...)
     35RTR3DECL(int) RTFileOpenF(PRTFILE pFile, uint64_t fOpen, const char *pszFilenameFmt, ...)
    3636{
    3737    va_list va;
  • trunk/src/VBox/Runtime/common/misc/RTFileOpenV.cpp

    r28800 r37596  
    3737
    3838
    39 RTR3DECL(int) RTFileOpenV(PRTFILE pFile, uint32_t fOpen, const char *pszFilenameFmt, va_list va)
     39RTR3DECL(int) RTFileOpenV(PRTFILE pFile, uint64_t fOpen, const char *pszFilenameFmt, va_list va)
    4040{
    4141    char szFilename[RTPATH_MAX];
  • trunk/src/VBox/Runtime/common/vfs/vfsbase.cpp

    r35213 r37596  
    22982298
    22992299
    2300 RTDECL(int)         RTVfsFileOpen(RTVFS hVfs, const char *pszFilename, uint32_t fOpen, PRTVFSFILE phVfsFile)
     2300RTDECL(int)         RTVfsFileOpen(RTVFS hVfs, const char *pszFilename, uint64_t fOpen, PRTVFSFILE phVfsFile)
    23012301{
    23022302    /*
  • trunk/src/VBox/Runtime/common/vfs/vfschain.cpp

    r34179 r37596  
    563563
    564564
    565 RTDECL(int) RTVfsChainOpenFile(const char *pszSpec, uint32_t fOpen, PRTVFSFILE phVfsFile, const char **ppszError)
     565RTDECL(int) RTVfsChainOpenFile(const char *pszSpec, uint64_t fOpen, PRTVFSFILE phVfsFile, const char **ppszError)
    566566{
    567567    AssertPtrReturn(pszSpec, VERR_INVALID_POINTER);
     
    610610
    611611
    612 RTDECL(int) RTVfsChainOpenIoStream(const char *pszSpec, uint32_t fOpen, PRTVFSIOSTREAM phVfsIos, const char **ppszError)
     612RTDECL(int) RTVfsChainOpenIoStream(const char *pszSpec, uint64_t fOpen, PRTVFSIOSTREAM phVfsIos, const char **ppszError)
    613613{
    614614    AssertPtrReturn(pszSpec, VERR_INVALID_POINTER);
  • trunk/src/VBox/Runtime/common/vfs/vfsmisc.cpp

    r33973 r37596  
    3939
    4040
    41 RTDECL(int)         RTVfsIoStrmFromStdHandle(RTHANDLESTD enmStdHandle, uint32_t fOpen, bool fLeaveOpen,
     41RTDECL(int)         RTVfsIoStrmFromStdHandle(RTHANDLESTD enmStdHandle, uint64_t fOpen, bool fLeaveOpen,
    4242                                             PRTVFSIOSTREAM phVfsIos)
    4343{
  • trunk/src/VBox/Runtime/common/vfs/vfsstdfile.cpp

    r36555 r37596  
    419419
    420420
    421 RTDECL(int) RTVfsFileFromRTFile(RTFILE hFile, uint32_t fOpen, bool fLeaveOpen, PRTVFSFILE phVfsFile)
     421RTDECL(int) RTVfsFileFromRTFile(RTFILE hFile, uint64_t fOpen, bool fLeaveOpen, PRTVFSFILE phVfsFile)
    422422{
    423423    /*
     
    451451
    452452
    453 RTDECL(int)         RTVfsIoStrmFromRTFile(RTFILE hFile, uint32_t fOpen, bool fLeaveOpen, PRTVFSIOSTREAM phVfsIos)
     453RTDECL(int)         RTVfsIoStrmFromRTFile(RTFILE hFile, uint64_t fOpen, bool fLeaveOpen, PRTVFSIOSTREAM phVfsIos)
    454454{
    455455    RTVFSFILE hVfsFile;
  • trunk/src/VBox/Runtime/include/internal/file.h

    r36597 r37596  
    4242 * @internal
    4343 */
    44 int rtFileRecalcAndValidateFlags(uint32_t *pfOpen);
     44int rtFileRecalcAndValidateFlags(uint64_t *pfOpen);
    4545
    4646
  • trunk/src/VBox/Runtime/include/internal/rand.h

    r36555 r37596  
    150150        struct RTRandFile
    151151        {
    152             /** The file handle. */
    153             RTFILE      hFile;
     152            /** The file handle (native). */
     153            intptr_t    hFile;
    154154        } File;
    155155    } u;
  • trunk/src/VBox/Runtime/r3/fileio.cpp

    r33540 r37596  
    107107 * @internal
    108108 */
    109 int rtFileRecalcAndValidateFlags(uint32_t *pfOpen)
     109int rtFileRecalcAndValidateFlags(uint64_t *pfOpen)
    110110{
    111111    /*
     
    128128            break;
    129129        default:
    130             AssertMsgFailed(("Invalid RW value, fOpen=%#x\n", fOpen));
     130            AssertMsgFailed(("Invalid RW value, fOpen=%#llx\n", fOpen));
    131131            return VERR_INVALID_PARAMETER;
    132132    }
     
    135135     * Validate                                                                                                                                       .
    136136     */
    137     AssertMsgReturn(fOpen & RTFILE_O_ACCESS_MASK, ("Missing RTFILE_O_READ/WRITE: fOpen=%#x\n", fOpen), VERR_INVALID_PARAMETER);
     137    AssertMsgReturn(fOpen & RTFILE_O_ACCESS_MASK, ("Missing RTFILE_O_READ/WRITE: fOpen=%#llx\n", fOpen), VERR_INVALID_PARAMETER);
    138138#if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2)
    139     AssertMsgReturn(!(fOpen & (~RTFILE_O_VALID_MASK | RTFILE_O_NON_BLOCK)), ("%#x\n", fOpen), VERR_INVALID_PARAMETER);
     139    AssertMsgReturn(!(fOpen & (~(uint64_t)RTFILE_O_VALID_MASK | RTFILE_O_NON_BLOCK)), ("%#llx\n", fOpen), VERR_INVALID_PARAMETER);
    140140#else
    141     AssertMsgReturn(!(fOpen & ~RTFILE_O_VALID_MASK), ("%#x\n", fOpen), VERR_INVALID_PARAMETER);
     141    AssertMsgReturn(!(fOpen & ~(uint64_t)RTFILE_O_VALID_MASK), ("%#llx\n", fOpen), VERR_INVALID_PARAMETER);
    142142#endif
    143     AssertMsgReturn((fOpen & (RTFILE_O_TRUNCATE | RTFILE_O_WRITE)) != RTFILE_O_TRUNCATE, ("%#x\n", fOpen), VERR_INVALID_PARAMETER);
     143    AssertMsgReturn((fOpen & (RTFILE_O_TRUNCATE | RTFILE_O_WRITE)) != RTFILE_O_TRUNCATE, ("%#llx\n", fOpen), VERR_INVALID_PARAMETER);
    144144
    145145    switch (fOpen & RTFILE_O_ACTION_MASK)
     
    150150            break;
    151151        case RTFILE_O_OPEN:
    152             AssertMsgReturn(!(RTFILE_O_NOT_CONTENT_INDEXED & fOpen), ("%#x\n", fOpen), VERR_INVALID_PARAMETER);
     152            AssertMsgReturn(!(RTFILE_O_NOT_CONTENT_INDEXED & fOpen), ("%#llx\n", fOpen), VERR_INVALID_PARAMETER);
    153153        case RTFILE_O_OPEN_CREATE:
    154154        case RTFILE_O_CREATE:
     
    156156            break;
    157157        default:
    158             AssertMsgFailed(("Invalid action value: fOpen=%#x\n", fOpen));
     158            AssertMsgFailed(("Invalid action value: fOpen=%#llx\n", fOpen));
    159159            return VERR_INVALID_PARAMETER;
    160160    }
     
    176176            break;
    177177        default:
    178             AssertMsgFailed(("Invalid deny value: fOpen=%#x\n", fOpen));
     178            AssertMsgFailed(("Invalid deny value: fOpen=%#llx\n", fOpen));
    179179            return VERR_INVALID_PARAMETER;
    180180    }
  • trunk/src/VBox/Runtime/r3/linux/fileaio-linux.cpp

    r33540 r37596  
    105105    int16_t   i16Priority;
    106106    /** The file descriptor. */
    107     uint32_t  File;
     107    uint32_t  uFileDesc;
    108108    /** The userspace pointer to the buffer containing/receiving the data. */
    109109    void     *pvBuf;
     
    379379     */
    380380    pReqInt->AioCB.u16IoOpCode = uTransferDirection;
    381     pReqInt->AioCB.File        = (uint32_t)hFile;
     381    pReqInt->AioCB.uFileDesc   = RTFileToNative(hFile);
    382382    pReqInt->AioCB.off         = off;
    383383    pReqInt->AioCB.cbTransfer  = cbTransfer;
  • trunk/src/VBox/Runtime/r3/posix/RTFileQueryFsSizes-posix.cpp

    r28800 r37596  
    4848    struct statvfs StatVFS;
    4949    RT_ZERO(StatVFS);
    50     if (fstatvfs(hFile, &StatVFS))
     50    if (fstatvfs(RTFileToNative(hFile), &StatVFS))
    5151        return RTErrConvertFromErrno(errno);
    5252
  • trunk/src/VBox/Runtime/r3/posix/fileaio-posix.cpp

    r33540 r37596  
    55
    66/*
    7  * Copyright (C) 2006-2007 Oracle Corporation
     7 * Copyright (C) 2006-2011 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    407407    pReqInt->fFlush               = false;
    408408    pReqInt->AioCB.aio_lio_opcode = uTransferDirection;
    409     pReqInt->AioCB.aio_fildes     = (int)hFile;
     409    pReqInt->AioCB.aio_fildes     = RTFileToNative(hFile);
    410410    pReqInt->AioCB.aio_offset     = off;
    411411    pReqInt->AioCB.aio_nbytes     = cbTransfer;
     
    445445
    446446    pReqInt->fFlush           = true;
    447     pReqInt->AioCB.aio_fildes = (int)hFile;
     447    pReqInt->AioCB.aio_fildes = RTFileToNative(hFile);
    448448    pReqInt->AioCB.aio_offset = 0;
    449449    pReqInt->AioCB.aio_nbytes = 0;
  • trunk/src/VBox/Runtime/r3/posix/fileio-posix.cpp

    r36597 r37596  
    9393
    9494
    95 RTR3DECL(int) RTFileOpen(PRTFILE pFile, const char *pszFilename, uint32_t fOpen)
     95RTR3DECL(int) RTFileOpen(PRTFILE pFile, const char *pszFilename, uint64_t fOpen)
    9696{
    9797    /*
     
    111111    if (fOpen & RTFILE_O_NON_BLOCK)
    112112    {
    113         AssertMsgFailed(("Invalid parameters! fOpen=%#x\n", fOpen));
     113        AssertMsgFailed(("Invalid parameters! fOpen=%#llx\n", fOpen));
    114114        return VERR_INVALID_PARAMETER;
    115115    }
     
    177177            break;
    178178        default:
    179             AssertMsgFailed(("RTFileOpen received an invalid RW value, fOpen=%#x\n", fOpen));
     179            AssertMsgFailed(("RTFileOpen received an invalid RW value, fOpen=%#llx\n", fOpen));
    180180            return VERR_INVALID_PARAMETER;
    181181    }
     
    322322        if (iErr == 0)
    323323        {
    324             *pFile = (RTFILE)fh;
    325             Assert((int)*pFile == fh);
    326             LogFlow(("RTFileOpen(%p:{%RTfile}, %p:{%s}, %#x): returns %Rrc\n",
     324            *pFile = (RTFILE)(uintptr_t)fh;
     325            Assert((intptr_t)*pFile == fh);
     326            LogFlow(("RTFileOpen(%p:{%RTfile}, %p:{%s}, %#llx): returns %Rrc\n",
    327327                     pFile, *pFile, pszFilename, pszFilename, fOpen, rc));
    328328            return VINF_SUCCESS;
     
    335335
    336336
    337 RTR3DECL(int)  RTFileOpenBitBucket(PRTFILE phFile, uint32_t fAccess)
     337RTR3DECL(int)  RTFileOpenBitBucket(PRTFILE phFile, uint64_t fAccess)
    338338{
    339339    AssertReturn(   fAccess == RTFILE_O_READ
     
    345345
    346346
    347 RTR3DECL(int)  RTFileClose(RTFILE File)
    348 {
    349     if (File == NIL_RTFILE)
    350         return VINF_SUCCESS;
    351     if (close((int)File) == 0)
     347RTR3DECL(int)  RTFileClose(RTFILE hFile)
     348{
     349    if (hFile == NIL_RTFILE)
     350        return VINF_SUCCESS;
     351    if (close(RTFileToNative(hFile)) == 0)
    352352        return VINF_SUCCESS;
    353353    return RTErrConvertFromErrno(errno);
     
    357357RTR3DECL(int) RTFileFromNative(PRTFILE pFile, RTHCINTPTR uNative)
    358358{
    359     if (    uNative < 0
    360         ||  (RTFILE)uNative != (RTUINTPTR)uNative)
     359    AssertCompile(sizeof(uNative) == sizeof(*pFile));
     360    if (uNative < 0)
    361361    {
    362362        AssertMsgFailed(("%p\n", uNative));
     
    369369
    370370
    371 RTR3DECL(RTHCINTPTR) RTFileToNative(RTFILE File)
    372 {
    373     AssertReturn(File != NIL_RTFILE, -1);
    374     return (RTHCINTPTR)File;
     371RTR3DECL(RTHCINTPTR) RTFileToNative(RTFILE hFile)
     372{
     373    AssertReturn(hFile != NIL_RTFILE, -1);
     374    return (intptr_t)hFile;
    375375}
    376376
     
    411411
    412412
    413 RTR3DECL(int)  RTFileSeek(RTFILE File, int64_t offSeek, unsigned uMethod, uint64_t *poffActual)
     413RTR3DECL(int)  RTFileSeek(RTFILE hFile, int64_t offSeek, unsigned uMethod, uint64_t *poffActual)
    414414{
    415415    static const unsigned aSeekRecode[] =
     
    438438    }
    439439
    440     off_t offCurrent = lseek((int)File, (off_t)offSeek, aSeekRecode[uMethod]);
     440    off_t offCurrent = lseek(RTFileToNative(hFile), (off_t)offSeek, aSeekRecode[uMethod]);
    441441    if (offCurrent != ~0)
    442442    {
     
    449449
    450450
    451 RTR3DECL(int)  RTFileRead(RTFILE File, void *pvBuf, size_t cbToRead, size_t *pcbRead)
     451RTR3DECL(int)  RTFileRead(RTFILE hFile, void *pvBuf, size_t cbToRead, size_t *pcbRead)
    452452{
    453453    if (cbToRead <= 0)
     
    457457     * Attempt read.
    458458     */
    459     ssize_t cbRead = read((int)File, pvBuf, cbToRead);
     459    ssize_t cbRead = read(RTFileToNative(hFile), pvBuf, cbToRead);
    460460    if (cbRead >= 0)
    461461    {
     
    468468            while ((ssize_t)cbToRead > cbRead)
    469469            {
    470                 ssize_t cbReadPart = read((int)File, (char*)pvBuf + cbRead, cbToRead - cbRead);
     470                ssize_t cbReadPart = read(RTFileToNative(hFile), (char*)pvBuf + cbRead, cbToRead - cbRead);
    471471                if (cbReadPart <= 0)
    472472                {
     
    485485
    486486
    487 RTR3DECL(int)  RTFileWrite(RTFILE File, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten)
     487RTR3DECL(int)  RTFileWrite(RTFILE hFile, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten)
    488488{
    489489    if (cbToWrite <= 0)
     
    493493     * Attempt write.
    494494     */
    495     ssize_t cbWritten = write((int)File, pvBuf, cbToWrite);
     495    ssize_t cbWritten = write(RTFileToNative(hFile), pvBuf, cbToWrite);
    496496    if (cbWritten >= 0)
    497497    {
     
    504504            while ((ssize_t)cbToWrite > cbWritten)
    505505            {
    506                 ssize_t cbWrittenPart = write((int)File, (const char *)pvBuf + cbWritten, cbToWrite - cbWritten);
     506                ssize_t cbWrittenPart = write(RTFileToNative(hFile), (const char *)pvBuf + cbWritten, cbToWrite - cbWritten);
    507507                if (cbWrittenPart <= 0)
    508508                    return RTErrConvertFromErrno(errno);
     
    516516
    517517
    518 RTR3DECL(int)  RTFileSetSize(RTFILE File, uint64_t cbSize)
     518RTR3DECL(int)  RTFileSetSize(RTFILE hFile, uint64_t cbSize)
    519519{
    520520    /*
     
    529529
    530530#if defined(_MSC_VER) || (defined(RT_OS_OS2) && (!defined(__INNOTEK_LIBC__) || __INNOTEK_LIBC__ < 0x006))
    531     if (chsize((int)File, (off_t)cbSize) == 0)
     531    if (chsize(RTFileToNative(hFile), (off_t)cbSize) == 0)
    532532#else
    533533    /* This relies on a non-standard feature of FreeBSD, Linux, and OS/2
     
    535535     * than the file.)
    536536     */
    537     if (ftruncate((int)File, (off_t)cbSize) == 0)
     537    if (ftruncate(RTFileToNative(hFile), (off_t)cbSize) == 0)
    538538#endif
    539539        return VINF_SUCCESS;
     
    542542
    543543
    544 RTR3DECL(int)   RTFileGetSize(RTFILE File, uint64_t *pcbSize)
     544RTR3DECL(int)   RTFileGetSize(RTFILE hFile, uint64_t *pcbSize)
    545545{
    546546    struct stat st;
    547     if (!fstat((int)File, &st))
     547    if (!fstat(RTFileToNative(hFile), &st))
    548548    {
    549549        *pcbSize = st.st_size;
     
    554554
    555555
    556 /**
    557  * Determine the maximum file size.
    558  *
    559  * @returns IPRT status code.
    560  * @param   File        Handle to the file.
    561  * @param   pcbMax      Where to store the max file size.
    562  * @see     RTFileGetMaxSize.
    563  */
    564 RTR3DECL(int) RTFileGetMaxSizeEx(RTFILE File, PRTFOFF pcbMax)
     556RTR3DECL(int) RTFileGetMaxSizeEx(RTFILE hFile, PRTFOFF pcbMax)
    565557{
    566558    /*
     
    568560     */
    569561    uint64_t offOld;
    570     int rc = RTFileSeek(File, 0, RTFILE_SEEK_CURRENT, &offOld);
     562    int rc = RTFileSeek(hFile, 0, RTFILE_SEEK_CURRENT, &offOld);
    571563    if (RT_FAILURE(rc))
    572564        return rc;
     
    588580            if (pcbMax)
    589581                *pcbMax = offLow;
    590             return RTFileSeek(File, offOld, RTFILE_SEEK_BEGIN, NULL);
    591         }
    592 
    593         rc = RTFileSeek(File, offLow + cbInterval, RTFILE_SEEK_BEGIN, NULL);
     582            return RTFileSeek(hFile, offOld, RTFILE_SEEK_BEGIN, NULL);
     583        }
     584
     585        rc = RTFileSeek(hFile, offLow + cbInterval, RTFILE_SEEK_BEGIN, NULL);
    594586        if (RT_FAILURE(rc))
    595587            offHigh = offLow + cbInterval;
     
    600592
    601593
    602 RTR3DECL(bool) RTFileIsValid(RTFILE File)
    603 {
    604     if (File != NIL_RTFILE)
    605     {
    606         int fFlags = fcntl(File, F_GETFD);
     594RTR3DECL(bool) RTFileIsValid(RTFILE hFile)
     595{
     596    if (hFile != NIL_RTFILE)
     597    {
     598        int fFlags = fcntl(RTFileToNative(hFile), F_GETFD);
    607599        if (fFlags >= 0)
    608600            return true;
     
    612604
    613605
    614 RTR3DECL(int)  RTFileFlush(RTFILE File)
    615 {
    616     if (fsync((int)File))
     606RTR3DECL(int)  RTFileFlush(RTFILE hFile)
     607{
     608    if (fsync(RTFileToNative(hFile)))
    617609        return RTErrConvertFromErrno(errno);
    618610    return VINF_SUCCESS;
     
    620612
    621613
    622 RTR3DECL(int) RTFileIoCtl(RTFILE File, unsigned long ulRequest, void *pvData, unsigned cbData, int *piRet)
    623 {
    624     int rc = ioctl((int)File, ulRequest, pvData);
     614RTR3DECL(int) RTFileIoCtl(RTFILE hFile, unsigned long ulRequest, void *pvData, unsigned cbData, int *piRet)
     615{
     616    int rc = ioctl(RTFileToNative(hFile), ulRequest, pvData);
    625617    if (piRet)
    626618        *piRet = rc;
     
    629621
    630622
    631 RTR3DECL(int) RTFileSetMode(RTFILE File, RTFMODE fMode)
     623RTR3DECL(int) RTFileSetMode(RTFILE hFile, RTFMODE fMode)
    632624{
    633625    /*
     
    638630        return VERR_INVALID_PARAMETER;
    639631
    640     if (fchmod((int)File, fMode & RTFS_UNIX_MASK))
     632    if (fchmod(RTFileToNative(hFile), fMode & RTFS_UNIX_MASK))
    641633    {
    642634        int rc = RTErrConvertFromErrno(errno);
    643         Log(("RTFileSetMode(%RTfile,%RTfmode): returns %Rrc\n", File, fMode, rc));
     635        Log(("RTFileSetMode(%RTfile,%RTfmode): returns %Rrc\n", hFile, fMode, rc));
    644636        return rc;
    645637    }
  • trunk/src/VBox/Runtime/r3/posix/fileio2-posix.cpp

    r34016 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
     
    6969
    7070
    71 RTR3DECL(int) RTFileQueryInfo(RTFILE File, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAdditionalAttribs)
     71RTR3DECL(int) RTFileQueryInfo(RTFILE hFile, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAdditionalAttribs)
    7272{
    7373    /*
    7474     * Validate input.
    7575     */
    76     if (File == NIL_RTFILE)
    77     {
    78         AssertMsgFailed(("Invalid File=%RTfile\n", File));
    79         return VERR_INVALID_PARAMETER;
    80     }
    81     if (!pObjInfo)
    82     {
    83         AssertMsgFailed(("Invalid pObjInfo=%p\n", pObjInfo));
    84         return VERR_INVALID_PARAMETER;
    85     }
     76    AssertReturn(hFile != NIL_RTFILE, VERR_INVALID_PARAMETER);
     77    AssertPtrReturn(pObjInfo, VERR_INVALID_PARAMETER);
    8678    if (    enmAdditionalAttribs < RTFSOBJATTRADD_NOTHING
    8779        ||  enmAdditionalAttribs > RTFSOBJATTRADD_LAST)
     
    9587     */
    9688    struct stat Stat;
    97     if (fstat((int)File, &Stat))
     89    if (fstat(RTFileToNative(hFile), &Stat))
    9890    {
    9991        int rc = RTErrConvertFromErrno(errno);
    100         Log(("RTFileQueryInfo(%RTfile,,%d): returns %Rrc\n", File, enmAdditionalAttribs, rc));
     92        Log(("RTFileQueryInfo(%RTfile,,%d): returns %Rrc\n", hFile, enmAdditionalAttribs, rc));
    10193        return rc;
    10294    }
     
    135127    }
    136128
    137     LogFlow(("RTFileQueryInfo(%RTfile,,%d): returns VINF_SUCCESS\n", File, enmAdditionalAttribs));
     129    LogFlow(("RTFileQueryInfo(%RTfile,,%d): returns VINF_SUCCESS\n", hFile, enmAdditionalAttribs));
    138130    return VINF_SUCCESS;
    139131}
    140132
    141133
    142 RTR3DECL(int) RTFileSetTimes(RTFILE File, PCRTTIMESPEC pAccessTime, PCRTTIMESPEC pModificationTime,
     134RTR3DECL(int) RTFileSetTimes(RTFILE hFile, PCRTTIMESPEC pAccessTime, PCRTTIMESPEC pModificationTime,
    143135                             PCRTTIMESPEC pChangeTime, PCRTTIMESPEC pBirthTime)
    144136{
     
    163155    {
    164156        RTFSOBJINFO ObjInfo;
    165         int rc = RTFileQueryInfo(File, &ObjInfo, RTFSOBJATTRADD_UNIX);
     157        int rc = RTFileQueryInfo(hFile, &ObjInfo, RTFSOBJATTRADD_UNIX);
    166158        if (RT_FAILURE(rc))
    167159            return rc;
     
    170162    }
    171163
    172     if (futimes((int)File, aTimevals))
     164    if (futimes(RTFileToNative(hFile), aTimevals))
    173165    {
    174166        int rc = RTErrConvertFromErrno(errno);
    175         Log(("RTFileSetTimes(%RTfile,%p,%p,,): returns %Rrc\n", File, pAccessTime, pModificationTime, rc));
     167        Log(("RTFileSetTimes(%RTfile,%p,%p,,): returns %Rrc\n", hFile, pAccessTime, pModificationTime, rc));
    176168        return rc;
    177169    }
  • trunk/src/VBox/Runtime/r3/posix/filelock-posix.cpp

    r28800 r37596  
    55
    66/*
    7  * Copyright (C) 2006-2007 Oracle Corporation
     7 * Copyright (C) 2006-2011 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    5050
    5151
    52 RTR3DECL(int)  RTFileLock(RTFILE File, unsigned fLock, int64_t offLock, uint64_t cbLock)
     52RTR3DECL(int)  RTFileLock(RTFILE hFile, unsigned fLock, int64_t offLock, uint64_t cbLock)
    5353{
    5454    Assert(offLock >= 0);
     
    8383
    8484    Assert(RTFILE_LOCK_WAIT);
    85     if (fcntl(File, (fLock & RTFILE_LOCK_WAIT) ? F_SETLKW : F_SETLK, &fl) >= 0)
     85    if (fcntl(RTFileToNative(hFile), (fLock & RTFILE_LOCK_WAIT) ? F_SETLKW : F_SETLK, &fl) >= 0)
    8686        return VINF_SUCCESS;
    8787
     
    9595
    9696
    97 RTR3DECL(int)  RTFileChangeLock(RTFILE File, unsigned fLock, int64_t offLock, uint64_t cbLock)
     97RTR3DECL(int)  RTFileChangeLock(RTFILE hFile, unsigned fLock, int64_t offLock, uint64_t cbLock)
    9898{
    9999    /** @todo We never returns VERR_FILE_NOT_LOCKED for now. */
    100     return RTFileLock(File, fLock, offLock, cbLock);
     100    return RTFileLock(hFile, fLock, offLock, cbLock);
    101101}
    102102
    103103
    104 RTR3DECL(int)  RTFileUnlock(RTFILE File, int64_t offLock, uint64_t cbLock)
     104RTR3DECL(int)  RTFileUnlock(RTFILE hFile, int64_t offLock, uint64_t cbLock)
    105105{
    106106    Assert(offLock >= 0);
     
    126126    fl.l_pid    = 0;
    127127
    128     if (fcntl(File, F_SETLK, &fl) >= 0)
     128    if (fcntl(RTFileToNative(hFile), F_SETLK, &fl) >= 0)
    129129        return VINF_SUCCESS;
    130130
  • trunk/src/VBox/Runtime/r3/posix/rand-posix.cpp

    r28800 r37596  
    7979    pThis->u32Magic = ~RTRANDINT_MAGIC;
    8080    int fd = pThis->u.File.hFile;
    81     pThis->u.File.hFile = NIL_RTFILE;
     81    pThis->u.File.hFile = -1;
    8282    RTMemFree(pThis);
    8383    close(fd);
  • trunk/src/VBox/Runtime/r3/win/fileaio-win.cpp

    r35408 r37596  
    55
    66/*
    7  * Copyright (C) 2006-2007 Oracle Corporation
     7 * Copyright (C) 2006-2011 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    189189
    190190    pReqInt->enmTransferDirection  = enmTransferDirection;
    191     pReqInt->hFile                 = (HANDLE)hFile;
     191    pReqInt->hFile                 = RTFileToNative(hFile);
    192192    pReqInt->Overlapped.Offset     = (DWORD)(off & 0xffffffff);
    193193    pReqInt->Overlapped.OffsetHigh = (DWORD)(off >> 32);
     
    318318    RTFILEAIOCTX_VALID_RETURN(pCtxInt);
    319319
    320     HANDLE hTemp = CreateIoCompletionPort((HANDLE)hFile, pCtxInt->hIoCompletionPort, 0, 1);
     320    HANDLE hTemp = CreateIoCompletionPort(RTFileToNative(hFile), pCtxInt->hIoCompletionPort, 0, 1);
    321321    if (hTemp != pCtxInt->hIoCompletionPort)
    322322        rc = RTErrConvertFromWin32(GetLastError());
  • trunk/src/VBox/Runtime/r3/win/fileio-win.cpp

    r36601 r37596  
    55
    66/*
    7  * Copyright (C) 2006-2007 Oracle Corporation
     7 * Copyright (C) 2006-2011 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    5555 *
    5656 * @returns Success indicator. Extended error information obtainable using GetLastError().
    57  * @param   File        Filehandle.
     57 * @param   hFile       Filehandle.
    5858 * @param   offSeek     Offset to seek.
    5959 * @param   poffNew     Where to store the new file offset. NULL allowed.
    6060 * @param   uMethod     Seek method. (The windows one!)
    6161 */
    62 DECLINLINE(bool) MySetFilePointer(RTFILE File, uint64_t offSeek, uint64_t *poffNew, unsigned uMethod)
     62DECLINLINE(bool) MySetFilePointer(RTFILE hFile, uint64_t offSeek, uint64_t *poffNew, unsigned uMethod)
    6363{
    6464    bool            fRc;
     
    6969    if (off.LowPart != INVALID_SET_FILE_POINTER)
    7070    {
    71         off.LowPart = SetFilePointer((HANDLE)File, off.LowPart, &off.HighPart, uMethod);
     71        off.LowPart = SetFilePointer((HANDLE)RTFileToNative(hFile), off.LowPart, &off.HighPart, uMethod);
    7272        fRc = off.LowPart != INVALID_SET_FILE_POINTER;
    7373    }
     
    7575    {
    7676        SetLastError(NO_ERROR);
    77         off.LowPart = SetFilePointer((HANDLE)File, off.LowPart, &off.HighPart, uMethod);
     77        off.LowPart = SetFilePointer(RTFileToNative(hFile), off.LowPart, &off.HighPart, uMethod);
    7878        fRc = GetLastError() == NO_ERROR;
    7979    }
    8080#else
    81     fRc = SetFilePointerEx((HANDLE)File, off, &off, uMethod);
     81    fRc = SetFilePointerEx((HANDLE)RTFileToNative(hFile), off, &off, uMethod);
    8282#endif
    8383    if (fRc && poffNew)
     
    9292 *
    9393 * @returns true for file size limit exceeded.
    94  * @param   File        Filehandle.
     94 * @param   hFile       Filehandle.
    9595 * @param   offSeek     Offset to seek.
    9696 * @param   uMethod     The seek method.
    9797 */
    98 DECLINLINE(bool) IsBeyondLimit(RTFILE File, uint64_t offSeek, unsigned uMethod)
     98DECLINLINE(bool) IsBeyondLimit(RTFILE hFile, uint64_t offSeek, unsigned uMethod)
    9999{
    100100    bool fIsBeyondLimit = false;
     
    108108 * file seeking, only at the time of writing (and some other odd ones we cannot make use of). */
    109109    uint64_t offCurrent;
    110     if (MySetFilePointer(File, 0, &offCurrent, FILE_CURRENT))
    111     {
    112         if (!MySetFilePointer(File, offSeek, NULL, uMethod))
     110    if (MySetFilePointer(hFile, 0, &offCurrent, FILE_CURRENT))
     111    {
     112        if (!MySetFilePointer(hFile, offSeek, NULL, uMethod))
    113113            fIsBeyondLimit = GetLastError() == ERROR_SEEK;
    114114        else /* Restore file pointer on success. */
    115             MySetFilePointer(File, offCurrent, NULL, FILE_BEGIN);
     115            MySetFilePointer(hFile, offCurrent, NULL, FILE_BEGIN);
    116116    }
    117117
     
    135135
    136136
    137 RTR3DECL(RTHCINTPTR) RTFileToNative(RTFILE File)
    138 {
    139     AssertReturn(File != NIL_RTFILE, (RTHCINTPTR)INVALID_HANDLE_VALUE);
    140     return (RTHCINTPTR)File;
    141 }
    142 
    143 
    144 RTR3DECL(int) RTFileOpen(PRTFILE pFile, const char *pszFilename, uint32_t fOpen)
     137RTR3DECL(RTHCINTPTR) RTFileToNative(RTFILE hFile)
     138{
     139    AssertReturn(hFile != NIL_RTFILE, (RTHCINTPTR)INVALID_HANDLE_VALUE);
     140    return (RTHCINTPTR)hFile;
     141}
     142
     143
     144RTR3DECL(int) RTFileOpen(PRTFILE pFile, const char *pszFilename, uint64_t fOpen)
    145145{
    146146    /*
     
    186186            break;
    187187        default:
    188             AssertMsgFailed(("Impossible fOpen=%#x\n", fOpen));
     188            AssertMsgFailed(("Impossible fOpen=%#llx\n", fOpen));
    189189            return VERR_INVALID_PARAMETER;
    190190    }
     
    207207            break;
    208208        default:
    209             AssertMsgFailed(("Impossible fOpen=%#x\n", fOpen));
     209            AssertMsgFailed(("Impossible fOpen=%#llx\n", fOpen));
    210210            return VERR_INVALID_PARAMETER;
    211211    }
     
    228228                case RTFILE_O_READWRITE:     dwDesiredAccess |= FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES | SYNCHRONIZE; break;
    229229                default:
    230                     AssertMsgFailed(("Impossible fOpen=%#x\n", fOpen));
     230                    AssertMsgFailed(("Impossible fOpen=%#llx\n", fOpen));
    231231                    return VERR_INVALID_PARAMETER;
    232232            }
     
    246246        case RTFILE_O_DENY_NOT_DELETE | RTFILE_O_DENY_READWRITE:dwShareMode = FILE_SHARE_DELETE; break;
    247247        default:
    248             AssertMsgFailed(("Impossible fOpen=%#x\n", fOpen));
     248            AssertMsgFailed(("Impossible fOpen=%#llx\n", fOpen));
    249249            return VERR_INVALID_PARAMETER;
    250250    }
     
    329329
    330330
    331 RTR3DECL(int)  RTFileOpenBitBucket(PRTFILE phFile, uint32_t fAccess)
     331RTR3DECL(int)  RTFileOpenBitBucket(PRTFILE phFile, uint64_t fAccess)
    332332{
    333333    AssertReturn(   fAccess == RTFILE_O_READ
     
    339339
    340340
    341 RTR3DECL(int)  RTFileClose(RTFILE File)
    342 {
    343     if (File == NIL_RTFILE)
    344         return VINF_SUCCESS;
    345     if (CloseHandle((HANDLE)File))
     341RTR3DECL(int)  RTFileClose(RTFILE hFile)
     342{
     343    if (hFile == NIL_RTFILE)
     344        return VINF_SUCCESS;
     345    if (CloseHandle((HANDLE)RTFileToNative(hFile)))
    346346        return VINF_SUCCESS;
    347347    return RTErrConvertFromWin32(GetLastError());
     
    372372
    373373
    374 RTR3DECL(int)  RTFileSeek(RTFILE File, int64_t offSeek, unsigned uMethod, uint64_t *poffActual)
     374RTR3DECL(int)  RTFileSeek(RTFILE hFile, int64_t offSeek, unsigned uMethod, uint64_t *poffActual)
    375375{
    376376    static ULONG aulSeekRecode[] =
     
    393393     * Execute the seek.
    394394     */
    395     if (MySetFilePointer(File, offSeek, poffActual, aulSeekRecode[uMethod]))
     395    if (MySetFilePointer(hFile, offSeek, poffActual, aulSeekRecode[uMethod]))
    396396        return VINF_SUCCESS;
    397397    return RTErrConvertFromWin32(GetLastError());
     
    399399
    400400
    401 RTR3DECL(int)  RTFileRead(RTFILE File, void *pvBuf, size_t cbToRead, size_t *pcbRead)
     401RTR3DECL(int)  RTFileRead(RTFILE hFile, void *pvBuf, size_t cbToRead, size_t *pcbRead)
    402402{
    403403    if (cbToRead <= 0)
     
    407407
    408408    ULONG cbRead = 0;
    409     if (ReadFile((HANDLE)File, pvBuf, cbToReadAdj, &cbRead, NULL))
     409    if (ReadFile((HANDLE)RTFileToNative(hFile), pvBuf, cbToReadAdj, &cbRead, NULL))
    410410    {
    411411        if (pcbRead)
     
    418418            {
    419419                ULONG cbReadPart = 0;
    420                 if (!ReadFile((HANDLE)File, (char*)pvBuf + cbRead, cbToReadAdj - cbRead, &cbReadPart, NULL))
     420                if (!ReadFile((HANDLE)RTFileToNative(hFile), (char*)pvBuf + cbRead, cbToReadAdj - cbRead, &cbReadPart, NULL))
    421421                    return RTErrConvertFromWin32(GetLastError());
    422422                if (cbReadPart == 0)
     
    446446            ULONG cbToRead   = RT_MIN(cbChunk, cbToReadAdj - cbRead);
    447447            ULONG cbReadPart = 0;
    448             if (!ReadFile((HANDLE)File, (char *)pvBuf + cbRead, cbToRead, &cbReadPart, NULL))
     448            if (!ReadFile((HANDLE)RTFileToNative(hFile), (char *)pvBuf + cbRead, cbToRead, &cbReadPart, NULL))
    449449            {
    450450                /* If we failed because the buffer is too big, shrink it and
     
    478478
    479479
    480 RTR3DECL(int)  RTFileWrite(RTFILE File, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten)
     480RTR3DECL(int)  RTFileWrite(RTFILE hFile, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten)
    481481{
    482482    if (cbToWrite <= 0)
     
    486486
    487487    ULONG cbWritten = 0;
    488     if (WriteFile((HANDLE)File, pvBuf, cbToWriteAdj, &cbWritten, NULL))
     488    if (WriteFile((HANDLE)RTFileToNative(hFile), pvBuf, cbToWriteAdj, &cbWritten, NULL))
    489489    {
    490490        if (pcbWritten)
     
    497497            {
    498498                ULONG cbWrittenPart = 0;
    499                 if (!WriteFile((HANDLE)File, (char*)pvBuf + cbWritten, cbToWriteAdj - cbWritten, &cbWrittenPart, NULL))
     499                if (!WriteFile((HANDLE)RTFileToNative(hFile), (char*)pvBuf + cbWritten,
     500                               cbToWriteAdj - cbWritten, &cbWrittenPart, NULL))
    500501                {
    501502                    int rc = RTErrConvertFromWin32(GetLastError());
    502503                    if (   rc == VERR_DISK_FULL
    503                         && IsBeyondLimit(File, cbToWriteAdj - cbWritten, FILE_CURRENT)
     504                        && IsBeyondLimit(RTFileToNative(hFile), cbToWriteAdj - cbWritten, FILE_CURRENT)
    504505                       )
    505506                        rc = VERR_FILE_TOO_BIG;
     
    532533            ULONG cbToWrite     = RT_MIN(cbChunk, cbToWriteAdj - cbWritten);
    533534            ULONG cbWrittenPart = 0;
    534             if (!WriteFile((HANDLE)File, (const char *)pvBuf + cbWritten, cbToWrite, &cbWrittenPart, NULL))
     535            if (!WriteFile((HANDLE)RTFileToNative(hFile), (const char *)pvBuf + cbWritten, cbToWrite, &cbWrittenPart, NULL))
    535536            {
    536537                /* If we failed because the buffer is too big, shrink it and
     
    545546                int rc = RTErrConvertFromWin32(dwErr);
    546547                if (   rc == VERR_DISK_FULL
    547                     && IsBeyondLimit(File, cbToWriteAdj - cbWritten, FILE_CURRENT))
     548                    && IsBeyondLimit(hFile, cbToWriteAdj - cbWritten, FILE_CURRENT))
    548549                    rc = VERR_FILE_TOO_BIG;
    549550                return rc;
     
    566567    int rc = RTErrConvertFromWin32(dwErr);
    567568    if (   rc == VERR_DISK_FULL
    568         && IsBeyondLimit(File, cbToWriteAdj - cbWritten, FILE_CURRENT))
     569        && IsBeyondLimit(hFile, cbToWriteAdj - cbWritten, FILE_CURRENT))
    569570        rc = VERR_FILE_TOO_BIG;
    570571    return rc;
     
    572573
    573574
    574 RTR3DECL(int)  RTFileFlush(RTFILE File)
    575 {
    576     if (!FlushFileBuffers((HANDLE)File))
     575RTR3DECL(int)  RTFileFlush(RTFILE hFile)
     576{
     577    if (!FlushFileBuffers((HANDLE)RTFileToNative(hFile)))
    577578    {
    578579        int rc = GetLastError();
     
    584585
    585586
    586 RTR3DECL(int)  RTFileSetSize(RTFILE File, uint64_t cbSize)
     587RTR3DECL(int)  RTFileSetSize(RTFILE hFile, uint64_t cbSize)
    587588{
    588589    /*
     
    591592    int         rc;
    592593    uint64_t    offCurrent;
    593     if (MySetFilePointer(File, 0, &offCurrent, FILE_CURRENT))
     594    if (MySetFilePointer(hFile, 0, &offCurrent, FILE_CURRENT))
    594595    {
    595596        /*
    596597         * Set new file pointer.
    597598         */
    598         if (MySetFilePointer(File, cbSize, NULL, FILE_BEGIN))
     599        if (MySetFilePointer(hFile, cbSize, NULL, FILE_BEGIN))
    599600        {
    600601            /* set file pointer */
    601             if (SetEndOfFile((HANDLE)File))
     602            if (SetEndOfFile((HANDLE)RTFileToNative(hFile)))
    602603            {
    603604                /*
     
    605606                 * If the old pointer was beyond the new file end, ignore failure.
    606607                 */
    607                 if (    MySetFilePointer(File, offCurrent, NULL, FILE_BEGIN)
     608                if (    MySetFilePointer(hFile, offCurrent, NULL, FILE_BEGIN)
    608609                    ||  offCurrent > cbSize)
    609610                    return VINF_SUCCESS;
     
    614615             */
    615616            rc = GetLastError();
    616             MySetFilePointer(File, offCurrent, NULL, FILE_BEGIN);
     617            MySetFilePointer(hFile, offCurrent, NULL, FILE_BEGIN);
    617618        }
    618619        else
     
    626627
    627628
    628 RTR3DECL(int)  RTFileGetSize(RTFILE File, uint64_t *pcbSize)
     629RTR3DECL(int)  RTFileGetSize(RTFILE hFile, uint64_t *pcbSize)
    629630{
    630631    ULARGE_INTEGER  Size;
    631     Size.LowPart = GetFileSize((HANDLE)File, &Size.HighPart);
     632    Size.LowPart = GetFileSize((HANDLE)RTFileToNative(hFile), &Size.HighPart);
    632633    if (Size.LowPart != INVALID_FILE_SIZE)
    633634    {
     
    641642
    642643
    643 RTR3DECL(int) RTFileGetMaxSizeEx(RTFILE File, PRTFOFF pcbMax)
     644RTR3DECL(int) RTFileGetMaxSizeEx(RTFILE hFile, PRTFOFF pcbMax)
    644645{
    645646    /** @todo r=bird:
     
    653654
    654655
    655 RTR3DECL(bool) RTFileIsValid(RTFILE File)
    656 {
    657     if (File != NIL_RTFILE)
    658     {
    659         DWORD dwType = GetFileType((HANDLE)File);
     656RTR3DECL(bool) RTFileIsValid(RTFILE hFile)
     657{
     658    if (hFile != NIL_RTFILE)
     659    {
     660        DWORD dwType = GetFileType((HANDLE)RTFileToNative(hFile));
    660661        switch (dwType)
    661662        {
     
    679680#define HIGH_DWORD(u64) (((DWORD *)&u64)[1])
    680681
    681 RTR3DECL(int)  RTFileLock(RTFILE File, unsigned fLock, int64_t offLock, uint64_t cbLock)
     682RTR3DECL(int)  RTFileLock(RTFILE hFile, unsigned fLock, int64_t offLock, uint64_t cbLock)
    682683{
    683684    Assert(offLock >= 0);
     
    704705
    705706    /* Note: according to Microsoft, LockFileEx API call is available starting from NT 3.5 */
    706     if (LockFileEx((HANDLE)File, dwFlags, 0, LOW_DWORD(cbLock), HIGH_DWORD(cbLock), &Overlapped))
     707    if (LockFileEx((HANDLE)RTFileToNative(hFile), dwFlags, 0, LOW_DWORD(cbLock), HIGH_DWORD(cbLock), &Overlapped))
    707708        return VINF_SUCCESS;
    708709
     
    711712
    712713
    713 RTR3DECL(int)  RTFileChangeLock(RTFILE File, unsigned fLock, int64_t offLock, uint64_t cbLock)
     714RTR3DECL(int)  RTFileChangeLock(RTFILE hFile, unsigned fLock, int64_t offLock, uint64_t cbLock)
    714715{
    715716    Assert(offLock >= 0);
     
    723724
    724725    /* Remove old lock. */
    725     int rc = RTFileUnlock(File, offLock, cbLock);
     726    int rc = RTFileUnlock(hFile, offLock, cbLock);
    726727    if (RT_FAILURE(rc))
    727728        return rc;
    728729
    729730    /* Set new lock. */
    730     rc = RTFileLock(File, fLock, offLock, cbLock);
     731    rc = RTFileLock(hFile, fLock, offLock, cbLock);
    731732    if (RT_SUCCESS(rc))
    732733        return rc;
     
    734735    /* Try to restore old lock. */
    735736    unsigned fLockOld = (fLock & RTFILE_LOCK_WRITE) ? fLock & ~RTFILE_LOCK_WRITE : fLock | RTFILE_LOCK_WRITE;
    736     rc = RTFileLock(File, fLockOld, offLock, cbLock);
     737    rc = RTFileLock(hFile, fLockOld, offLock, cbLock);
    737738    if (RT_SUCCESS(rc))
    738739        return VERR_FILE_LOCK_VIOLATION;
     
    742743
    743744
    744 RTR3DECL(int)  RTFileUnlock(RTFILE File, int64_t offLock, uint64_t cbLock)
     745RTR3DECL(int)  RTFileUnlock(RTFILE hFile, int64_t offLock, uint64_t cbLock)
    745746{
    746747    Assert(offLock >= 0);
    747748
    748     if (UnlockFile((HANDLE)File, LOW_DWORD(offLock), HIGH_DWORD(offLock), LOW_DWORD(cbLock), HIGH_DWORD(cbLock)))
     749    if (UnlockFile((HANDLE)RTFileToNative(hFile),
     750                   LOW_DWORD(offLock), HIGH_DWORD(offLock),
     751                   LOW_DWORD(cbLock), HIGH_DWORD(cbLock)))
    749752        return VINF_SUCCESS;
    750753
     
    754757
    755758
    756 RTR3DECL(int) RTFileQueryInfo(RTFILE File, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAdditionalAttribs)
     759RTR3DECL(int) RTFileQueryInfo(RTFILE hFile, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAdditionalAttribs)
    757760{
    758761    /*
    759762     * Validate input.
    760763     */
    761     if (File == NIL_RTFILE)
    762     {
    763         AssertMsgFailed(("Invalid File=%RTfile\n", File));
     764    if (hFile == NIL_RTFILE)
     765    {
     766        AssertMsgFailed(("Invalid hFile=%RTfile\n", hFile));
    764767        return VERR_INVALID_PARAMETER;
    765768    }
     
    780783     */
    781784    BY_HANDLE_FILE_INFORMATION Data;
    782     if (!GetFileInformationByHandle((HANDLE)File, &Data))
     785    if (!GetFileInformationByHandle((HANDLE)RTFileToNative(hFile), &Data))
    783786    {
    784787        DWORD dwErr = GetLastError();
     
    851854
    852855
    853 RTR3DECL(int) RTFileSetTimes(RTFILE File, PCRTTIMESPEC pAccessTime, PCRTTIMESPEC pModificationTime,
     856RTR3DECL(int) RTFileSetTimes(RTFILE hFile, PCRTTIMESPEC pAccessTime, PCRTTIMESPEC pModificationTime,
    854857                             PCRTTIMESPEC pChangeTime, PCRTTIMESPEC pBirthTime)
    855858{
     
    873876
    874877    int rc = VINF_SUCCESS;
    875     if (!SetFileTime((HANDLE)File, pCreationTimeFT, pLastAccessTimeFT, pLastWriteTimeFT))
     878    if (!SetFileTime((HANDLE)RTFileToNative(hFile), pCreationTimeFT, pLastAccessTimeFT, pLastWriteTimeFT))
    876879    {
    877880        DWORD Err = GetLastError();
    878881        rc = RTErrConvertFromWin32(Err);
    879882        Log(("RTFileSetTimes(%RTfile, %p, %p, %p, %p): SetFileTime failed with lasterr %d (%Rrc)\n",
    880              File, pAccessTime, pModificationTime, pChangeTime, pBirthTime, Err, rc));
     883             hFile, pAccessTime, pModificationTime, pChangeTime, pBirthTime, Err, rc));
    881884    }
    882885    return rc;
     
    890893
    891894
    892 RTR3DECL(int) RTFileSetMode(RTFILE File, RTFMODE fMode)
     895RTR3DECL(int) RTFileSetMode(RTFILE hFile, RTFMODE fMode)
    893896{
    894897    /*
     
    900903
    901904    ULONG FileAttributes = (fMode & RTFS_DOS_MASK) >> RTFS_DOS_SHIFT;
    902     int Err = rtFileNativeSetAttributes((HANDLE)File, FileAttributes);
     905    int Err = rtFileNativeSetAttributes((HANDLE)hFile, FileAttributes);
    903906    if (Err != ERROR_SUCCESS)
    904907    {
    905908        int rc = RTErrConvertFromWin32(Err);
    906909        Log(("RTFileSetMode(%RTfile, %RTfmode): rtFileNativeSetAttributes (0x%08X) failed with err %d (%Rrc)\n",
    907              File, fMode, FileAttributes, Err, rc));
     910             hFile, fMode, FileAttributes, Err, rc));
    908911        return rc;
    909912    }
  • trunk/src/VBox/Runtime/r3/win/rtFileNativeSetAttributes-win.cpp

    r28800 r37596  
    6060
    6161    /** @todo resolve dynamically to avoid dragging in NtDll? */
    62     NTSTATUS Status = NtSetInformationFile(hFile,
     62    NTSTATUS Status = NtSetInformationFile(RTFileToNative(hFile),
    6363                                           &IoStatusBlock,
    6464                                           &Info,
  • trunk/src/VBox/VMM/VMMR3/PDMAsyncCompletionFile.cpp

    r37045 r37596  
    10121012         * contain dirty buffers.
    10131013         */
    1014         RTFILE File = NIL_RTFILE;
    1015 
    1016         rc = RTFileOpen(&File, pszUri, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
     1014        RTFILE hFile = NIL_RTFILE;
     1015
     1016        rc = RTFileOpen(&hFile, pszUri, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
    10171017        if (RT_SUCCESS(rc))
    10181018        {
    10191019            uint64_t cbSize;
    10201020
    1021             rc = pdmacFileEpNativeGetSize(File, &cbSize);
     1021            rc = pdmacFileEpNativeGetSize(hFile, &cbSize);
    10221022            Assert(RT_FAILURE(rc) || cbSize != 0);
    10231023
     
    10341034#endif
    10351035            }
    1036             RTFileClose(File);
     1036            RTFileClose(hFile);
    10371037        }
    10381038    }
    10391039
    10401040    /* Open with final flags. */
    1041     rc = RTFileOpen(&pEpFile->File, pszUri, fFileFlags);
     1041    rc = RTFileOpen(&pEpFile->hFile, pszUri, fFileFlags);
    10421042    if ((rc == VERR_INVALID_FUNCTION) || (rc == VERR_INVALID_PARAMETER))
    10431043    {
     
    10641064
    10651065        /* Open again. */
    1066         rc = RTFileOpen(&pEpFile->File, pszUri, fFileFlags);
     1066        rc = RTFileOpen(&pEpFile->hFile, pszUri, fFileFlags);
    10671067
    10681068        if (RT_FAILURE(rc))
     
    10771077        pEpFile->fFlags = fFileFlags;
    10781078
    1079         rc = pdmacFileEpNativeGetSize(pEpFile->File, (uint64_t *)&pEpFile->cbFile);
     1079        rc = pdmacFileEpNativeGetSize(pEpFile->hFile, (uint64_t *)&pEpFile->cbFile);
    10801080        Assert(RT_FAILURE(rc) || pEpFile->cbFile != 0);
    10811081
     
    11471147
    11481148        if (RT_FAILURE(rc))
    1149             RTFileClose(pEpFile->File);
     1149            RTFileClose(pEpFile->hFile);
    11501150    }
    11511151
     
    12071207    RTAvlrFileOffsetDestroy(pEpFile->AioMgr.pTreeRangesLocked, pdmacFileEpRangesLockedDestroy, NULL);
    12081208
    1209     RTFileClose(pEpFile->File);
     1209    RTFileClose(pEpFile->hFile);
    12101210
    12111211#ifdef VBOX_WITH_STATISTICS
     
    13011301
    13021302    ASMAtomicWriteU64(&pEpFile->cbFile, cbSize);
    1303     return RTFileSetSize(pEpFile->File, cbSize);
     1303    return RTFileSetSize(pEpFile->hFile, cbSize);
    13041304}
    13051305
  • trunk/src/VBox/VMM/VMMR3/PDMAsyncCompletionFileFailsafe.cpp

    r36001 r37596  
    7878            case PDMACTASKFILETRANSFER_FLUSH:
    7979            {
    80                 rc = RTFileFlush(pEndpoint->File);
     80                rc = RTFileFlush(pEndpoint->hFile);
    8181                break;
    8282            }
     
    8686                if (pCurr->enmTransferType == PDMACTASKFILETRANSFER_READ)
    8787                {
    88                     rc = RTFileReadAt(pEndpoint->File, pCurr->Off,
     88                    rc = RTFileReadAt(pEndpoint->hFile, pCurr->Off,
    8989                                      pCurr->DataSeg.pvSeg,
    9090                                      pCurr->DataSeg.cbSeg,
     
    9696                    {
    9797                        ASMAtomicWriteU64(&pEndpoint->cbFile, pCurr->Off + pCurr->DataSeg.cbSeg);
    98                         RTFileSetSize(pEndpoint->File, pCurr->Off + pCurr->DataSeg.cbSeg);
     98                        RTFileSetSize(pEndpoint->hFile, pCurr->Off + pCurr->DataSeg.cbSeg);
    9999                    }
    100100
    101                     rc = RTFileWriteAt(pEndpoint->File, pCurr->Off,
     101                    rc = RTFileWriteAt(pEndpoint->hFile, pCurr->Off,
    102102                                       pCurr->DataSeg.pvSeg,
    103103                                       pCurr->DataSeg.cbSeg,
  • trunk/src/VBox/VMM/VMMR3/PDMAsyncCompletionFileNormal.cpp

    r37045 r37596  
    205205
    206206        /* Reopen the file so that the new endpoint can re-associate with the file */
    207         RTFileClose(pEndpointRemove->File);
    208         int rc = RTFileOpen(&pEndpointRemove->File, pEndpointRemove->Core.pszUri, pEndpointRemove->fFlags);
     207        RTFileClose(pEndpointRemove->hFile);
     208        int rc = RTFileOpen(&pEndpointRemove->hFile, pEndpointRemove->Core.pszUri, pEndpointRemove->fFlags);
    209209        AssertRC(rc);
    210210        return false;
     
    341341    while (pCurr)
    342342    {
    343         RTFileClose(pCurr->File);
    344         rc = RTFileOpen(&pCurr->File, pCurr->Core.pszUri, pCurr->fFlags);
     343        RTFileClose(pCurr->hFile);
     344        rc = RTFileOpen(&pCurr->hFile, pCurr->Core.pszUri, pCurr->fFlags);
    345345        AssertRC(rc);
    346346
     
    390390    while (pCurr)
    391391    {
    392         rc = RTFileAioCtxAssociateWithFile(pAioMgr->hAioCtx, pCurr->File);
     392        rc = RTFileAioCtxAssociateWithFile(pAioMgr->hAioCtx, pCurr->hFile);
    393393        AssertRC(rc);
    394394
     
    790790            {
    791791                ASMAtomicWriteU64(&pEndpoint->cbFile, pTask->Off + pTask->DataSeg.cbSeg);
    792                 RTFileSetSize(pEndpoint->File, pTask->Off + pTask->DataSeg.cbSeg);
    793             }
    794 
    795             rc = RTFileAioReqPrepareWrite(hReq, pEndpoint->File,
     792                RTFileSetSize(pEndpoint->hFile, pTask->Off + pTask->DataSeg.cbSeg);
     793            }
     794
     795            rc = RTFileAioReqPrepareWrite(hReq, pEndpoint->hFile,
    796796                                          pTask->Off, pTask->DataSeg.pvSeg,
    797797                                          pTask->DataSeg.cbSeg, pTask);
    798798        }
    799799        else
    800             rc = RTFileAioReqPrepareRead(hReq, pEndpoint->File,
     800            rc = RTFileAioReqPrepareRead(hReq, pEndpoint->hFile,
    801801                                         pTask->Off, pTask->DataSeg.pvSeg,
    802802                                         pTask->DataSeg.cbSeg, pTask);
     
    925925                {
    926926                    ASMAtomicWriteU64(&pEndpoint->cbFile, pTask->Off + pTask->DataSeg.cbSeg);
    927                     RTFileSetSize(pEndpoint->File, pTask->Off + pTask->DataSeg.cbSeg);
    928                 }
    929 
    930                 rc = RTFileAioReqPrepareWrite(hReq, pEndpoint->File,
     927                    RTFileSetSize(pEndpoint->hFile, pTask->Off + pTask->DataSeg.cbSeg);
     928                }
     929
     930                rc = RTFileAioReqPrepareWrite(hReq, pEndpoint->hFile,
    931931                                              offStart, pvBuf, cbToTransfer, pTask);
    932932            }
    933933            else
    934                 rc = RTFileAioReqPrepareRead(hReq, pEndpoint->File,
     934                rc = RTFileAioReqPrepareRead(hReq, pEndpoint->hFile,
    935935                                             offStart, pvBuf, cbToTransfer, pTask);
    936936            AssertRC(rc);
     
    10041004                    LogFlow(("Flush request %#p\n", hReq));
    10051005
    1006                     rc = RTFileAioReqPrepareFlush(hReq, pEndpoint->File, pCurr);
     1006                    rc = RTFileAioReqPrepareFlush(hReq, pEndpoint->hFile, pCurr);
    10071007                    if (RT_FAILURE(rc))
    10081008                    {
     
    11891189
    11901190            /* Assign the completion point to this file. */
    1191             rc = RTFileAioCtxAssociateWithFile(pAioMgr->hAioCtx, pEndpointNew->File);
     1191            rc = RTFileAioCtxAssociateWithFile(pAioMgr->hAioCtx, pEndpointNew->hFile);
    11921192            fNotifyWaiter = true;
    11931193            pAioMgr->cEndpoints++;
     
    12891289        {
    12901290            /* Reopen the file so that the new endpoint can re-associate with the file */
    1291             RTFileClose(pEndpoint->File);
    1292             rc = RTFileOpen(&pEndpoint->File, pEndpoint->Core.pszUri, pEndpoint->fFlags);
     1291            RTFileClose(pEndpoint->hFile);
     1292            rc = RTFileOpen(&pEndpoint->hFile, pEndpoint->Core.pszUri, pEndpoint->fFlags);
    12931293            AssertRC(rc);
    12941294
     
    14721472                if (pTask->fPrefetch || pTask->enmTransferType == PDMACTASKFILETRANSFER_READ)
    14731473                {
    1474                     rc = RTFileAioReqPrepareRead(hReq, pEndpoint->File, offStart,
     1474                    rc = RTFileAioReqPrepareRead(hReq, pEndpoint->hFile, offStart,
    14751475                                                 pbBuf, cbToTransfer, pTask);
    14761476                }
     
    14791479                    AssertMsg(pTask->enmTransferType == PDMACTASKFILETRANSFER_WRITE,
    14801480                                  ("Invalid transfer type\n"));
    1481                     rc = RTFileAioReqPrepareWrite(hReq, pEndpoint->File, offStart,
     1481                    rc = RTFileAioReqPrepareWrite(hReq, pEndpoint->hFile, offStart,
    14821482                                                  pbBuf, cbToTransfer, pTask);
    14831483                }
     
    15071507                {
    15081508                    ASMAtomicWriteU64(&pEndpoint->cbFile, pTask->Off + pTask->DataSeg.cbSeg);
    1509                     RTFileSetSize(pEndpoint->File, pTask->Off + pTask->DataSeg.cbSeg);
    1510                 }
    1511 
    1512                 rc = RTFileAioReqPrepareWrite(hReq, pEndpoint->File,
     1509                    RTFileSetSize(pEndpoint->hFile, pTask->Off + pTask->DataSeg.cbSeg);
     1510                }
     1511
     1512                rc = RTFileAioReqPrepareWrite(hReq, pEndpoint->hFile,
    15131513                                              offStart, pTask->pvBounceBuffer, cbToTransfer, pTask);
    15141514                AssertRC(rc);
  • trunk/src/VBox/VMM/include/PDMAsyncCompletionFileInternal.h

    r36799 r37596  
    327327    unsigned                               fFlags;
    328328    /** File handle. */
    329     RTFILE                                 File;
     329    RTFILE                                 hFile;
    330330    /**
    331331     * Real size of the file. Only updated if
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