- else if (!strcmp (argv[i], "-f"))
- format_filesys = true;
- else if (!strcmp (argv[i], "-cp"))
- fsutil_copy_arg = argv[++i];
- else if (!strcmp (argv[i], "-p"))
- fsutil_print_file = argv[++i];
- else if (!strcmp (argv[i], "-r"))
- fsutil_remove_file = argv[++i];
- else if (!strcmp (argv[i], "-ls"))
- fsutil_list_files = true;
- else if (!strcmp (argv[i], "-D"))
- fsutil_dump_filesys = true;
-#endif
- else if (!strcmp (argv[i], "-u"))
- {
- printk (
- "Kernel options:\n"
- " -rs SEED Seed random seed to SEED.\n"
- " -d CLASS[,...] Enable the given classes of debug messages.\n"
+ {"ls", 1, fsutil_ls},
+ {"cat", 2, fsutil_cat},
+ {"rm", 2, fsutil_rm},
+ {"put", 2, fsutil_put},
+ {"get", 2, fsutil_get},
+#endif
+ {NULL, 0, NULL},
+ };
+
+ while (*argv != NULL)
+ {
+ const struct action *a;
+ int i;
+
+ /* Find action name. */
+ for (a = actions; ; a++)
+ if (a->name == NULL)
+ PANIC ("unknown action `%s' (use -h for help)", *argv);
+ else if (!strcmp (*argv, a->name))
+ break;
+
+ /* Check for required arguments. */
+ for (i = 1; i < a->argc; i++)
+ if (argv[i] == NULL)
+ PANIC ("action `%s' requires %d argument(s)", *argv, a->argc - 1);
+
+ /* Invoke action and advance. */
+ a->function (argv);
+ argv += a->argc;
+ }
+
+}
+
+/* Prints a kernel command line help message and powers off the
+ machine. */
+static void
+usage (void)
+{
+ printf ("\nCommand line syntax: [OPTION...] [ACTION...]\n"
+ "Options must precede actions.\n"
+ "Actions are executed in the order specified.\n"
+ "\nAvailable actions:\n"