From d43c1af88b1834a00f8b5f09aa0af1a5e4f5b4aa Mon Sep 17 00:00:00 2001 From: dzwdz Date: Mon, 18 Jul 2022 14:01:21 +0200 Subject: user: a super primitive ELF loader holy shit. this was simpler than i expected it to be --- src/user/app/shell.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/user/app') 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 +#include #include +#include #include #include -#include -#include 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")) { -- cgit v1.2.3