From 95450710a8b8290a110686d78c2357d3920bcda5 Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Wed, 22 Oct 2014 14:06:04 +0200 Subject: working on filesys and readdir syscall --- userspace/foolshell.c | 15 ++++++++++++++- userspace/syscalls.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) (limited to 'userspace') 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 #include #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")) { @@ -140,6 +141,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 #include +#include +#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"); -- cgit v1.2.3