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