]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
Implement DIOCGMEDIASIZE for FreeBSD's GEOM.
authorMatthias Andree <matthias.andree@gmx.de>
Mon, 29 May 2006 22:54:49 +0000 (00:54 +0200)
committerMatthias Andree <matthias.andree@gmx.de>
Mon, 29 May 2006 22:54:49 +0000 (00:54 +0200)
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>
lib/blkid/getsize.c

index 75bec525279af507c0fd0c6daa8bdf89d4df074b..5525d19bdab3181b1b8e4be99d13b6f494f304a3 100644 (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;