From f72b8ff09837d6e495d604b6eef4f4e732193df9 Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Tue, 30 May 2006 00:54:49 +0200 Subject: [PATCH] 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 --- lib/blkid/getsize.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/blkid/getsize.c b/lib/blkid/getsize.c index 75bec52..5525d19 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; -- 1.8.3.1