From: Chris Mason Date: Tue, 1 Apr 2008 15:08:13 +0000 (-0400) Subject: Use getopt_long and introduce long mkfs options. -s now means --sectorsize X-Git-Tag: upstream/0.20.rc1~298 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6a87b4c00a08e377ee6265dee6c2548d2d0f67b0;p=platform%2Fupstream%2Fbtrfs-progs.git Use getopt_long and introduce long mkfs options. -s now means --sectorsize --- diff --git a/mkfs.c b/mkfs.c index 8d7530f..aa05536 100644 --- a/mkfs.c +++ b/mkfs.c @@ -17,12 +17,14 @@ */ #define _XOPEN_SOURCE 500 +#define _GNU_SOURCE #include #include #include #include #include #include +#include #include #include #include @@ -139,10 +141,23 @@ err: static void print_usage(void) { - fprintf(stderr, "usage: mkfs.btrfs [ -l leafsize ] [ -n nodesize] dev [ blocks ]\n"); + fprintf(stderr, "usage: mkfs.btrfs [options] dev [ dev ... ]\n"); + fprintf(stderr, "options:\n"); + fprintf(stderr, "\t -b --byte-count total number of bytes in the FS\n"); + fprintf(stderr, "\t -l --leafsize size of btree leaves\n"); + fprintf(stderr, "\t -n --nodesize size of btree leaves\n"); + fprintf(stderr, "\t -s --sectorsize min block allocation\n"); exit(1); } +static struct option long_options[] = { + { "byte-count", 1, NULL, 'b' }, + { "leafsize", 1, NULL, 'l' }, + { "nodesize", 1, NULL, 'n' }, + { "sectorsize", 1, NULL, 's' }, + { 0, 0, 0, 0} +}; + int main(int ac, char **av) { char *file; @@ -158,12 +173,14 @@ int main(int ac, char **av) u32 stripesize = 4096; u64 blocks[6]; int zero_end = 1; + int option_index = 0; struct btrfs_root *root; struct btrfs_trans_handle *trans; while(1) { int c; - c = getopt(ac, av, "b:l:n:s:"); + c = getopt_long(ac, av, "b:l:n:s:", long_options, + &option_index); if (c < 0) break; switch(c) { @@ -174,7 +191,7 @@ int main(int ac, char **av) nodesize = parse_size(optarg); break; case 's': - stripesize = parse_size(optarg); + sectorsize = parse_size(optarg); break; case 'b': block_count = parse_size(optarg); @@ -184,6 +201,7 @@ int main(int ac, char **av) print_usage(); } } + sectorsize = max(sectorsize, (u32)getpagesize()); if (leafsize < sectorsize || (leafsize & (sectorsize - 1))) { fprintf(stderr, "Illegal leafsize %u\n", leafsize); exit(1);