diff options
Diffstat (limited to 'src/sysbin')
-rw-r--r-- | src/sysbin/init/main.c | 6 | ||||
-rw-r--r-- | src/sysbin/shell/main.c | 42 | ||||
-rw-r--r-- | src/sysbin/terminal/main.c | 14 |
3 files changed, 49 insertions, 13 deletions
diff --git a/src/sysbin/init/main.c b/src/sysbin/init/main.c index d7f3f36..6ac003b 100644 --- a/src/sysbin/init/main.c +++ b/src/sysbin/init/main.c @@ -80,10 +80,10 @@ void setup_sys() { char* sep = strchr(buf, ':'); if (sep == 0) { - ok = fs_subfs("sys", "root", buf, FM_READ | FM_MMAP); + ok = fs_subfs("sys", "root", buf, FM_READ | FM_MMAP | FM_READDIR); } else { *sep = 0; - ok = fs_subfs("sys", buf, sep +1, FM_READ | FM_MMAP); + ok = fs_subfs("sys", buf, sep +1, FM_READ | FM_MMAP | FM_READDIR); } if (!ok) PANIC("[init] Could not bind root:/sys to sys:/"); @@ -166,7 +166,7 @@ int main(int argc, char **argv) { char buf[50]; snprintf(buf, 50, "/config/%s", config); - bool ok = fs_subfs("config", "root", buf, FM_READ | FM_WRITE | FM_MMAP); + bool ok = fs_subfs("config", "root", buf, FM_READ | FM_WRITE | FM_MMAP | FM_READDIR); if (!ok) PANIC("[init] Could not setup config:"); } diff --git a/src/sysbin/shell/main.c b/src/sysbin/shell/main.c index 54cec06..1929025 100644 --- a/src/sysbin/shell/main.c +++ b/src/sysbin/shell/main.c @@ -4,22 +4,58 @@ #include <debug.h> #include <stdio.h> +#include <unistd.h> #include <syscall.h> +void ls(char* dir) { + fd_t f = open(dir, FM_READDIR); + if (f) { + dirent_t i; + int ent_no = 0; + while (readdir(f, ent_no++, &i)) { + printf("%s\n", i.name); + } + close(f); + } else { + printf("Could not open directory '%s'\n", dir); + } +} + int main(int argc, char **argv) { dbg_printf("[shell] Starting\n"); /*fctl(stdio, FC_SET_BLOCKING, 0);*/ - puts("Hello, world!\n"); + puts("Kogata shell.\n"); + + chdir("sys:"); while(true) { - puts("> "); char buf[256]; + printf("\n%s> ", getcwd(buf, 256)); + getline(buf, 256); - printf("You said: '%s'. I don't understand a word of that.\n\n", buf); + if (!strncmp(buf, "cd ", 3)) { + chdir(buf + 3); + } else if (!strcmp(buf, "ls")) { + if (getcwd(buf, 256)) { + ls(buf); + } + } else if (!strncmp(buf, "ls ", 3)) { + char buf2[256]; + if (getcwd(buf2, 256)) { + if (pathncat(buf2, buf + 3, 256)) { + ls(buf2); + } + } + } else if (!strcmp(buf, "exit")) { + break; + } else { + printf("No such command.\n"); + } } + printf("Bye.\n"); return 0; } diff --git a/src/sysbin/terminal/main.c b/src/sysbin/terminal/main.c index 133736b..1174305 100644 --- a/src/sysbin/terminal/main.c +++ b/src/sysbin/terminal/main.c @@ -231,13 +231,7 @@ void c_buffer_info(gip_handler_t *s, gip_msg_header *p, gip_buffer_info_msg *m) void c_key_down(gip_handler_t *s, gip_msg_header *p) { term_t *c = (term_t*)s->data; - keyboard_press(c->kb, p->arg); -} - -void c_key_up(gip_handler_t *s, gip_msg_header *p) { - term_t *c = (term_t*)s->data; - - key_t k = keyboard_release(c->kb, p->arg); + key_t k = keyboard_press(c->kb, p->arg); c->wr_c_buf = 0; if (k.flags & KBD_CHAR) { @@ -250,6 +244,12 @@ void c_key_up(gip_handler_t *s, gip_msg_header *p) { mainloop_nonblocking_write(&c->app, &c->wr_c_buf, 1, false); } +void c_key_up(gip_handler_t *s, gip_msg_header *p) { + term_t *c = (term_t*)s->data; + + keyboard_release(c->kb, p->arg); +} + void c_unknown_msg(gip_handler_t *s, gip_msg_header *p) { // TODO } |