From: Kevin Wolf <kwolf@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com
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 [thread overview]
Message-ID: <1423244107-21403-6-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1423244107-21403-1-git-send-email-kwolf@redhat.com>
From: Programmingkid <programmingkidx@gmail.com>
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 <programmingkidx@gmail.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Tested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
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
next prev parent reply other threads:[~2015-02-06 17:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-06 17:35 [Qemu-devel] [PULL v2 00/47] Block patches Kevin Wolf
2015-02-06 17:35 ` [Qemu-devel] [PULL v2 43/47] blockdev: Give find_block_job() an Error ** parameter Kevin Wolf
2015-02-06 17:35 ` [Qemu-devel] [PULL v2 44/47] blockdev: Eliminate silly QERR_BLOCK_JOB_NOT_ACTIVE macro Kevin Wolf
2015-02-06 17:35 ` [Qemu-devel] [PULL v2 45/47] block: New bdrv_add_key(), convert monitor to use it Kevin Wolf
2015-02-06 17:35 ` [Qemu-devel] [PULL v2 46/47] block: Eliminate silly QERR_ macros used for encryption keys Kevin Wolf
2015-02-06 17:35 ` Kevin Wolf [this message]
2015-02-09 22:33 ` [Qemu-devel] [PULL v2 00/47] Block patches Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1423244107-21403-6-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).