From b14c31b595fd6f499ad4252ac7e2ecb7dfa2b591 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Tue, 15 Mar 2011 20:28:30 +1100 Subject: [PATCH] lafs: make 'statesize' a choice. It must be a power of 2, so it can easily be a 'choice'. Signed-off-by: NeilBrown --- tools/lafs.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/tools/lafs.c b/tools/lafs.c index efa6e88..d9923f0 100644 --- a/tools/lafs.c +++ b/tools/lafs.c @@ -750,12 +750,15 @@ static void c_reset(struct state *st, void **args) /****** NEWFS ******/ static char help_newfs[] = "Create a new LaFS filesystem, which can then be stored on one or more devices."; static char *block_sizes[] = { "512", "1024", "2048", "4096", NULL }; +static char *state_sizes[] = { "512", "1024", "2048", "4096", "8192", + "16384", "32768", NULL }; static struct args args_newfs[] = { { "BLOCK-SIZE", choice, -1, {.options=block_sizes}, "Block size, 512..4096, defaults to 1024"}, { "-block-size", choice, 0, {.options=block_sizes}, "Block size, 512..4096, defaults to 1024"}, - { "-state-size", opaque, -1, {NULL}, "Size of state block, defaults to 1024"}, + { "-state-size", choice, -1, {.options=state_sizes}, + "Size of state block, 512..32768, defaults to 1024"}, { "-uuid", opaque, -1, {NULL}, "UUID - normally randomly generated"}, { "-black", opaque, -1, {NULL}, "nothing (just testing)"}, TERMINAL_ARG @@ -764,7 +767,6 @@ static void c_newfs(struct state *st, void **args) { int blockbytes = 1024; int state_size = 0; - char *err = NULL; char uuidstr[37]; uuid_t uu; struct lafs_ino *ifile, *imfile, *rootdir; @@ -782,14 +784,7 @@ static void c_newfs(struct state *st, void **args) if (args[3]) { /* state-size was given */ - if (get_int(args[3], &state_size) < 0) - err = "state-size must be a number"; - else if (state_size <= 0 || state_size % 1024) - err = "state-size must be a positive multiple of 1024"; - if (err) { - printf("newfs: %s: %s\n", err, (char*)args[3]); - return; - } + get_int(args[3], &state_size); } if (args[4]) { /* uuid was given */ -- 2.39.5