Received: from eggs.gnu.org ([2001:4830:134:3::10]:57495) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YBu1N-0008GC-0A for qemu-devel@nongnu.org; Thu, 15 Jan 2015 18:40:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YBu1I-0006ts-0l for qemu-devel@nongnu.org; Thu, 15 Jan 2015 18:40:12 -0500 Received: from mail-qa0-x22c.google.com ([2607:f8b0:400d:c00::22c]:45727) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YBu1H-0006tM-RV for qemu-devel@nongnu.org; Thu, 15 Jan 2015 18:40:07 -0500 Received: by mail-qa0-f44.google.com with SMTP id w8so13405516qac.3 for ; Thu, 15 Jan 2015 15:40:07 -0800 (PST) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Programmingkid In-Reply-To: Date: Thu, 15 Jan 2015 18:40:03 -0500 Content-Transfer-Encoding: quoted-printable Message-Id: <3581523B-8162-4CB7-9B21-DFA980E15F97@gmail.com> References: <71BB46AD-4E5B-4876-84F0-12260D6846D3@gmail.com> Subject: [Qemu-devel] [PATCH v7] block/raw-posix.c: Fixes raw_getlength() on Mac OS X so that it reports the correct length of a real CD List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: qemu-devel qemu-devel 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.=20 Signed-off-by: John Arbuckle --- Totally rewritten. 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..a95cfcf 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -1312,7 +1312,20 @@ again: if (size =3D=3D 0) #endif #if defined(__APPLE__) && defined(__MACH__) - size =3D LLONG_MAX; + { + uint64_t sectors =3D 0; + uint32_t sector_size =3D 0; + + if (ioctl(fd, DKIOCGETBLOCKCOUNT, §ors) =3D=3D 0 + && ioctl(fd, DKIOCGETBLOCKSIZE, §or_size) =3D=3D 0) { + size =3D sectors * sector_size; + } else { + size =3D lseek(fd, 0LL, SEEK_END); + if (size < 0) { + return -errno; + } + } + } #else size =3D lseek(fd, 0LL, SEEK_END); if (size < 0) { --=20 1.7.5.4