}
+/****** WRITE_DEV ******/
+static char help_write_dev[] = "Write devices blocks to one or all devices";
+static struct args args_write_dev[] = {
+ { "DEVNAME", external, -1, {NULL}, "Device to write devblocks to"},
+ { "-all", flag, 0, {NULL}, "Write to all devices"},
+ TERMINAL_ARG
+};
+static void c_write_dev(struct state *st, void **args)
+{
+ struct lafs_device *dev;
+ int found = 0;
+ if (!args[1] && !args[2]) {
+ printf("write dev: no device given for writing\n");
+ return;
+ }
+
+ for (dev = st->lafs->devs; dev; dev = dev->next) {
+ if (args[2] || strcmp(dev->name, (char*)args[1]) == 0) {
+ int err = lafs_write_dev(dev);
+ found = 1;
+ if (err)
+ printf("write dev: error when writing to %s\n",
+ dev->name);
+ else if (st->verbose)
+ printf("Device block written to %s\n", dev->name);
+ }
+ }
+ if (found)
+ return;
+ if (args[2])
+ printf("write dev: no devices exist to write to.\n");
+ else
+ printf("write dev: %s is not a registered device in this LaFS.\n",
+ (char*)args[1]);
+}
+
/****** STORE ******/
static char help_store[] = "Create a file in the LaFS from an external file";
static struct args args_store[] = {
CMD(quit),
CMD(reset),
CMD(store),
+ CMD(write_dev),
{ NULL, NULL, NULL, NULL}
};