Implement DIOCGMEDIASIZE for FreeBSD's GEOM.

Try DIOCGMEDIASIZE ioctl() if defined, to obtain
the media size on FreeBSD 5.0 and newer.
The binary search fallback doesn't work, as FreeBSD
block devices are unbuffered and refuse reads below
the block size.

Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
bitmap-optimize
Matthias Andree 2006-05-30 00:54:49 +02:00
parent 604f1a91e5
commit f72b8ff098
1 changed files with 6 additions and 0 deletions

View File

@ -122,6 +122,12 @@ blkid_loff_t blkid_get_dev_size(int fd)
return (blkid_loff_t)size << 9;
#endif
/* tested on FreeBSD 6.1-RELEASE i386 */
#ifdef DIOCGMEDIASIZE
if (ioctl(fd, DIOCGMEDIASIZE, &size64) >= 0)
return (off_t)size64;
#endif /* DIOCGMEDIASIZE */
#ifdef FDGETPRM
if (ioctl(fd, FDGETPRM, &this_floppy) >= 0)
return (blkid_loff_t)this_floppy.size << 9;