From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44728) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y51qJ-0006KE-Gt for qemu-devel@nongnu.org; Sat, 27 Dec 2014 19:36:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y51qG-00086q-CA for qemu-devel@nongnu.org; Sat, 27 Dec 2014 19:36:23 -0500 Received: from mail-qa0-x231.google.com ([2607:f8b0:400d:c00::231]:62964) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y51qG-00086l-7i for qemu-devel@nongnu.org; Sat, 27 Dec 2014 19:36:20 -0500 Received: by mail-qa0-f49.google.com with SMTP id dc16so7976278qab.22 for ; Sat, 27 Dec 2014 16:36:19 -0800 (PST) From: Programmingkid Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Date: Sat, 27 Dec 2014 19:36:16 -0500 Message-Id: <6392322B-686D-496A-9E66-30C9F962355D@gmail.com> Mime-Version: 1.0 (Apple Message framework v1084) Subject: [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 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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.=20 signed-off-by: John Arbuckle --- 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 =3D=3D 0) #endif #if defined(__APPLE__) && defined(__MACH__) - size =3D LLONG_MAX; + // Query the number of sectors on the disk + uint64_t sectors =3D 0; + ioctl(fd, DKIOCGETBLOCKCOUNT, §ors); + + // Query the size of each sector + uint32_t sectorSize =3D 0; + ioctl(fd, DKIOCGETBLOCKSIZE, §orSize); + + size =3D sectors * sectorSize; + //printf("size of disc =3D %d MB\n", size/(1024*1024)); #else size =3D lseek(fd, 0LL, SEEK_END); if (size < 0) { --=20 1.7.5.4