summaryrefslogtreecommitdiffstats
path: root/disk-utils/blockdev.c
diff options
context:
space:
mode:
authorKarel Zak2007-08-01 15:06:18 +0200
committerKarel Zak2007-08-01 15:06:18 +0200
commit3281d4268a192cbd1951347a4a857b94428dc958 (patch)
treea48a8696980f9b01dcfbc87c8eb864b2cd8b54aa /disk-utils/blockdev.c
parentmount: should set proper permissions on locktime (diff)
downloadkernel-qcow2-util-linux-3281d4268a192cbd1951347a4a857b94428dc958.tar.gz
kernel-qcow2-util-linux-3281d4268a192cbd1951347a4a857b94428dc958.tar.xz
kernel-qcow2-util-linux-3281d4268a192cbd1951347a4a857b94428dc958.zip
blockdev: fix "blockdev --getsz" for large devices
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>
Diffstat (limited to 'disk-utils/blockdev.c')
-rw-r--r--disk-utils/blockdev.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/disk-utils/blockdev.c b/disk-utils/blockdev.c
index 46b7fa719..0dd531c4a 100644
--- a/disk-utils/blockdev.c
+++ b/disk-utils/blockdev.c
@@ -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;