Rename io_raw module to more appropriate file_windows
[lwext4.git] / fs_test / lwext4_generic.c
index 21a4526e6dd5c6be0ef0b7f015fa9c43241b80d9..1c2f302eafed9eedeeb242afc7897bf16b148ab4 100644 (file)
@@ -39,7 +39,7 @@
 
 #include <ext4.h>
 #include "../blockdev/linux/ext4_filedev.h"
-#include "../blockdev/windows/io_raw.h"
+#include "../blockdev/windows/file_windows.h"
 #include "common/test_lwext4.h"
 
 #ifdef WIN32
@@ -58,9 +58,6 @@ static int rw_count = 10;
 /**@brief   Directory test count*/
 static int dir_cnt = 0;
 
-/**@brief   Static or dynamic cache mode*/
-static bool cache_mode = true;
-
 /**@brief   Cleanup after test.*/
 static bool cleanup_flag = false;
 
@@ -73,14 +70,14 @@ static bool sbstat = false;
 /**@brief   Indicates that input is windows partition.*/
 static bool winpart = false;
 
+/**@brief   Verbose mode*/
+static bool verbose = 0;
+
 /**@brief   Block device handle.*/
 static struct ext4_blockdev *bd;
 
-/**@brief   Static cache instance*/
-EXT4_BCACHE_STATIC_INSTANCE(_lwext4_cache, CONFIG_BLOCK_DEV_CACHE_SIZE, 1024);
-
 /**@brief   Block cache handle.*/
-static struct ext4_bcache *bc = &_lwext4_cache;
+static struct ext4_bcache *bc;
 
 static const char *usage = "                                    \n\
 Welcome in ext4 generic demo.                                   \n\
@@ -89,7 +86,6 @@ Usage:                                                          \n\
 [-i] --input    - input file         (default = ext2)           \n\
 [-w] --rw_size  - single R/W size    (default = 1024 * 1024)    \n\
 [-c] --rw_count - R/W count          (default = 10)             \n\
-[-a] --cache  - 0 static, 1 dynamic  (default = 1)              \n\
 [-d] --dirs   - directory test count (default = 0)              \n\
 [-l] --clean  - clean up after test                             \n\
 [-b] --bstat  - block device stats                              \n\
@@ -148,6 +144,10 @@ static bool open_windows(void)
 #endif
 }
 
+static bool open_filedev(void)
+{
+       return winpart ? open_windows() : open_linux();
+}
 
 static bool parse_opt(int argc, char **argv)
 {
@@ -158,15 +158,16 @@ static bool parse_opt(int argc, char **argv)
            {"input", required_argument, 0, 'i'},
            {"rw_size", required_argument, 0, 's'},
            {"rw_count", required_argument, 0, 'c'},
-           {"cache", required_argument, 0, 'a'},
            {"dirs", required_argument, 0, 'd'},
            {"clean", no_argument, 0, 'l'},
            {"bstat", no_argument, 0, 'b'},
            {"sbstat", no_argument, 0, 't'},
            {"wpart", no_argument, 0, 'w'},
+           {"verbose", no_argument, 0, 'v'},
+           {"version", no_argument, 0, 'x'},
            {0, 0, 0, 0}};
 
-       while (-1 != (c = getopt_long(argc, argv, "i:s:c:q:d:lbtw",
+       while (-1 != (c = getopt_long(argc, argv, "i:s:c:q:d:lbtwvx",
                                      long_options, &option_index))) {
 
                switch (c) {
@@ -179,9 +180,6 @@ static bool parse_opt(int argc, char **argv)
                case 'c':
                        rw_count = atoi(optarg);
                        break;
-               case 'a':
-                       cache_mode = atoi(optarg);
-                       break;
                case 'd':
                        dir_cnt = atoi(optarg);
                        break;
@@ -197,6 +195,13 @@ static bool parse_opt(int argc, char **argv)
                case 'w':
                        winpart = true;
                        break;
+               case 'v':
+                       verbose = true;
+                       break;
+               case 'x':
+                       puts(VERSION);
+                       exit(0);
+                       break;
                default:
                        printf("%s", usage);
                        return false;
@@ -210,23 +215,19 @@ int main(int argc, char **argv)
        if (!parse_opt(argc, argv))
                return EXIT_FAILURE;
 
+       printf("ext4_generic\n");
        printf("test conditions:\n");
        printf("\timput name: %s\n", input_name);
        printf("\trw size: %d\n", rw_szie);
        printf("\trw count: %d\n", rw_count);
-       printf("\tcache mode: %s\n", cache_mode ? "dynamic" : "static");
-
-       if (winpart) {
-               if (!open_windows())
-                       return EXIT_FAILURE;
-       } else {
-               if (!open_linux())
-                       return EXIT_FAILURE;
-       }
 
+       if (!open_filedev()) {
+               printf("open_filedev error\n");
+               return EXIT_FAILURE;
+       }
 
-       if (cache_mode)
-               bc = NULL;
+       if (verbose)
+               ext4_dmask_set(DEBUG_ALL);
 
        if (!test_lwext4_mount(bd, bc))
                return EXIT_FAILURE;