diff options
author | dzwdz | 2022-07-18 14:01:21 +0200 |
---|---|---|
committer | dzwdz | 2022-07-18 14:01:21 +0200 |
commit | d43c1af88b1834a00f8b5f09aa0af1a5e4f5b4aa (patch) | |
tree | 7743cd9eb761dee12711cf719ab846228a888dbd /src/user/app | |
parent | 620bd6af8e005057e04c8a2891c7537ec3556345 (diff) |
user: a super primitive ELF loader
holy shit.
this was simpler than i expected it to be
Diffstat (limited to 'src/user/app')
-rw-r--r-- | src/user/app/shell.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/user/app/shell.c b/src/user/app/shell.c index 952b9b7..9085aed 100644 --- a/src/user/app/shell.c +++ b/src/user/app/shell.c @@ -1,8 +1,9 @@ +#include <shared/syscalls.h> +#include <stdbool.h> #include <user/app/shell.h> +#include <user/lib/elfload.h> #include <user/lib/stdlib.h> #include <user/tests/main.h> -#include <shared/syscalls.h> -#include <stdbool.h> static bool isspace(char c) { return c == ' ' || c == '\t' || c == '\n'; @@ -157,6 +158,15 @@ void shell_loop(void) { if (!strcmp(cmd, "echo")) { printf("%s\n", args); + } else if (!strcmp(cmd, "exec")) { + libc_file *file = file_open(args, 0); + if (!file) { + printf("couldn't open file\n"); + } else { + elf_execf(file); + file_close(file); + printf("elf_execf failed\n"); + } } else if (!strcmp(cmd, "cat")) { cmd_cat_ls(args, false); } else if (!strcmp(cmd, "ls")) { |