]> err.no Git - util-linux/commitdiff
blockdev: fix "blockdev --getsz" for large devices
authorKarel Zak <kzak@redhat.com>
Wed, 1 Aug 2007 13:06:18 +0000 (15:06 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 1 Aug 2007 13:06:18 +0000 (15:06 +0200)
The "blockdev --getsz" command doesn't try to use BLKGETSIZE64 when
previous BLKGETSIZE failed with EFBIG. This patch fixes this problem.

Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/blockdev.c

index 46b7fa71940981c82175ba4055c401bec9b5c49a..0dd531c4ab928aff61495068cca425ec23e63e4e 100644 (file)
@@ -9,6 +9,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <sys/ioctl.h>
+#include <errno.h>
 
 #include "nls.h"
 
@@ -148,8 +149,10 @@ getsize(int fd, long long *sectors) {
        long long b;
 
        err = ioctl (fd, BLKGETSIZE, &sz);
-       if (err)
-               return err;
+       if (err) {
+               if (errno != EFBIG)
+                       return err;
+       }
        err = ioctl(fd, BLKGETSIZE64, &b);
        if (err || b == 0 || b == sz)
                *sectors = sz;