Changeset 37596 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Jun 22, 2011 7:30:06 PM (14 years ago)
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
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 {
Note:
See TracChangeset
for help on using the changeset viewer.