]> err.no Git - util-linux/commitdiff
blockdev: use LU and LLU for BLKGETSIZE and BLKGETSIZE64
authorKarel Zak <kzak@redhat.com>
Wed, 1 Aug 2007 13:47:33 +0000 (15:47 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 1 Aug 2007 13:47:33 +0000 (15:47 +0200)
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>
disk-utils/blockdev.c

index 0dd531c4ab928aff61495068cca425ec23e63e4e..0b30cd5c468a472ab6516b4a4feb4344e768a595 100644 (file)
@@ -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));