diff --git a/src/kernel/main.c b/src/kernel/main.c index d3bd8a9..fd20d8d 100644 --- a/src/kernel/main.c +++ b/src/kernel/main.c @@ -20,7 +20,10 @@ char *fileName = combineStrings("initrd/", name); void *elfData = findTarFile(initrd, initrdSize, fileName); free(fileName); - return loadElf(elfData, name); + if (elfData) { + return loadElf(elfData, name); + } + return NULL; } Service *loadProgram(char *name, Syscall *respondingTo, bool initialize) { diff --git a/src/kernel/main.c b/src/kernel/main.c index d3bd8a9..fd20d8d 100644 --- a/src/kernel/main.c +++ b/src/kernel/main.c @@ -20,7 +20,10 @@ char *fileName = combineStrings("initrd/", name); void *elfData = findTarFile(initrd, initrdSize, fileName); free(fileName); - return loadElf(elfData, name); + if (elfData) { + return loadElf(elfData, name); + } + return NULL; } Service *loadProgram(char *name, Syscall *respondingTo, bool initialize) { diff --git a/src/kernel/multiboot/initrdSyscall.c b/src/kernel/multiboot/initrdSyscall.c index 7b5ee70..7fc4bb1 100644 --- a/src/kernel/multiboot/initrdSyscall.c +++ b/src/kernel/multiboot/initrdSyscall.c @@ -8,6 +8,8 @@ char *name = retrieveString(call->parameters[0]); Service *service = call->service; Service *result = loadProgram(name, (void *)call, call->parameters[1]); - call->returnValue = result->id; + if (result) { + call->returnValue = result->id; + } call->avoidReschedule = call->parameters[1]; } diff --git a/src/kernel/main.c b/src/kernel/main.c index d3bd8a9..fd20d8d 100644 --- a/src/kernel/main.c +++ b/src/kernel/main.c @@ -20,7 +20,10 @@ char *fileName = combineStrings("initrd/", name); void *elfData = findTarFile(initrd, initrdSize, fileName); free(fileName); - return loadElf(elfData, name); + if (elfData) { + return loadElf(elfData, name); + } + return NULL; } Service *loadProgram(char *name, Syscall *respondingTo, bool initialize) { diff --git a/src/kernel/multiboot/initrdSyscall.c b/src/kernel/multiboot/initrdSyscall.c index 7b5ee70..7fc4bb1 100644 --- a/src/kernel/multiboot/initrdSyscall.c +++ b/src/kernel/multiboot/initrdSyscall.c @@ -8,6 +8,8 @@ char *name = retrieveString(call->parameters[0]); Service *service = call->service; Service *result = loadProgram(name, (void *)call, call->parameters[1]); - call->returnValue = result->id; + if (result) { + call->returnValue = result->id; + } call->avoidReschedule = call->parameters[1]; } diff --git a/src/userland/shell/main.c b/src/userland/shell/main.c index 8f642ed..c45b150 100644 --- a/src/userland/shell/main.c +++ b/src/userland/shell/main.c @@ -10,6 +10,11 @@ while (1) { printf("> "); gets(buffer); - loadFromInitrd(buffer); + uint32_t service = loadFromInitrdUninitialized(buffer); + if (service) { + request(service, 0, 0, 0); + } else { + printf("%s: command not found\n", buffer); + } } }