X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lib%2Fblkid%2Fgetsize.c;h=9e9085729df9472f783b7a2b9df5f243e0c58960;hb=6fb57a92d19696c123d02d89cfa1f1e6703dfc32;hp=6639246c0d7c8b2044ebfbfb0ee1b11ea9576042;hpb=5beaabb0f88e3fb2a4b3617fed9ac76f7a60f440;p=tools%2Fe2fsprogs.git diff --git a/lib/blkid/getsize.c b/lib/blkid/getsize.c index 6639246..9e90857 100644 --- a/lib/blkid/getsize.c +++ b/lib/blkid/getsize.c @@ -70,7 +70,7 @@ static int valid_offset(int fd, blkid_loff_t offset) } /* - * Returns the number of blocks in a partition + * Returns the number of bytes in a partition */ blkid_loff_t blkid_get_dev_size(int fd) { @@ -133,11 +133,14 @@ blkid_loff_t blkid_get_dev_size(int fd) return (blkid_loff_t)this_floppy.size << 9; #endif #ifdef HAVE_SYS_DISKLABEL_H -#if 1 /* - * This should work in theory but I haven't tested it. Anyone - * on a BSD system want to test this for me? In the meantime, - * binary search mechanism should work just fine. + * This code works for FreeBSD 4.11 i386, except for the full device + * (such as /dev/ad0). It doesn't work properly for newer FreeBSD + * though. FreeBSD >= 5.0 should be covered by the DIOCGMEDIASIZE + * above however. + * + * Note that FreeBSD >= 4.0 has disk devices as unbuffered (raw, + * character) devices, so we need to check for S_ISCHR, too. */ if ((fstat(fd, &st) >= 0) && (S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode))) part = st.st_rdev & 7; @@ -146,7 +149,6 @@ blkid_loff_t blkid_get_dev_size(int fd) if (pp->p_size) return pp->p_size << 9; } -#endif #endif /* HAVE_SYS_DISKLABEL_H */ { #ifdef HAVE_FSTAT64