On 13 January 2015 at 18:45, Programmingkid <programmingk...@gmail.com> wrote:
>
> On Jan 13, 2015, at 1:34 PM, Peter Maydell wrote:
>
>> On 13 January 2015 at 18:26, Programmingkid <programmingk...@gmail.com> 
>> wrote:
>>> Signed-off-by: John Arbuckle <programmingk...@gmail.com>
>>> +        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...

> I did try using lseek, but it doesn't work with Mac OS X block
> devices. It would always fail.

Right, but for block devices the ioctl will succeed, I thought?
We'll only try lseek() if the ioctl fails (hence "fall back").

-- PMM

Reply via email to