[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 47/47] block/raw-posix.c: Fix raw_getlength() on M
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL v2 47/47] block/raw-posix.c: Fix raw_getlength() on Mac OS X block devices |
Date: |
Fri, 6 Feb 2015 18:35:07 +0100 |
From: Programmingkid <address@hidden>
This patch replaces the dummy code in raw_getlength() for block devices
on OS X, which always returned LLONG_MAX, with a real implementation
that returns the actual block device size.
Signed-off-by: John Arbuckle <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Tested-by: Peter Maydell <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/raw-posix.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/block/raw-posix.c b/block/raw-posix.c
index 7b42f37..e474c17 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -1375,7 +1375,20 @@ again:
if (size == 0)
#endif
#if defined(__APPLE__) && defined(__MACH__)
- size = LLONG_MAX;
+ {
+ uint64_t sectors = 0;
+ uint32_t sector_size = 0;
+
+ if (ioctl(fd, DKIOCGETBLOCKCOUNT, §ors) == 0
+ && ioctl(fd, DKIOCGETBLOCKSIZE, §or_size) == 0) {
+ size = sectors * sector_size;
+ } else {
+ size = lseek(fd, 0LL, SEEK_END);
+ if (size < 0) {
+ return -errno;
+ }
+ }
+ }
#else
size = lseek(fd, 0LL, SEEK_END);
if (size < 0) {
--
1.8.3.1
- [Qemu-devel] [PULL v2 00/47] Block patches, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL v2 44/47] blockdev: Eliminate silly QERR_BLOCK_JOB_NOT_ACTIVE macro, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL v2 45/47] block: New bdrv_add_key(), convert monitor to use it, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL v2 43/47] blockdev: Give find_block_job() an Error ** parameter, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL v2 46/47] block: Eliminate silly QERR_ macros used for encryption keys, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL v2 47/47] block/raw-posix.c: Fix raw_getlength() on Mac OS X block devices,
Kevin Wolf <=
- Re: [Qemu-devel] [PULL v2 00/47] Block patches, Peter Maydell, 2015/02/09