Received: from eggs.gnu.org ([2001:4830:134:3::10]:50529) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDZoZ-0004cA-UE for qemu-devel@nongnu.org; Tue, 20 Jan 2015 09:29:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YDZoU-0004Uj-US for qemu-devel@nongnu.org; Tue, 20 Jan 2015 09:29:55 -0500 Received: from mail-qc0-x236.google.com ([2607:f8b0:400d:c01::236]:54416) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDZoU-0004Uf-LI for qemu-devel@nongnu.org; Tue, 20 Jan 2015 09:29:50 -0500 Received: by mail-qc0-f182.google.com with SMTP id l6so26819786qcy.13 for ; Tue, 20 Jan 2015 06:29:50 -0800 (PST) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Programmingkid In-Reply-To: <87oapt7sxo.fsf@blackfin.pond.sub.org> Date: Tue, 20 Jan 2015 09:29:46 -0500 Content-Transfer-Encoding: 7bit Message-Id: <2AB4B322-B3CF-4609-B57E-32B93C124761@gmail.com> References: <2ACCDD16-AFEC-49BF-8BD3-3A3EC55DB2E5@gmail.com> <87oapt7sxo.fsf@blackfin.pond.sub.org> 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: Markus Armbruster Cc: Kevin Wolf , Peter Maydell , qemu-devel qemu-devel On Jan 20, 2015, at 3:33 AM, Markus Armbruster wrote: > 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. I thought I did this. The information above is the description of the patch. Not its history. > >> 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? We don't. It's just a habit. > > Patch looks plausible otherwise, but know nothing about Macs :) It does do the job. > >> + >> + 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) {