]> git.ipfire.org Git - thirdparty/e2fsprogs.git/blobdiff - debugfs/debugfs.c
Fix gcc -Wall warnings
[thirdparty/e2fsprogs.git] / debugfs / debugfs.c
index 20d1f4bf224315688e0308a4fec6854533c4f207..190c4b7b26fef7e94392b49496d8cd2f5052ea70 100644 (file)
@@ -120,16 +120,15 @@ errout:
 
 void do_open_filesys(int argc, char **argv)
 {
-       const char *usage = "Usage: open [-s superblock] [-b blocksize] [-c] [-w] <device>";
        int     c, err;
        int     catastrophic = 0;
        blk_t   superblock = 0;
        blk_t   blocksize = 0;
-       int     open_flags = 0;
+       int     open_flags = EXT2_FLAG_SOFTSUPP_FEATURES;
        char    *data_filename = 0;
        
        reset_getopt();
-       while ((c = getopt (argc, argv, "iwfcb:s:d:")) != EOF) {
+       while ((c = getopt (argc, argv, "iwfecb:s:d:")) != EOF) {
                switch (c) {
                case 'i':
                        open_flags |= EXT2_FLAG_IMAGE_FILE;
@@ -140,6 +139,9 @@ void do_open_filesys(int argc, char **argv)
                case 'f':
                        open_flags |= EXT2_FLAG_FORCE;
                        break;
+               case 'e':
+                       open_flags |= EXT2_FLAG_EXCLUSIVE;
+                       break;
                case 'c':
                        catastrophic = 1;
                        break;
@@ -159,26 +161,30 @@ void do_open_filesys(int argc, char **argv)
                                return;
                        break;
                default:
-                       com_err(argv[0], 0, usage);
-                       return;
+                       goto print_usage;
                }
        }
        if (optind != argc-1) {
-               com_err(argv[0], 0, usage);
-               return;
+               goto print_usage;
        }
        if (check_fs_not_open(argv[0]))
                return;
        open_filesystem(argv[optind], open_flags,
                        superblock, blocksize, catastrophic, 
                        data_filename);
+       return;
+
+print_usage:
+       fprintf(stderr, "%s: Usage: open [-s superblock] [-b blocksize] "
+               "[-c] [-w] <device>\n", argv[0]);
 }
 
 void do_lcd(int argc, char **argv)
 {
-       if (common_args_process(argc, argv, 2, 2, "lcd",
-                               "<native dir>", 0))
+       if (argc != 2) {
+               com_err(argv[0], 0, "Usage: %s %s", argv[0], "<native dir>");
                return;
+       }
 
        if (chdir(argv[1]) == -1) {
                com_err(argv[0], errno,
@@ -195,16 +201,16 @@ static void close_filesystem(NOARGS)
        if (current_fs->flags & EXT2_FLAG_IB_DIRTY) {
                retval = ext2fs_write_inode_bitmap(current_fs);
                if (retval)
-                       com_err("ext2fs_write_inode_bitmap", retval, "");
+                       com_err("ext2fs_write_inode_bitmap", retval, 0);
        }
        if (current_fs->flags & EXT2_FLAG_BB_DIRTY) {
                retval = ext2fs_write_block_bitmap(current_fs);
                if (retval)
-                       com_err("ext2fs_write_block_bitmap", retval, "");
+                       com_err("ext2fs_write_block_bitmap", retval, 0);
        }
        retval = ext2fs_close(current_fs);
        if (retval)
-               com_err("ext2fs_close", retval, "");
+               com_err("ext2fs_close", retval, 0);
        current_fs = NULL;
        return;
 }
@@ -261,14 +267,26 @@ static void print_features(struct ext2_super_block * s, FILE *f)
        fputs("\n", f);
 }
 
+static void print_bg_opts(struct ext2_group_desc *gdp, int mask,
+                         const char *str, int *first, FILE *f)
+{
+       if (gdp->bg_flags & mask) {
+               if (*first) {
+                       fputs("           [", f);
+                       *first = 0;
+               } else
+                       fputs(", ", f);
+               fputs(str, f);
+       }
+}
+
 void do_show_super_stats(int argc, char *argv[])
 {
        dgrp_t  i;
        FILE    *out;
        struct ext2_group_desc *gdp;
        int     c, header_only = 0;
-       int     numdirs = 0;
-       const char *usage = "Usage: show_super [-h]";
+       int     numdirs = 0, first;
 
        reset_getopt();
        while ((c = getopt (argc, argv, "h")) != EOF) {
@@ -277,13 +295,11 @@ void do_show_super_stats(int argc, char *argv[])
                        header_only++;
                        break;
                default:
-                       com_err(argv[0], 0, usage);
-                       return;
+                       goto print_usage;
                }
        }
        if (optind != argc) {
-               com_err(argv[0], 0, usage);
-               return;
+               goto print_usage;
        }
        if (check_fs_open(argv[0]))
                return;
@@ -300,10 +316,10 @@ void do_show_super_stats(int argc, char *argv[])
        }
        
        gdp = &current_fs->group_desc[0];
-       for (i = 0; i < current_fs->group_desc_count; i++, gdp++)
-               fprintf(out, " Group %2d: block bitmap at %d, "
-                       "inode bitmap at %d, "
-                       "inode table at %d\n"
+       for (i = 0; i < current_fs->group_desc_count; i++, gdp++) {
+               fprintf(out, " Group %2d: block bitmap at %u, "
+                       "inode bitmap at %u, "
+                       "inode table at %u\n"
                        "           %d free %s, "
                        "%d free %s, "
                        "%d used %s\n",
@@ -316,7 +332,18 @@ void do_show_super_stats(int argc, char *argv[])
                        gdp->bg_used_dirs_count,
                        gdp->bg_used_dirs_count != 1 ? "directories"
                                : "directory");
+               first = 1;
+               print_bg_opts(gdp, EXT2_BG_INODE_UNINIT, "Inode not init",
+                             &first, out);
+               print_bg_opts(gdp, EXT2_BG_BLOCK_UNINIT, "Block not init",
+                             &first, out);
+               if (!first)
+                       fputs("]\n", out);
+       }
        close_pager(out);
+       return;
+print_usage:
+       fprintf(stderr, "%s: Usage: show_super [-h]\n", argv[0]);
 }
 
 void do_dirty_filesys(int argc EXT2FS_ATTR((unused)), 
@@ -351,10 +378,12 @@ static void finish_range(struct list_blocks_struct *lb)
        else
                fprintf(lb->f, ", ");
        if (lb->first_block == lb->last_block)
-               fprintf(lb->f, "(%lld):%d", lb->first_bcnt, lb->first_block);
+               fprintf(lb->f, "(%lld):%u",
+                       (long long)lb->first_bcnt, lb->first_block);
        else
-               fprintf(lb->f, "(%lld-%lld):%d-%d", lb->first_bcnt,
-                       lb->last_bcnt, lb->first_block, lb->last_block);
+               fprintf(lb->f, "(%lld-%lld):%u-%u",
+                       (long long)lb->first_bcnt, (long long)lb->last_bcnt,
+                       lb->first_block, lb->last_block);
        lb->first_block = 0;
 }
 
@@ -395,15 +424,15 @@ static int list_blocks_proc(ext2_filsys fs EXT2FS_ATTR((unused)),
        else
                fprintf(lb->f, ", ");
        if (blockcnt == -1)
-               fprintf(lb->f, "(IND):%d", *blocknr);
+               fprintf(lb->f, "(IND):%u", *blocknr);
        else if (blockcnt == -2)
-               fprintf(lb->f, "(DIND):%d", *blocknr);
+               fprintf(lb->f, "(DIND):%u", *blocknr);
        else if (blockcnt == -3)
-               fprintf(lb->f, "(TIND):%d", *blocknr);
+               fprintf(lb->f, "(TIND):%u", *blocknr);
        return 0;
 }
 
-void dump_xattr_string(FILE *out, const unsigned char *str, int len)
+static void dump_xattr_string(FILE *out, const char *str, int len)
 {
        int printable = 1;
        int i;
@@ -417,21 +446,22 @@ void dump_xattr_string(FILE *out, const unsigned char *str, int len)
 
        for (i = 0; i < len; i++)
                if (printable)
-                       fprintf(out, "%c", str[i]);
+                       fprintf(out, "%c", (unsigned char)str[i]);
                else
-                       fprintf(out, "%02x ", str[i]);
+                       fprintf(out, "%02x ", (unsigned char)str[i]);
 }
 
-void internal_dump_inode_extra(FILE *out, const char *prefix,
-                        ext2_ino_t inode_num, struct ext2_inode_large *inode)
+static void internal_dump_inode_extra(FILE *out, 
+                                     const char *prefix EXT2FS_ATTR((unused)),
+                                     ext2_ino_t inode_num EXT2FS_ATTR((unused)), 
+                                     struct ext2_inode_large *inode)
 {
        struct ext2_ext_attr_entry *entry;
        __u32 *magic;
        char *start, *end;
-       int storage_size;
-       int i;
+       unsigned int storage_size;
 
-       fprintf(out, "Size of extra inode fields: %d\n", inode->i_extra_isize);
+       fprintf(out, "Size of extra inode fields: %u\n", inode->i_extra_isize);
        if (inode->i_extra_isize > EXT2_INODE_SIZE(current_fs->super) -
                        EXT2_GOOD_OLD_INODE_SIZE) {
                fprintf(stderr, "invalid inode->i_extra_isize (%u)\n",
@@ -462,7 +492,7 @@ void internal_dump_inode_extra(FILE *out, const char *prefix,
                        fprintf(out, " = \"");
                        dump_xattr_string(out, start + entry->e_value_offs,
                                                entry->e_value_size);
-                       fprintf(out, "\" (%d)\n", entry->e_value_size);
+                       fprintf(out, "\" (%u)\n", entry->e_value_size);
                        entry = next;
                }
        }
@@ -481,7 +511,7 @@ static void dump_blocks(FILE *f, const char *prefix, ext2_ino_t inode)
                             list_blocks_proc, (void *)&lb);
        finish_range(&lb);
        if (lb.total)
-               fprintf(f, "\n%sTOTAL: %lld\n", prefix, lb.total);
+               fprintf(f, "\n%sTOTAL: %lld\n", prefix, (long long)lb.total);
        fprintf(f,"\n");
 }
 
@@ -507,15 +537,15 @@ void internal_dump_inode(FILE *out, const char *prefix,
                prefix, 
                inode->i_mode & 0777, inode->i_flags, inode->i_generation);
        fprintf(out, "%sUser: %5d   Group: %5d   Size: ",
-               prefix, inode->i_uid, inode->i_gid);
+               prefix, inode_uid(*inode), inode_gid(*inode));
        if (LINUX_S_ISREG(inode->i_mode)) {
-               __u64 i_size = (inode->i_size |
-                               ((unsigned long long)inode->i_size_high << 32));
+               unsigned long long i_size = (inode->i_size |
+                                   ((unsigned long long)inode->i_size_high << 32));
 
-               fprintf(out, "%lld\n", i_size);
+               fprintf(out, "%llu\n", i_size);
        } else
                fprintf(out, "%d\n", inode->i_size);
