qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v3] 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 21:18 Programmingkid
  2014-12-28 21:24 ` Peter Maydell
  2015-01-02 14:38 ` Stefan Hajnoczi
  0 siblings, 2 replies; 5+ messages in thread
From: Programmingkid @ 2014-12-28 21:18 UTC (permalink / raw)
  To: qemu-devel qemu-devel; +Cc: Kevin Wolf, Peter Maydell

This patch fixes the problem with raw_getlength() on Mac OS X so that it actually calculates the correct size of a volume. It has been updated to fix certain coding style issues. Booting and using a real CD in QEMU works again. 

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

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

diff --git a/block/raw-posix.c b/block/raw-posix.c
index e51293a..a090c9c 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -1312,7 +1312,24 @@ again:
         if (size == 0)
 #endif
 #if defined(__APPLE__) && defined(__MACH__)
-        size = LLONG_MAX;
+   {
+        uint64_t sectors = 0;
+        uint32_t sectorSize = 0;
+        int ret;
+
+        /* Query the number of sectors on the disk */
+        ret = ioctl(fd, DKIOCGETBLOCKCOUNT, &sectors);
+        if (ret == -1) {
+           return -errno;
+        }
+
+        /* Query the size of each sector */
+        ret = ioctl(fd, DKIOCGETBLOCKSIZE, &sectorSize);
+        if (ret == -1) {
+           return -errno;
+        }
+        size = sectors * sectorSize;
+   }
 #else
         size = lseek(fd, 0LL, SEEK_END);
         if (size < 0) {
-- 
1.7.5.4

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

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

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-28 21:18 [Qemu-devel] [PATCH v3] 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 21:24 ` Peter Maydell
2015-01-02 14:38 ` Stefan Hajnoczi
2015-01-02 16:47   ` Programmingkid
2015-01-02 17:20     ` 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).