[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v5 2/5] raw-posix: Refactor logical block size d
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH v5 2/5] raw-posix: Refactor logical block size detection. |
Date: |
Fri, 2 Jan 2015 11:52:47 +0000 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Thu, Dec 18, 2014 at 12:18:01PM +0100, Ekaterina Tumanova wrote:
> +#if defined(BLKSSZGET)
> +# define SECTOR_SIZE BLKSSZGET
> +#elif defined(DKIOCGETBLOCKSIZE)
> +# define SECTOR_SIZE DKIOCGETBLOCKSIZE
> +#elif defined(DIOCGSECTORSIZE)
> +# define SECTOR_SIZE DIOCGSECTORSIZE
> +#else
> + return -ENOTSUP
> +#endif
> + if (ioctl(fd, SECTOR_SIZE, sector_size) < 0) {
> + return -errno;
> + }
> + return 0;
> +#undef SECTOR_SIZE
Not a reason to respin, but I would have preferred simply moving the old
code.
I think the new code works because BLKSSZGET is Linux, DKIOCGETBLOCKSIZE
is Mac OS, and DIOCGSECTORSIZE is FreeBSD.
If there is a host OS where more than one ioctl is available and the
first one fails then the new code is broken. The old code didn't use
#elif so each ioctl had a chance to run.
Also, the name SECTOR_SIZE is misleading. It's not a sector size value
but the "get sector size" ioctl request code.
Stefan
pgpm3EFOUT93S.pgp
Description: PGP signature
- Re: [Qemu-devel] [PATCH v5 2/5] raw-posix: Refactor logical block size detection.,
Stefan Hajnoczi <=