Whamcloud - gitweb
Fix filefrag to be 32-bit clean
authorTheodore Ts'o <tytso@mit.edu>
Sat, 22 Apr 2006 08:49:09 +0000 (04:49 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 22 Apr 2006 08:49:09 +0000 (04:49 -0400)
Currently filefrag uses signed int for block numbers, thus it reporting
corrupted block number for a file on a more than 8TB ext3. The following
trivial patch replace the signed int type block number with "unsigned
long type.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
misc/ChangeLog
misc/filefrag.c

index 4140ad6..605928a 100644 (file)
@@ -1,3 +1,8 @@
+2006-04-22  Theodore Ts'o  <tytso@mit.edu>
+
+       * filefrag.c: Make filefrag 32-bit clean, so that it works on 
+               filesystems > 8TB.
+
 2006-03-29  Theodore Ts'o  <tytso@mit.edu>
 
        * dumpe2fs.c (print_inline_journal_information): Print the size of
index 8cd9d01..0a8b29d 100644 (file)
@@ -71,7 +71,8 @@ static void frag_report(const char *filename)
        struct statfs   fsinfo;
        struct stat64   fileinfo;
        int             bs;
-       long            i, fd, block, last_block = 0, numblocks;
+       long            i, fd;
+       unsigned long   block, last_block = 0, numblocks;
        long            bpib;   /* Blocks per indirect block */
        long            cylgroups;
        int             discont = 0, expected;
@@ -124,7 +125,7 @@ static void frag_report(const char *filename)
        if (verbose) {
                printf("File size of %s is %lld (%ld blocks)\n", filename, 
                       (long long) fileinfo.st_size, numblocks);
-               printf("First block: %ld\nLast block: %ld\n",
+               printf("First block: %lu\nLast block: %lu\n",
                       get_bmap(fd, 0), get_bmap(fd, numblocks - 1));
        }
        for (i=0; i < numblocks; i++) {
@@ -141,7 +142,7 @@ static void frag_report(const char *filename)
                        continue;
                if (last_block && (block != last_block +1) ) {
                        if (verbose)
-                               printf("Discontinuity: Block %ld is at %ld (was %ld)\n",
+                               printf("Discontinuity: Block %ld is at %lu (was %lu)\n",
                                       i, block, last_block);
                        discont++;
                }