Changeset 35190 in vbox
- Timestamp:
- Dec 16, 2010 3:24:55 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/PDMAsyncCompletionFile.cpp
r34612 r35190 41 41 #include <iprt/path.h> 42 42 43 #if defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) 44 # include <errno.h> 45 # include <sys/ioctl.h> 46 # include <sys/types.h> 47 # include <sys/stat.h> 48 # include <fcntl.h> 49 # include <unistd.h> 50 #endif 51 43 52 #ifdef RT_OS_WINDOWS 44 53 # define _WIN32_WINNT 0x0500 … … 46 55 # include <winioctl.h> 47 56 #endif 57 #ifdef RT_OS_DARWIN 58 # include <sys/disk.h> 59 #endif /* RT_OS_DARWIN */ 60 #ifdef RT_OS_SOLARIS 61 # include <stropts.h> 62 # include <sys/dkio.h> 63 # include <sys/vtoc.h> 64 #endif /* RT_OS_SOLARIS */ 65 #ifdef RT_OS_FREEBSD 66 # include <sys/disk.h> 67 #endif /* RT_OS_FREEBSD */ 48 68 49 69 #include "PDMAsyncCompletionFileInternal.h" … … 614 634 rc = RTErrConvertFromWin32(GetLastError()); 615 635 } 636 #elif defined(RT_OS_DARWIN) 637 struct stat DevStat; 638 if (!fstat(hFile, &DevStat) && S_ISBLK(DevStat.st_mode)) 639 { 640 uint64_t cBlocks; 641 uint32_t cbBlock; 642 if (!ioctl(hFile, DKIOCGETBLOCKCOUNT, &cBlocks)) 643 { 644 if (!ioctl(hFile, DKIOCGETBLOCKSIZE, &cbBlock)) 645 cbSize = cBlocks * cbBlock; 646 else 647 rc = RTErrConvertFromErrno(errno); 648 } 649 else 650 rc = RTErrConvertFromErrno(errno); 651 } 652 else 653 rc = VERR_INVALID_PARAMETER; 654 #elif defined(RT_OS_SOLARIS) 655 struct stat DevStat; 656 if (!fstat(hFile, &DevStat) && ( S_ISBLK(DevStat.st_mode) 657 || S_ISCHR(DevStat.st_mode))) 658 { 659 struct dk_minfo mediainfo; 660 if (!ioctl(hFile, DKIOCGMEDIAINFO, &mediainfo)) 661 cbSize = mediainfo.dki_capacity * mediainfo.dki_lbsize; 662 else 663 rc = RTErrConvertFromErrno(errno); 664 } 665 else 666 rc = VERR_INVALID_PARAMETER; 667 #elif defined(RT_OS_FREEBSD) 668 struct stat DevStat; 669 if (!fstat(hFile, &DevStat) && S_ISCHR(DevStat.st_mode)) 670 { 671 off_t cbMedia = 0; 672 if (!ioctl(hFile, DIOCGMEDIASIZE, &cbMedia)) 673 { 674 cbSize = cbMedia; 675 } 676 else 677 rc = RTErrConvertFromErrno(errno); 678 } 679 else 680 rc = VERR_INVALID_PARAMETER; 616 681 #else 617 682 /* Could be a block device */ 618 683 rc = RTFileSeek(hFile, 0, RTFILE_SEEK_END, &cbSize); 619 620 #endif 684 #endif 685 621 686 if (RT_SUCCESS(rc) && (cbSize != 0)) 622 687 *pcbSize = cbSize;
Note:
See TracChangeset
for help on using the changeset viewer.