Changeset 37596 in vbox for trunk/src/VBox
- Timestamp:
- Jun 22, 2011 7:30:06 PM (14 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 59 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3Lib.cpp
r36408 r37596 188 188 } 189 189 } 190 g_File = hf;190 g_File = (RTFILE)hf; 191 191 192 192 #elif defined(VBOX_VBGLR3_XFREE86) … … 267 267 g_File = NIL_RTFILE; 268 268 AssertReturnVoid(File != NIL_RTFILE); 269 APIRET rc = DosClose( File);269 APIRET rc = DosClose((uintptr_t)File); 270 270 AssertMsg(!rc, ("%ld\n", rc)); 271 271 … … 323 323 int32_t vrc = VERR_INTERNAL_ERROR; 324 324 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, 326 326 pvData, cbData, &cbOS2Parm, 327 327 &vrc, sizeof(vrc), &cbOS2Data); … … 344 344 * header with an error code return field (much better alternative 345 345 * actually). */ 346 int rc = ioctl( (int)g_File, iFunction, &Hdr);346 int rc = ioctl(RTFileToNative(g_File), iFunction, &Hdr); 347 347 if (rc == -1) 348 348 { … … 356 356 int rc = xf86ioctl((int)g_File, iFunction, pvData); 357 357 # else 358 int rc = ioctl( (int)g_File, iFunction, pvData);358 int rc = ioctl(RTFileToNative(g_File), iFunction, pvData); 359 359 # endif 360 360 if (RT_LIKELY(rc == 0)) -
trunk/src/VBox/Devices/Network/DrvNAT.cpp
r35922 r37596 5 5 6 6 /* 7 * Copyright (C) 2006-201 0Oracle Corporation7 * Copyright (C) 2006-2011 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 28 28 #include <VBox/vmm/pdmnetifs.h> 29 29 #include <VBox/vmm/pdmnetinline.h> 30 30 31 #include <iprt/assert.h> 32 #include <iprt/critsect.h> 33 #include <iprt/cidr.h> 31 34 #include <iprt/file.h> 32 35 #include <iprt/mem.h> 36 #include <iprt/pipe.h> 33 37 #include <iprt/string.h> 34 #include <iprt/critsect.h>35 #include <iprt/cidr.h>36 38 #include <iprt/stream.h> 37 39 #include <iprt/uuid.h> … … 163 165 #ifndef RT_OS_WINDOWS 164 166 /** The write end of the control pipe. */ 165 RT FILEPipeWrite;167 RTPIPE hPipeWrite; 166 168 /** The read end of the control pipe. */ 167 RT FILEPipeRead;169 RTPIPE hPipeRead; 168 170 #else 169 171 /** for external notification */ … … 569 571 #ifndef RT_OS_WINDOWS 570 572 /* kick poll() */ 571 rc = RTFileWrite(pThis->PipeWrite, "", 1, NULL); 573 size_t cbIgnored; 574 rc = RTPipeWrite(pThis->hPipeWrite, "", 1, &cbIgnored); 572 575 #else 573 576 /* kick WSAWaitForMultipleEvents */ … … 744 747 slirp_select_fill(pThis->pNATState, &nFDs, &polls[1]); 745 748 746 polls[0].fd = pThis->PipeRead;749 polls[0].fd = RTPipeToNative(pThis->hPipeRead); 747 750 /* 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; 749 752 polls[0].revents = 0; 750 753 … … 770 773 if (polls[0].revents & (POLLRDNORM|POLLPRI|POLLRDBAND)) 771 774 { 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 778 778 * device's thread sends before we've entered multiplex, 779 779 * so to avoid false alarm drain pipe here to the very end … … 782 782 * deep pipe has been filed before drain. 783 783 * 784 * XXX:Make it reading exactly we need to drain the pipe.785 784 */ 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); 789 790 } 790 791 } … … 1345 1346 * Create the control pipe. 1346 1347 */ 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); 1356 1350 #else 1357 1351 pThis->hWakeupEvent = CreateEvent(NULL, FALSE, FALSE, NULL); /* auto-reset event */ … … 1362 1356 rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pSlirpThread, pThis, drvNATAsyncIoThread, 1363 1357 drvNATAsyncIoWakeup, 128 * _1K, RTTHREADTYPE_IO, "NAT"); 1364 AssertRC (rc);1358 AssertRCReturn(rc, rc); 1365 1359 1366 1360 #ifdef VBOX_WITH_SLIRP_MT 1367 1361 rc = PDMDrvHlpThreadCreate(pDrvIns, &pThis->pGuestThread, pThis, drvNATAsyncIoGuest, 1368 1362 drvNATAsyncIoGuestWakeup, 128 * _1K, RTTHREADTYPE_IO, "NATGUEST"); 1369 AssertRC (rc);1363 AssertRCReturn(rc, rc); 1370 1364 #endif 1371 1365 -
trunk/src/VBox/Devices/Network/DrvNetSniffer.cpp
r37461 r37596 66 66 char szFilename[RTPATH_MAX]; 67 67 /** The filehandle. */ 68 RTFILE File;68 RTFILE hFile; 69 69 /** The lock serializing the file access. */ 70 70 RTCRITSECT Lock; … … 134 134 RTCritSectEnter(&pThis->Lock); 135 135 if (!pSgBuf->pvUser) 136 PcapFileFrame(pThis-> File, pThis->StartNanoTS,136 PcapFileFrame(pThis->hFile, pThis->StartNanoTS, 137 137 pSgBuf->aSegs[0].pvSeg, 138 138 pSgBuf->cbUsed, 139 139 RT_MIN(pSgBuf->cbUsed, pSgBuf->aSegs[0].cbSeg)); 140 140 else 141 PcapFileGsoFrame(pThis-> File, pThis->StartNanoTS, (PCPDMNETWORKGSO)pSgBuf->pvUser,141 PcapFileGsoFrame(pThis->hFile, pThis->StartNanoTS, (PCPDMNETWORKGSO)pSgBuf->pvUser, 142 142 pSgBuf->aSegs[0].pvSeg, 143 143 pSgBuf->cbUsed, … … 206 206 /* output to sniffer */ 207 207 RTCritSectEnter(&pThis->Lock); 208 PcapFileFrame(pThis-> File, pThis->StartNanoTS, pvBuf, cb, cb);208 PcapFileFrame(pThis->hFile, pThis->StartNanoTS, pvBuf, cb, cb); 209 209 RTCritSectLeave(&pThis->Lock); 210 210 … … 217 217 Hdr.ts_usec = (uint32_t)((u64TS / 1000) % 1000000); 218 218 Hdr.incl_len = 0; 219 RTFileWrite(pThis-> File, &Hdr, sizeof(Hdr), NULL);219 RTFileWrite(pThis->hFile, &Hdr, sizeof(Hdr), NULL); 220 220 RTCritSectLeave(&pThis->Lock); 221 221 #endif … … 358 358 RTCritSectDelete(&pThis->XmitLock); 359 359 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; 365 362 } 366 363 … … 380 377 */ 381 378 pThis->pDrvIns = pDrvIns; 382 pThis-> File= NIL_RTFILE;379 pThis->hFile = NIL_RTFILE; 383 380 /* The pcap file *must* start at time offset 0,0. */ 384 381 pThis->StartNanoTS = RTTimeNanoTS() - RTTimeProgramNanoTS(); … … 483 480 * Open output file / pipe. 484 481 */ 485 rc = RTFileOpen(&pThis-> File, pThis->szFilename,482 rc = RTFileOpen(&pThis->hFile, pThis->szFilename, 486 483 RTFILE_O_WRITE | RTFILE_O_CREATE_REPLACE | RTFILE_O_DENY_WRITE); 487 484 if (RT_FAILURE(rc)) … … 494 491 * current time again. 495 492 */ 496 PcapFileHdr(pThis-> File, RTTimeNanoTS());493 PcapFileHdr(pThis->hFile, RTTimeNanoTS()); 497 494 498 495 return VINF_SUCCESS; -
trunk/src/VBox/Devices/Network/DrvTAP.cpp
r35353 r37596 31 31 #include <iprt/mem.h> 32 32 #include <iprt/path.h> 33 #include <iprt/pipe.h> 33 34 #include <iprt/semaphore.h> 34 35 #include <iprt/string.h> … … 93 94 PPDMDRVINS pDrvIns; 94 95 /** TAP device file handle. */ 95 RTFILE FileDevice;96 RTFILE hFileDevice; 96 97 /** The configured TAP device name. */ 97 98 char *pszDeviceName; … … 104 105 # else 105 106 /** IP device file handle (/dev/udp). */ 106 RTFILE IPFileDevice;107 int iIPFileDes; 107 108 # endif 108 109 /** Whether device name is obtained from setup application. */ … … 114 115 char *pszTerminateApplication; 115 116 /** The write end of the control pipe. */ 116 RT FILEPipeWrite;117 RTPIPE hPipeWrite; 117 118 /** The read end of the control pipe. */ 118 RT FILEPipeRead;119 RTPIPE hPipeRead; 119 120 /** Reader thread. */ 120 121 PPDMTHREAD pThread; … … 275 276 pSgBuf->aSegs[0].pvSeg, pSgBuf->cbUsed, pSgBuf->cbUsed, pSgBuf->aSegs[0].pvSeg)); 276 277 277 rc = RTFileWrite(pThis-> FileDevice, pSgBuf->aSegs[0].pvSeg, pSgBuf->cbUsed, NULL);278 rc = RTFileWrite(pThis->hFileDevice, pSgBuf->aSegs[0].pvSeg, pSgBuf->cbUsed, NULL); 278 279 } 279 280 else … … 289 290 void *pvSegFrame = PDMNetGsoCarveSegmentQD(pGso, (uint8_t *)pbFrame, pSgBuf->cbUsed, abHdrScratch, 290 291 iSeg, cSegs, &cbSegFrame); 291 rc = RTFileWrite(pThis-> FileDevice, pvSegFrame, cbSegFrame, NULL);292 rc = RTFileWrite(pThis->hFileDevice, pvSegFrame, cbSegFrame, NULL); 292 293 if (RT_FAILURE(rc)) 293 294 break; … … 366 367 */ 367 368 struct pollfd aFDs[2]; 368 aFDs[0].fd = pThis->FileDevice;369 aFDs[0].fd = RTFileToNative(pThis->hFileDevice); 369 370 aFDs[0].events = POLLIN | POLLPRI; 370 371 aFDs[0].revents = 0; 371 aFDs[1].fd = pThis->PipeRead;372 aFDs[1].fd = RTPipeToNative(pThis->hPipeRead); 372 373 aFDs[1].events = POLLIN | POLLPRI | POLLERR | POLLHUP; 373 374 aFDs[1].revents = 0; … … 398 399 * after poll() returned successfully. I don't know why but a second 399 400 * 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); 401 402 #endif 402 403 if (RT_SUCCESS(rc)) … … 459 460 char ch; 460 461 size_t cbRead; 461 RT FileRead(pThis->PipeRead, &ch, 1, &cbRead);462 RTPipeRead(pThis->hPipeRead, &ch, 1, &cbRead); 462 463 } 463 464 else … … 495 496 PDRVTAP pThis = PDMINS_2_DATA(pDrvIns, PDRVTAP); 496 497 497 int rc = RTFileWrite(pThis->PipeWrite, "", 1, NULL); 498 size_t cbIgnored; 499 int rc = RTPipeWrite(pThis->hPipeWrite, "", 1, &cbIgnored); 498 500 AssertRC(rc); 499 501 … … 657 659 if (rc == DLPI_SUCCESS) 658 660 { 659 pThis->FileDevice= g_pfnLibDlpiFd(pThis->pDeviceHandle);661 int fd = g_pfnLibDlpiFd(pThis->pDeviceHandle); 660 662 if (pThis->FileDevice >= 0) 661 663 { 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 } 664 670 } 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")); 668 674 } 669 675 else … … 879 885 } 880 886 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; 883 895 884 896 return VINF_SUCCESS; … … 922 934 * Terminate the control pipe. 923 935 */ 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; 936 941 937 942 #ifdef RT_OS_SOLARIS 938 943 /** @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); 942 947 AssertRC(rc); 943 pThis-> FileDevice = NIL_RTFILE;948 pThis->hFileDevice = NIL_RTFILE; 944 949 } 945 950 946 951 # 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; 952 956 } 953 957 # endif … … 1007 1011 */ 1008 1012 pThis->pDrvIns = pDrvIns; 1009 pThis-> FileDevice= NIL_RTFILE;1013 pThis->hFileDevice = NIL_RTFILE; 1010 1014 pThis->pszDeviceName = NULL; 1011 1015 #ifdef RT_OS_SOLARIS … … 1013 1017 pThis->pDeviceHandle = NULL; 1014 1018 # else 1015 pThis-> IPFileDevice = NIL_RTFILE;1019 pThis->iIPFileDes = -1; 1016 1020 # endif 1017 1021 pThis->fStatic = true; … … 1126 1130 #else /* !RT_OS_SOLARIS */ 1127 1131 1128 int32_t iFile;1129 rc = CFGMR3Query S32(pCfg, "FileHandle", &iFile);1132 uint64_t u64File; 1133 rc = CFGMR3QueryU64(pCfg, "FileHandle", &u64File); 1130 1134 if (RT_FAILURE(rc)) 1131 1135 return PDMDRV_SET_ERROR(pDrvIns, rc, 1132 1136 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)) 1135 1139 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); 1137 1141 #endif /* !RT_OS_SOLARIS */ 1138 1142 … … 1149 1153 * found any way to do that. 1150 1154 */ 1151 if (fcntl( pThis->FileDevice, F_SETFL, O_NONBLOCK) == -1)1155 if (fcntl(RTFileToNative(pThis->hFileDevice), F_SETFL, O_NONBLOCK) == -1) 1152 1156 return PDMDrvHlpVMSetError(pDrvIns, VERR_HOSTIF_IOCTL, RT_SRC_POS, 1153 1157 N_("Configuration error: Failed to configure /dev/net/tun. errno=%d"), errno); 1154 1158 /** @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)); 1156 1160 rc = VINF_SUCCESS; 1157 1161 … … 1159 1163 * Create the control pipe. 1160 1164 */ 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); 1174 1167 1175 1168 /* -
trunk/src/VBox/Devices/Network/DrvVDE.cpp
r37299 r37596 34 34 #include <iprt/param.h> 35 35 #include <iprt/path.h> 36 #include <iprt/pipe.h> 36 37 #include <iprt/semaphore.h> 37 38 #include <iprt/string.h> … … 64 65 /** Pointer to the driver instance. */ 65 66 PPDMDRVINS pDrvIns; 66 /** VDE device file handle. */67 RTFILE FileDevice;68 67 /** The configured VDE device name. */ 69 68 char *pszDeviceName; 70 69 /** The write end of the control pipe. */ 71 RT FILEPipeWrite;70 RTPIPE hPipeWrite; 72 71 /** The read end of the control pipe. */ 73 RT FILEPipeRead;72 RTPIPE hPipeRead; 74 73 /** Reader thread. */ 75 74 PPDMTHREAD pThread; 76 75 /** The connection to the VDE switch */ 77 VDECONN * vdeconn;76 VDECONN *pVdeConn; 78 77 79 78 /** @todo The transmit thread. */ … … 225 224 226 225 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); 228 227 rc = cbSent < 0 ? RTErrConvertFromErrno(-cbSent) : VINF_SUCCESS; 229 228 } … … 241 240 iSeg, cSegs, &cbSegFrame); 242 241 ssize_t cbSent; 243 cbSent = vde_send(pThis-> vdeconn, pvSegFrame, cbSegFrame, 0);242 cbSent = vde_send(pThis->pVdeConn, pvSegFrame, cbSegFrame, 0); 244 243 rc = cbSent < 0 ? RTErrConvertFromErrno(-cbSent) : VINF_SUCCESS; 245 244 if (RT_FAILURE(rc)) … … 319 318 */ 320 319 struct pollfd aFDs[2]; 321 aFDs[0].fd = vde_datafd(pThis-> vdeconn);320 aFDs[0].fd = vde_datafd(pThis->pVdeConn); 322 321 aFDs[0].events = POLLIN | POLLPRI; 323 322 aFDs[0].revents = 0; 324 aFDs[1].fd = pThis->PipeRead;323 aFDs[1].fd = RTPipeToNative(pThis->hPipeRead); 325 324 aFDs[1].events = POLLIN | POLLPRI | POLLERR | POLLHUP; 326 325 aFDs[1].revents = 0; … … 343 342 char achBuf[16384]; 344 343 ssize_t cbRead = 0; 345 cbRead = vde_recv(pThis-> vdeconn, achBuf, sizeof(achBuf), 0);344 cbRead = vde_recv(pThis->pVdeConn, achBuf, sizeof(achBuf), 0); 346 345 rc = cbRead < 0 ? RTErrConvertFromErrno(-cbRead) : VINF_SUCCESS; 347 346 if (RT_SUCCESS(rc)) … … 404 403 char ch; 405 404 size_t cbRead; 406 RT FileRead(pThis->PipeRead, &ch, 1, &cbRead);405 RTPipeRead(pThis->hPipeRead, &ch, 1, &cbRead); 407 406 } 408 407 else … … 440 439 PDRVVDE pThis = PDMINS_2_DATA(pDrvIns, PDRVVDE); 441 440 442 int rc = RTFileWrite(pThis->PipeWrite, "", 1, NULL); 441 size_t cbIgnored; 442 int rc = RTPipeWrite(pThis->hPipeWrite, "", 1, &cbIgnored); 443 443 AssertRC(rc); 444 444 … … 481 481 * Terminate the control pipe. 482 482 */ 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; 495 487 496 488 MMR3HeapFree(pThis->pszDeviceName); … … 502 494 RTCritSectDelete(&pThis->XmitLock); 503 495 504 vde_close(pThis->vdeconn); 496 vde_close(pThis->pVdeConn); 497 pThis->pVdeConn = NULL; 498 505 499 #ifdef VBOX_WITH_STATISTICS 506 500 /* … … 530 524 * Init the static parts. 531 525 */ 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; 537 530 538 531 /* IBase */ 539 pDrvIns->IBase.pfnQueryInterface = drvVDEQueryInterface;532 pDrvIns->IBase.pfnQueryInterface = drvVDEQueryInterface; 540 533 /* INetwork */ 541 534 pThis->INetworkUp.pfnBeginXmit = drvVDENetworkUp_BeginXmit; … … 592 585 return PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_HIF_OPEN_FAILED, RT_SRC_POS, 593 586 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) 596 589 return PDMDrvHlpVMSetError(pThis->pDrvIns, VERR_PDM_HIF_OPEN_FAILED, RT_SRC_POS, 597 590 N_("Failed to connect to the VDE SWITCH")); … … 606 599 * Create the control pipe. 607 600 */ 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); 617 603 618 604 /* -
trunk/src/VBox/Devices/Parallel/DrvHostParallel.cpp
r35353 r37596 27 27 #include <iprt/assert.h> 28 28 #include <iprt/file.h> 29 #include <iprt/pipe.h> 29 30 #include <iprt/semaphore.h> 30 31 #include <iprt/stream.h> … … 64 65 char *pszDevicePath; 65 66 /** Device Handle */ 66 RTFILE FileDevice;67 RTFILE hFileDevice; 67 68 /** Thread waiting for interrupts. */ 68 69 PPDMTHREAD pMonitorThread; 69 70 /** Wakeup pipe read end. */ 70 RT FILEWakeupPipeR;71 RTPIPE hWakeupPipeR; 71 72 /** Wakeup pipe write end. */ 72 RT FILEWakeupPipeW;73 RTPIPE hWakeupPipeW; 73 74 } DRVHOSTPARALLEL, *PDRVHOSTPARALLEL; 74 75 … … 102 103 LogFlow(("%s: pvBuf=%#p cbWrite=%d\n", __FUNCTION__, pvBuf, *cbWrite)); 103 104 104 ioctl( pThis->FileDevice, PPWDATA, pBuffer);105 ioctl(RTFileToNative(pThis->hFileDevice), PPWDATA, pBuffer); 105 106 *cbWrite = 1; 106 107 … … 115 116 LogFlow(("%s: pvBuf=%#p cbRead=%d\n", __FUNCTION__, pvBuf, cbRead)); 116 117 117 ioctl( pThis->FileDevice, PPRDATA, pBuffer);118 ioctl(RTFileToNative(pThis->hFileDevice), PPRDATA, pBuffer); 118 119 *cbRead = 1; 119 120 … … 140 141 } 141 142 142 ioctl( pThis->FileDevice, PPSETMODE, &ppdev_mode);143 ioctl(RTFileToNative(pThis->hFileDevice), PPSETMODE, &ppdev_mode); 143 144 144 145 return VINF_SUCCESS; … … 150 151 151 152 LogFlow(("%s: fReg=%d\n", __FUNCTION__, fReg)); 152 153 ioctl(pThis->FileDevice, PPWCONTROL, &fReg); 153 ioctl(RTFileToNative(pThis->hFileDevice), PPWCONTROL, &fReg); 154 154 155 155 return VINF_SUCCESS; … … 159 159 { 160 160 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); 165 164 LogFlow(("%s: fReg=%d\n", __FUNCTION__, fReg)); 166 167 165 *pfReg = fReg; 168 166 … … 173 171 { 174 172 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); 179 176 LogFlow(("%s: fReg=%d\n", __FUNCTION__, fReg)); 180 181 177 *pfReg = fReg; 182 178 … … 196 192 int rc; 197 193 198 aFDs[0].fd = pThis->FileDevice;194 aFDs[0].fd = RTFileToNative(pThis->hFileDevice); 199 195 aFDs[0].events = POLLIN; 200 196 aFDs[0].revents = 0; 201 aFDs[1].fd = pThis->WakeupPipeR;197 aFDs[1].fd = RTPipeToNative(pThis->hWakeupPipeR); 202 198 aFDs[1].events = POLLIN | POLLERR | POLLHUP; 203 199 aFDs[1].revents = 0; … … 218 214 char ch; 219 215 size_t cbRead; 220 RT FileRead(pThis->WakeupPipeR, &ch, 1, &cbRead);216 RTPipeRead(pThis->hWakeupPipeR, &ch, 1, &cbRead); 221 217 continue; 222 218 } … … 240 236 { 241 237 PDRVHOSTPARALLEL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTPARALLEL); 242 243 return RT FileWrite(pThis->WakeupPipeW, "", 1, NULL);238 size_t cbIgnored; 239 return RTPipeWrite(pThis->hWakeupPipeW, "", 1, &cbIgnored); 244 240 } 245 241 … … 257 253 LogFlow(("%s: iInstance=%d\n", __FUNCTION__, pDrvIns->iInstance)); 258 254 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 280 269 if (pThis->pszDevicePath) 281 270 { … … 297 286 298 287 /* 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 /*306 288 * 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; 308 295 309 296 /* IBase. */ … … 318 305 319 306 /* 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 /* 320 314 * Query configuration. 321 315 */ … … 331 325 * Open the device 332 326 */ 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); 334 328 if (RT_FAILURE(rc)) 335 329 return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("Parallel#%d could not open '%s'"), … … 339 333 * Try to get exclusive access to parallel port 340 334 */ 341 rc = ioctl( pThis->FileDevice, PPEXCL);335 rc = ioctl(RTFileToNative(pThis->hFileDevice), PPEXCL); 342 336 if (rc < 0) 343 337 return PDMDrvHlpVMSetError(pDrvIns, RTErrConvertFromErrno(errno), RT_SRC_POS, … … 349 343 * Claim the parallel port 350 344 */ 351 rc = ioctl( pThis->FileDevice, PPCLAIM);345 rc = ioctl(RTFileToNative(pThis->hFileDevice), PPCLAIM); 352 346 if (rc < 0) 353 347 return PDMDrvHlpVMSetError(pDrvIns, RTErrConvertFromErrno(errno), RT_SRC_POS, … … 367 361 * Create wakeup pipe. 368 362 */ 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); 378 365 379 366 /* -
trunk/src/VBox/Devices/Serial/DrvHostSerial.cpp
r35769 r37596 30 30 #include <iprt/file.h> 31 31 #include <iprt/mem.h> 32 #include <iprt/pipe.h> 32 33 #include <iprt/semaphore.h> 33 34 #include <iprt/uuid.h> … … 103 104 #if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) 104 105 /** the device handle */ 105 RTFILE DeviceFile;106 RTFILE hDeviceFile; 106 107 # ifdef RT_OS_DARWIN 107 108 /** The device handle used for reading. 108 109 * Used to prevent the read select from blocking the writes. */ 109 RTFILE DeviceFileR;110 RTFILE hDeviceFileR; 110 111 # endif 111 112 /** The read end of the control pipe */ 112 RT FILEWakeupPipeR;113 RTPIPE hWakeupPipeR; 113 114 /** The write end of the control pipe */ 114 RT FILEWakeupPipeW;115 RTPIPE hWakeupPipeW; 115 116 # ifndef RT_OS_LINUX 116 117 /** The current line status. … … 265 266 #ifdef RT_OS_LINUX 266 267 struct serial_struct serialStruct; 267 if (ioctl( pThis->DeviceFile, TIOCGSERIAL, &serialStruct) != -1)268 if (ioctl(RTFileToNative(pThis->hDeviceFile), TIOCGSERIAL, &serialStruct) != -1) 268 269 { 269 270 serialStruct.custom_divisor = serialStruct.baud_base / Bps; … … 272 273 serialStruct.flags &= ~ASYNC_SPD_MASK; 273 274 serialStruct.flags |= ASYNC_SPD_CUST; 274 ioctl( pThis->DeviceFile, TIOCSSERIAL, &serialStruct);275 ioctl(RTFileToNative(pThis->hDeviceFile), TIOCSSERIAL, &serialStruct); 275 276 baud_rate = B38400; 276 277 } … … 328 329 termiosSetup->c_lflag &= ~(ICANON | ECHO | ECHOE | ECHONL | ECHOK | ISIG | IEXTEN); 329 330 330 tcsetattr( pThis->DeviceFile, TCSANOW, termiosSetup);331 tcsetattr(RTFileToNative(pThis->hDeviceFile), TCSANOW, termiosSetup); 331 332 RTMemTmpFree(termiosSetup); 332 333 … … 486 487 487 488 size_t cbWritten; 488 rc = RTFileWrite(pThis-> DeviceFile, &ch, 1, &cbWritten);489 rc = RTFileWrite(pThis->hDeviceFile, &ch, 1, &cbWritten); 489 490 if (rc == VERR_TRY_AGAIN) 490 491 cbWritten = 0; … … 498 499 fd_set WrSet; 499 500 FD_ZERO(&WrSet); 500 FD_SET( pThis->DeviceFile, &WrSet);501 FD_SET(RTFileToNative(pThis->hDeviceFile), &WrSet); 501 502 fd_set XcptSet; 502 503 FD_ZERO(&XcptSet); 503 FD_SET( pThis->DeviceFile, &XcptSet);504 FD_SET(RTFileToNative(pThis->hDeviceFile), &XcptSet); 504 505 # ifdef DEBUG 505 506 uint64_t u64Now = RTTimeMilliTS(); 506 507 # endif 507 rc = select( pThis->DeviceFile+ 1, NULL, &WrSet, &XcptSet, NULL);508 rc = select(RTFileToNative(pThis->hDeviceFile) + 1, NULL, &WrSet, &XcptSet, NULL); 508 509 /** @todo check rc? */ 509 510 … … 512 513 # endif 513 514 /* try write more */ 514 rc = RTFileWrite(pThis-> DeviceFile, &ch, 1, &cbWritten);515 rc = RTFileWrite(pThis->hDeviceFile, &ch, 1, &cbWritten); 515 516 if (rc == VERR_TRY_AGAIN) 516 517 cbWritten = 0; … … 627 628 fd_set RdSet; 628 629 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); 631 632 fd_set XcptSet; 632 633 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); 635 636 # 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); 637 639 # else 638 640 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); 640 643 # endif 641 644 if (rc == -1) … … 655 658 /* drain the wakeup pipe */ 656 659 size_t cbRead; 657 if ( FD_ISSET( pThis->WakeupPipeR, &RdSet)658 || FD_ISSET(pThis-> WakeupPipeR, &XcptSet))659 { 660 rc = RT FileRead(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); 661 664 if (RT_FAILURE(rc)) 662 665 { … … 669 672 670 673 /* read data from the serial port. */ 671 rc = RTFileRead(pThis-> DeviceFileR, abBuffer, sizeof(abBuffer), &cbRead);674 rc = RTFileRead(pThis->hDeviceFileR, abBuffer, sizeof(abBuffer), &cbRead); 672 675 if (RT_FAILURE(rc)) 673 676 { … … 682 685 size_t cbRead; 683 686 struct pollfd aFDs[2]; 684 aFDs[0].fd = pThis->DeviceFile;687 aFDs[0].fd = RTFileToNative(pThis->hDeviceFile); 685 688 aFDs[0].events = POLLIN; 686 689 aFDs[0].revents = 0; 687 aFDs[1].fd = pThis->WakeupPipeR;690 aFDs[1].fd = RTPipeToNative(pThis->hWakeupPipeR); 688 691 aFDs[1].events = POLLIN | POLLERR | POLLHUP; 689 692 aFDs[1].revents = 0; … … 704 707 break; 705 708 /* notification to terminate -- drain the pipe */ 706 RT FileRead(pThis->WakeupPipeR, &abBuffer, 1, &cbRead);709 RTPipeRead(pThis->hWakeupPipeR, &abBuffer, 1, &cbRead); 707 710 continue; 708 711 } 709 rc = RTFileRead(pThis-> DeviceFile, abBuffer, sizeof(abBuffer), &cbRead);712 rc = RTFileRead(pThis->hDeviceFile, abBuffer, sizeof(abBuffer), &cbRead); 710 713 if (RT_FAILURE(rc)) 711 714 { … … 844 847 PDRVHOSTSERIAL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTSERIAL); 845 848 #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 847 852 #elif defined(RT_OS_WINDOWS) 848 853 if (!SetEvent(pThis->hHaltEventSem)) … … 883 888 * Get the status line state. 884 889 */ 885 rc = ioctl( pThis->DeviceFile, TIOCMGET, &statusLines);890 rc = ioctl(RTFileToNative(pThis->hDeviceFile), TIOCMGET, &statusLines); 886 891 if (rc < 0) 887 892 { … … 916 921 * is to send a signal after each tcsetattr. 917 922 */ 918 ioctl( pThis->DeviceFile, TIOCMIWAIT, uStatusLinesToCheck);923 ioctl(RTFileToNative(pThis->hDeviceFile), TIOCMIWAIT, uStatusLinesToCheck); 919 924 # else 920 925 /* Poll for status line change. */ … … 989 994 990 995 if (modemStateSet) 991 ioctl( pThis->DeviceFile, TIOCMBIS, &modemStateSet);996 ioctl(RTFileToNative(pThis->hDeviceFile), TIOCMBIS, &modemStateSet); 992 997 993 998 if (modemStateClear) 994 ioctl( pThis->DeviceFile, TIOCMBIC, &modemStateClear);999 ioctl(RTFileToNative(pThis->hDeviceFile), TIOCMBIC, &modemStateClear); 995 1000 996 1001 #elif defined(RT_OS_WINDOWS) … … 1024 1029 #if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) 1025 1030 if (fBreak) 1026 ioctl( pThis->DeviceFile, TIOCSBRK);1031 ioctl(RTFileToNative(pThis->hDeviceFile), TIOCSBRK); 1027 1032 else 1028 ioctl( pThis->DeviceFile, TIOCCBRK);1033 ioctl(RTFileToNative(pThis->hDeviceFile), TIOCCBRK); 1029 1034 1030 1035 #elif defined(RT_OS_WINDOWS) … … 1058 1063 pThis->SendSem = NIL_RTSEMEVENT; 1059 1064 1065 int rc; 1060 1066 #if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) 1061 1067 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 1074 1073 # 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) 1078 1077 { 1079 int rc = RTFileClose(pThis->DeviceFileR);1078 rc = RTFileClose(pThis->hDeviceFileR); 1080 1079 AssertRC(rc); 1081 1080 } 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; 1091 1086 1092 1087 #elif defined(RT_OS_WINDOWS) 1093 1094 1088 CloseHandle(pThis->hEventRecv); 1095 1089 CloseHandle(pThis->hEventSend); … … 1121 1115 */ 1122 1116 #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; 1124 1118 # 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; 1129 1127 #endif 1130 1128 /* IBase. */ … … 1191 1189 fOpen |= RTFILE_O_NON_BLOCK; 1192 1190 # endif 1193 rc = RTFileOpen(&pThis-> DeviceFile, pThis->pszDevicePath, fOpen);1191 rc = RTFileOpen(&pThis->hDeviceFile, pThis->pszDevicePath, fOpen); 1194 1192 # ifdef RT_OS_LINUX 1195 1193 /* RTFILE_O_NON_BLOCK not supported? */ 1196 1194 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); 1198 1196 # endif 1199 1197 # ifdef RT_OS_DARWIN 1200 1198 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); 1202 1200 # endif 1203 1201 … … 1232 1230 #if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) 1233 1231 1234 fcntl( pThis->DeviceFile, F_SETFL, O_NONBLOCK);1232 fcntl(RTFileToNative(pThis->hDeviceFile), F_SETFL, O_NONBLOCK); 1235 1233 # 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); 1247 1238 1248 1239 #elif defined(RT_OS_WINDOWS) -
trunk/src/VBox/Devices/Serial/DrvRawFile.cpp
r35353 r37596 60 60 char *pszLocation; 61 61 /** Flag whether VirtualBox represents the server or client side. */ 62 RTFILE OutputFile;62 RTFILE hOutputFile; 63 63 } DRVRAWFILE, *PDRVRAWFILE; 64 64 … … 75 75 76 76 Assert(pvBuf); 77 if (pThis-> OutputFile != NIL_RTFILE)77 if (pThis->hOutputFile != NIL_RTFILE) 78 78 { 79 79 size_t cbWritten; 80 rc = RTFileWrite(pThis-> OutputFile, pvBuf, *pcbWrite, &cbWritten);80 rc = RTFileWrite(pThis->hOutputFile, pvBuf, *pcbWrite, &cbWritten); 81 81 #if 0 82 82 /* don't flush here, takes too long and we will loose characters */ 83 83 if (RT_SUCCESS(rc)) 84 RTFileFlush(pThis-> OutputFile);84 RTFileFlush(pThis->hOutputFile); 85 85 #endif 86 86 *pcbWrite = cbWritten; … … 121 121 LogFlow(("%s: %s\n", __FUNCTION__, pThis->pszLocation)); 122 122 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; 128 125 } 129 126 … … 146 143 MMR3HeapFree(pThis->pszLocation); 147 144 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; 153 147 } 154 148 … … 169 163 pThis->pDrvIns = pDrvIns; 170 164 pThis->pszLocation = NULL; 171 pThis-> OutputFile= NIL_RTFILE;165 pThis->hOutputFile = NIL_RTFILE; 172 166 /* IBase */ 173 167 pDrvIns->IBase.pfnQueryInterface = drvRawFileQueryInterface; … … 188 182 * Open the raw file. 189 183 */ 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); 191 185 if (RT_FAILURE(rc)) 192 186 { -
trunk/src/VBox/Devices/Storage/DrvHostBase.cpp
r36797 r37596 185 185 * Seek and read. 186 186 */ 187 rc = RTFile Seek(pThis->FileDevice, off, RTFILE_SEEK_BEGIN, NULL);187 rc = RTFileReadAt(pThis->hFileDevice, off, pvBuf, cbRead, NULL); 188 188 if (RT_SUCCESS(rc)) 189 189 { 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)); 201 193 } 202 194 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)); 205 198 #endif 206 199 } … … 241 234 * Seek and write. 242 235 */ 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)); 255 241 #endif 256 242 } … … 282 268 /** @todo scsi device buffer flush... */ 283 269 #else 284 rc = RTFileFlush(pThis-> FileDevice);270 rc = RTFileFlush(pThis->hFileDevice); 285 271 #endif 286 272 } … … 762 748 static int drvHostBaseOpen(PDRVHOSTBASE pThis, PRTFILE pFileDevice, bool fReadOnly) 763 749 { 764 # ifdef RT_OS_DARWIN750 # ifdef RT_OS_DARWIN 765 751 /* Darwin is kind of special... */ 766 752 Assert(!pFileDevice); NOREF(pFileDevice); … … 940 926 return rc; 941 927 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 950 928 #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); 955 931 if (RT_FAILURE(rc)) 956 932 return rc; … … 964 940 965 941 DeviceCCB.ccb_h.func_code = XPT_GDEVLIST; 966 int rcBSD = ioctl( FileDevice, CAMGETPASSTHRU, &DeviceCCB);942 int rcBSD = ioctl(RTFileToNative(hFileDevice), CAMGETPASSTHRU, &DeviceCCB); 967 943 if (!rcBSD) 968 944 { … … 972 948 if (rc >= 0) 973 949 { 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); 978 952 RTStrFree(pszPassthroughDevice); 979 980 953 if (RT_SUCCESS(rc)) 981 954 { … … 989 962 DeviceCCB.ccb_h.func_code = XPT_GDEVLIST; 990 963 991 rcBSD = ioctl( PassthroughDevice, CAMGETPASSTHRU, &DeviceCCB);964 rcBSD = ioctl(RTFileToNative(hPassthroughDevice), CAMGETPASSTHRU, &DeviceCCB); 992 965 if (!rcBSD) 993 966 { … … 997 970 pThis->ScsiTargetID = DeviceCCB.ccb_h.target_id; 998 971 pThis->ScsiLunID = DeviceCCB.ccb_h.target_lun; 999 *pFileDevice = PassthroughDevice;972 *pFileDevice = hPassthroughDevice; 1000 973 } 1001 974 else … … 1009 982 1010 983 if (RT_FAILURE(rc)) 1011 RTFileClose( PassthroughDevice);984 RTFileClose(hPassthroughDevice); 1012 985 } 1013 986 } … … 1018 991 rc = RTErrConvertFromErrno(errno); 1019 992 1020 RTFileClose( FileDevice);993 RTFileClose(hFileDevice); 1021 994 return rc; 995 1022 996 #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); 1025 1002 #endif 1026 1003 } … … 1072 1049 LogFlow(("%s-%d: drvHostBaseReopen: '%s'\n", pThis->pDrvIns->pReg->szName, pThis->pDrvIns->iInstance, pThis->pszDeviceOpen)); 1073 1050 1074 RTFILE FileDevice;1051 RTFILE hFileDevice; 1075 1052 #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); 1088 1065 #else 1089 int rc = drvHostBaseOpen(pThis, & FileDevice, pThis->fReadOnlyConfig);1066 int rc = drvHostBaseOpen(pThis, &hFileDevice, pThis->fReadOnlyConfig); 1090 1067 #endif 1091 1068 if (RT_FAILURE(rc)) … … 1095 1072 LogFlow(("%s-%d: drvHostBaseReopen: '%s' - retry readonly (%Rrc)\n", pThis->pDrvIns->pReg->szName, pThis->pDrvIns->iInstance, pThis->pszDeviceOpen, rc)); 1096 1073 #ifdef RT_OS_SOLARIS 1097 rc = drvHostBaseOpen(pThis, & FileDevice, &FileRawDevice, false);1074 rc = drvHostBaseOpen(pThis, &hFileDevice, &hFileRawDevice, false); 1098 1075 #else 1099 rc = drvHostBaseOpen(pThis, & FileDevice, false);1076 rc = drvHostBaseOpen(pThis, &hFileDevice, false); 1100 1077 #endif 1101 1078 } … … 1112 1089 1113 1090 #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; 1122 1099 #endif /* !RT_OS_DARWIN */ 1123 1100 return VINF_SUCCESS; … … 1170 1147 */ 1171 1148 struct dk_minfo MediaInfo; 1172 if (ioctl( pThis->FileRawDevice, DKIOCGMEDIAINFO, &MediaInfo) == 0)1149 if (ioctl(RTFileToNative(pThis->hFileRawDevice), DKIOCGMEDIAINFO, &MediaInfo) == 0) 1173 1150 { 1174 1151 *pcb = MediaInfo.dki_capacity * (uint64_t)MediaInfo.dki_lbsize; 1175 1152 return VINF_SUCCESS; 1176 1153 } 1177 return RTFileSeek(pThis-> FileDevice, 0, RTFILE_SEEK_END, pcb);1154 return RTFileSeek(pThis->hFileDevice, 0, RTFILE_SEEK_END, pcb); 1178 1155 1179 1156 #elif defined(RT_OS_WINDOWS) … … 1181 1158 IO_STATUS_BLOCK IoStatusBlock = {0}; 1182 1159 FILE_FS_SIZE_INFORMATION FsSize= {0}; 1183 NTSTATUS rcNt = NtQueryVolumeInformationFile( (HANDLE)pThis->FileDevice, &IoStatusBlock,1160 NTSTATUS rcNt = NtQueryVolumeInformationFile(RTFileToNative(pThis->hFileDevice), &IoStatusBlock, 1184 1161 &FsSize, sizeof(FsSize), FileFsSizeInformation); 1185 1162 int cRetries = 5; … … 1187 1164 { 1188 1165 RTThreadSleep(10); 1189 rcNt = NtQueryVolumeInformationFile( (HANDLE)pThis->FileDevice, &IoStatusBlock,1166 rcNt = NtQueryVolumeInformationFile(RTFileToNative(pThis->hFileDevice), &IoStatusBlock, 1190 1167 &FsSize, sizeof(FsSize), FileFsSizeInformation); 1191 1168 } … … 1207 1184 return rc; 1208 1185 #else 1209 return RTFileSeek(pThis-> FileDevice, 0, RTFILE_SEEK_END, pcb);1186 return RTFileSeek(pThis->hFileDevice, 0, RTFILE_SEEK_END, pcb); 1210 1187 #endif 1211 1188 } … … 1340 1317 pDeviceCCB->ccb_h.func_code = XPT_GDEV_TYPE; 1341 1318 1342 rcBSD = ioctl( pThis->FileDevice, CAMIOCOMMAND, pDeviceCCB);1319 rcBSD = ioctl(RTFileToNative(pThis->hFileDevice), CAMIOCOMMAND, pDeviceCCB); 1343 1320 if (!rcBSD) 1344 1321 { … … 1375 1352 1376 1353 /* Send command */ 1377 rcBSD = ioctl( pThis->FileDevice, CAMIOCOMMAND, pDeviceCCB);1354 rcBSD = ioctl(RTFileToNative(pThis->hFileDevice), CAMIOCOMMAND, pDeviceCCB); 1378 1355 if (!rcBSD) 1379 1356 { … … 1715 1692 * (We're currently not unlocking the device after use. See todo in DevATA.cpp.) */ 1716 1693 if ( pThis->fLocked 1717 && pThis-> FileDevice != NIL_RTFILE1694 && pThis->hFileDevice != NIL_RTFILE 1718 1695 #endif 1719 1696 && pThis->pfnDoLock) … … 1785 1762 } 1786 1763 #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); 1790 1767 AssertRC(rc); 1791 pThis-> FileDevice = NIL_RTFILE;1768 pThis->hFileDevice = NIL_RTFILE; 1792 1769 } 1793 1770 #endif 1794 1771 1795 1772 #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); 1799 1776 AssertRC(rc); 1800 pThis-> FileRawDevice = NIL_RTFILE;1777 pThis->hFileRawDevice = NIL_RTFILE; 1801 1778 } 1802 1779 … … 1863 1840 pThis->pDASession = NULL; 1864 1841 #else 1865 pThis-> FileDevice= NIL_RTFILE;1842 pThis->hFileDevice = NIL_RTFILE; 1866 1843 #endif 1867 1844 #ifdef RT_OS_SOLARIS 1868 pThis-> FileRawDevice= NIL_RTFILE;1845 pThis->hFileRawDevice = NIL_RTFILE; 1869 1846 #endif 1870 1847 pThis->enmType = enmType; … … 2110 2087 && RT_SUCCESS(RTPathReal(pszDevice, szPathReal, sizeof(szPathReal)))) 2111 2088 pszDevice = szPathReal; 2112 pThis-> FileDevice = NIL_RTFILE;2089 pThis->hFileDevice = NIL_RTFILE; 2113 2090 #endif 2114 2091 #ifdef RT_OS_SOLARIS 2115 pThis-> FileRawDevice = NIL_RTFILE;2092 pThis->hFileRawDevice = NIL_RTFILE; 2116 2093 #endif 2117 2094 -
trunk/src/VBox/Devices/Storage/DrvHostBase.h
r33540 r37596 83 83 #if !defined(RT_OS_DARWIN) 84 84 /** The filehandle of the device. */ 85 RTFILE FileDevice;85 RTFILE hFileDevice; 86 86 #endif 87 87 #ifdef RT_OS_SOLARIS 88 88 /** The raw filehandle of the device. */ 89 RTFILE FileRawDevice;89 RTFILE hFileRawDevice; 90 90 #endif 91 91 -
trunk/src/VBox/Devices/Storage/DrvHostDVD.cpp
r35560 r37596 156 156 157 157 #elif defined(RT_OS_LINUX) 158 rc = ioctl( pThis->FileDevice, CDROMEJECT, 0);158 rc = ioctl(RTFileToNative(pThis->hFileDevice), CDROMEJECT, 0); 159 159 if (rc < 0) 160 160 { … … 168 168 169 169 #elif defined(RT_OS_SOLARIS) 170 rc = ioctl( pThis->FileRawDevice, DKIOCEJECT, 0);170 rc = ioctl(RTFileToNative(pThis->hFileRawDevice), DKIOCEJECT, 0); 171 171 if (rc < 0) 172 172 { … … 182 182 183 183 #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); 187 187 if (RT_SUCCESS(rc)) 188 188 { 189 189 /* do ioctl */ 190 190 DWORD cbReturned; 191 if (DeviceIoControl( (HANDLE)FileDevice, IOCTL_STORAGE_EJECT_MEDIA,191 if (DeviceIoControl(RTFileToNative(hFileDevice), IOCTL_STORAGE_EJECT_MEDIA, 192 192 NULL, 0, 193 193 NULL, 0, &cbReturned, … … 198 198 199 199 /* clean up handle */ 200 if ( FileDevice != pThis->FileDevice)201 RTFileClose( FileDevice);200 if (hFileDevice != pThis->hFileDevice) 201 RTFileClose(hFileDevice); 202 202 } 203 203 else … … 246 246 247 247 #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); 249 249 if (rc < 0) 250 250 { … … 258 258 259 259 #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); 261 261 if (rc < 0) 262 262 { … … 274 274 DWORD cbReturned; 275 275 int rc; 276 if (DeviceIoControl( (HANDLE)pThis->FileDevice, IOCTL_STORAGE_MEDIA_REMOVAL,276 if (DeviceIoControl(RTFileToNative(pThis->hFileDevice), IOCTL_STORAGE_MEDIA_REMOVAL, 277 277 &PreventMediaRemoval, sizeof(PreventMediaRemoval), 278 278 NULL, 0, &cbReturned, … … 309 309 */ 310 310 /* 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); 313 313 314 314 } … … 357 357 358 358 #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; 360 360 361 361 #elif defined(RT_OS_SOLARIS) … … 366 366 static dkio_state s_DeviceState = DKIO_NONE; 367 367 dkio_state PreviousState = s_DeviceState; 368 int rc2 = ioctl( pThis->FileRawDevice, DKIOCSTATE, &s_DeviceState);368 int rc2 = ioctl(RTFileToNative(pThis->hFileRawDevice), DKIOCSTATE, &s_DeviceState); 369 369 if (rc2 == 0) 370 370 { … … 398 398 /* taken care of above. */ 399 399 #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; 401 401 #else 402 402 # error "Unsupported platform." … … 484 484 cgc.quiet = false; 485 485 cgc.timeout = cTimeoutMillies; 486 rc = ioctl( pThis->FileDevice, CDROM_SEND_PACKET, &cgc);486 rc = ioctl(RTFileToNative(pThis->hFileDevice), CDROM_SEND_PACKET, &cgc); 487 487 if (rc < 0) 488 488 { … … 560 560 solarisEnterRootMode(&effUserID); /** @todo check return code when this really works. */ 561 561 #endif 562 rc = ioctl( pThis->FileRawDevice, USCSICMD, &usc);562 rc = ioctl(RTFileToNative(pThis->hFileRawDevice), USCSICMD, &usc); 563 563 #ifdef VBOX_WITH_SUID_WRAPPER 564 564 solarisExitRootMode(&effUserID); … … 620 620 Req.spt.SenseInfoLength = (UCHAR)RT_MIN(sizeof(Req.aSense), cbSense); 621 621 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, 623 623 &Req, sizeof(Req), &Req, sizeof(Req), &cbReturned, NULL)) 624 624 { -
trunk/src/VBox/Devices/Storage/DrvHostFloppy.cpp
r35353 r37596 73 73 static DECLCALLBACK(int) drvHostFloppyGetMediaSize(PDRVHOSTBASE pThis, uint64_t *pcb) 74 74 { 75 int rc = ioctl( pThis->FileDevice, FDFLUSH);75 int rc = ioctl(RTFileToNative(pThis->hFileDevice), FDFLUSH); 76 76 if (rc) 77 77 { … … 82 82 83 83 floppy_drive_struct DrvStat; 84 rc = ioctl( pThis->FileDevice, FDGETDRVSTAT, &DrvStat);84 rc = ioctl(RTFileToNative(pThis->hFileDevice), FDGETDRVSTAT, &DrvStat); 85 85 if (rc) 86 86 { … … 91 91 pThis->fReadOnly = !(DrvStat.flags & FD_DISK_WRITABLE); 92 92 93 return RTFileSeek(pThis-> FileDevice, 0, RTFILE_SEEK_END, pcb);93 return RTFileSeek(pThis->hFileDevice, 0, RTFILE_SEEK_END, pcb); 94 94 } 95 95 #endif /* RT_OS_LINUX */ … … 108 108 PDRVHOSTFLOPPY pThisFloppy = (PDRVHOSTFLOPPY)pThis; 109 109 floppy_drive_struct DrvStat; 110 int rc = ioctl( pThis->FileDevice, FDPOLLDRVSTAT, &DrvStat);110 int rc = ioctl(RTFileToNative(pThis->hFileDevice), FDPOLLDRVSTAT, &DrvStat); 111 111 if (rc) 112 112 return RTErrConvertFromErrno(errno); -
trunk/src/VBox/Devices/Storage/DrvMediaISO.cpp
r35353 r37596 60 60 char *pszFilename; 61 61 /** File handle of the ISO file. */ 62 RTFILE File;62 RTFILE hFile; 63 63 } DRVMEDIAISO, *PDRVMEDIAISO; 64 64 … … 74 74 75 75 uint64_t cbFile; 76 int rc = RTFileGetSize(pThis-> File, &cbFile);76 int rc = RTFileGetSize(pThis->hFile, &cbFile); 77 77 if (RT_SUCCESS(rc)) 78 78 { … … 124 124 LogFlow(("drvMediaISORead: off=%#llx pvBuf=%p cbRead=%#x (%s)\n", off, pvBuf, cbRead, pThis->pszFilename)); 125 125 126 Assert(pThis-> File);126 Assert(pThis->hFile != NIL_RTFILE); 127 127 Assert(pvBuf); 128 128 … … 130 130 * Seek to the position and read. 131 131 */ 132 int rc = RTFile Seek(pThis->File, off, RTFILE_SEEK_BEGIN, NULL);132 int rc = RTFileReadAt(pThis->hFile, off, pvBuf, cbRead, NULL); 133 133 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)); 147 138 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)); 149 141 LogFlow(("drvMediaISORead: returns %Rrc\n", rc)); 150 142 return rc; … … 212 204 PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns); 213 205 214 if (pThis->File != NIL_RTFILE) 206 RTFileClose(pThis->hFile); 207 pThis->hFile = NIL_RTFILE; 208 209 if (pThis->pszFilename) 215 210 { 216 RTFileClose(pThis->File);217 pThis-> File = NIL_RTFILE;211 MMR3HeapFree(pThis->pszFilename); 212 pThis->pszFilename = NULL; 218 213 } 219 if (pThis->pszFilename)220 MMR3HeapFree(pThis->pszFilename);221 214 } 222 215 … … 236 229 */ 237 230 pThis->pDrvIns = pDrvIns; 238 pThis-> File= NIL_RTFILE;231 pThis->hFile = NIL_RTFILE; 239 232 /* IBase */ 240 233 pDrvIns->IBase.pfnQueryInterface = drvMediaISOQueryInterface; … … 265 258 * Open the image. 266 259 */ 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); 269 261 if (RT_SUCCESS(rc)) 270 262 { -
trunk/src/VBox/Devices/Storage/DrvRawImage.cpp
r35353 r37596 61 61 char *pszFilename; 62 62 /** File handle of the raw image file. */ 63 RTFILE File;63 RTFILE hFile; 64 64 /** True if the image is operating in readonly mode. */ 65 65 bool fReadOnly; … … 77 77 78 78 uint64_t cbFile; 79 int rc = RTFileGetSize(pThis-> File, &cbFile);79 int rc = RTFileGetSize(pThis->hFile, &cbFile); 80 80 if (RT_SUCCESS(rc)) 81 81 { … … 127 127 LogFlow(("drvRawImageRead: off=%#llx pvBuf=%p cbRead=%#x (%s)\n", off, pvBuf, cbRead, pThis->pszFilename)); 128 128 129 Assert(pThis-> File);129 Assert(pThis->hFile != NIL_RTFILE); 130 130 Assert(pvBuf); 131 131 … … 133 133 * Seek to the position and read. 134 134 */ 135 int rc = RTFileSeek(pThis-> File, off, RTFILE_SEEK_BEGIN, NULL);135 int rc = RTFileSeek(pThis->hFile, off, RTFILE_SEEK_BEGIN, NULL); 136 136 if (RT_SUCCESS(rc)) 137 137 { 138 rc = RTFileRead(pThis-> File, pvBuf, cbRead, NULL);138 rc = RTFileRead(pThis->hFile, pvBuf, cbRead, NULL); 139 139 if (RT_SUCCESS(rc)) 140 140 { … … 145 145 } 146 146 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)); 149 149 } 150 150 else 151 AssertMsgFailed(("RTFileSeek(% d,%#llx,) -> %Rrc\n", pThis->File, off, rc));151 AssertMsgFailed(("RTFileSeek(%RTfile,%#llx,) -> %Rrc\n", pThis->hFile, off, rc)); 152 152 LogFlow(("drvRawImageRead: returns %Rrc\n", rc)); 153 153 return rc; … … 161 161 LogFlow(("drvRawImageWrite: off=%#llx pvBuf=%p cbWrite=%#x (%s)\n", off, pvBuf, cbWrite, pThis->pszFilename)); 162 162 163 Assert(pThis-> File);163 Assert(pThis->hFile != NIL_RTFILE); 164 164 Assert(pvBuf); 165 165 … … 167 167 * Seek to the position and write. 168 168 */ 169 int rc = RTFileSeek(pThis-> File, off, RTFILE_SEEK_BEGIN, NULL);169 int rc = RTFileSeek(pThis->hFile, off, RTFILE_SEEK_BEGIN, NULL); 170 170 if (RT_SUCCESS(rc)) 171 171 { 172 rc = RTFileWrite(pThis-> File, pvBuf, cbWrite, NULL);172 rc = RTFileWrite(pThis->hFile, pvBuf, cbWrite, NULL); 173 173 if (RT_SUCCESS(rc)) 174 174 { … … 179 179 } 180 180 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)); 183 183 } 184 184 else 185 AssertMsgFailed(("RTFileSeek(% d,%#llx,) -> %Rrc\n", pThis->File, off, rc));185 AssertMsgFailed(("RTFileSeek(%RTfile,%#llx,) -> %Rrc\n", pThis->hFile, off, rc)); 186 186 LogFlow(("drvRawImageWrite: returns %Rrc\n", rc)); 187 187 return rc; … … 195 195 LogFlow(("drvRawImageFlush: (%s)\n", pThis->pszFilename)); 196 196 197 Assert(pThis-> File != NIL_RTFILE);198 int rc = RTFileFlush(pThis-> File);197 Assert(pThis->hFile != NIL_RTFILE); 198 int rc = RTFileFlush(pThis->hFile); 199 199 LogFlow(("drvRawImageFlush: returns %Rrc\n", rc)); 200 200 return rc; … … 249 249 PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns); 250 250 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 256 254 if (pThis->pszFilename) 255 { 257 256 MMR3HeapFree(pThis->pszFilename); 257 pThis->pszFilename = NULL; 258 } 258 259 } 259 260 … … 273 274 */ 274 275 pThis->pDrvIns = pDrvIns; 275 pThis-> File= NIL_RTFILE;276 pThis->hFile = NIL_RTFILE; 276 277 /* IBase */ 277 278 pDrvIns->IBase.pfnQueryInterface = drvRawImageQueryInterface; … … 305 306 * Open the image. 306 307 */ 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); 309 309 if (RT_SUCCESS(rc)) 310 310 { … … 315 315 else 316 316 { 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); 319 318 if (RT_SUCCESS(rc)) 320 319 { -
trunk/src/VBox/Devices/Storage/DrvSCSIHost.cpp
r35353 r37596 58 58 char *pszDevicePath; 59 59 /** Handle to the device. */ 60 RTFILE DeviceFile;60 RTFILE hDeviceFile; 61 61 62 62 /** The dedicated I/O thread. */ … … 302 302 ScsiIoReq.flags |= SG_FLAG_DIRECT_IO; 303 303 304 /* *Issue command. */305 rc = ioctl( pThis->DeviceFile, SG_IO, &ScsiIoReq);304 /* Issue command. */ 305 rc = ioctl(RTFileToNative(pThis->hDeviceFile), SG_IO, &ScsiIoReq); 306 306 if (rc < 0) 307 307 { … … 420 420 PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns); 421 421 422 if (pThis->DeviceFile != NIL_RTFILE)423 RTFileClose(pThis->DeviceFile);422 RTFileClose(pThis->hDeviceFile); 423 pThis->hDeviceFile = NIL_RTFILE; 424 424 425 425 if (pThis->pszDevicePath) 426 { 426 427 MMR3HeapFree(pThis->pszDevicePath); 428 pThis->pszDevicePath = NULL; 429 } 427 430 428 431 if (pThis->pQueueRequests) … … 457 460 pDrvIns->IBase.pfnQueryInterface = drvscsihostQueryInterface; 458 461 pThis->ISCSIConnector.pfnSCSIRequestSend = drvscsihostRequestSend; 459 pThis->pDrvIns = pDrvIns;460 pThis-> DeviceFile = NIL_RTFILE;462 pThis->pDrvIns = pDrvIns; 463 pThis->hDeviceFile = NIL_RTFILE; 461 464 462 465 /* Query the SCSI port interface above. */ … … 474 477 N_("Configuration error: Failed to get the \"DevicePath\" value")); 475 478 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); 477 480 if (RT_FAILURE(rc)) 478 481 return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, -
trunk/src/VBox/Devices/USB/USBProxyDevice.h
r33590 r37596 207 207 * The Linux and Darwin backends are making use of this. */ 208 208 void *pv; 209 RTFILE File;209 RTFILE hFile; 210 210 int fd; 211 211 struct vrdp_priv -
trunk/src/VBox/Devices/USB/freebsd/USBProxyDevice-freebsd.cpp
r36797 r37596 94 94 { 95 95 /** The open file. */ 96 RTFILE File;96 RTFILE hFile; 97 97 /** Software endpoint structures */ 98 98 USBENDPOINTFBSD aSwEndpoint[USBFBSD_MAXENDPOINTS]; … … 133 133 do 134 134 { 135 rc = ioctl( pDevFBSD->File, iCmd, pvArg);135 rc = ioctl(RTFileToNative(pDevFBSD->hFile), iCmd, pvArg); 136 136 if (rc >= 0) 137 137 return VINF_SUCCESS; … … 369 369 * Try open the device node. 370 370 */ 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); 374 373 if (RT_SUCCESS(rc)) 375 374 { 376 375 /* 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)); 382 379 if (pDevFBSD) 383 380 { 384 pDevFBSD-> File =File;381 pDevFBSD->hFile = hFile; 385 382 pProxyDev->Backend.pv = pDevFBSD; 386 383 … … 388 385 if (RT_SUCCESS(rc)) 389 386 { 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)); 394 389 395 390 return VINF_SUCCESS; … … 401 396 rc = VERR_NO_MEMORY; 402 397 403 RTFileClose( File);398 RTFileClose(hFile); 404 399 } 405 400 else if (rc == VERR_ACCESS_DENIED) … … 455 450 static void usbProxyFreeBSDClose(PUSBPROXYDEV pProxyDev) 456 451 { 457 PUSBPROXYDEVFBSD pDevFBSD = (PUSBPROXYDEVFBSD) 452 PUSBPROXYDEVFBSD pDevFBSD = (PUSBPROXYDEVFBSD)pProxyDev->Backend.pv; 458 453 459 454 LogFlow(("usbProxyFreeBSDClose: pProxyDev=%s\n", pProxyDev->pUsbIns->pszName)); … … 464 459 usbProxyFreeBSDFsUnInit(pProxyDev); 465 460 466 RTFileClose(pDevFBSD->File); 467 468 pDevFBSD->File = NIL_RTFILE; 461 RTFileClose(pDevFBSD->hFile); 462 pDevFBSD->hFile = NIL_RTFILE; 469 463 470 464 RTMemFree(pDevFBSD); 471 472 465 pProxyDev->Backend.pv = NULL; 473 466 … … 991 984 { 992 985 /* Poll for finished transfers */ 993 PollFd.fd = (int)pDevFBSD->File;986 PollFd.fd = RTFileToNative(pDevFBSD->hFile); 994 987 PollFd.events = POLLIN | POLLRDNORM; 995 988 PollFd.revents = 0; -
trunk/src/VBox/Devices/USB/linux/USBProxyDevice-linux.cpp
r35346 r37596 137 137 { 138 138 /** The open file. */ 139 RTFILE File;139 RTFILE hFile; 140 140 /** Critical section protecting the two lists. */ 141 141 RTCRITSECT CritSect; … … 194 194 do 195 195 { 196 rc = ioctl( pDevLnx->File, iCmd, pvArg);196 rc = ioctl(RTFileToNative(pDevLnx->hFile), iCmd, pvArg); 197 197 if (rc >= 0) 198 198 return rc; … … 236 236 pUrbLnx = pUrbLnx->pNext; 237 237 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.. */ 239 239 if (!pCur->KUrb.status) 240 240 pCur->KUrb.status = -ENODEV; … … 596 596 { 597 597 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); 600 600 } 601 601 … … 653 653 * Try open the device node. 654 654 */ 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); 657 657 if (RT_SUCCESS(rc)) 658 658 { … … 666 666 memcpy(&pDevLnx->szPath[0], pszPath, cchPath); 667 667 pDevLnx->szPath[cchPath] = '\0'; 668 pDevLnx-> File =File;668 pDevLnx->hFile = hFile; 669 669 rc = RTCritSectInit(&pDevLnx->CritSect); 670 670 if (RT_SUCCESS(rc)) … … 672 672 pProxyDev->Backend.pv = pDevLnx; 673 673 674 LogFlow(("usbProxyLinuxOpen(%p, %s): returns successfully File=% diActiveCfg=%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)); 676 676 677 677 return VINF_SUCCESS; … … 682 682 else 683 683 rc = VERR_NO_MEMORY; 684 RTFileClose( File);684 RTFileClose(hFile); 685 685 } 686 686 else if (rc == VERR_ACCESS_DENIED) … … 812 812 } 813 813 814 RTFileClose(pDevLnx-> File);815 pDevLnx-> File = NIL_RTFILE;814 RTFileClose(pDevLnx->hFile); 815 pDevLnx->hFile = NIL_RTFILE; 816 816 817 817 RTMemFree(pDevLnx); … … 1278 1278 unsigned cTries = 0; 1279 1279 1280 while (ioctl( pDevLnx->File, USBDEVFS_SUBMITURB, &pCur->KUrb))1280 while (ioctl(RTFileToNative(pDevLnx->hFile), USBDEVFS_SUBMITURB, &pCur->KUrb)) 1281 1281 { 1282 1282 if (errno == EINTR) … … 1516 1516 */ 1517 1517 cTries = 0; 1518 while (ioctl( pDevLnx->File, USBDEVFS_SUBMITURB, &pUrbLnx->KUrb))1518 while (ioctl(RTFileToNative(pDevLnx->hFile), USBDEVFS_SUBMITURB, &pUrbLnx->KUrb)) 1519 1519 { 1520 1520 if (errno == EINTR) … … 1760 1760 { 1761 1761 struct pollfd pfd; 1762 int rc; 1763 1764 pfd.fd = pDevLnx->File; 1762 pfd.fd = RTFileToNative(pDevLnx->hFile); 1765 1763 pfd.events = POLLOUT | POLLWRNORM /* completed async */ 1766 1764 | POLLERR | POLLHUP /* disconnected */; 1767 1765 pfd.revents = 0; 1768 rc = poll(&pfd, 1, cMillies);1766 int rc = poll(&pfd, 1, cMillies); 1769 1767 Log(("usbProxyLinuxUrbReap: poll rc = %d\n", rc)); 1770 1768 if (rc >= 1) … … 1790 1788 { 1791 1789 struct usbdevfs_urb *pKUrb; 1792 while (ioctl( pDevLnx->File, USBDEVFS_REAPURBNDELAY, &pKUrb))1790 while (ioctl(RTFileToNative(pDevLnx->hFile), USBDEVFS_REAPURBNDELAY, &pKUrb)) 1793 1791 if (errno != EINTR) 1794 1792 { -
trunk/src/VBox/Devices/USB/solaris/USBProxyDevice-solaris.cpp
r35346 r37596 80 80 char *pszDevicePath; 81 81 /** The connection to the client driver. */ 82 RTFILE File;82 RTFILE hFile; 83 83 /** Pointer to the proxy device instance. */ 84 84 PUSBPROXYDEV pProxyDev; … … 196 196 static void usbProxySolarisCloseFile(PUSBPROXYDEVSOL pDevSol) 197 197 { 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; 203 200 } 204 201 … … 215 212 static int usbProxySolarisIOCtl(PUSBPROXYDEVSOL pDevSol, unsigned Function, void *pvData, size_t cbData) 216 213 { 217 if (RT_UNLIKELY(pDevSol-> File == NIL_RTFILE))214 if (RT_UNLIKELY(pDevSol->hFile == NIL_RTFILE)) 218 215 { 219 216 LogFlow((USBPROXY ":usbProxySolarisIOCtl connection to driver gone!\n")); … … 228 225 229 226 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); 231 228 if (RT_SUCCESS(rc)) 232 229 { … … 327 324 * Open the client driver. 328 325 */ 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); 331 328 if (RT_SUCCESS(rc)) 332 329 { 333 pDevSol-> File =File;330 pDevSol->hFile = hFile; 334 331 pDevSol->pProxyDev = pProxyDev; 335 332 … … 363 360 } 364 361 365 RTFileClose(pDevSol-> File);366 pDevSol-> File = NIL_RTFILE;362 RTFileClose(pDevSol->hFile); 363 pDevSol->hFile = NIL_RTFILE; 367 364 pDevSol->pProxyDev = NULL; 368 365 } … … 721 718 { 722 719 struct pollfd pfd; 723 int rc; 724 725 pfd.fd = pDevSol->File; 720 pfd.fd = RTFileToNative(pDevSol->hFile); 726 721 pfd.events = POLLIN; 727 722 pfd.revents = 0; 728 rc = poll(&pfd, 1, cMillies); 729 723 int rc = poll(&pfd, 1, cMillies); 730 724 if (rc > 0) 731 725 { -
trunk/src/VBox/Frontends/VBoxBFE/VBoxBFE.cpp
r37418 r37596 1703 1703 strcpy(IfReq.ifr_name, "tun%d"); 1704 1704 IfReq.ifr_flags = IFF_TAP | IFF_NO_PI; 1705 rc = ioctl( tapFD, TUNSETIFF, &IfReq);1705 rc = ioctl(RTFileToNative(tapFD), TUNSETIFF, &IfReq); 1706 1706 if (rc) 1707 1707 { … … 1712 1712 } 1713 1713 1714 rc = fcntl( tapFD, F_SETFL, O_NONBLOCK);1714 rc = fcntl(RTFileToNative(tapFD), F_SETFL, O_NONBLOCK); 1715 1715 if (rc) 1716 1716 { … … 1722 1722 1723 1723 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(); 1725 1725 1726 1726 #elif defined(RT_OS_SOLARIS) -
trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp
r36527 r37596 864 864 return errorSyntax(USAGE_LISTPARTITIONS, "Mandatory parameter -rawdisk missing"); 865 865 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); 868 868 if (RT_FAILURE(vrc)) 869 869 { … … 873 873 874 874 HOSTPARTITIONS partitions; 875 vrc = partRead( RawFile, &partitions);875 vrc = partRead(hRawFile, &partitions); 876 876 /* Don't bail out on errors, print the table and return the result code. */ 877 877 … … 989 989 fRelative = true; 990 990 #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); 993 993 if (RT_FAILURE(vrc)) 994 994 { … … 1008 1008 DISK_GEOMETRY DriveGeo; 1009 1009 DWORD cbDriveGeo; 1010 if (DeviceIoControl((HANDLE)R awFile,1010 if (DeviceIoControl((HANDLE)RTFileToNative(hRawFile), 1011 1011 IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, 1012 1012 &DriveGeo, sizeof(DriveGeo), &cbDriveGeo, NULL)) … … 1029 1029 GET_LENGTH_INFORMATION DiskLenInfo; 1030 1030 DWORD junk; 1031 if (DeviceIoControl((HANDLE)R awFile,1031 if (DeviceIoControl((HANDLE)RTFileToNative(hRawFile), 1032 1032 IOCTL_DISK_GET_LENGTH_INFO, NULL, 0, 1033 1033 &DiskLenInfo, sizeof(DiskLenInfo), &junk, (LPOVERLAPPED)NULL)) … … 1045 1045 #elif defined(RT_OS_LINUX) 1046 1046 struct stat DevStat; 1047 if (!fstat(R awFile, &DevStat) && S_ISBLK(DevStat.st_mode))1047 if (!fstat(RTFileToNative(hRawFile), &DevStat) && S_ISBLK(DevStat.st_mode)) 1048 1048 { 1049 1049 #ifdef BLKGETSIZE64 … … 1056 1056 { 1057 1057 uint64_t cbBlk; 1058 if (!ioctl(R awFile, BLKGETSIZE64, &cbBlk))1058 if (!ioctl(RTFileToNative(hRawFile), BLKGETSIZE64, &cbBlk)) 1059 1059 cbSize = cbBlk; 1060 1060 } … … 1063 1063 { 1064 1064 long cBlocks; 1065 if (!ioctl(R awFile, BLKGETSIZE, &cBlocks))1065 if (!ioctl(RTFileToNative(hRawFile), BLKGETSIZE, &cBlocks)) 1066 1066 cbSize = (uint64_t)cBlocks << 9; 1067 1067 else … … 1081 1081 #elif defined(RT_OS_DARWIN) 1082 1082 struct stat DevStat; 1083 if (!fstat(R awFile, &DevStat) && S_ISBLK(DevStat.st_mode))1083 if (!fstat(RTFileToNative(hRawFile), &DevStat) && S_ISBLK(DevStat.st_mode)) 1084 1084 { 1085 1085 uint64_t cBlocks; 1086 1086 uint32_t cbBlock; 1087 if (!ioctl(R awFile, DKIOCGETBLOCKCOUNT, &cBlocks))1088 { 1089 if (!ioctl(R awFile, DKIOCGETBLOCKSIZE, &cbBlock))1087 if (!ioctl(RTFileToNative(hRawFile), DKIOCGETBLOCKCOUNT, &cBlocks)) 1088 { 1089 if (!ioctl(RTFileToNative(hRawFile), DKIOCGETBLOCKSIZE, &cbBlock)) 1090 1090 cbSize = cBlocks * cbBlock; 1091 1091 else … … 1111 1111 #elif defined(RT_OS_SOLARIS) 1112 1112 struct stat DevStat; 1113 if (!fstat(R awFile, &DevStat) && ( S_ISBLK(DevStat.st_mode)1113 if (!fstat(RTFileToNative(hRawFile), &DevStat) && ( S_ISBLK(DevStat.st_mode) 1114 1114 || S_ISCHR(DevStat.st_mode))) 1115 1115 { 1116 1116 struct dk_minfo mediainfo; 1117 if (!ioctl(R awFile, DKIOCGMEDIAINFO, &mediainfo))1117 if (!ioctl(RTFileToNative(hRawFile), DKIOCGMEDIAINFO, &mediainfo)) 1118 1118 cbSize = mediainfo.dki_capacity * mediainfo.dki_lbsize; 1119 1119 else … … 1132 1132 #elif defined(RT_OS_FREEBSD) 1133 1133 struct stat DevStat; 1134 if (!fstat(R awFile, &DevStat) && S_ISCHR(DevStat.st_mode))1134 if (!fstat(RTFileToNative(hRawFile), &DevStat) && S_ISCHR(DevStat.st_mode)) 1135 1135 { 1136 1136 off_t cbMedia = 0; 1137 if (!ioctl(R awFile, DIOCGMEDIASIZE, &cbMedia))1137 if (!ioctl(RTFileToNative(hRawFile), DIOCGMEDIASIZE, &cbMedia)) 1138 1138 { 1139 1139 cbSize = cbMedia; … … 1155 1155 /* Hopefully this works on all other hosts. If it doesn't, it'll just fail 1156 1156 * creating the VMDK, so no real harm done. */ 1157 vrc = RTFileGetSize( RawFile, &cbSize);1157 vrc = RTFileGetSize(hRawFile, &cbSize); 1158 1158 if (RT_FAILURE(vrc)) 1159 1159 { … … 1213 1213 1214 1214 HOSTPARTITIONS partitions; 1215 vrc = partRead( RawFile, &partitions);1215 vrc = partRead(hRawFile, &partitions); 1216 1216 if (RT_FAILURE(vrc)) 1217 1217 { … … 1268 1268 goto out; 1269 1269 } 1270 vrc = RTFileReadAt( RawFile, partitions.aPartitions[i].uPartDataStart * 512,1270 vrc = RTFileReadAt(hRawFile, partitions.aPartitions[i].uPartDataStart * 512, 1271 1271 pPartData, (size_t)pPartDesc->cbData, NULL); 1272 1272 if (RT_FAILURE(vrc)) … … 1415 1415 } 1416 1416 1417 RTFileClose( RawFile);1417 RTFileClose(hRawFile); 1418 1418 1419 1419 #ifdef DEBUG_klaus … … 1638 1638 vrc = VINF_SUCCESS; 1639 1639 if (fWriteToStdOut) 1640 outFile = 1;1640 vrc = RTFileFromNative(&outFile, 1); 1641 1641 else 1642 1642 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 97 97 SUPLIBDATA g_supLibData = 98 98 { 99 NIL_RTFILE99 SUP_HDEVICE_NIL 100 100 #if defined(RT_OS_DARWIN) 101 101 , NULL … … 185 185 return VERR_INVALID_MAGIC; 186 186 if ( !(fFlags & SUPSECMAIN_FLAGS_DONT_OPEN_DEV) 187 && pPreInitData->Data.hDevice == NIL_RTFILE)187 && pPreInitData->Data.hDevice == SUP_HDEVICE_NIL) 188 188 return VERR_INVALID_HANDLE; 189 189 if ( (fFlags & SUPSECMAIN_FLAGS_DONT_OPEN_DEV) 190 && pPreInitData->Data.hDevice != NIL_RTFILE)190 && pPreInitData->Data.hDevice != SUP_HDEVICE_NIL) 191 191 return VERR_INVALID_PARAMETER; 192 192 -
trunk/src/VBox/HostDrivers/Support/SUPLibInternal.h
r35188 r37596 185 185 { 186 186 /** The device handle. */ 187 RTFILE hDevice; 187 #if defined(RT_OS_WINDOWS) 188 void *hDevice; 189 #else 190 int hDevice; 191 #endif 188 192 #if defined(RT_OS_DARWIN) 189 193 /** The connection to the VBoxSupDrv service. */ … … 203 207 /** Pointer to const pre-init data. */ 204 208 typedef 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 205 216 206 217 -
trunk/src/VBox/HostDrivers/Support/SUPR3HardenedMain.cpp
r35311 r37596 1019 1019 */ 1020 1020 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; 1024 1024 1025 1025 #ifdef SUP_HARDENED_SUID -
trunk/src/VBox/HostDrivers/Support/darwin/SUPLib-darwin.cpp
r33540 r37596 194 194 * Do the job. 195 195 */ 196 Assert(pThis->hDevice == NIL_RTFILE);196 Assert(pThis->hDevice == (intptr_t)NIL_RTFILE); 197 197 int rc = suplibDarwinOpenService(pThis); 198 198 if (RT_SUCCESS(rc)) … … 237 237 * Check if we're inited at all. 238 238 */ 239 if (pThis->hDevice != NIL_RTFILE)239 if (pThis->hDevice != (intptr_t)NIL_RTFILE) 240 240 { 241 241 if (close(pThis->hDevice)) 242 242 AssertFailed(); 243 pThis->hDevice = NIL_RTFILE;243 pThis->hDevice = (intptr_t)NIL_RTFILE; 244 244 } 245 245 -
trunk/src/VBox/HostDrivers/Support/freebsd/SUPLib-freebsd.cpp
r33540 r37596 133 133 * Check if we're inited at all. 134 134 */ 135 if (pThis->hDevice != NIL_RTFILE)135 if (pThis->hDevice != (intptr_t)NIL_RTFILE) 136 136 { 137 137 if (close(pThis->hDevice)) 138 138 AssertFailed(); 139 pThis->hDevice = NIL_RTFILE;139 pThis->hDevice = (intptr_t)NIL_RTFILE; 140 140 } 141 141 return VINF_SUCCESS; -
trunk/src/VBox/HostDrivers/Support/linux/SUPLib-linux.cpp
r37556 r37596 79 79 if (fPreInited) 80 80 return VINF_SUCCESS; 81 Assert(pThis->hDevice == NIL_RTFILE);81 Assert(pThis->hDevice == (intptr_t)NIL_RTFILE); 82 82 83 83 /* … … 145 145 * Close the device if it's actually open. 146 146 */ 147 if (pThis->hDevice != NIL_RTFILE)147 if (pThis->hDevice != (intptr_t)NIL_RTFILE) 148 148 { 149 149 if (close(pThis->hDevice)) 150 150 AssertFailed(); 151 pThis->hDevice = NIL_RTFILE;151 pThis->hDevice = (intptr_t)NIL_RTFILE; 152 152 } 153 153 … … 172 172 int suplibOsIOCtl(PSUPLIBDATA pThis, uintptr_t uFunction, void *pvReq, size_t cbReq) 173 173 { 174 AssertMsg(pThis->hDevice != NIL_RTFILE, ("SUPLIB not initiated successfully!\n"));174 AssertMsg(pThis->hDevice != (intptr_t)NIL_RTFILE, ("SUPLIB not initiated successfully!\n")); 175 175 176 176 /* -
trunk/src/VBox/HostDrivers/Support/os2/SUPLib-os2.cpp
r33540 r37596 100 100 } 101 101 102 pThis->hDevice = (RTFILE)hDevice;102 pThis->hDevice = hDevice; 103 103 return VINF_SUCCESS; 104 104 } … … 112 112 * Check if we're inited at all. 113 113 */ 114 if (pThis->hDevice != NIL_RTFILE)114 if (pThis->hDevice != (intptr_t)NIL_RTFILE) 115 115 { 116 116 APIRET rc = DosClose((HFILE)pThis->hDevice); 117 117 AssertMsg(rc == NO_ERROR, ("%d\n", rc)); NOREF(rc); 118 pThis->hDevice = NIL_RTFILE;118 pThis->hDevice = (intptr_t)NIL_RTFILE; 119 119 } 120 120 -
trunk/src/VBox/HostDrivers/Support/solaris/SUPLib-solaris.cpp
r28800 r37596 162 162 if (close(pThis->hDevice)) 163 163 AssertFailed(); 164 pThis->hDevice = NIL_RTFILE;164 pThis->hDevice = (intptr_t)NIL_RTFILE; 165 165 } 166 166 -
trunk/src/VBox/HostDrivers/Support/win/SUPLib-win.cpp
r33540 r37596 139 139 * We're done. 140 140 */ 141 pThis->hDevice = (RTFILE)hDevice;141 pThis->hDevice = hDevice; 142 142 return VINF_SUCCESS; 143 143 } … … 475 475 * Check if we're inited at all. 476 476 */ 477 if (pThis->hDevice != N IL_RTFILE)477 if (pThis->hDevice != NULL) 478 478 { 479 479 if (!CloseHandle((HANDLE)pThis->hDevice)) 480 480 AssertFailed(); 481 pThis->hDevice = NIL_RTFILE; 481 pThis->hDevice = NIL_RTFILE; /* yes, that's right */ 482 482 } 483 483 -
trunk/src/VBox/Main/include/USBProxyService.h
r36993 r37596 256 256 private: 257 257 /** File handle to the '/proc/bus/usb/devices' file. */ 258 RTFILE m File;258 RTFILE mhFile; 259 259 /** Pipe used to interrupt wait(), the read end. */ 260 RT FILE mWakeupPipeR;260 RTPIPE mhWakeupPipeR; 261 261 /** Pipe used to interrupt wait(), the write end. */ 262 RT FILE mWakeupPipeW;262 RTPIPE mhWakeupPipeW; 263 263 /** The root of usbfs. */ 264 264 Utf8Str mDevicesRoot; -
trunk/src/VBox/Main/src-server/linux/USBProxyServiceLinux.cpp
r36997 r37596 39 39 #include <iprt/param.h> 40 40 #include <iprt/path.h> 41 #include <iprt/pipe.h> 41 42 #include <iprt/stream.h> 42 43 #include <iprt/linux/sysfs.h> … … 60 61 */ 61 62 USBProxyServiceLinux::USBProxyServiceLinux(Host *aHost) 62 : USBProxyService(aHost), m File(NIL_RTFILE), mWakeupPipeR(NIL_RTFILE),63 m WakeupPipeW(NIL_RTFILE), mUsingUsbfsDevices(true /* see init */),63 : USBProxyService(aHost), mhFile(NIL_RTFILE), mhWakeupPipeR(NIL_RTPIPE), 64 mhWakeupPipeW(NIL_RTPIPE), mUsingUsbfsDevices(true /* see init */), 64 65 mUdevPolls(0), mpWaiter(NULL) 65 66 #ifdef UNIT_TEST … … 209 210 if (pszDevices) 210 211 { 211 rc = RTFileOpen(&m File, 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); 212 213 if (RT_SUCCESS(rc)) 213 214 { 214 int pipes[2];215 if ( !pipe(pipes))215 rc = RTPipeCreate(&mhWakeupPipeR, &mhWakeupPipeW, 0 /*fFlags*/); 216 if (RT_SUCCESS(rc)) 216 217 { 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)) 220 223 { 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; 238 227 } 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; 246 232 } 247 233 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); 253 236 } 254 237 … … 332 315 * Free resources. 333 316 */ 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; 345 323 } 346 324 … … 434 412 435 413 memset(&PollFds, 0, sizeof(PollFds)); 436 PollFds[0].fd = mFile;414 PollFds[0].fd = RTFileToNative(mhFile); 437 415 PollFds[0].events = POLLIN; 438 PollFds[1].fd = mWakeupPipeR;416 PollFds[1].fd = RTPipeToNative(mhWakeupPipeR); 439 417 PollFds[1].events = POLLIN | POLLERR | POLLHUP; 440 418 … … 448 426 { 449 427 char szBuf[WAKE_UP_STRING_LEN]; 450 rc = RT FileRead(mWakeupPipeR, szBuf, sizeof(szBuf), NULL);428 rc = RTPipeReadBlocking(mhWakeupPipeR, szBuf, sizeof(szBuf), NULL); 451 429 AssertRC(rc); 452 430 } … … 484 462 } 485 463 #endif /* VBOX_USB_WITH_SYSFS */ 486 int rc = RT FileWrite(mWakeupPipeW, WAKE_UP_STRING, WAKE_UP_STRING_LEN, NULL);464 int rc = RTPipeWriteBlocking(mhWakeupPipeW, WAKE_UP_STRING, WAKE_UP_STRING_LEN, NULL); 487 465 if (RT_SUCCESS(rc)) 488 RT FileFlush(mWakeupPipeW);466 RTPipeFlush(mhWakeupPipeW); 489 467 LogFlowFunc(("returning %Rrc\n", rc)); 490 468 return rc; -
trunk/src/VBox/NetworkServices/NAT/VBoxNetNAT.cpp
r36470 r37596 35 35 #include <iprt/path.h> 36 36 #include <iprt/param.h> 37 #include <iprt/pipe.h> 37 38 #include <iprt/getopt.h> 38 39 #include <iprt/string.h> … … 90 91 HANDLE m_hWakeupEvent; 91 92 #else 92 RT FILE m_PipeWrite;93 RT FILE m_PipeRead;93 RTPIPE m_hPipeWrite; 94 RTPIPE m_hPipeRead; 94 95 #endif 95 96 /** Queue for NAT-thread-external events. */ … … 126 127 #ifndef RT_OS_WINDOWS 127 128 /* kick select() */ 128 rc = RTFileWrite(g_pNAT->m_PipeWrite, "", 1, NULL); 129 size_t cbIgnored; 130 rc = RTPipeWrite(g_pNAT->m_hPipeWrite, "", 1, &cbIgnored); 129 131 #else 130 132 /* kick WSAWaitForMultipleEvents */ … … 170 172 * Create the control pipe. 171 173 */ 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); 181 176 #else 182 177 m_hWakeupEvent = CreateEvent(NULL, FALSE, FALSE, NULL); /* auto-reset event */ 178 AssertReleaseRC(m_hWakeupEvent != NULL); 183 179 slirp_register_external_event(m_pNATState, m_hWakeupEvent, VBOX_WAKEUP_EVENT_INDEX); 184 180 #endif … … 299 295 #ifndef RT_OS_WINDOWS 300 296 /* kick select() */ 301 rc = RTFileWrite(m_PipeWrite, "", 1, NULL); 297 size_t cbIgnored; 298 rc = RTPipeWrite(m_hPipeWrite, "", 1, &cbIgnored); 302 299 AssertRC(rc); 303 300 #else … … 468 465 unsigned int cMsTimeout = slirp_get_timeout_ms(pThis->m_pNATState); 469 466 470 polls[0].fd = pThis->m_PipeRead;467 polls[0].fd = RTPipeToNative(pThis->m_hPipeRead); 471 468 /* POLLRDBAND usually doesn't used on Linux but seems used on Solaris */ 472 469 polls[0].events = POLLRDNORM|POLLPRI|POLLRDBAND; … … 494 491 if (polls[0].revents & (POLLRDNORM|POLLPRI|POLLRDBAND)) 495 492 { 496 /* drain the pipe */ 497 char ch[1]; 498 size_t cbRead; 499 int counter = 0; 500 /* 493 /* drain the pipe 494 * 495 * Note! 501 496 * drvNATSend decoupled so we don't know how many times 502 497 * device's thread sends before we've entered multiplex, … … 506 501 * deep pipe has been filed before drain. 507 502 * 508 * XXX:Make it reading exactly we need to drain the pipe.509 503 */ 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); 511 509 } 512 510 } -
trunk/src/VBox/Runtime/common/ldr/ldr.cpp
r28800 r37596 39 39 #include <iprt/log.h> 40 40 #include "internal/ldr.h" 41 42 43 /*******************************************************************************44 * Structures and Typedefs *45 *******************************************************************************/46 typedef struct RTLDRREADERFILE47 {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 60 41 61 42 -
trunk/src/VBox/Runtime/common/ldr/ldrFile.cpp
r28800 r37596 55 55 RTLDRREADER Core; 56 56 /** The file. */ 57 RTFILE File;57 RTFILE hFile; 58 58 /** The file size. */ 59 59 RTFOFF cbFile; … … 79 79 if (pFileReader->off != off) 80 80 { 81 int rc = RTFileSeek(pFileReader-> File, off, RTFILE_SEEK_BEGIN, NULL);81 int rc = RTFileSeek(pFileReader->hFile, off, RTFILE_SEEK_BEGIN, NULL); 82 82 if (RT_FAILURE(rc)) 83 83 { … … 91 91 * Read. 92 92 */ 93 int rc = RTFileRead(pFileReader-> File, pvBuf, cb, NULL);93 int rc = RTFileRead(pFileReader->hFile, pvBuf, cb, NULL); 94 94 if (RT_SUCCESS(rc)) 95 95 pFileReader->off += cb; … … 185 185 int rc = VINF_SUCCESS; 186 186 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); 190 190 AssertRC(rc); 191 pFileReader-> File = NIL_RTFILE;191 pFileReader->hFile = NIL_RTFILE; 192 192 } 193 193 RTMemFree(pFileReader); … … 211 211 { 212 212 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); 214 214 if (RT_SUCCESS(rc)) 215 215 { 216 rc = RTFileGetSize(pFileReader-> File, (uint64_t *)&pFileReader->cbFile);216 rc = RTFileGetSize(pFileReader->hFile, (uint64_t *)&pFileReader->cbFile); 217 217 if (RT_SUCCESS(rc)) 218 218 { … … 230 230 return VINF_SUCCESS; 231 231 } 232 RTFileClose(pFileReader->File); 232 233 RTFileClose(pFileReader->hFile); 233 234 } 234 235 RTMemFree(pFileReader); -
trunk/src/VBox/Runtime/common/log/log.cpp
r37593 r37596 129 129 130 130 /** Handle to log file (if open). */ 131 union 132 { 133 RTFILE hFile; 134 RTHCUINTPTR uPaddingForNewRTFILE; 135 } u; 131 RTFILE hFile; 136 132 /** Log file history settings: maximum amount of data to put in a file. */ 137 133 uint64_t cbHistoryFileMax; … … 157 153 /** The size of the RTLOGGERINTERNAL structure in ring-0. */ 158 154 # define RTLOGGERINTERNAL_R0_SIZE RT_OFFSETOF(RTLOGGERINTERNAL, pfnPhase) 159 AssertCompileMemberAlignment(RTLOGGERINTERNAL, u.hFile, sizeof(void *));155 AssertCompileMemberAlignment(RTLOGGERINTERNAL, hFile, sizeof(void *)); 160 156 AssertCompileMemberAlignment(RTLOGGERINTERNAL, cbHistoryFileMax, sizeof(uint64_t)); 161 157 #endif … … 341 337 { 342 338 PRTLOGGER pLogger = (PRTLOGGER)pvArg; 343 RTFileWrite(pLogger->pInt-> u.hFile, pachChars, cbChars, NULL);339 RTFileWrite(pLogger->pInt->hFile, pachChars, cbChars, NULL); 344 340 return cbChars; 345 341 } … … 479 475 # ifdef IN_RING3 480 476 pLogger->pInt->pfnPhase = pfnPhase; 481 pLogger->pInt-> u.hFile= NIL_RTFILE;477 pLogger->pInt->hFile = NIL_RTFILE; 482 478 pLogger->pInt->cHistory = cHistory; 483 479 if (cbHistoryFileMax == 0) … … 596 592 597 593 /* 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) 599 595 { 600 596 pLogger->pInt->cbHistoryFileWritten = 0; … … 638 634 } 639 635 # ifdef IN_RING3 640 RTFileClose(pLogger->pInt-> u.hFile);636 RTFileClose(pLogger->pInt->hFile); 641 637 # endif 642 638 # if defined(LOG_USE_C99) && defined(RT_WITHOUT_EXEC_ALLOC) … … 736 732 */ 737 733 if ( (pLogger->fDestFlags & RTLOGDEST_FILE) 738 && pLogger->pInt-> u.hFile != NIL_RTFILE)734 && pLogger->pInt->hFile != NIL_RTFILE) 739 735 pLogger->pInt->pfnPhase(pLogger, RTLOGPHASE_END, rtlogPhaseMsgLocked); 740 736 … … 742 738 * Close output stuffs. 743 739 */ 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); 747 743 AssertRC(rc2); 748 744 if (RT_FAILURE(rc2) && RT_SUCCESS(rc)) 749 745 rc = rc2; 750 pLogger->pInt-> u.hFile = NIL_RTFILE;746 pLogger->pInt->hFile = NIL_RTFILE; 751 747 } 752 748 # endif … … 2558 2554 fOpen |= RTFILE_O_WRITE_THROUGH; 2559 2555 2560 int rc = RTFileOpen(&pLogger->pInt-> u.hFile, pLogger->pInt->szFilename, fOpen);2556 int rc = RTFileOpen(&pLogger->pInt->hFile, pLogger->pInt->szFilename, fOpen); 2561 2557 if (RT_FAILURE(rc)) 2562 2558 { 2563 pLogger->pInt-> u.hFile = NIL_RTFILE;2559 pLogger->pInt->hFile = NIL_RTFILE; 2564 2560 if (pszErrorMsg) 2565 2561 RTStrPrintf(pszErrorMsg, cchErrorMsg, N_("could not open file '%s' (fOpen=%#x)"), pLogger->pInt->szFilename, fOpen); … … 2567 2563 else 2568 2564 { 2569 rc = RTFileGetSize(pLogger->pInt-> u.hFile, &pLogger->pInt->cbHistoryFileWritten);2565 rc = RTFileGetSize(pLogger->pInt->hFile, &pLogger->pInt->cbHistoryFileWritten); 2570 2566 if (RT_FAILURE(rc)) 2571 2567 { … … 2619 2615 * Close the old log file. 2620 2616 */ 2621 if (pLogger->pInt-> u.hFile != NIL_RTFILE)2617 if (pLogger->pInt->hFile != NIL_RTFILE) 2622 2618 { 2623 2619 /* Use the callback to generate some final log contents, but only if … … 2631 2627 pLogger->fDestFlags = fODestFlags; 2632 2628 } 2633 RTFileClose(pLogger->pInt-> u.hFile);2634 pLogger->pInt-> u.hFile = NIL_RTFILE;2629 RTFileClose(pLogger->pInt->hFile); 2630 pLogger->pInt->hFile = NIL_RTFILE; 2635 2631 } 2636 2632 … … 2717 2713 if (pLogger->fDestFlags & RTLOGDEST_FILE) 2718 2714 { 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); 2722 2718 if (pLogger->fFlags & RTLOGFLAGS_FLUSH) 2723 RTFileFlush(pLogger->pInt-> u.hFile);2719 RTFileFlush(pLogger->pInt->hFile); 2724 2720 } 2725 2721 if (pLogger->pInt->cHistory) -
trunk/src/VBox/Runtime/common/misc/RTFileOpenF.cpp
r28800 r37596 33 33 34 34 35 RTR3DECL(int) RTFileOpenF(PRTFILE pFile, uint 32_t fOpen, const char *pszFilenameFmt, ...)35 RTR3DECL(int) RTFileOpenF(PRTFILE pFile, uint64_t fOpen, const char *pszFilenameFmt, ...) 36 36 { 37 37 va_list va; -
trunk/src/VBox/Runtime/common/misc/RTFileOpenV.cpp
r28800 r37596 37 37 38 38 39 RTR3DECL(int) RTFileOpenV(PRTFILE pFile, uint 32_t fOpen, const char *pszFilenameFmt, va_list va)39 RTR3DECL(int) RTFileOpenV(PRTFILE pFile, uint64_t fOpen, const char *pszFilenameFmt, va_list va) 40 40 { 41 41 char szFilename[RTPATH_MAX]; -
trunk/src/VBox/Runtime/common/vfs/vfsbase.cpp
r35213 r37596 2298 2298 2299 2299 2300 RTDECL(int) RTVfsFileOpen(RTVFS hVfs, const char *pszFilename, uint 32_t fOpen, PRTVFSFILE phVfsFile)2300 RTDECL(int) RTVfsFileOpen(RTVFS hVfs, const char *pszFilename, uint64_t fOpen, PRTVFSFILE phVfsFile) 2301 2301 { 2302 2302 /* -
trunk/src/VBox/Runtime/common/vfs/vfschain.cpp
r34179 r37596 563 563 564 564 565 RTDECL(int) RTVfsChainOpenFile(const char *pszSpec, uint 32_t fOpen, PRTVFSFILE phVfsFile, const char **ppszError)565 RTDECL(int) RTVfsChainOpenFile(const char *pszSpec, uint64_t fOpen, PRTVFSFILE phVfsFile, const char **ppszError) 566 566 { 567 567 AssertPtrReturn(pszSpec, VERR_INVALID_POINTER); … … 610 610 611 611 612 RTDECL(int) RTVfsChainOpenIoStream(const char *pszSpec, uint 32_t fOpen, PRTVFSIOSTREAM phVfsIos, const char **ppszError)612 RTDECL(int) RTVfsChainOpenIoStream(const char *pszSpec, uint64_t fOpen, PRTVFSIOSTREAM phVfsIos, const char **ppszError) 613 613 { 614 614 AssertPtrReturn(pszSpec, VERR_INVALID_POINTER); -
trunk/src/VBox/Runtime/common/vfs/vfsmisc.cpp
r33973 r37596 39 39 40 40 41 RTDECL(int) RTVfsIoStrmFromStdHandle(RTHANDLESTD enmStdHandle, uint 32_t fOpen, bool fLeaveOpen,41 RTDECL(int) RTVfsIoStrmFromStdHandle(RTHANDLESTD enmStdHandle, uint64_t fOpen, bool fLeaveOpen, 42 42 PRTVFSIOSTREAM phVfsIos) 43 43 { -
trunk/src/VBox/Runtime/common/vfs/vfsstdfile.cpp
r36555 r37596 419 419 420 420 421 RTDECL(int) RTVfsFileFromRTFile(RTFILE hFile, uint 32_t fOpen, bool fLeaveOpen, PRTVFSFILE phVfsFile)421 RTDECL(int) RTVfsFileFromRTFile(RTFILE hFile, uint64_t fOpen, bool fLeaveOpen, PRTVFSFILE phVfsFile) 422 422 { 423 423 /* … … 451 451 452 452 453 RTDECL(int) RTVfsIoStrmFromRTFile(RTFILE hFile, uint 32_t fOpen, bool fLeaveOpen, PRTVFSIOSTREAM phVfsIos)453 RTDECL(int) RTVfsIoStrmFromRTFile(RTFILE hFile, uint64_t fOpen, bool fLeaveOpen, PRTVFSIOSTREAM phVfsIos) 454 454 { 455 455 RTVFSFILE hVfsFile; -
trunk/src/VBox/Runtime/include/internal/file.h
r36597 r37596 42 42 * @internal 43 43 */ 44 int rtFileRecalcAndValidateFlags(uint 32_t *pfOpen);44 int rtFileRecalcAndValidateFlags(uint64_t *pfOpen); 45 45 46 46 -
trunk/src/VBox/Runtime/include/internal/rand.h
r36555 r37596 150 150 struct RTRandFile 151 151 { 152 /** The file handle . */153 RTFILEhFile;152 /** The file handle (native). */ 153 intptr_t hFile; 154 154 } File; 155 155 } u; -
trunk/src/VBox/Runtime/r3/fileio.cpp
r33540 r37596 107 107 * @internal 108 108 */ 109 int rtFileRecalcAndValidateFlags(uint 32_t *pfOpen)109 int rtFileRecalcAndValidateFlags(uint64_t *pfOpen) 110 110 { 111 111 /* … … 128 128 break; 129 129 default: 130 AssertMsgFailed(("Invalid RW value, fOpen=%# x\n", fOpen));130 AssertMsgFailed(("Invalid RW value, fOpen=%#llx\n", fOpen)); 131 131 return VERR_INVALID_PARAMETER; 132 132 } … … 135 135 * Validate . 136 136 */ 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); 138 138 #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); 140 140 #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); 142 142 #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); 144 144 145 145 switch (fOpen & RTFILE_O_ACTION_MASK) … … 150 150 break; 151 151 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); 153 153 case RTFILE_O_OPEN_CREATE: 154 154 case RTFILE_O_CREATE: … … 156 156 break; 157 157 default: 158 AssertMsgFailed(("Invalid action value: fOpen=%# x\n", fOpen));158 AssertMsgFailed(("Invalid action value: fOpen=%#llx\n", fOpen)); 159 159 return VERR_INVALID_PARAMETER; 160 160 } … … 176 176 break; 177 177 default: 178 AssertMsgFailed(("Invalid deny value: fOpen=%# x\n", fOpen));178 AssertMsgFailed(("Invalid deny value: fOpen=%#llx\n", fOpen)); 179 179 return VERR_INVALID_PARAMETER; 180 180 } -
trunk/src/VBox/Runtime/r3/linux/fileaio-linux.cpp
r33540 r37596 105 105 int16_t i16Priority; 106 106 /** The file descriptor. */ 107 uint32_t File;107 uint32_t uFileDesc; 108 108 /** The userspace pointer to the buffer containing/receiving the data. */ 109 109 void *pvBuf; … … 379 379 */ 380 380 pReqInt->AioCB.u16IoOpCode = uTransferDirection; 381 pReqInt->AioCB. File = (uint32_t)hFile;381 pReqInt->AioCB.uFileDesc = RTFileToNative(hFile); 382 382 pReqInt->AioCB.off = off; 383 383 pReqInt->AioCB.cbTransfer = cbTransfer; -
trunk/src/VBox/Runtime/r3/posix/RTFileQueryFsSizes-posix.cpp
r28800 r37596 48 48 struct statvfs StatVFS; 49 49 RT_ZERO(StatVFS); 50 if (fstatvfs( hFile, &StatVFS))50 if (fstatvfs(RTFileToNative(hFile), &StatVFS)) 51 51 return RTErrConvertFromErrno(errno); 52 52 -
trunk/src/VBox/Runtime/r3/posix/fileaio-posix.cpp
r33540 r37596 5 5 6 6 /* 7 * Copyright (C) 2006-20 07Oracle Corporation7 * Copyright (C) 2006-2011 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 407 407 pReqInt->fFlush = false; 408 408 pReqInt->AioCB.aio_lio_opcode = uTransferDirection; 409 pReqInt->AioCB.aio_fildes = (int)hFile;409 pReqInt->AioCB.aio_fildes = RTFileToNative(hFile); 410 410 pReqInt->AioCB.aio_offset = off; 411 411 pReqInt->AioCB.aio_nbytes = cbTransfer; … … 445 445 446 446 pReqInt->fFlush = true; 447 pReqInt->AioCB.aio_fildes = (int)hFile;447 pReqInt->AioCB.aio_fildes = RTFileToNative(hFile); 448 448 pReqInt->AioCB.aio_offset = 0; 449 449 pReqInt->AioCB.aio_nbytes = 0; -
trunk/src/VBox/Runtime/r3/posix/fileio-posix.cpp
r36597 r37596 93 93 94 94 95 RTR3DECL(int) RTFileOpen(PRTFILE pFile, const char *pszFilename, uint 32_t fOpen)95 RTR3DECL(int) RTFileOpen(PRTFILE pFile, const char *pszFilename, uint64_t fOpen) 96 96 { 97 97 /* … … 111 111 if (fOpen & RTFILE_O_NON_BLOCK) 112 112 { 113 AssertMsgFailed(("Invalid parameters! fOpen=%# x\n", fOpen));113 AssertMsgFailed(("Invalid parameters! fOpen=%#llx\n", fOpen)); 114 114 return VERR_INVALID_PARAMETER; 115 115 } … … 177 177 break; 178 178 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)); 180 180 return VERR_INVALID_PARAMETER; 181 181 } … … 322 322 if (iErr == 0) 323 323 { 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", 327 327 pFile, *pFile, pszFilename, pszFilename, fOpen, rc)); 328 328 return VINF_SUCCESS; … … 335 335 336 336 337 RTR3DECL(int) RTFileOpenBitBucket(PRTFILE phFile, uint 32_t fAccess)337 RTR3DECL(int) RTFileOpenBitBucket(PRTFILE phFile, uint64_t fAccess) 338 338 { 339 339 AssertReturn( fAccess == RTFILE_O_READ … … 345 345 346 346 347 RTR3DECL(int) RTFileClose(RTFILE File)348 { 349 if ( File == NIL_RTFILE)350 return VINF_SUCCESS; 351 if (close( (int)File) == 0)347 RTR3DECL(int) RTFileClose(RTFILE hFile) 348 { 349 if (hFile == NIL_RTFILE) 350 return VINF_SUCCESS; 351 if (close(RTFileToNative(hFile)) == 0) 352 352 return VINF_SUCCESS; 353 353 return RTErrConvertFromErrno(errno); … … 357 357 RTR3DECL(int) RTFileFromNative(PRTFILE pFile, RTHCINTPTR uNative) 358 358 { 359 if ( uNative < 0360 || (RTFILE)uNative != (RTUINTPTR)uNative)359 AssertCompile(sizeof(uNative) == sizeof(*pFile)); 360 if (uNative < 0) 361 361 { 362 362 AssertMsgFailed(("%p\n", uNative)); … … 369 369 370 370 371 RTR3DECL(RTHCINTPTR) RTFileToNative(RTFILE File)372 { 373 AssertReturn( File != NIL_RTFILE, -1);374 return ( RTHCINTPTR)File;371 RTR3DECL(RTHCINTPTR) RTFileToNative(RTFILE hFile) 372 { 373 AssertReturn(hFile != NIL_RTFILE, -1); 374 return (intptr_t)hFile; 375 375 } 376 376 … … 411 411 412 412 413 RTR3DECL(int) RTFileSeek(RTFILE File, int64_t offSeek, unsigned uMethod, uint64_t *poffActual)413 RTR3DECL(int) RTFileSeek(RTFILE hFile, int64_t offSeek, unsigned uMethod, uint64_t *poffActual) 414 414 { 415 415 static const unsigned aSeekRecode[] = … … 438 438 } 439 439 440 off_t offCurrent = lseek( (int)File, (off_t)offSeek, aSeekRecode[uMethod]);440 off_t offCurrent = lseek(RTFileToNative(hFile), (off_t)offSeek, aSeekRecode[uMethod]); 441 441 if (offCurrent != ~0) 442 442 { … … 449 449 450 450 451 RTR3DECL(int) RTFileRead(RTFILE File, void *pvBuf, size_t cbToRead, size_t *pcbRead)451 RTR3DECL(int) RTFileRead(RTFILE hFile, void *pvBuf, size_t cbToRead, size_t *pcbRead) 452 452 { 453 453 if (cbToRead <= 0) … … 457 457 * Attempt read. 458 458 */ 459 ssize_t cbRead = read( (int)File, pvBuf, cbToRead);459 ssize_t cbRead = read(RTFileToNative(hFile), pvBuf, cbToRead); 460 460 if (cbRead >= 0) 461 461 { … … 468 468 while ((ssize_t)cbToRead > cbRead) 469 469 { 470 ssize_t cbReadPart = read( (int)File, (char*)pvBuf + cbRead, cbToRead - cbRead);470 ssize_t cbReadPart = read(RTFileToNative(hFile), (char*)pvBuf + cbRead, cbToRead - cbRead); 471 471 if (cbReadPart <= 0) 472 472 { … … 485 485 486 486 487 RTR3DECL(int) RTFileWrite(RTFILE File, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten)487 RTR3DECL(int) RTFileWrite(RTFILE hFile, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten) 488 488 { 489 489 if (cbToWrite <= 0) … … 493 493 * Attempt write. 494 494 */ 495 ssize_t cbWritten = write( (int)File, pvBuf, cbToWrite);495 ssize_t cbWritten = write(RTFileToNative(hFile), pvBuf, cbToWrite); 496 496 if (cbWritten >= 0) 497 497 { … … 504 504 while ((ssize_t)cbToWrite > cbWritten) 505 505 { 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); 507 507 if (cbWrittenPart <= 0) 508 508 return RTErrConvertFromErrno(errno); … … 516 516 517 517 518 RTR3DECL(int) RTFileSetSize(RTFILE File, uint64_t cbSize)518 RTR3DECL(int) RTFileSetSize(RTFILE hFile, uint64_t cbSize) 519 519 { 520 520 /* … … 529 529 530 530 #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) 532 532 #else 533 533 /* This relies on a non-standard feature of FreeBSD, Linux, and OS/2 … … 535 535 * than the file.) 536 536 */ 537 if (ftruncate( (int)File, (off_t)cbSize) == 0)537 if (ftruncate(RTFileToNative(hFile), (off_t)cbSize) == 0) 538 538 #endif 539 539 return VINF_SUCCESS; … … 542 542 543 543 544 RTR3DECL(int) RTFileGetSize(RTFILE File, uint64_t *pcbSize)544 RTR3DECL(int) RTFileGetSize(RTFILE hFile, uint64_t *pcbSize) 545 545 { 546 546 struct stat st; 547 if (!fstat( (int)File, &st))547 if (!fstat(RTFileToNative(hFile), &st)) 548 548 { 549 549 *pcbSize = st.st_size; … … 554 554 555 555 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) 556 RTR3DECL(int) RTFileGetMaxSizeEx(RTFILE hFile, PRTFOFF pcbMax) 565 557 { 566 558 /* … … 568 560 */ 569 561 uint64_t offOld; 570 int rc = RTFileSeek( File, 0, RTFILE_SEEK_CURRENT, &offOld);562 int rc = RTFileSeek(hFile, 0, RTFILE_SEEK_CURRENT, &offOld); 571 563 if (RT_FAILURE(rc)) 572 564 return rc; … … 588 580 if (pcbMax) 589 581 *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); 594 586 if (RT_FAILURE(rc)) 595 587 offHigh = offLow + cbInterval; … … 600 592 601 593 602 RTR3DECL(bool) RTFileIsValid(RTFILE File)603 { 604 if ( File != NIL_RTFILE)605 { 606 int fFlags = fcntl( File, F_GETFD);594 RTR3DECL(bool) RTFileIsValid(RTFILE hFile) 595 { 596 if (hFile != NIL_RTFILE) 597 { 598 int fFlags = fcntl(RTFileToNative(hFile), F_GETFD); 607 599 if (fFlags >= 0) 608 600 return true; … … 612 604 613 605 614 RTR3DECL(int) RTFileFlush(RTFILE File)615 { 616 if (fsync( (int)File))606 RTR3DECL(int) RTFileFlush(RTFILE hFile) 607 { 608 if (fsync(RTFileToNative(hFile))) 617 609 return RTErrConvertFromErrno(errno); 618 610 return VINF_SUCCESS; … … 620 612 621 613 622 RTR3DECL(int) RTFileIoCtl(RTFILE File, unsigned long ulRequest, void *pvData, unsigned cbData, int *piRet)623 { 624 int rc = ioctl( (int)File, ulRequest, pvData);614 RTR3DECL(int) RTFileIoCtl(RTFILE hFile, unsigned long ulRequest, void *pvData, unsigned cbData, int *piRet) 615 { 616 int rc = ioctl(RTFileToNative(hFile), ulRequest, pvData); 625 617 if (piRet) 626 618 *piRet = rc; … … 629 621 630 622 631 RTR3DECL(int) RTFileSetMode(RTFILE File, RTFMODE fMode)623 RTR3DECL(int) RTFileSetMode(RTFILE hFile, RTFMODE fMode) 632 624 { 633 625 /* … … 638 630 return VERR_INVALID_PARAMETER; 639 631 640 if (fchmod( (int)File, fMode & RTFS_UNIX_MASK))632 if (fchmod(RTFileToNative(hFile), fMode & RTFS_UNIX_MASK)) 641 633 { 642 634 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)); 644 636 return rc; 645 637 } -
trunk/src/VBox/Runtime/r3/posix/fileio2-posix.cpp
r34016 r37596 5 5 6 6 /* 7 * Copyright (C) 2006-201 0Oracle Corporation7 * Copyright (C) 2006-2011 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 69 69 70 70 71 RTR3DECL(int) RTFileQueryInfo(RTFILE File, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAdditionalAttribs)71 RTR3DECL(int) RTFileQueryInfo(RTFILE hFile, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAdditionalAttribs) 72 72 { 73 73 /* 74 74 * Validate input. 75 75 */ 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); 86 78 if ( enmAdditionalAttribs < RTFSOBJATTRADD_NOTHING 87 79 || enmAdditionalAttribs > RTFSOBJATTRADD_LAST) … … 95 87 */ 96 88 struct stat Stat; 97 if (fstat( (int)File, &Stat))89 if (fstat(RTFileToNative(hFile), &Stat)) 98 90 { 99 91 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)); 101 93 return rc; 102 94 } … … 135 127 } 136 128 137 LogFlow(("RTFileQueryInfo(%RTfile,,%d): returns VINF_SUCCESS\n", File, enmAdditionalAttribs));129 LogFlow(("RTFileQueryInfo(%RTfile,,%d): returns VINF_SUCCESS\n", hFile, enmAdditionalAttribs)); 138 130 return VINF_SUCCESS; 139 131 } 140 132 141 133 142 RTR3DECL(int) RTFileSetTimes(RTFILE File, PCRTTIMESPEC pAccessTime, PCRTTIMESPEC pModificationTime,134 RTR3DECL(int) RTFileSetTimes(RTFILE hFile, PCRTTIMESPEC pAccessTime, PCRTTIMESPEC pModificationTime, 143 135 PCRTTIMESPEC pChangeTime, PCRTTIMESPEC pBirthTime) 144 136 { … … 163 155 { 164 156 RTFSOBJINFO ObjInfo; 165 int rc = RTFileQueryInfo( File, &ObjInfo, RTFSOBJATTRADD_UNIX);157 int rc = RTFileQueryInfo(hFile, &ObjInfo, RTFSOBJATTRADD_UNIX); 166 158 if (RT_FAILURE(rc)) 167 159 return rc; … … 170 162 } 171 163 172 if (futimes( (int)File, aTimevals))164 if (futimes(RTFileToNative(hFile), aTimevals)) 173 165 { 174 166 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)); 176 168 return rc; 177 169 } -
trunk/src/VBox/Runtime/r3/posix/filelock-posix.cpp
r28800 r37596 5 5 6 6 /* 7 * Copyright (C) 2006-20 07Oracle Corporation7 * Copyright (C) 2006-2011 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 50 50 51 51 52 RTR3DECL(int) RTFileLock(RTFILE File, unsigned fLock, int64_t offLock, uint64_t cbLock)52 RTR3DECL(int) RTFileLock(RTFILE hFile, unsigned fLock, int64_t offLock, uint64_t cbLock) 53 53 { 54 54 Assert(offLock >= 0); … … 83 83 84 84 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) 86 86 return VINF_SUCCESS; 87 87 … … 95 95 96 96 97 RTR3DECL(int) RTFileChangeLock(RTFILE File, unsigned fLock, int64_t offLock, uint64_t cbLock)97 RTR3DECL(int) RTFileChangeLock(RTFILE hFile, unsigned fLock, int64_t offLock, uint64_t cbLock) 98 98 { 99 99 /** @todo We never returns VERR_FILE_NOT_LOCKED for now. */ 100 return RTFileLock( File, fLock, offLock, cbLock);100 return RTFileLock(hFile, fLock, offLock, cbLock); 101 101 } 102 102 103 103 104 RTR3DECL(int) RTFileUnlock(RTFILE File, int64_t offLock, uint64_t cbLock)104 RTR3DECL(int) RTFileUnlock(RTFILE hFile, int64_t offLock, uint64_t cbLock) 105 105 { 106 106 Assert(offLock >= 0); … … 126 126 fl.l_pid = 0; 127 127 128 if (fcntl( File, F_SETLK, &fl) >= 0)128 if (fcntl(RTFileToNative(hFile), F_SETLK, &fl) >= 0) 129 129 return VINF_SUCCESS; 130 130 -
trunk/src/VBox/Runtime/r3/posix/rand-posix.cpp
r28800 r37596 79 79 pThis->u32Magic = ~RTRANDINT_MAGIC; 80 80 int fd = pThis->u.File.hFile; 81 pThis->u.File.hFile = NIL_RTFILE;81 pThis->u.File.hFile = -1; 82 82 RTMemFree(pThis); 83 83 close(fd); -
trunk/src/VBox/Runtime/r3/win/fileaio-win.cpp
r35408 r37596 5 5 6 6 /* 7 * Copyright (C) 2006-20 07Oracle Corporation7 * Copyright (C) 2006-2011 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 189 189 190 190 pReqInt->enmTransferDirection = enmTransferDirection; 191 pReqInt->hFile = (HANDLE)hFile;191 pReqInt->hFile = RTFileToNative(hFile); 192 192 pReqInt->Overlapped.Offset = (DWORD)(off & 0xffffffff); 193 193 pReqInt->Overlapped.OffsetHigh = (DWORD)(off >> 32); … … 318 318 RTFILEAIOCTX_VALID_RETURN(pCtxInt); 319 319 320 HANDLE hTemp = CreateIoCompletionPort( (HANDLE)hFile, pCtxInt->hIoCompletionPort, 0, 1);320 HANDLE hTemp = CreateIoCompletionPort(RTFileToNative(hFile), pCtxInt->hIoCompletionPort, 0, 1); 321 321 if (hTemp != pCtxInt->hIoCompletionPort) 322 322 rc = RTErrConvertFromWin32(GetLastError()); -
trunk/src/VBox/Runtime/r3/win/fileio-win.cpp
r36601 r37596 5 5 6 6 /* 7 * Copyright (C) 2006-20 07Oracle Corporation7 * Copyright (C) 2006-2011 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 55 55 * 56 56 * @returns Success indicator. Extended error information obtainable using GetLastError(). 57 * @param FileFilehandle.57 * @param hFile Filehandle. 58 58 * @param offSeek Offset to seek. 59 59 * @param poffNew Where to store the new file offset. NULL allowed. 60 60 * @param uMethod Seek method. (The windows one!) 61 61 */ 62 DECLINLINE(bool) MySetFilePointer(RTFILE File, uint64_t offSeek, uint64_t *poffNew, unsigned uMethod)62 DECLINLINE(bool) MySetFilePointer(RTFILE hFile, uint64_t offSeek, uint64_t *poffNew, unsigned uMethod) 63 63 { 64 64 bool fRc; … … 69 69 if (off.LowPart != INVALID_SET_FILE_POINTER) 70 70 { 71 off.LowPart = SetFilePointer((HANDLE) File, off.LowPart, &off.HighPart, uMethod);71 off.LowPart = SetFilePointer((HANDLE)RTFileToNative(hFile), off.LowPart, &off.HighPart, uMethod); 72 72 fRc = off.LowPart != INVALID_SET_FILE_POINTER; 73 73 } … … 75 75 { 76 76 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); 78 78 fRc = GetLastError() == NO_ERROR; 79 79 } 80 80 #else 81 fRc = SetFilePointerEx((HANDLE) File, off, &off, uMethod);81 fRc = SetFilePointerEx((HANDLE)RTFileToNative(hFile), off, &off, uMethod); 82 82 #endif 83 83 if (fRc && poffNew) … … 92 92 * 93 93 * @returns true for file size limit exceeded. 94 * @param FileFilehandle.94 * @param hFile Filehandle. 95 95 * @param offSeek Offset to seek. 96 96 * @param uMethod The seek method. 97 97 */ 98 DECLINLINE(bool) IsBeyondLimit(RTFILE File, uint64_t offSeek, unsigned uMethod)98 DECLINLINE(bool) IsBeyondLimit(RTFILE hFile, uint64_t offSeek, unsigned uMethod) 99 99 { 100 100 bool fIsBeyondLimit = false; … … 108 108 * file seeking, only at the time of writing (and some other odd ones we cannot make use of). */ 109 109 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)) 113 113 fIsBeyondLimit = GetLastError() == ERROR_SEEK; 114 114 else /* Restore file pointer on success. */ 115 MySetFilePointer( File, offCurrent, NULL, FILE_BEGIN);115 MySetFilePointer(hFile, offCurrent, NULL, FILE_BEGIN); 116 116 } 117 117 … … 135 135 136 136 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, uint 32_t fOpen)137 RTR3DECL(RTHCINTPTR) RTFileToNative(RTFILE hFile) 138 { 139 AssertReturn(hFile != NIL_RTFILE, (RTHCINTPTR)INVALID_HANDLE_VALUE); 140 return (RTHCINTPTR)hFile; 141 } 142 143 144 RTR3DECL(int) RTFileOpen(PRTFILE pFile, const char *pszFilename, uint64_t fOpen) 145 145 { 146 146 /* … … 186 186 break; 187 187 default: 188 AssertMsgFailed(("Impossible fOpen=%# x\n", fOpen));188 AssertMsgFailed(("Impossible fOpen=%#llx\n", fOpen)); 189 189 return VERR_INVALID_PARAMETER; 190 190 } … … 207 207 break; 208 208 default: 209 AssertMsgFailed(("Impossible fOpen=%# x\n", fOpen));209 AssertMsgFailed(("Impossible fOpen=%#llx\n", fOpen)); 210 210 return VERR_INVALID_PARAMETER; 211 211 } … … 228 228 case RTFILE_O_READWRITE: dwDesiredAccess |= FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES | SYNCHRONIZE; break; 229 229 default: 230 AssertMsgFailed(("Impossible fOpen=%# x\n", fOpen));230 AssertMsgFailed(("Impossible fOpen=%#llx\n", fOpen)); 231 231 return VERR_INVALID_PARAMETER; 232 232 } … … 246 246 case RTFILE_O_DENY_NOT_DELETE | RTFILE_O_DENY_READWRITE:dwShareMode = FILE_SHARE_DELETE; break; 247 247 default: 248 AssertMsgFailed(("Impossible fOpen=%# x\n", fOpen));248 AssertMsgFailed(("Impossible fOpen=%#llx\n", fOpen)); 249 249 return VERR_INVALID_PARAMETER; 250 250 } … … 329 329 330 330 331 RTR3DECL(int) RTFileOpenBitBucket(PRTFILE phFile, uint 32_t fAccess)331 RTR3DECL(int) RTFileOpenBitBucket(PRTFILE phFile, uint64_t fAccess) 332 332 { 333 333 AssertReturn( fAccess == RTFILE_O_READ … … 339 339 340 340 341 RTR3DECL(int) RTFileClose(RTFILE File)342 { 343 if ( File == NIL_RTFILE)344 return VINF_SUCCESS; 345 if (CloseHandle((HANDLE) File))341 RTR3DECL(int) RTFileClose(RTFILE hFile) 342 { 343 if (hFile == NIL_RTFILE) 344 return VINF_SUCCESS; 345 if (CloseHandle((HANDLE)RTFileToNative(hFile))) 346 346 return VINF_SUCCESS; 347 347 return RTErrConvertFromWin32(GetLastError()); … … 372 372 373 373 374 RTR3DECL(int) RTFileSeek(RTFILE File, int64_t offSeek, unsigned uMethod, uint64_t *poffActual)374 RTR3DECL(int) RTFileSeek(RTFILE hFile, int64_t offSeek, unsigned uMethod, uint64_t *poffActual) 375 375 { 376 376 static ULONG aulSeekRecode[] = … … 393 393 * Execute the seek. 394 394 */ 395 if (MySetFilePointer( File, offSeek, poffActual, aulSeekRecode[uMethod]))395 if (MySetFilePointer(hFile, offSeek, poffActual, aulSeekRecode[uMethod])) 396 396 return VINF_SUCCESS; 397 397 return RTErrConvertFromWin32(GetLastError()); … … 399 399 400 400 401 RTR3DECL(int) RTFileRead(RTFILE File, void *pvBuf, size_t cbToRead, size_t *pcbRead)401 RTR3DECL(int) RTFileRead(RTFILE hFile, void *pvBuf, size_t cbToRead, size_t *pcbRead) 402 402 { 403 403 if (cbToRead <= 0) … … 407 407 408 408 ULONG cbRead = 0; 409 if (ReadFile((HANDLE) File, pvBuf, cbToReadAdj, &cbRead, NULL))409 if (ReadFile((HANDLE)RTFileToNative(hFile), pvBuf, cbToReadAdj, &cbRead, NULL)) 410 410 { 411 411 if (pcbRead) … … 418 418 { 419 419 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)) 421 421 return RTErrConvertFromWin32(GetLastError()); 422 422 if (cbReadPart == 0) … … 446 446 ULONG cbToRead = RT_MIN(cbChunk, cbToReadAdj - cbRead); 447 447 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)) 449 449 { 450 450 /* If we failed because the buffer is too big, shrink it and … … 478 478 479 479 480 RTR3DECL(int) RTFileWrite(RTFILE File, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten)480 RTR3DECL(int) RTFileWrite(RTFILE hFile, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten) 481 481 { 482 482 if (cbToWrite <= 0) … … 486 486 487 487 ULONG cbWritten = 0; 488 if (WriteFile((HANDLE) File, pvBuf, cbToWriteAdj, &cbWritten, NULL))488 if (WriteFile((HANDLE)RTFileToNative(hFile), pvBuf, cbToWriteAdj, &cbWritten, NULL)) 489 489 { 490 490 if (pcbWritten) … … 497 497 { 498 498 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)) 500 501 { 501 502 int rc = RTErrConvertFromWin32(GetLastError()); 502 503 if ( rc == VERR_DISK_FULL 503 && IsBeyondLimit( File, cbToWriteAdj - cbWritten, FILE_CURRENT)504 && IsBeyondLimit(RTFileToNative(hFile), cbToWriteAdj - cbWritten, FILE_CURRENT) 504 505 ) 505 506 rc = VERR_FILE_TOO_BIG; … … 532 533 ULONG cbToWrite = RT_MIN(cbChunk, cbToWriteAdj - cbWritten); 533 534 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)) 535 536 { 536 537 /* If we failed because the buffer is too big, shrink it and … … 545 546 int rc = RTErrConvertFromWin32(dwErr); 546 547 if ( rc == VERR_DISK_FULL 547 && IsBeyondLimit( File, cbToWriteAdj - cbWritten, FILE_CURRENT))548 && IsBeyondLimit(hFile, cbToWriteAdj - cbWritten, FILE_CURRENT)) 548 549 rc = VERR_FILE_TOO_BIG; 549 550 return rc; … … 566 567 int rc = RTErrConvertFromWin32(dwErr); 567 568 if ( rc == VERR_DISK_FULL 568 && IsBeyondLimit( File, cbToWriteAdj - cbWritten, FILE_CURRENT))569 && IsBeyondLimit(hFile, cbToWriteAdj - cbWritten, FILE_CURRENT)) 569 570 rc = VERR_FILE_TOO_BIG; 570 571 return rc; … … 572 573 573 574 574 RTR3DECL(int) RTFileFlush(RTFILE File)575 { 576 if (!FlushFileBuffers((HANDLE) File))575 RTR3DECL(int) RTFileFlush(RTFILE hFile) 576 { 577 if (!FlushFileBuffers((HANDLE)RTFileToNative(hFile))) 577 578 { 578 579 int rc = GetLastError(); … … 584 585 585 586 586 RTR3DECL(int) RTFileSetSize(RTFILE File, uint64_t cbSize)587 RTR3DECL(int) RTFileSetSize(RTFILE hFile, uint64_t cbSize) 587 588 { 588 589 /* … … 591 592 int rc; 592 593 uint64_t offCurrent; 593 if (MySetFilePointer( File, 0, &offCurrent, FILE_CURRENT))594 if (MySetFilePointer(hFile, 0, &offCurrent, FILE_CURRENT)) 594 595 { 595 596 /* 596 597 * Set new file pointer. 597 598 */ 598 if (MySetFilePointer( File, cbSize, NULL, FILE_BEGIN))599 if (MySetFilePointer(hFile, cbSize, NULL, FILE_BEGIN)) 599 600 { 600 601 /* set file pointer */ 601 if (SetEndOfFile((HANDLE) File))602 if (SetEndOfFile((HANDLE)RTFileToNative(hFile))) 602 603 { 603 604 /* … … 605 606 * If the old pointer was beyond the new file end, ignore failure. 606 607 */ 607 if ( MySetFilePointer( File, offCurrent, NULL, FILE_BEGIN)608 if ( MySetFilePointer(hFile, offCurrent, NULL, FILE_BEGIN) 608 609 || offCurrent > cbSize) 609 610 return VINF_SUCCESS; … … 614 615 */ 615 616 rc = GetLastError(); 616 MySetFilePointer( File, offCurrent, NULL, FILE_BEGIN);617 MySetFilePointer(hFile, offCurrent, NULL, FILE_BEGIN); 617 618 } 618 619 else … … 626 627 627 628 628 RTR3DECL(int) RTFileGetSize(RTFILE File, uint64_t *pcbSize)629 RTR3DECL(int) RTFileGetSize(RTFILE hFile, uint64_t *pcbSize) 629 630 { 630 631 ULARGE_INTEGER Size; 631 Size.LowPart = GetFileSize((HANDLE) File, &Size.HighPart);632 Size.LowPart = GetFileSize((HANDLE)RTFileToNative(hFile), &Size.HighPart); 632 633 if (Size.LowPart != INVALID_FILE_SIZE) 633 634 { … … 641 642 642 643 643 RTR3DECL(int) RTFileGetMaxSizeEx(RTFILE File, PRTFOFF pcbMax)644 RTR3DECL(int) RTFileGetMaxSizeEx(RTFILE hFile, PRTFOFF pcbMax) 644 645 { 645 646 /** @todo r=bird: … … 653 654 654 655 655 RTR3DECL(bool) RTFileIsValid(RTFILE File)656 { 657 if ( File != NIL_RTFILE)658 { 659 DWORD dwType = GetFileType((HANDLE) File);656 RTR3DECL(bool) RTFileIsValid(RTFILE hFile) 657 { 658 if (hFile != NIL_RTFILE) 659 { 660 DWORD dwType = GetFileType((HANDLE)RTFileToNative(hFile)); 660 661 switch (dwType) 661 662 { … … 679 680 #define HIGH_DWORD(u64) (((DWORD *)&u64)[1]) 680 681 681 RTR3DECL(int) RTFileLock(RTFILE File, unsigned fLock, int64_t offLock, uint64_t cbLock)682 RTR3DECL(int) RTFileLock(RTFILE hFile, unsigned fLock, int64_t offLock, uint64_t cbLock) 682 683 { 683 684 Assert(offLock >= 0); … … 704 705 705 706 /* 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)) 707 708 return VINF_SUCCESS; 708 709 … … 711 712 712 713 713 RTR3DECL(int) RTFileChangeLock(RTFILE File, unsigned fLock, int64_t offLock, uint64_t cbLock)714 RTR3DECL(int) RTFileChangeLock(RTFILE hFile, unsigned fLock, int64_t offLock, uint64_t cbLock) 714 715 { 715 716 Assert(offLock >= 0); … … 723 724 724 725 /* Remove old lock. */ 725 int rc = RTFileUnlock( File, offLock, cbLock);726 int rc = RTFileUnlock(hFile, offLock, cbLock); 726 727 if (RT_FAILURE(rc)) 727 728 return rc; 728 729 729 730 /* Set new lock. */ 730 rc = RTFileLock( File, fLock, offLock, cbLock);731 rc = RTFileLock(hFile, fLock, offLock, cbLock); 731 732 if (RT_SUCCESS(rc)) 732 733 return rc; … … 734 735 /* Try to restore old lock. */ 735 736 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); 737 738 if (RT_SUCCESS(rc)) 738 739 return VERR_FILE_LOCK_VIOLATION; … … 742 743 743 744 744 RTR3DECL(int) RTFileUnlock(RTFILE File, int64_t offLock, uint64_t cbLock)745 RTR3DECL(int) RTFileUnlock(RTFILE hFile, int64_t offLock, uint64_t cbLock) 745 746 { 746 747 Assert(offLock >= 0); 747 748 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))) 749 752 return VINF_SUCCESS; 750 753 … … 754 757 755 758 756 RTR3DECL(int) RTFileQueryInfo(RTFILE File, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAdditionalAttribs)759 RTR3DECL(int) RTFileQueryInfo(RTFILE hFile, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAdditionalAttribs) 757 760 { 758 761 /* 759 762 * Validate input. 760 763 */ 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)); 764 767 return VERR_INVALID_PARAMETER; 765 768 } … … 780 783 */ 781 784 BY_HANDLE_FILE_INFORMATION Data; 782 if (!GetFileInformationByHandle((HANDLE) File, &Data))785 if (!GetFileInformationByHandle((HANDLE)RTFileToNative(hFile), &Data)) 783 786 { 784 787 DWORD dwErr = GetLastError(); … … 851 854 852 855 853 RTR3DECL(int) RTFileSetTimes(RTFILE File, PCRTTIMESPEC pAccessTime, PCRTTIMESPEC pModificationTime,856 RTR3DECL(int) RTFileSetTimes(RTFILE hFile, PCRTTIMESPEC pAccessTime, PCRTTIMESPEC pModificationTime, 854 857 PCRTTIMESPEC pChangeTime, PCRTTIMESPEC pBirthTime) 855 858 { … … 873 876 874 877 int rc = VINF_SUCCESS; 875 if (!SetFileTime((HANDLE) File, pCreationTimeFT, pLastAccessTimeFT, pLastWriteTimeFT))878 if (!SetFileTime((HANDLE)RTFileToNative(hFile), pCreationTimeFT, pLastAccessTimeFT, pLastWriteTimeFT)) 876 879 { 877 880 DWORD Err = GetLastError(); 878 881 rc = RTErrConvertFromWin32(Err); 879 882 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)); 881 884 } 882 885 return rc; … … 890 893 891 894 892 RTR3DECL(int) RTFileSetMode(RTFILE File, RTFMODE fMode)895 RTR3DECL(int) RTFileSetMode(RTFILE hFile, RTFMODE fMode) 893 896 { 894 897 /* … … 900 903 901 904 ULONG FileAttributes = (fMode & RTFS_DOS_MASK) >> RTFS_DOS_SHIFT; 902 int Err = rtFileNativeSetAttributes((HANDLE) File, FileAttributes);905 int Err = rtFileNativeSetAttributes((HANDLE)hFile, FileAttributes); 903 906 if (Err != ERROR_SUCCESS) 904 907 { 905 908 int rc = RTErrConvertFromWin32(Err); 906 909 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)); 908 911 return rc; 909 912 } -
trunk/src/VBox/Runtime/r3/win/rtFileNativeSetAttributes-win.cpp
r28800 r37596 60 60 61 61 /** @todo resolve dynamically to avoid dragging in NtDll? */ 62 NTSTATUS Status = NtSetInformationFile( hFile,62 NTSTATUS Status = NtSetInformationFile(RTFileToNative(hFile), 63 63 &IoStatusBlock, 64 64 &Info, -
trunk/src/VBox/VMM/VMMR3/PDMAsyncCompletionFile.cpp
r37045 r37596 1012 1012 * contain dirty buffers. 1013 1013 */ 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); 1017 1017 if (RT_SUCCESS(rc)) 1018 1018 { 1019 1019 uint64_t cbSize; 1020 1020 1021 rc = pdmacFileEpNativeGetSize( File, &cbSize);1021 rc = pdmacFileEpNativeGetSize(hFile, &cbSize); 1022 1022 Assert(RT_FAILURE(rc) || cbSize != 0); 1023 1023 … … 1034 1034 #endif 1035 1035 } 1036 RTFileClose( File);1036 RTFileClose(hFile); 1037 1037 } 1038 1038 } 1039 1039 1040 1040 /* Open with final flags. */ 1041 rc = RTFileOpen(&pEpFile-> File, pszUri, fFileFlags);1041 rc = RTFileOpen(&pEpFile->hFile, pszUri, fFileFlags); 1042 1042 if ((rc == VERR_INVALID_FUNCTION) || (rc == VERR_INVALID_PARAMETER)) 1043 1043 { … … 1064 1064 1065 1065 /* Open again. */ 1066 rc = RTFileOpen(&pEpFile-> File, pszUri, fFileFlags);1066 rc = RTFileOpen(&pEpFile->hFile, pszUri, fFileFlags); 1067 1067 1068 1068 if (RT_FAILURE(rc)) … … 1077 1077 pEpFile->fFlags = fFileFlags; 1078 1078 1079 rc = pdmacFileEpNativeGetSize(pEpFile-> File, (uint64_t *)&pEpFile->cbFile);1079 rc = pdmacFileEpNativeGetSize(pEpFile->hFile, (uint64_t *)&pEpFile->cbFile); 1080 1080 Assert(RT_FAILURE(rc) || pEpFile->cbFile != 0); 1081 1081 … … 1147 1147 1148 1148 if (RT_FAILURE(rc)) 1149 RTFileClose(pEpFile-> File);1149 RTFileClose(pEpFile->hFile); 1150 1150 } 1151 1151 … … 1207 1207 RTAvlrFileOffsetDestroy(pEpFile->AioMgr.pTreeRangesLocked, pdmacFileEpRangesLockedDestroy, NULL); 1208 1208 1209 RTFileClose(pEpFile-> File);1209 RTFileClose(pEpFile->hFile); 1210 1210 1211 1211 #ifdef VBOX_WITH_STATISTICS … … 1301 1301 1302 1302 ASMAtomicWriteU64(&pEpFile->cbFile, cbSize); 1303 return RTFileSetSize(pEpFile-> File, cbSize);1303 return RTFileSetSize(pEpFile->hFile, cbSize); 1304 1304 } 1305 1305 -
trunk/src/VBox/VMM/VMMR3/PDMAsyncCompletionFileFailsafe.cpp
r36001 r37596 78 78 case PDMACTASKFILETRANSFER_FLUSH: 79 79 { 80 rc = RTFileFlush(pEndpoint-> File);80 rc = RTFileFlush(pEndpoint->hFile); 81 81 break; 82 82 } … … 86 86 if (pCurr->enmTransferType == PDMACTASKFILETRANSFER_READ) 87 87 { 88 rc = RTFileReadAt(pEndpoint-> File, pCurr->Off,88 rc = RTFileReadAt(pEndpoint->hFile, pCurr->Off, 89 89 pCurr->DataSeg.pvSeg, 90 90 pCurr->DataSeg.cbSeg, … … 96 96 { 97 97 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); 99 99 } 100 100 101 rc = RTFileWriteAt(pEndpoint-> File, pCurr->Off,101 rc = RTFileWriteAt(pEndpoint->hFile, pCurr->Off, 102 102 pCurr->DataSeg.pvSeg, 103 103 pCurr->DataSeg.cbSeg, -
trunk/src/VBox/VMM/VMMR3/PDMAsyncCompletionFileNormal.cpp
r37045 r37596 205 205 206 206 /* 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); 209 209 AssertRC(rc); 210 210 return false; … … 341 341 while (pCurr) 342 342 { 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); 345 345 AssertRC(rc); 346 346 … … 390 390 while (pCurr) 391 391 { 392 rc = RTFileAioCtxAssociateWithFile(pAioMgr->hAioCtx, pCurr-> File);392 rc = RTFileAioCtxAssociateWithFile(pAioMgr->hAioCtx, pCurr->hFile); 393 393 AssertRC(rc); 394 394 … … 790 790 { 791 791 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, 796 796 pTask->Off, pTask->DataSeg.pvSeg, 797 797 pTask->DataSeg.cbSeg, pTask); 798 798 } 799 799 else 800 rc = RTFileAioReqPrepareRead(hReq, pEndpoint-> File,800 rc = RTFileAioReqPrepareRead(hReq, pEndpoint->hFile, 801 801 pTask->Off, pTask->DataSeg.pvSeg, 802 802 pTask->DataSeg.cbSeg, pTask); … … 925 925 { 926 926 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, 931 931 offStart, pvBuf, cbToTransfer, pTask); 932 932 } 933 933 else 934 rc = RTFileAioReqPrepareRead(hReq, pEndpoint-> File,934 rc = RTFileAioReqPrepareRead(hReq, pEndpoint->hFile, 935 935 offStart, pvBuf, cbToTransfer, pTask); 936 936 AssertRC(rc); … … 1004 1004 LogFlow(("Flush request %#p\n", hReq)); 1005 1005 1006 rc = RTFileAioReqPrepareFlush(hReq, pEndpoint-> File, pCurr);1006 rc = RTFileAioReqPrepareFlush(hReq, pEndpoint->hFile, pCurr); 1007 1007 if (RT_FAILURE(rc)) 1008 1008 { … … 1189 1189 1190 1190 /* Assign the completion point to this file. */ 1191 rc = RTFileAioCtxAssociateWithFile(pAioMgr->hAioCtx, pEndpointNew-> File);1191 rc = RTFileAioCtxAssociateWithFile(pAioMgr->hAioCtx, pEndpointNew->hFile); 1192 1192 fNotifyWaiter = true; 1193 1193 pAioMgr->cEndpoints++; … … 1289 1289 { 1290 1290 /* 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); 1293 1293 AssertRC(rc); 1294 1294 … … 1472 1472 if (pTask->fPrefetch || pTask->enmTransferType == PDMACTASKFILETRANSFER_READ) 1473 1473 { 1474 rc = RTFileAioReqPrepareRead(hReq, pEndpoint-> File, offStart,1474 rc = RTFileAioReqPrepareRead(hReq, pEndpoint->hFile, offStart, 1475 1475 pbBuf, cbToTransfer, pTask); 1476 1476 } … … 1479 1479 AssertMsg(pTask->enmTransferType == PDMACTASKFILETRANSFER_WRITE, 1480 1480 ("Invalid transfer type\n")); 1481 rc = RTFileAioReqPrepareWrite(hReq, pEndpoint-> File, offStart,1481 rc = RTFileAioReqPrepareWrite(hReq, pEndpoint->hFile, offStart, 1482 1482 pbBuf, cbToTransfer, pTask); 1483 1483 } … … 1507 1507 { 1508 1508 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, 1513 1513 offStart, pTask->pvBounceBuffer, cbToTransfer, pTask); 1514 1514 AssertRC(rc); -
trunk/src/VBox/VMM/include/PDMAsyncCompletionFileInternal.h
r36799 r37596 327 327 unsigned fFlags; 328 328 /** File handle. */ 329 RTFILE File;329 RTFILE hFile; 330 330 /** 331 331 * Real size of the file. Only updated if
Note:
See TracChangeset
for help on using the changeset viewer.