]> git.neil.brown.name Git - lafs-utils.git/commitdiff
lafs: add write_state command
authorNeilBrown <neilb@suse.de>
Mon, 14 Mar 2011 01:22:17 +0000 (12:22 +1100)
committerNeilBrown <neilb@suse.de>
Mon, 14 Mar 2011 01:22:17 +0000 (12:22 +1100)
Signed-off-by: NeilBrown <neilb@suse.de>
lib/lafs_write_state.c
tools/lafs.c

index d564fca44050c042f5219c77fa18edb030b48ac3..1d091bb1d5730382c00efb7ebdc037b63d18f4c4 100644 (file)
@@ -39,5 +39,5 @@ int lafs_write_state(struct lafs *fs)
                        write(dev->fd, buf, fs->statesize);
                }
        }
-       return 1;
+       return 0;
 }
index 28e0a6eec476197daa6ffddc04c812d5c7c60cd7..4cb06f204d2012be53fe073752460a07b012211b 100644 (file)
@@ -995,6 +995,25 @@ static void c_write_dev(struct state *st, void **args)
                       (char*)args[1]);
 }
 
+/****** WRITE_STATE ******/
+static char help_write_state[] = "Write state blocks to all devices";
+static struct args args_write_state[] = {
+       TERMINAL_ARG
+};
+static void c_write_state(struct state *st, void **args)
+{
+       if (st->lafs->blocksize == 0)
+               printf("write state: filesystem is not initialised\n");
+       else if (st->lafs->devs == NULL)
+               printf("write state: No devices exist to write to\n");
+       else if (lafs_write_state(st->lafs))
+               printf("write state: Error writing a state block\n");
+       else if (st->verbose)
+               printf("%s state blocks written: seq now %llu\n",
+                      (st->lafs->seq & 1) ? "Odd" : "Even",
+                      (unsigned long long) st->lafs->seq);
+}
+
 /****** STORE ******/
 static char help_store[] = "Create a file in the LaFS from an external file";
 static struct args args_store[] = {
@@ -1027,6 +1046,7 @@ static struct cmd lafs_cmds[] = {
        CMD(reset),
        CMD(store),
        CMD(write_dev),
+       CMD(write_state),
        { NULL, NULL, NULL, NULL}
 };