diff --git a/sys/amd64/syscall.c b/sys/amd64/syscall.c index 0345218..f890b4a 100644 --- a/sys/amd64/syscall.c +++ b/sys/amd64/syscall.c @@ -42,11 +42,8 @@ static void sys_sigret(void); __attribute__((noreturn)) void amd64_syscall_yield_stopped(void); -uint64_t syscall_last_time = 0; -uint64_t syscall_count = 0; - intptr_t amd64_syscall(uintptr_t rdi, uintptr_t rsi, uintptr_t rdx, uintptr_t rcx, uintptr_t r10, uintptr_t rax) { - ++syscall_count; + asm volatile ("cli"); switch (rax) { case SYSCALL_NR_READ: return sys_read((int) rdi, (void *) rsi, (size_t) rdx); diff --git a/usr/init.c b/usr/init.c index 803c65d..b17d5b0 100644 --- a/usr/init.c +++ b/usr/init.c @@ -328,6 +328,32 @@ static int cmd_exec(const char *line) { } } + // Try to execute binary from / + struct stat st; + char path[64] = "/"; + strcat(path, cmd); + if (stat(path, &st) == 0) { + const char *argp[] = { + e, NULL + }; + + int pid = fork(); + + switch (pid) { + case -1: + perror("fork()"); + return -1; + case 0: + if (execve(path, argp, NULL) != 0) { + perror("execve()"); + } + exit(-1); + default: + // TODO: waitpid + return 0; + } + } + printf("%s: Unknown command\n", cmd); return -1; }