Whamcloud - gitweb
e2fsck: copy badblocks when copying fs
[tools/e2fsprogs.git] / resize / test_extent.c
index 6a3f49d..11ad132 100644 (file)
@@ -4,14 +4,15 @@
  * Copyright (C) 1997, 1998 by Theodore Ts'o and
  *     PowerQuest, Inc.
  *
- * Copyright (C) 1999, 2000 by Theosore Ts'o
- * 
+ * Copyright (C) 1999, 2000 by Theodore Ts'o
+ *
  * %Begin-Header%
  * This file may be redistributed under the terms of the GNU Public
  * License.
  * %End-Header%
  */
 
+#include "config.h"
 #include "resize2fs.h"
 
 void do_test(FILE *in, FILE *out);
@@ -20,12 +21,12 @@ void do_test(FILE *in, FILE *out)
 {
        char            buf[128];
        char            *cp, *cmd, *arg1, *arg2;
-       __u32           num1, num2;
-       int             size;
+       __u64           num1, num2;
+       __u64           size;
        errcode_t       retval;
        ext2_extent     extent = 0;
        const char      *no_table = "# No extent table\n";
-       
+
        while (!feof(in)) {
                if (!fgets(buf, sizeof(buf), in))
                        break;
@@ -55,7 +56,7 @@ void do_test(FILE *in, FILE *out)
                        *cp++ = '\0';
                        arg1 = cp;
                        num1 = strtoul(arg1, 0, 0);
-                       
+
                        cp = strchr(cp, ' ');
                }
                if (cp) {
@@ -63,7 +64,7 @@ void do_test(FILE *in, FILE *out)
                        arg2 = cp;
                        num2 = strtoul(arg2, 0, 0);
                }
-               
+
                if (!strcmp(cmd, "create")) {
                        retval = ext2fs_create_extent_table(&extent, num1);
                        if (retval) {
@@ -77,7 +78,7 @@ void do_test(FILE *in, FILE *out)
                if (!extent) {
                        fputs(no_table, out);
                        continue;
-               }               
+               }
                if (!strcmp(cmd, "free")) {
                        ext2fs_free_extent_table(extent);
                        extent = 0;
@@ -87,7 +88,8 @@ void do_test(FILE *in, FILE *out)
                                goto handle_error;
                } else if (!strcmp(cmd, "lookup")) {
                        num2 = ext2fs_extent_translate(extent, num1);
-                       fprintf(out, "# Answer: %u%s\n", num2,
+                       fprintf(out, "# Answer: %llu%s\n",
+                               (unsigned long long) num2,
                                num2 ? "" : " (not found)");
                } else if (!strcmp(cmd, "dump")) {
                        ext2fs_extent_dump(extent, out);
@@ -102,12 +104,16 @@ void do_test(FILE *in, FILE *out)
                                        goto handle_error;
                                if (!size)
                                        break;
-                               fprintf(out, "# %u -> %u (%d)\n",
-                                       num1, num2, size);
+                               fprintf(out, "# %llu -> %llu (%llu)\n",
+                                       (unsigned long long) num1,
+                                       (unsigned long long) num2,
+                                       (unsigned long long) size);
                        }
-               } else 
+               } else
                        fputs("# Syntax error\n", out);
        }
+       if (extent)
+               ext2fs_free_extent_table(extent);
 }
 
 #ifdef __GNUC__