[sys] Special-case stdio for now, need to make these actual files later.
This commit is contained in:
parent
ba82c63a34
commit
a99fbf39a2
@ -177,6 +177,12 @@ start_shell() {
|
||||
set_kbd(0,0,0);
|
||||
} else if (!strcmp(cmd, "multiboot")) {
|
||||
dump_multiboot(mboot_ptr);
|
||||
} else if (!strcmp(cmd, "exec")) {
|
||||
if (tokenid < 2) {
|
||||
continue;
|
||||
}
|
||||
int ret = system(argv[1], tokenid - 1, &argv[1]);
|
||||
kprintf("Returned %d\n", ret);
|
||||
} else if (!strcmp(cmd, "test-alloc")) {
|
||||
kprintf("Testing the kernel allocator...\n");
|
||||
uint32_t sizers[] = { 1, 4, 4, 32, 64, 256, 1024, 795, 2042, 6204, 2525 };
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <system.h>
|
||||
#include <syscall.h>
|
||||
|
||||
#define SPECIAL_CASE_STDIO
|
||||
|
||||
/*
|
||||
* System calls themselves
|
||||
@ -38,6 +39,12 @@ static int exit(int retval) {
|
||||
}
|
||||
|
||||
static int read(int fd, char * ptr, int len) {
|
||||
#ifdef SPECIAL_CASE_STDIO
|
||||
if (fd == 0) {
|
||||
kgets(ptr, len);
|
||||
return strlen(ptr);
|
||||
}
|
||||
#endif
|
||||
if (fd >= current_task->next_fd || fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
@ -49,6 +56,14 @@ static int read(int fd, char * ptr, int len) {
|
||||
}
|
||||
|
||||
static int write(int fd, char * ptr, int len) {
|
||||
#ifdef SPECIAL_CASE_STDIO
|
||||
if (fd == 1 || fd == 2) {
|
||||
for (int i = 0; i < len; ++i) {
|
||||
ansi_put(ptr[i]);
|
||||
}
|
||||
return len;
|
||||
}
|
||||
#endif
|
||||
if (fd >= current_task->next_fd || fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user