Whamcloud - gitweb
ChangeLog, badblocks.c:
authorTheodore Ts'o <tytso@mit.edu>
Thu, 11 Jan 2001 16:04:59 +0000 (16:04 +0000)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 11 Jan 2001 16:04:59 +0000 (16:04 +0000)
  badblocks.c (flush_bufs): Use ext2fs_sync_device() to sync and flush
   the device.

misc/ChangeLog
misc/badblocks.c

index d530659..e993326 100644 (file)
@@ -1,5 +1,8 @@
 2001-01-11    <tytso@snap.thunk.org>
 
+       * badblocks.c (flush_bufs): Use ext2fs_sync_device() to sync and
+               flush the device.
+
        * mke2fs.c: Change ino_t to ext2_ino_t.
 
 2001-01-08    <tytso@snap.thunk.org>
index 8c72885..23b22ae 100644 (file)
@@ -47,10 +47,6 @@ extern int optind;
 #include <sys/ioctl.h>
 #include <sys/types.h>
 
-#if HAVE_LINUX_FS_H
-#include <linux/fd.h>
-#endif
-
 #include "et/com_err.h"
 #include "ext2fs/ext2_io.h"
 #include <linux/ext2_fs.h>
@@ -214,22 +210,13 @@ static long do_write (int dev, char * buffer, int try, int block_size,
 
 static int host_dev;
 
-static void flush_bufs (int dev)
+static void flush_bufs(void)
 {
-#ifdef HAVE_FDATASYNC
-  if (fdatasync (dev) == -1)
-    com_err (program_name, errno, _("during fdatasync"));
-#else
-  if (fsync (dev) == -1)
-    com_err (program_name, errno, _("during fsync"));
-#endif
+       errcode_t       retval;
 
-#ifdef BLKFLSBUF
-  ioctl (host_dev, BLKFLSBUF, 0);   /* In case this is a HD */
-#endif
-#ifdef FDFLUSH
-  ioctl (host_dev, FDFLUSH, 0);   /* In case this is floppy */
-#endif
+       retval = ext2fs_sync_device(host_dev, 1);
+       if (retval)
+               com_err(program_name, retval, _("during ext2fs_sync_device"));
 }
 
 static unsigned int test_ro (int dev, unsigned long blocks_count,
@@ -258,7 +245,7 @@ static unsigned int test_ro (int dev, unsigned long blocks_count,
                com_err (program_name, ENOMEM, _("while allocating buffers"));
                exit (1);
        }
-       flush_bufs(dev);
+       flush_bufs();
        if (v_flag) {
            fprintf(stderr, _("Checking for bad blocks in read-only mode\n"));
            fprintf (stderr, _("From block %lu to %lu\n"), from_count,
@@ -328,7 +315,7 @@ static unsigned int test_rw (int dev, unsigned long blocks_count,
                exit (1);
        }
 
-       flush_bufs(dev);
+       flush_bufs();
 
        if (v_flag) {
                fprintf(stderr,
@@ -363,7 +350,7 @@ static unsigned int test_rw (int dev, unsigned long blocks_count,
                alarm (0);
                if (s_flag | v_flag)
                        fprintf(stderr, _(done_string));
-               flush_bufs(dev);
+               flush_bufs();
                if (s_flag | v_flag)
                        fprintf (stderr, _("Reading and comparing: "));
                num_blocks = blocks_count;
@@ -391,7 +378,7 @@ static unsigned int test_rw (int dev, unsigned long blocks_count,
                alarm (0);
                if (s_flag | v_flag)
                        fprintf(stderr, _(done_string));
-               flush_bufs(dev);
+               flush_bufs();
        }
 
        return bb_count;
@@ -446,7 +433,7 @@ static unsigned int test_nd (int dev, unsigned long blocks_count,
                (*ptr) = random() % (1 << sizeof(char));
        }
 
-       flush_bufs(dev);
+       flush_bufs();
        if (v_flag) {
            fprintf (stderr,
                     _("Checking for bad blocks in non-destructive read-write mode\n"));
@@ -539,7 +526,7 @@ static unsigned int test_nd (int dev, unsigned long blocks_count,
                    (currently_testing < blocks_count))
                        continue;
 
-               flush_bufs(dev);
+               flush_bufs();
                save_currently_testing = currently_testing;
 
                /*
@@ -668,7 +655,7 @@ int main (int argc, char ** argv)
        textdomain(NLS_CAT_NAME);
 #endif
        test_func = test_ro;
-       
+
        if (argc && *argv)
                program_name = *argv;
        while ((c = getopt (argc, argv, "b:fi:o:svwnc:p:h:")) != EOF) {