From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47367) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y7A1W-0006oT-Ds for qemu-devel@nongnu.org; Fri, 02 Jan 2015 16:44:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y7A1T-0003F1-7D for qemu-devel@nongnu.org; Fri, 02 Jan 2015 16:44:46 -0500 Received: from mail-qg0-x231.google.com ([2607:f8b0:400d:c04::231]:43091) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y7A1S-0003Ep-QD for qemu-devel@nongnu.org; Fri, 02 Jan 2015 16:44:43 -0500 Received: by mail-qg0-f49.google.com with SMTP id f51so274123qge.22 for ; Fri, 02 Jan 2015 13:44:41 -0800 (PST) From: Programmingkid Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Date: Fri, 2 Jan 2015 16:44:38 -0500 Message-Id: Mime-Version: 1.0 (Apple Message framework v1084) Subject: [Qemu-devel] [PATCH v4] 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 , Stefan Hajnoczi Cc: qemu-devel qemu-devel Removes redundant ret variable and renames sectorSize variable to meet = QEMU coding standards.=20 Signed-off-by: John Arbuckle --- block/raw-posix.c | 18 +++++++++++++++++- configure | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/block/raw-posix.c b/block/raw-posix.c index e51293a..16fa0a4 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -1312,7 +1312,23 @@ 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; + + /* Query the number of sectors on the disk */ + ret =3D ioctl(fd, DKIOCGETBLOCKCOUNT, §ors); + if (ret =3D=3D -1) { + return -errno; + } + + /* Query the size of each sector */ + ret =3D ioctl(fd, DKIOCGETBLOCKSIZE, §or_size); + if (ret =3D=3D -1) { + return -errno; + } + size =3D sectors * sector_size; + } #else size =3D lseek(fd, 0LL, SEEK_END); if (size < 0) { diff --git a/configure b/configure index cae588c..32d3d3f 100755 --- a/configure +++ b/configure @@ -611,7 +611,7 @@ Darwin) cocoa=3D"yes" audio_drv_list=3D"coreaudio" audio_possible_drivers=3D"coreaudio sdl fmod" - LDFLAGS=3D"-framework CoreFoundation -framework IOKit $LDFLAGS" + LDFLAGS=3D"-framework CoreFoundation -framework IOKit -framework = ApplicationServices $LDFLAGS" libs_softmmu=3D"-F/System/Library/Frameworks -framework Cocoa = -framework IOKit $libs_softmmu" # Disable attempts to use ObjectiveC features in os/object.h since = they # won't work when we're compiling with gcc as a C compiler. --=20 1.7.5.4