All of lore.kernel.org
 help / color / mirror / Atom feed
From: Programmingkid <programmingkidx@gmail.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel qemu-devel <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH v8] block/raw-posix.c: Fix raw_getlength() on Mac OS X for CD
Date: Mon, 19 Jan 2015 17:12:55 -0500	[thread overview]
Message-ID: <2ACCDD16-AFEC-49BF-8BD3-3A3EC55DB2E5@gmail.com> (raw)

Subject was: 
Re: [PATCH v7] block/raw-posix.c: Fixes raw_getlength() 
on Mac OS X so that it reports the correct length of a real CD

This patch allows Mac OS X to use a real CDROM disc in QEMU.
Testing this patch will require using QEMU v2.2.0 because the
 current git version has a bug in it that prevents /dev/cdrom from
 being used.  "make check" did pass and my Debian boot disc did work. 

Signed-off-by: John Arbuckle <programmingkidx@gmail.com>

---
Fixed code indentation to be inline with removed
size = LLONG_MAX.

 block/raw-posix.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/block/raw-posix.c b/block/raw-posix.c
index e51293a..fa431b2 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -1312,7 +1312,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, &sectors) == 0
+               && ioctl(fd, DKIOCGETBLOCKSIZE, &sector_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.7.5.4

             reply	other threads:[~2015-01-19 22:13 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-19 22:12 Programmingkid [this message]
2015-01-20  8:33 ` [Qemu-devel] [PATCH v8] block/raw-posix.c: Fix raw_getlength() on Mac OS X for CD Markus Armbruster
2015-01-20 14:29   ` Programmingkid
2015-01-20 15:22     ` Eric Blake
2015-01-20 16:08       ` Programmingkid
2015-01-20 20:28         ` Markus Armbruster
2015-01-20 20:36           ` Programmingkid
2015-01-21  7:54             ` Markus Armbruster
2015-01-21 14:38               ` Programmingkid
2015-01-20 14:46 ` Stefan Hajnoczi
2015-01-20 14:55   ` Peter Maydell
2015-02-06 17:14 ` Kevin Wolf

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=2ACCDD16-AFEC-49BF-8BD3-3A3EC55DB2E5@gmail.com \
    --to=programmingkidx@gmail.com \
    --cc=peter.maydell@linaro.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.