diff options
author | dzwdz | 2021-11-04 07:35:23 +0000 |
---|---|---|
committer | dzwdz | 2021-11-04 07:35:23 +0000 |
commit | d9b7a1a5d222a618b7530ecfa42b1ccb4f9a5f4c (patch) | |
tree | 99732f38912a7db5bf8fabc610a03a9ca366a4be /src/init | |
parent | 0c24ed6eb939bd68c9a882d21fd45e2079e1bb66 (diff) | |
parent | e0ddaaa6290f74fcce6e067c1e5f1c9c87974f4c (diff) |
Merge branch 'main' into fork2
Diffstat (limited to 'src/init')
-rw-r--r-- | src/init/shell.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/init/shell.c b/src/init/shell.c index 53ad995..7cb8a8c 100644 --- a/src/init/shell.c +++ b/src/init/shell.c @@ -44,10 +44,13 @@ static int readline(char *buf, size_t max) { } static void cmd_cat(const char *args) { - int fd = _syscall_open(args, strlen(args)); + int fd; static char buf[256]; int len = 256; + if (!args) return; // no argument + + fd = _syscall_open(args, strlen(args)); if (fd < 0) { printf("couldn't open.\n"); return; @@ -71,6 +74,18 @@ void shell_loop(void) { printf("%s\n", args); } else if (!strcmp(cmd, "cat")) { cmd_cat(args); + } else if (!strcmp(cmd, "catall")) { + const char *files[] = { + "/init/fake.txt", + "/init/1.txt", "/init/2.txt", + "/init/dir/3.txt", NULL}; + for (int i = 0; files[i]; i++) { + printf("%s:\n", files[i]); + cmd_cat(files[i]); + printf("\n"); + } + } else if (!strcmp(cmd, "shadow")) { + _syscall_mount(-1, args, strlen(args)); } else if (!strcmp(cmd, "exit")) { _syscall_exit(0); } else if (!strcmp(cmd, "fork")) { |