Whamcloud - gitweb
libext2fs: install hashmap.h since it is needed by libext2fs.h
[tools/e2fsprogs.git] / e2fsck / iscan.c
index 72acb01..52cad11 100644 (file)
@@ -3,6 +3,7 @@
  * anything else)
  */
 
+#include "config.h"
 #include <string.h>
 #include <fcntl.h>
 #include <ctype.h>
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
 #endif
-#ifdef HAVE_MNTENT_H
-#include <mntent.h>
-#endif
 #include <sys/ioctl.h>
+#ifdef HAVE_MALLOC_H
 #include <malloc.h>
+#endif
 
 #include "et/com_err.h"
 #include "e2fsck.h"
@@ -38,10 +38,10 @@ int invalid_bitmaps = 0;
 
 struct resource_track  global_rtrack;
 
-static void usage(NOARGS)
+static void usage(void)
 {
        fprintf(stderr,
-               "Usage: %s [-F] [-I inode_buffer_blocks] device\n",
+               _("Usage: %s [-F] [-I inode_buffer_blocks] device\n"),
                program_name);
        exit(1);
 }
@@ -49,26 +49,22 @@ static void usage(NOARGS)
 static void PRS(int argc, char *argv[])
 {
        int             flush = 0;
-       char            c;
+       int             c;
 #ifdef MTRACE
        extern void     *mallwatch;
 #endif
+       errcode_t       retval;
 
        setbuf(stdout, NULL);
        setbuf(stderr, NULL);
        initialize_ext2_error_table();
-       
+
        if (argc && *argv)
                program_name = *argv;
        while ((c = getopt (argc, argv, "FI")) != EOF)
                switch (c) {
                case 'F':
-#ifdef BLKFLSBUF
                        flush = 1;
-#else
-                       fprintf(stderr, "-F not supported");
-                       exit(1);
-#endif
                        break;
                case 'I':
                        inode_buffer_blocks = atoi(optarg);
@@ -78,37 +74,32 @@ static void PRS(int argc, char *argv[])
                }
        device_name = argv[optind];
        if (flush) {
-#ifdef BLKFLSBUF
                int     fd = open(device_name, O_RDONLY, 0);
 
                if (fd < 0) {
-                       com_err("open", errno, "while opening %s for flushing",
-                               device_name);
+                       com_err("open", errno,
+                           _("while opening %s for flushing"), device_name);
                        exit(FSCK_ERROR);
                }
-               if (ioctl(fd, BLKFLSBUF, 0) < 0) {
-                       com_err("BLKFLSBUF", errno, "while trying to flush %s",
-                               device_name);
+               if ((retval = ext2fs_sync_device(fd, 1))) {
+                       com_err("ext2fs_sync_device", retval,
+                               _("while trying to flush %s"), device_name);
                        exit(FSCK_ERROR);
                }
                close(fd);
-#else
-               fprintf(stderr, "BLKFLSBUF not supported");
-               exit(1);
-#endif /* BLKFLSBUF */
        }
 }
-                                       
+
 int main (int argc, char *argv[])
 {
        errcode_t       retval = 0;
        int             exit_value = FSCK_OK;
        ext2_filsys     fs;
-       ino_t   ino;
-       int     num_inodes = 0;
+       ext2_ino_t      ino;
+       __u32   num_inodes = 0;
        struct ext2_inode inode;
        ext2_inode_scan scan;
-       
+
        init_resource_track(&global_rtrack);
 
        PRS(argc, argv);
@@ -116,16 +107,16 @@ int main (int argc, char *argv[])
        retval = ext2fs_open(device_name, 0,
                             0, 0, unix_io_manager, &fs);
        if (retval) {
-               com_err(program_name, retval, "while trying to open %s",
+               com_err(program_name, retval, _("while trying to open '%s'"),
                        device_name);
                exit(1);
        }
 
        ehandler_init(fs->io);
-       
+
        retval = ext2fs_open_inode_scan(fs, inode_buffer_blocks, &scan);
        if (retval) {
-               com_err(program_name, retval, "while opening inode scan");
+               com_err(program_name, retval, _("while opening inode scan"));
                exit(1);
        }
 
@@ -133,16 +124,16 @@ int main (int argc, char *argv[])
                retval = ext2fs_get_next_inode(scan, &ino, &inode);
                if (retval) {
                        com_err(program_name, retval,
-                               "while getting next inode");
+                               _("while getting next inode"));
                        exit(1);
                }
                if (ino == 0)
                        break;
                num_inodes++;
        }
-       
+
        print_resource_track(NULL, &global_rtrack);
-       printf("%d inodes scanned.\n", num_inodes);
-       
+       printf(_("%u inodes scanned.\n"), num_inodes);
+
        exit(0);
 }