diff options
author | dzwdz | 2022-08-07 23:50:15 +0200 |
---|---|---|
committer | dzwdz | 2022-08-07 23:50:15 +0200 |
commit | b0addbe14d2353e9c33f7f4d8a0b4ba8b24b2bd9 (patch) | |
tree | 0831f7c86e41ca2933e6dc5ec02c2d8b7078cd73 /src/user/app/shell/builtins.c | |
parent | bd6af34828a9075edbda7f09011175d0bd11143f (diff) |
user/shell: make `whitelist` work in a more sensible way
doesn't need to be a shell builtin now
Diffstat (limited to 'src/user/app/shell/builtins.c')
-rw-r--r-- | src/user/app/shell/builtins.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/user/app/shell/builtins.c b/src/user/app/shell/builtins.c index 53534ed..2562c18 100644 --- a/src/user/app/shell/builtins.c +++ b/src/user/app/shell/builtins.c @@ -4,6 +4,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <user/lib/fs/misc.h> #define DEFAULT_ARGV(...) \ char *_argv_default[] = {argv[0], __VA_ARGS__}; \ @@ -155,6 +156,21 @@ static void cmd_touch(int argc, char **argv) { } } +static void cmd_whitelist(int argc, char **argv) { + int split = 1; + for (;;) { + if (split >= argc) { + eprintf("no command"); + return; + } + if (!strcmp("--", argv[split])) break; + split++; + } + argv[split] = NULL; + MOUNT_AT("/") { fs_whitelist((void*)&argv[1]); } + run_args(argc - split - 1, &argv[split + 1], NULL); +} + struct builtin builtins[] = { {"cat", cmd_cat}, {"echo", cmd_echo}, @@ -163,5 +179,6 @@ struct builtin builtins[] = { {"ls", cmd_ls}, {"sleep", cmd_sleep}, {"touch", cmd_touch}, + {"whitelist", cmd_whitelist}, {NULL, NULL}, }; |