]> git.neil.brown.name Git - lafs-utils.git/commitdiff
lafs: make 'statesize' a choice.
authorNeilBrown <neilb@suse.de>
Tue, 15 Mar 2011 09:28:30 +0000 (20:28 +1100)
committerNeilBrown <neilb@suse.de>
Tue, 15 Mar 2011 09:28:30 +0000 (20:28 +1100)
It must be a power of 2, so it can easily be a 'choice'.

Signed-off-by: NeilBrown <neilb@suse.de>
tools/lafs.c

index efa6e8888fd1b617696effac23c641c517b9f913..d9923f0f4fa83ca353b4633a70c233bfed918f1b 100644 (file)
@@ -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 */