}
+/****** WRITE *****/
+static struct cmd write_cmds[];
+
+static char help_write[] = "Write content of various structures";
+static struct args args_write[] = {
+ { "STRUCT", subcommand, -1, {write_cmds}, "Structure type to write"},
+ TERMINAL_ARG
+};
+static void c_write(struct state *st, void **args)
+{
+ struct cmd *c = args[1];
+ if (!c) {
+ printf("write: Please give a structure to write\n");
+ return;
+ }
+
+ c->cmd(st, args);
+}
+
/****** WRITE_DEV ******/
static char help_write_dev[] = "Write devices blocks to one or all devices";
static struct args args_write_dev[] = {
{
struct lafs_device *dev;
int found = 0;
- if (!args[1] && !args[2]) {
+ if (!args[2] && !args[3]) {
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) {
+ if (args[3] || strcmp(dev->name, (char*)args[2]) == 0) {
int err = lafs_write_dev(dev);
found = 1;
if (err)
}
if (found)
return;
- if (args[2])
+ if (args[3])
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]);
+ (char*)args[2]);
}
/****** WRITE_STATE ******/
(unsigned long long) st->lafs->seq);
}
+#define WCMD(x) {#x, c_write_##x, args_write_##x, help_write_##x}
+static struct cmd write_cmds[] = {
+ WCMD(checkpoint),
+ WCMD(dev),
+ WCMD(state),
+ { NULL, NULL, NULL, NULL}
+};
+
/****** LOAD_DEV ******/
static char help_load_dev[] = "Allow access to LaFS filesystem stored on given device";
static struct args args_load_dev[] = {
CMD(reset),
CMD(show),
CMD(store),
- CMD(write_checkpoint),
- CMD(write_dev),
- CMD(write_state),
+ CMD(write),
{ NULL, NULL, NULL, NULL}
};