From: Matthias Andree Date: Mon, 29 May 2006 22:54:49 +0000 (+0200) Subject: Implement DIOCGMEDIASIZE for FreeBSD's GEOM. X-Git-Tag: E2FSPROGS-1_40-WIP-1114~98 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f72b8ff09837d6e495d604b6eef4f4e732193df9;p=thirdparty%2Fe2fsprogs.git 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 --- diff --git a/lib/blkid/getsize.c b/lib/blkid/getsize.c index 75bec5252..5525d19bd 100644 --- a/lib/blkid/getsize.c +++ b/lib/blkid/getsize.c @@ -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;