qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block/raw-posix.c: Fixes raw_getlength() on Mac OS X so that it reports the correct length of a real CD
@ 2014-12-28  0:36 Programmingkid
  2014-12-28  1:19 ` Peter Maydell
  0 siblings, 1 reply; 6+ messages in thread
From: Programmingkid @ 2014-12-28  0:36 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel qemu-devel

The raw_getlength() function under Mac OS X incorrectly returned a constant value instead of calculating the size of a real CD-ROM disc. This patch fixes this problem and makes booting from a real CD-ROM disc possible again under Mac OS X. 

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

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

diff --git a/block/raw-posix.c b/block/raw-posix.c
index e51293a..d723133 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -1312,7 +1312,16 @@ again:
         if (size == 0)
 #endif
 #if defined(__APPLE__) && defined(__MACH__)
-        size = LLONG_MAX;
+        // Query the number of sectors on the disk
+        uint64_t sectors = 0;
+        ioctl(fd, DKIOCGETBLOCKCOUNT, &sectors);
+
+        // Query the size of each sector
+        uint32_t sectorSize = 0;
+        ioctl(fd, DKIOCGETBLOCKSIZE, &sectorSize);
+
+        size = sectors * sectorSize;
+        //printf("size of disc = %d MB\n", size/(1024*1024));
 #else
         size = lseek(fd, 0LL, SEEK_END);
         if (size < 0) {
-- 
1.7.5.4

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

end of thread, other threads:[~2014-12-28 19:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-28  0:36 [Qemu-devel] [PATCH] block/raw-posix.c: Fixes raw_getlength() on Mac OS X so that it reports the correct length of a real CD Programmingkid
2014-12-28  1:19 ` Peter Maydell
2014-12-28  3:00   ` [Qemu-devel] [PATCH v2] " Programmingkid
2014-12-28 10:23     ` Peter Maydell
2014-12-28 17:37       ` Programmingkid
2014-12-28 19:43         ` Peter Maydell

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