-       if (current_fs->super->s_creator_os == EXT2_OS_HURD)
+       if (os == EXT2_OS_HURD)
                fprintf(out,
                        "%sFile ACL: %d    Directory ACL: %d Translator: %d\n",
                        prefix,
@@ -525,13 +555,16 @@ void internal_dump_inode(FILE *out, const char *prefix,
                fprintf(out, "%sFile ACL: %d    Directory ACL: %d\n",
                        prefix,
                        inode->i_file_acl, LINUX_S_ISDIR(inode->i_mode) ? inode->i_dir_acl : 0);
-       fprintf(out, "%sLinks: %d   Blockcount: %d\n", 
-               prefix, inode->i_links_count, inode->i_blocks);
+       if (os == EXT2_OS_LINUX) 
+               fprintf(out, "%sLinks: %d   Blockcount: %llu\n",
+                       prefix, inode->i_links_count, 
+                       (((unsigned long long) 
+                         inode->osd2.linux2.l_i_blocks_hi << 32)) + 
+                       inode->i_blocks);
+       else
+               fprintf(out, "%sLinks: %d   Blockcount: %u\n",
+                       prefix, inode->i_links_count, inode->i_blocks);
        switch (os) {
-           case EXT2_OS_LINUX:
-               frag = inode->osd2.linux2.l_i_frag;
-               fsize = inode->osd2.linux2.l_i_fsize;
-               break;
            case EXT2_OS_HURD:
                frag = inode->osd2.hurd2.h_i_frag;
                fsize = inode->osd2.hurd2.h_i_fsize;
@@ -631,7 +664,7 @@ void do_chroot(int argc, char *argv[])
 
        retval = ext2fs_check_directory(current_fs, inode);
        if (retval)  {
-               com_err(argv[1], retval, "");
+               com_err(argv[1], retval, 0);
                return;
        }
        root = inode;
@@ -696,7 +729,7 @@ void do_testi(int argc, char *argv[])
 void do_freeb(int argc, char *argv[])
 {
        blk_t block;
-       int count = 1;
+       blk_t count = 1;
 
        if (common_block_args_process(argc, argv, &block, &count))
                return;
@@ -704,7 +737,7 @@ void do_freeb(int argc, char *argv[])
                return;
        while (count-- > 0) {
                if (!ext2fs_test_block_bitmap(current_fs->block_map,block))
-                       com_err(argv[0], 0, "Warning: block %d already clear",
+                       com_err(argv[0], 0, "Warning: block %u already clear",
                                block);
                ext2fs_unmark_block_bitmap(current_fs->block_map,block);
                block++;
@@ -715,7 +748,7 @@ void do_freeb(int argc, char *argv[])
 void do_setb(int argc, char *argv[])
 {
        blk_t block;
-       int count = 1;
+       blk_t count = 1;
 
        if (common_block_args_process(argc, argv, &block, &count))
                return;
@@ -723,7 +756,7 @@ void do_setb(int argc, char *argv[])
                return;
        while (count-- > 0) {
                if (ext2fs_test_block_bitmap(current_fs->block_map,block))
-                       com_err(argv[0], 0, "Warning: block %d already set",
+                       com_err(argv[0], 0, "Warning: block %u already set",
                                block);
                ext2fs_mark_block_bitmap(current_fs->block_map,block);
                block++;
@@ -734,15 +767,15 @@ void do_setb(int argc, char *argv[])
 void do_testb(int argc, char *argv[])
 {
        blk_t block;
-       int count = 1;
+       blk_t count = 1;
 
        if (common_block_args_process(argc, argv, &block, &count))
                return;
        while (count-- > 0) {
                if (ext2fs_test_block_bitmap(current_fs->block_map,block))
-                       printf("Block %d marked in use\n", block);
+                       printf("Block %u marked in use\n", block);
                else
-                       printf("Block %d not in use\n", block);
+                       printf("Block %u not in use\n", block);
                block++;
        }
 }
@@ -822,6 +855,7 @@ void do_modify_inode(int argc, char *argv[])
        const char      *hex_format = "0x%x";
        const char      *octal_format = "0%o";
        const char      *decimal_format = "%d";
+       const char      *unsignedlong_format = "%lu";
        
        if (common_inode_args_process(argc, argv, &inode_num, CHECK_FS_RW))
                return;
@@ -834,13 +868,16 @@ void do_modify_inode(int argc, char *argv[])
        modify_u16(argv[0], "Mode", octal_format, &inode.i_mode);
        modify_u16(argv[0], "User ID", decimal_format, &inode.i_uid);
        modify_u16(argv[0], "Group ID", decimal_format, &inode.i_gid);
-       modify_u32(argv[0], "Size", decimal_format, &inode.i_size);
+       modify_u32(argv[0], "Size", unsignedlong_format, &inode.i_size);
        modify_u32(argv[0], "Creation time", decimal_format, &inode.i_ctime);
        modify_u32(argv[0], "Modification time", decimal_format, &inode.i_mtime);
        modify_u32(argv[0], "Access time", decimal_format, &inode.i_atime);
        modify_u32(argv[0], "Deletion time", decimal_format, &inode.i_dtime);
        modify_u16(argv[0], "Link count", decimal_format, &inode.i_links_count);
-       modify_u32(argv[0], "Block count", decimal_format, &inode.i_blocks);
+       if (os == EXT2_OS_LINUX)
+               modify_u16(argv[0], "Block count high", unsignedlong_format, 
+                          &inode.osd2.linux2.l_i_blocks_hi);
+       modify_u32(argv[0], "Block count", unsignedlong_format, &inode.i_blocks);
        modify_u32(argv[0], "File flags", hex_format, &inode.i_flags);
        modify_u32(argv[0], "Generation", hex_format, &inode.i_generation);
 #if 0
@@ -852,16 +889,12 @@ void do_modify_inode(int argc, char *argv[])
        else
                modify_u32(argv[0], "High 32bits of size", decimal_format, &inode.i_size_high);
 
-       if (current_fs->super->s_creator_os == EXT2_OS_HURD)
+       if (os == EXT2_OS_HURD)
                modify_u32(argv[0], "Translator Block",
                            decimal_format, &inode.osd1.hurd1.h_i_translator);
        
        modify_u32(argv[0], "Fragment address", decimal_format, &inode.i_faddr);
        switch (os) {
-           case EXT2_OS_LINUX:
-               frag = &inode.osd2.linux2.l_i_frag;
-               fsize = &inode.osd2.linux2.l_i_fsize;
-               break;
            case EXT2_OS_HURD:
                frag = &inode.osd2.hurd2.h_i_frag;
                fsize = &inode.osd2.hurd2.h_i_fsize;
@@ -902,7 +935,7 @@ void do_change_working_dir(int argc, char *argv[])
 
        retval = ext2fs_check_directory(current_fs, inode);
        if (retval) {
-               com_err(argv[1], retval, "");
+               com_err(argv[1], retval, 0);
                return;
        }
        cwd = inode;
@@ -923,15 +956,23 @@ void do_print_working_directory(int argc, char *argv[])
                com_err(argv[0], retval,
                        "while trying to get pathname of cwd");
        }
-       printf("[pwd]   INODE: %6u  PATH: %s\n", cwd, pathname);
-       free(pathname);
+       printf("[pwd]   INODE: %6u  PATH: %s\n",
+              cwd, pathname ? pathname : "NULL");
+        if (pathname) {
+               free(pathname);
+               pathname = NULL;
+        }
        retval = ext2fs_get_pathname(current_fs, root, 0, &pathname);
        if (retval) {
                com_err(argv[0], retval,
                        "while trying to get pathname of root");
        }
-       printf("[root]  INODE: %6u  PATH: %s\n", root, pathname);
-       free(pathname);
+       printf("[root]  INODE: %6u  PATH: %s\n",
+              root, pathname ? pathname : "NULL");
+       if (pathname) {
+               free(pathname);
+               pathname = NULL;
+       }
        return;
 }
 
@@ -970,7 +1011,7 @@ static void make_link(char *sourcename, char *destname)
        struct ext2_inode inode;
        int             retval;
        ext2_ino_t      dir;
-       char            *dest, *cp, *basename;
+       char            *dest, *cp, *base_name;
 
        /*
         * Get the source inode
@@ -978,17 +1019,17 @@ static void make_link(char *sourcename, char *destname)
        ino = string_to_inode(sourcename);
        if (!ino)
                return;
-       basename = strrchr(sourcename, '/');
-       if (basename)
-               basename++;
+       base_name = strrchr(sourcename, '/');
+       if (base_name)
+               base_name++;
        else
-               basename = sourcename;
+               base_name = sourcename;
        /*
         * Figure out the destination.  First see if it exists and is
         * a directory.  
         */
        if (! (retval=ext2fs_namei(current_fs, root, cwd, destname, &dir)))
-               dest = basename;
+               dest = base_name;
        else {
                /*
                 * OK, it doesn't exist.  See if it is
@@ -1013,7 +1054,7 @@ static void make_link(char *sourcename, char *destname)
        retval = ext2fs_link(current_fs, dir, dest, ino, 
                             ext2_file_type(inode.i_mode));
        if (retval)
-               com_err("make_link", retval, "");
+               com_err("make_link", retval, 0);
        return;
 }
 
@@ -1082,21 +1123,21 @@ static void unlink_file_by_name(char *filename)
 {
        int             retval;
        ext2_ino_t      dir;
-       char            *basename;
+       char            *base_name;
        
-       basename = strrchr(filename, '/');
-       if (basename) {
-               *basename++ = '\0';
+       base_name = strrchr(filename, '/');
+       if (base_name) {
+               *base_name++ = '\0';
                dir = string_to_inode(filename);
                if (!dir)
                        return;
        } else {
                dir = cwd;
-               basename = filename;
+               base_name = filename;
        }
-       retval = ext2fs_unlink(current_fs, dir, basename, 0, 0);
+       retval = ext2fs_unlink(current_fs, dir, base_name, 0, 0);
        if (retval)
-               com_err("unlink_file_by_name", retval, "");
+               com_err("unlink_file_by_name", retval, 0);
        return;
 }
 
@@ -1148,10 +1189,10 @@ void do_find_free_block(int argc, char *argv[])
                retval = ext2fs_new_block(current_fs, free_blk + 1, 0,
                                          &free_blk);
                if (retval) {
-                       com_err("ext2fs_new_block", retval, "");
+                       com_err("ext2fs_new_block", retval, 0);
                        return;
                } else
-                       printf("%d ", free_blk);
+                       printf("%u ", free_blk);
        }
        printf("\n");
 }
@@ -1190,7 +1231,7 @@ void do_find_free_inode(int argc, char *argv[])
 
        retval = ext2fs_new_inode(current_fs, dir, mode, 0, &free_inode);
        if (retval)
-               com_err("ext2fs_new_inode", retval, "");
+               com_err("ext2fs_new_inode", retval, 0);
        else
                printf("Free inode found: %u\n", free_inode);
 }
@@ -1251,11 +1292,11 @@ void do_write(int argc, char *argv[])
 
        fd = open(argv[1], O_RDONLY);
        if (fd < 0) {
-               com_err(argv[1], errno, "");
+               com_err(argv[1], errno, 0);
                return;
        }
        if (fstat(fd, &statbuf) < 0) {
-               com_err(argv[1], errno, "");
+               com_err(argv[1], errno, 0);
                close(fd);
                return;
        }
@@ -1269,7 +1310,7 @@ void do_write(int argc, char *argv[])
 
        retval = ext2fs_new_inode(current_fs, cwd, 010755, 0, &newfile);
        if (retval) {
-               com_err(argv[0], retval, "");
+               com_err(argv[0], retval, 0);
                close(fd);
                return;
        }
@@ -1286,7 +1327,7 @@ void do_write(int argc, char *argv[])
                                     EXT2_FT_REG_FILE);
        }
        if (retval) {
-               com_err(argv[2], retval, "");
+               com_err(argv[2], retval, 0);
                close(fd);
                return;
        }
@@ -1306,7 +1347,7 @@ void do_write(int argc, char *argv[])
        if (LINUX_S_ISREG(inode.i_mode)) {
                retval = copy_file(fd, newfile);
                if (retval)
-                       com_err("copy_file", retval, "");
+                       com_err("copy_file", retval, 0);
        }
        close(fd);
 }
@@ -1359,7 +1400,7 @@ void do_mknod(int argc, char *argv[])
                return;
        retval = ext2fs_new_inode(current_fs, cwd, 010755, 0, &newfile);
        if (retval) {
-               com_err(argv[0], retval, "");
+               com_err(argv[0], retval, 0);
                return;
        }
        printf("Allocated inode: %u\n", newfile);
@@ -1374,7 +1415,7 @@ void do_mknod(int argc, char *argv[])
                                     filetype);
        }
        if (retval) {
-               com_err(argv[1], retval, "");
+               com_err(argv[1], retval, 0);
                return;
        }
         if (ext2fs_test_inode_bitmap(current_fs->inode_map,newfile))
@@ -1413,7 +1454,7 @@ void do_mkdir(int argc, char *argv[])
                *cp = 0;
                parent = string_to_inode(argv[1]);
                if (!parent) {
-                       com_err(argv[1], ENOENT, "");
+                       com_err(argv[1], ENOENT, 0);
                        return;
                }
                name = cp+1;
@@ -1433,7 +1474,7 @@ try_again:
                goto try_again;
        }
        if (retval) {
-               com_err("ext2fs_mkdir", retval, "");
+               com_err("ext2fs_mkdir", retval, 0);
                return;
        }
 
@@ -1619,7 +1660,7 @@ void do_expand_dir(int argc, char *argv[])
 
        retval = ext2fs_expand_dir(current_fs, inode);
        if (retval)
-               com_err("ext2fs_expand_dir", retval, "");
+               com_err("ext2fs_expand_dir", retval, 0);
        return;
 }
 
@@ -1662,10 +1703,10 @@ void do_bmap(int argc, char *argv[])
        errcode = ext2fs_bmap(current_fs, ino, 0, 0, 0, blk, &pblk);
        if (errcode) {
                com_err("argv[0]", errcode,
-                       "while mapping logical block %d\n", blk);
+                       "while mapping logical block %u\n", blk);
                return;
        }
-       printf("%d\n", pblk);
+       printf("%u\n", pblk);
 }
 
 void do_imap(int argc, char *argv[])
@@ -1701,8 +1742,6 @@ void do_imap(int argc, char *argv[])
 
 void do_set_current_time(int argc, char *argv[])
 {
-       ext2_ino_t      ino;
-       unsigned long   group, block, block_nr, offset;
        time_t now;
 
        if (common_args_process(argc, argv, 2, 2, argv[0],
@@ -1765,7 +1804,7 @@ int main(int argc, char **argv)
        int             sci_idx;
        const char      *usage = "Usage: debugfs [-b blocksize] [-s superblock] [-f cmd_file] [-R request] [-V] [[-w] [-c] device]";
        int             c;
-       int             open_flags = 0;
+       int             open_flags = EXT2_FLAG_SOFTSUPP_FEATURES;
        char            *request = 0;
        int             exit_status = 0;
        char            *cmd_file = 0;
@@ -1774,7 +1813,7 @@ int main(int argc, char **argv)
        int             catastrophic = 0;
        char            *data_filename = 0;
        
-       initialize_ext2_error_table();
+       add_error_table(&et_ext2_error_table);
        fprintf (stderr, "debugfs %s (%s)\n", E2FSPROGS_VERSION,
                 E2FSPROGS_DATE);
 
@@ -1850,5 +1889,6 @@ int main(int argc, char **argv)
        if (current_fs)
                close_filesystem();
        
+       remove_error_table(&et_ext2_error_table);
        return exit_status;
 }