Add -v option that prints version and copyright.

This commit is contained in:
relan
2011-03-01 05:35:14 +00:00
parent ce2a407503
commit 9c76a44a67
5 changed files with 64 additions and 19 deletions

View File

@@ -143,7 +143,7 @@ static int dump_full(const char* spec, int used_sectors)
static void usage(const char* prog)
{
fprintf(stderr, "Usage: %s [-s] [-u] <device>\n", prog);
fprintf(stderr, "Usage: %s [-s] [-u] [-v] <device>\n", prog);
exit(1);
}
@@ -154,12 +154,20 @@ int main(int argc, char* argv[])
int sb_only = 0;
int used_sectors = 0;
printf("dumpexfat %u.%u.%u\n",
EXFAT_VERSION_MAJOR, EXFAT_VERSION_MINOR, EXFAT_VERSION_PATCH);
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 (strcmp(*pp, "-v") == 0)
{
puts("Copyright (C) 2010 Andrew Nayenko");
return 0;
}
else if (spec == NULL)
spec = *pp;
else

View File

@@ -113,22 +113,40 @@ static void fsck(struct exfat* ef)
dirck(ef, "");
}
static void usage(const char* prog)
{
fprintf(stderr, "Usage: %s [-v] <device>\n", prog);
exit(1);
}
int main(int argc, char* argv[])
{
char** pp;
const char* spec = NULL;
struct exfat ef;
if (argc != 2)
{
fprintf(stderr, "Usage: %s <device>\n", argv[0]);
return 1;
}
printf("exfatfsck %u.%u.%u\n",
EXFAT_VERSION_MAJOR, EXFAT_VERSION_MINOR, EXFAT_VERSION_PATCH);
if (exfat_mount(&ef, argv[1], "ro") != 0)
for (pp = argv + 1; *pp; pp++)
{
if (strcmp(*pp, "-v") == 0)
{
puts("Copyright (C) 2009 Andrew Nayenko");
return 0;
}
else if (spec == NULL)
spec = *pp;
else
usage(argv[0]);
}
if (spec == NULL)
usage(argv[0]);
if (exfat_mount(&ef, spec, "ro") != 0)
return 1;
printf("Checking file system on %s.\n", argv[1]);
printf("Checking file system on %s.\n", spec);
fsck(&ef);
exfat_unmount(&ef);
printf("Totally %"PRIu64" directories and %"PRIu64" files.\n",

View File

@@ -258,7 +258,7 @@ static void fuse_exfat_destroy(void* unused)
static void usage(const char* prog)
{
fprintf(stderr, "Usage: %s [-d] [-o options] <device> <dir>\n", prog);
fprintf(stderr, "Usage: %s [-d] [-o options] [-v] <device> <dir>\n", prog);
exit(1);
}
@@ -398,6 +398,12 @@ int main(int argc, char* argv[])
}
else if (strcmp(*pp, "-d") == 0)
debug = 1;
else if (strcmp(*pp, "-v") == 0)
{
free(mount_options);
puts("Copyright (C) 2009 Andrew Nayenko");
return 0;
}
else if (spec == NULL)
spec = *pp;
else if (mount_point == NULL)

View File

@@ -19,16 +19,27 @@
*/
#include <stdio.h>
#include <string.h>
#include <exfat.h>
int main(int argc, char* argv[])
{
char** pp;
struct exfat ef;
int rc = 0;
for (pp = argv + 1; *pp; pp++)
if (strcmp(*pp, "-v") == 0)
{
printf("exfatlabel %u.%u.%u\n", EXFAT_VERSION_MAJOR,
EXFAT_VERSION_MINOR, EXFAT_VERSION_PATCH);
puts("Copyright (C) 2011 Andrew Nayenko");
return 0;
}
if (argc != 2 && argc != 3)
{
fprintf(stderr, "Usage: %s <device> [label]\n", argv[0]);
fprintf(stderr, "Usage: %s [-v] <device> [label]\n", argv[0]);
return 1;
}

View File

@@ -2,7 +2,7 @@
main.c (15.08.10)
Creates exFAT file system.
Copyright (C) 2009, 2010 Andrew Nayenko
Copyright (C) 2010 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
@@ -360,7 +360,7 @@ static void usage(const char* prog)
{
fprintf(stderr, "Usage: %s [-i volume-id] [-n label] "
"[-p partition-first-sector] "
"[-s sectors-per-cluster] <device>\n", prog);
"[-s sectors-per-cluster] [-v] <device>\n", prog);
exit(1);
}
@@ -373,6 +373,9 @@ int main(int argc, char* argv[])
uint32_t volume_serial = 0;
int first_sector = 0;
printf("mkexfatfs %u.%u.%u\n",
EXFAT_VERSION_MAJOR, EXFAT_VERSION_MINOR, EXFAT_VERSION_PATCH);
for (pp = argv + 1; *pp; pp++)
{
if (strcmp(*pp, "-s") == 0)
@@ -409,19 +412,18 @@ int main(int argc, char* argv[])
usage(argv[0]);
first_sector = atoi(*pp);
}
else if (**pp == '-')
else if (strcmp(*pp, "-v") == 0)
{
exfat_error("unrecognized option `%s'", *pp);
return 1;
puts("Copyright (C) 2010 Andrew Nayenko");
return 0;
}
else
else if (spec == NULL)
spec = *pp;
else
usage(argv[0]);
}
if (spec == NULL)
usage(argv[0]);
printf("mkexfatfs %u.%u.%u\n",
EXFAT_VERSION_MAJOR, EXFAT_VERSION_MINOR, EXFAT_VERSION_PATCH);
return mkfs(spec, 9, spc_bits, volume_label, volume_serial, first_sector);
}