Received: from eggs.gnu.org ([2001:4830:134:3::10]:51946) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDUFR-0000ZA-8Q for qemu-devel@nongnu.org; Tue, 20 Jan 2015 03:33:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YDUFN-00084f-Vn for qemu-devel@nongnu.org; Tue, 20 Jan 2015 03:33:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58980) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDUFN-00084X-PS for qemu-devel@nongnu.org; Tue, 20 Jan 2015 03:33:13 -0500 From: Markus Armbruster References: <2ACCDD16-AFEC-49BF-8BD3-3A3EC55DB2E5@gmail.com> Date: Tue, 20 Jan 2015 09:33:07 +0100 In-Reply-To: <2ACCDD16-AFEC-49BF-8BD3-3A3EC55DB2E5@gmail.com> (Programmingkid's message of "Mon, 19 Jan 2015 17:12:55 -0500") Message-ID: <87oapt7sxo.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v8] block/raw-posix.c: Fix raw_getlength() on Mac OS X for CD List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Programmingkid Cc: Peter Maydell , qemu-devel qemu-devel Programmingkid writes: > 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 Patch history information goes... > > 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 > > --- ... below the --- divider. > 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; Ignorant question: why do you need to initialize these? Patch looks plausible otherwise, but know nothing about Macs :) > + > + if (ioctl(fd, DKIOCGETBLOCKCOUNT, §ors) == 0 > + && ioctl(fd, DKIOCGETBLOCKSIZE, §or_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) {