qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v5] block/raw-posix.c: Fixes raw_getlength() on


From: Programmingkid
Subject: Re: [Qemu-devel] [PATCH v5] block/raw-posix.c: Fixes raw_getlength() on Mac OS X so that it reports the correct length of a real CD
Date: Tue, 13 Jan 2015 13:45:48 -0500

On Jan 13, 2015, at 1:34 PM, Peter Maydell wrote:

> On 13 January 2015 at 18:26, Programmingkid <address@hidden> wrote:
>> 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 <address@hidden>
>> 
>> ---
>> 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, &sectors);
>> +        if (ret == -1) {
>> +            return 0;
> 
> We should be falling back to lseek, not returning 0...
> 
> thanks
> -- PMM

I did try using lseek, but it doesn't work with Mac OS X block devices. It 
would always fail. Here is some more information on the problem: 
http://stackoverflow.com/questions/9073614/open-raw-disk-and-get-size-os-x. 

I thought things would be as simple as using fopen() with a block device as the 
argument, but Apple decided to make things more difficult. It looks like they 
are forcing developers to use the IOKit for device communications. Simple posix 
functions like lseek don't work.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]