static char *ext4_fname = "ext2";
/**@brief Verbose mode*/
-static int verbose = 0;
+static bool verbose = false;
/**@brief Winpart mode*/
-static int winpart = 0;
+static bool winpart = false;
/**@brief Blockdev handle*/
static struct ext4_blockdev *bd;
-static int cache_wb = 0;
+static bool cache_wb = false;
static char read_buffer[MAX_RW_BUFFER];
static char write_buffer[MAX_RW_BUFFER];
static struct option long_options[] = {
{"image", required_argument, 0, 'i'},
{"port", required_argument, 0, 'p'},
- {"verbose", required_argument, 0, 'v'},
- {"winpart", required_argument, 0, 'w'},
- {"cache_wb", required_argument, 0, 'c'},
+ {"verbose", no_argument, 0, 'v'},
+ {"winpart", no_argument, 0, 'w'},
+ {"cache_wb", no_argument, 0, 'c'},
{0, 0, 0, 0}};
- while (-1 != (c = getopt_long(argc, argv, "c:i:p:v:w:", long_options,
+ while (-1 != (c = getopt_long(argc, argv, "i:p:vcw", long_options,
&option_index))) {
switch (c) {
connection_port = atoi(optarg);
break;
case 'v':
- verbose = atoi(optarg);
+ verbose = true;
break;
case 'c':
- cache_wb = atoi(optarg);
+ cache_wb = true;
break;
case 'w':
- winpart = atoi(optarg);
+ winpart = true;
break;
default:
printf("%s", usage);
return -1;
}
+ if (verbose)
+ ext4_dmask_set(DEBUG_ALL);
+
rc = ext4_mount(dev_name, mount_point);
+ if (rc != EOK)
+ return rc;
+
+ rc = ext4_recover(mount_point);
+ if (rc != EOK && rc != ENOTSUP)
+ return rc;
+
+ rc = ext4_journal_start(mount_point);
+ if (rc != EOK)
+ return rc;
+
if (cache_wb)
ext4_cache_write_back(mount_point, 1);
return rc;
int _umount(char *p)
{
char mount_point[32];
+ int rc;
if (sscanf(p, "%s", mount_point) != 1) {
printf("Param list error\n");
if (cache_wb)
ext4_cache_write_back(mount_point, 0);
- return ext4_umount(mount_point);
+ rc = ext4_journal_stop(mount_point);
+ if (rc != EOK)
+ return rc;
+
+ rc = ext4_umount(mount_point);
+ if (rc != EOK)
+ return rc;
+
+ return rc;
}
int _mount_point_stats(char *p)