]> git.sven.stormbind.net Git - sven/exfat-utils.git/blobdiff - dump/main.c
releasing version 1.0.0-1
[sven/exfat-utils.git] / dump / main.c
index 357557d6ee2af4dfa0a4dda46f85d1b9d835c42f..fa80903b8a0c07a32c20d3a6daee67c50ce52e2b 100644 (file)
@@ -2,7 +2,7 @@
        main.c (08.11.10)
        Prints detailed information about exFAT volume.
 
-       Copyright (C) 2010  Andrew Nayenko
+       Copyright (C) 2011-2013  Andrew Nayenko
 
        This program is free software: you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
@@ -73,23 +73,22 @@ static void print_other_info(const struct exfat_super_block* sb)
 
 static int dump_sb(const char* spec)
 {
-       int fd;
+       struct exfat_dev* dev;
        struct exfat_super_block sb;
 
-       fd = exfat_open(spec, 1);
-       if (fd < 0)
+       dev = exfat_open(spec, EXFAT_MODE_RO);
+       if (dev == NULL)
                return 1;
 
-       if (read(fd, &sb, sizeof(struct exfat_super_block))
-                       != sizeof(struct exfat_super_block))
+       if (exfat_read(dev, &sb, sizeof(struct exfat_super_block)) < 0)
        {
-               close(fd);
+               exfat_close(dev);
                exfat_error("failed to read from `%s'", spec);
                return 1;
        }
        if (memcmp(sb.oem_name, "EXFAT   ", sizeof(sb.oem_name)) != 0)
        {
-               close(fd);
+               exfat_close(dev);
                exfat_error("exFAT file system is not found on `%s'", spec);
                return 1;
        }
@@ -99,7 +98,7 @@ static int dump_sb(const char* spec)
        print_cluster_info(&sb);
        print_other_info(&sb);
 
-       close(fd);
+       exfat_close(dev);
        return 0;
 }
 
@@ -113,7 +112,7 @@ static void dump_sectors(struct exfat* ef)
        puts("");
 }
 
-static int dump_full(const char* spec, int used_sectors)
+static int dump_full(const char* spec, bool used_sectors)
 {
        struct exfat ef;
        uint32_t free_clusters;
@@ -149,8 +148,8 @@ int main(int argc, char* argv[])
 {
        char** pp;
        const char* spec = NULL;
-       int sb_only = 0;
-       int used_sectors = 0;
+       bool sb_only = false;
+       bool used_sectors = false;
 
        printf("dumpexfat %u.%u.%u\n",
                        EXFAT_VERSION_MAJOR, EXFAT_VERSION_MINOR, EXFAT_VERSION_PATCH);
@@ -158,12 +157,12 @@ int main(int argc, char* argv[])
        for (pp = argv + 1; *pp; pp++)
        {
                if (strcmp(*pp, "-s") == 0)
-                       sb_only = 1;
+                       sb_only = true;
                else if (strcmp(*pp, "-u") == 0)
-                       used_sectors = 1;
+                       used_sectors = true;
                else if (strcmp(*pp, "-v") == 0)
                {
-                       puts("Copyright (C) 2010  Andrew Nayenko");
+                       puts("Copyright (C) 2011-2013  Andrew Nayenko");
                        return 0;
                }
                else if (spec == NULL)