Allows for using real cdrom disc in QEMU under Mac OS X. This command was used to see if this patch worked: ./qemu-system-i386 -drive if=none,id=drive0,file=/dev/null,format=raw
Signed-off-by: John Arbuckle <programmingk...@gmail.com> --- Replaced -errno with 0 for ioctl() failure return value. "make check" now passes with this patch. 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 0; + } + + /* Query the size of each sector */ + ret = ioctl(fd, DKIOCGETBLOCKSIZE, §or_size); + if (ret == -1) { + return 0; + } + 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. -- 1.7.5.4