X-Git-Url: http://git.sven.stormbind.net/?a=blobdiff_plain;ds=inline;f=mkfs%2Fmain.c;h=61d9a6dab29d4d51862266450e11a69caa18a3cd;hb=refs%2Fheads%2Fjessie-updates;hp=89dc3d0a34c4bd594f6fce36a862df651239abe7;hpb=4efb596cee7f7cc961990f8dffc3b210e579e49c;p=sven%2Fexfat-utils.git
diff --git a/mkfs/main.c b/mkfs/main.c
index 89dc3d0..61d9a6d 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -2,11 +2,12 @@
main.c (15.08.10)
Creates exFAT file system.
- Copyright (C) 2011-2013 Andrew Nayenko
+ Free exFAT implementation.
+ Copyright (C) 2011-2014 Andrew Nayenko
- This program is free software: you can redistribute it and/or modify
+ 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
- the Free Software Foundation, either version 3 of the License, or
+ the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -14,8 +15,9 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include
@@ -188,14 +190,14 @@ static void usage(const char* prog)
{
fprintf(stderr, "Usage: %s [-i volume-id] [-n label] "
"[-p partition-first-sector] "
- "[-s sectors-per-cluster] [-v] \n", prog);
+ "[-s sectors-per-cluster] [-V] \n", prog);
exit(1);
}
int main(int argc, char* argv[])
{
const char* spec = NULL;
- char** pp;
+ int opt;
int spc_bits = -1;
const char* volume_label = NULL;
uint32_t volume_serial = 0;
@@ -205,53 +207,38 @@ int main(int argc, char* argv[])
printf("mkexfatfs %u.%u.%u\n",
EXFAT_VERSION_MAJOR, EXFAT_VERSION_MINOR, EXFAT_VERSION_PATCH);
- for (pp = argv + 1; *pp; pp++)
+ while ((opt = getopt(argc, argv, "i:n:p:s:V")) != -1)
{
- if (strcmp(*pp, "-s") == 0)
+ switch (opt)
{
- pp++;
- if (*pp == NULL)
- usage(argv[0]);
- spc_bits = logarithm2(atoi(*pp));
+ case 'i':
+ volume_serial = strtol(optarg, NULL, 16);
+ break;
+ case 'n':
+ volume_label = optarg;
+ break;
+ case 'p':
+ first_sector = strtoll(optarg, NULL, 10);
+ break;
+ case 's':
+ spc_bits = logarithm2(atoi(optarg));
if (spc_bits < 0)
{
- exfat_error("invalid option value: `%s'", *pp);
+ exfat_error("invalid option value: '%s'", optarg);
return 1;
}
- }
- else if (strcmp(*pp, "-n") == 0)
- {
- pp++;
- if (*pp == NULL)
- usage(argv[0]);
- volume_label = *pp;
- }
- else if (strcmp(*pp, "-i") == 0)
- {
- pp++;
- if (*pp == NULL)
- usage(argv[0]);
- volume_serial = strtol(*pp, NULL, 16);
- }
- else if (strcmp(*pp, "-p") == 0)
- {
- pp++;
- if (*pp == NULL)
- usage(argv[0]);
- first_sector = strtoll(*pp, NULL, 10);
- }
- else if (strcmp(*pp, "-v") == 0)
- {
- puts("Copyright (C) 2011-2013 Andrew Nayenko");
+ break;
+ case 'V':
+ puts("Copyright (C) 2011-2014 Andrew Nayenko");
return 0;
- }
- else if (spec == NULL)
- spec = *pp;
- else
+ default:
usage(argv[0]);
+ break;
+ }
}
- if (spec == NULL)
+ if (argc - optind != 1)
usage(argv[0]);
+ spec = argv[optind];
dev = exfat_open(spec, EXFAT_MODE_RW);
if (dev == NULL)