diff options
Diffstat (limited to 'userspace')
| -rw-r--r-- | userspace/foolshell.c | 15 | ||||
| -rw-r--r-- | userspace/syscalls.c | 28 |
2 files changed, 42 insertions, 1 deletions
diff --git a/userspace/foolshell.c b/userspace/foolshell.c index 173b0b2..15f26e3 100644 --- a/userspace/foolshell.c +++ b/userspace/foolshell.c @@ -1,6 +1,7 @@ #include <stdio.h> #include <string.h> #include "syscalls.c" +#include "../fs/fs.h" void hello() { puts( @@ -85,7 +86,7 @@ int process(char *buf) if(!strcmp(command,"HELP")) { - puts("foolshell: supported built-in commands: HELP, ECHO, TIME, MEM, PROC, TASKS, ALLOC, READ, SYSCALL."); + puts("foolshell: supported built-in commands: HELP, ECHO, TIME, MEM, PROC, TASKS, ALLOC, LS, SYSCALL."); } else if(!strcmp(command,"TIME")) { @@ -141,6 +142,18 @@ int process(char *buf) printf("system call returned %i\n",ebx); } + else if(!strcmp(command,"LS")) + { + + fs_dirent dirs[5]; + int ls=readdir("/dupa",&dirs,5); + int i; + for(i=0;i<ls;i++) + { + printf("%i %s%c\n",dirs[i].inode, dirs[i].name, ((dirs[i].type==2)?'/':' ')); + } + + } else if(!strcmp(command,"ECHO")) { diff --git a/userspace/syscalls.c b/userspace/syscalls.c index f4e77a1..f92541c 100644 --- a/userspace/syscalls.c +++ b/userspace/syscalls.c @@ -3,6 +3,8 @@ #include <sys/stat.h> #include <string.h> +#include <stdint.h> +#include "../fs/fs.h" static int preread; static int alloc; @@ -68,6 +70,32 @@ int read(int file, char *ptr, int len) return ebx; } +int readdir(const char *name,fs_dirent *dirs,int max) +{ + + int ebx; // WILL Hold return value; + + asm("pusha"); + + // select syscall + asm("mov $63,%eax"); + + // pass params + asm("mov %0,%%edx"::"m"(name)); + asm("mov %0,%%ecx"::"m"(dirs)); + asm("mov %0,%%ebx"::"m"(max)); + + // interrrupt + asm("int $0x80"); + + // get return value + asm("mov %%ebx, %0": "=b" (ebx)); + + asm("popa"); + + return ebx; +} + int open(const char *name, int flags, int mode) { // easywrite("syscall: open\n"); |
