aboutsummaryrefslogtreecommitdiffstats
path: root/dump
diff options
context:
space:
mode:
authorrelan <relan@users.noreply.github.com>2011-02-05 14:36:45 +0000
committerrelan <relan@users.noreply.github.com>2015-08-24 08:26:13 +0300
commit17f4354d95e34defd2dfb5163edbe818ef81866b (patch)
tree4d82c9d1399c0ac90e19a1ab5b16dd0afb473bcf /dump
parentd00f9f0d59274c9c0bd7038245227d962dccbbac (diff)
downloadandroid_external_exfat-17f4354d95e34defd2dfb5163edbe818ef81866b.tar.gz
android_external_exfat-17f4354d95e34defd2dfb5163edbe818ef81866b.tar.bz2
android_external_exfat-17f4354d95e34defd2dfb5163edbe818ef81866b.zip
Add -u option for dumpexfat that prints used sectors.
It's useful for fast FS cloning.
Diffstat (limited to 'dump')
-rw-r--r--dump/main.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/dump/main.c b/dump/main.c
index 670d382..f613958 100644
--- a/dump/main.c
+++ b/dump/main.c
@@ -105,7 +105,17 @@ static int dump_sb(const char* spec)
return 0;
}
-static int dump_full(const char* spec)
+static void dump_sectors(struct exfat* ef)
+{
+ off_t a = 0, b = 0;
+
+ printf("Used sectors ");
+ while (exfat_find_used_blocks(ef, &a, &b) == 0)
+ printf(" %"PRIu64"-%"PRIu64, a, b);
+ puts("");
+}
+
+static int dump_full(const char* spec, int used_sectors)
{
struct exfat ef;
uint32_t free_clusters;
@@ -124,6 +134,8 @@ static int dump_full(const char* spec)
print_cluster_info(ef.sb);
printf("Free clusters %10u\n", free_clusters);
print_other_info(ef.sb);
+ if (used_sectors)
+ dump_sectors(&ef);
exfat_unmount(&ef);
return 0;
@@ -131,7 +143,7 @@ static int dump_full(const char* spec)
static void usage(const char* prog)
{
- fprintf(stderr, "Usage: %s [-s] <device>\n", prog);
+ fprintf(stderr, "Usage: %s [-s] [-u] <device>\n", prog);
exit(1);
}
@@ -140,11 +152,14 @@ int main(int argc, char* argv[])
char** pp;
const char* spec = NULL;
int sb_only = 0;
+ int used_sectors = 0;
for (pp = argv + 1; *pp; pp++)
{
if (strcmp(*pp, "-s") == 0)
sb_only = 1;
+ else if (strcmp(*pp, "-u") == 0)
+ used_sectors = 1;
else if (spec == NULL)
spec = *pp;
else
@@ -155,6 +170,6 @@ int main(int argc, char* argv[])
if (sb_only)
return dump_sb(spec);
- else
- return dump_full(spec);
+
+ return dump_full(spec, used_sectors);
}