qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v8] block/raw-posix.c: Fix raw_getlength() on Mac OS X for CD
@ 2015-01-19 22:12 Programmingkid
  2015-01-20  8:33 ` Markus Armbruster
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Programmingkid @ 2015-01-19 22:12 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel qemu-devel

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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2015-02-06 17:14 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-19 22:12 [Qemu-devel] [PATCH v8] block/raw-posix.c: Fix raw_getlength() on Mac OS X for CD Programmingkid
2015-01-20  8:33 ` 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

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).