summaryrefslogtreecommitdiffstats
path: root/disk-utils
diff options
context:
space:
mode:
authorKarel Zak2007-08-01 15:47:33 +0200
committerKarel Zak2007-08-01 15:47:33 +0200
commit1dea05a811ffe81ba647adf0f6942917574c98e1 (patch)
tree486f5ed0379d466af096788904b867d135116605 /disk-utils
parentblockdev: fix "blockdev --getsz" for large devices (diff)
downloadkernel-qcow2-util-linux-1dea05a811ffe81ba647adf0f6942917574c98e1.tar.gz
kernel-qcow2-util-linux-1dea05a811ffe81ba647adf0f6942917574c98e1.tar.xz
kernel-qcow2-util-linux-1dea05a811ffe81ba647adf0f6942917574c98e1.zip
blockdev: use LU and LLU for BLKGETSIZE and BLKGETSIZE64
The "blkockdev --getsize" returns negative numbers on i386 for 1Tb devices. The BLKGETSIZE and BLKGETSIZE64 have to use unsigned long and unsigned long long. $ blockdev --getsize /dev/mapper/huge -2147483648 Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'disk-utils')
-rw-r--r--disk-utils/blockdev.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/disk-utils/blockdev.c b/disk-utils/blockdev.c
index 0dd531c4a..0b30cd5c4 100644
--- a/disk-utils/blockdev.c
+++ b/disk-utils/blockdev.c
@@ -57,6 +57,8 @@ struct bdc {
#define ARGINTG 4
#define ARGLINTG 5
#define ARGLLINTG 6
+#define ARGLU 7
+#define ARGLLU 8
long argval;
char *argname;
char *help;
@@ -78,10 +80,10 @@ struct bdc {
{ "--setbsz", "BLKBSZSET", BLKBSZSET, ARGINTAP, 0, "BLOCKSIZE", N_("set blocksize") },
#endif
#ifdef BLKGETSIZE
- { "--getsize", "BLKGETSIZE", BLKGETSIZE, ARGLINTG, -1, NULL, N_("get 32-bit sector count") },
+ { "--getsize", "BLKGETSIZE", BLKGETSIZE, ARGLU, -1, NULL, N_("get 32-bit sector count") },
#endif
#ifdef BLKGETSIZE64
- { "--getsize64", "BLKGETSIZE64", BLKGETSIZE64, ARGLLINTG, -1, NULL, N_("get size in bytes") },
+ { "--getsize64", "BLKGETSIZE64", BLKGETSIZE64, ARGLLU, -1, NULL, N_("get size in bytes") },
#endif
#ifdef BLKRASET
{ "--setra", "BLKRASET", BLKRASET, ARGINTA, 0, "READAHEAD", N_("set readahead") },
@@ -245,6 +247,8 @@ do_commands(int fd, char **argv, int d) {
int iarg;
long larg;
long long llarg;
+ unsigned long lu;
+ unsigned long long llu;
int verbose = 0;
for (i = 1; i < d; i++) {
@@ -309,6 +313,15 @@ do_commands(int fd, char **argv, int d) {
llarg = bdcms[j].argval;
res = ioctl(fd, bdcms[j].ioc, &llarg);
break;
+ case ARGLU:
+ lu = bdcms[j].argval;
+ res = ioctl(fd, bdcms[j].ioc, &lu);
+ break;
+ case ARGLLU:
+ llu = bdcms[j].argval;
+ res = ioctl(fd, bdcms[j].ioc, &llu);
+ break;
+
}
if (res == -1) {
perror(bdcms[j].iocname);
@@ -335,6 +348,19 @@ do_commands(int fd, char **argv, int d) {
else
printf("%lld\n", llarg);
break;
+ case ARGLU:
+ if (verbose)
+ printf("%s: %lu\n", _(bdcms[j].help), lu);
+ else
+ printf("%lu\n", lu);
+ break;
+ case ARGLLU:
+ if (verbose)
+ printf("%s: %llu\n", _(bdcms[j].help), llu);
+ else
+ printf("%llu\n", llu);
+ break;
+
default:
if (verbose)
printf(_("%s succeeded.\n"), _(bdcms[j].help));