From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53378) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9WdH-0004dr-AC for qemu-devel@nongnu.org; Fri, 09 Jan 2015 05:17:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y9WdG-0000vB-GW for qemu-devel@nongnu.org; Fri, 09 Jan 2015 05:17:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47887) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9WdG-0000uY-6v for qemu-devel@nongnu.org; Fri, 09 Jan 2015 05:17:30 -0500 From: Stefan Hajnoczi Date: Fri, 9 Jan 2015 10:16:47 +0000 Message-Id: <1420798626-11428-8-git-send-email-stefanha@redhat.com> In-Reply-To: <1420798626-11428-1-git-send-email-stefanha@redhat.com> References: <1420798626-11428-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PULL 07/26] 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: qemu-devel@nongnu.org Cc: Peter Maydell , Stefan Hajnoczi , Programmingkid From: Programmingkid Signed-off-by: John Arbuckle Signed-off-by: Stefan Hajnoczi --- 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 == 0) #endif #if defined(__APPLE__) && defined(__MACH__) - size = LLONG_MAX; + { + uint64_t sectors = 0; + uint32_t sector_size = 0; + + /* Query the number of sectors on the disk */ + ret = ioctl(fd, DKIOCGETBLOCKCOUNT, §ors); + if (ret == -1) { + return -errno; + } + + /* Query the size of each sector */ + ret = ioctl(fd, DKIOCGETBLOCKSIZE, §or_size); + if (ret == -1) { + return -errno; + } + size = sectors * sector_size; + } #else size = 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="yes" audio_drv_list="coreaudio" audio_possible_drivers="coreaudio sdl fmod" - LDFLAGS="-framework CoreFoundation -framework IOKit $LDFLAGS" + LDFLAGS="-framework CoreFoundation -framework IOKit -framework ApplicationServices $LDFLAGS" libs_softmmu="-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. -- 2.1.0