From 61eff36a01a2639efeb515ec32f578ba99d97ff4 Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Sun, 23 Nov 2014 19:53:48 +0100 Subject: moved ls to own binary --- userspace/Makefile | 2 +- userspace/ls.c | 28 ++++++++++++++++++++++++++++ userspace/shell.c | 34 ++++++++++------------------------ 3 files changed, 39 insertions(+), 25 deletions(-) create mode 100644 userspace/ls.c (limited to 'userspace') diff --git a/userspace/Makefile b/userspace/Makefile index 74ced40..d66afd2 100644 --- a/userspace/Makefile +++ b/userspace/Makefile @@ -1,7 +1,7 @@ CC=i686-foolos-gcc CFLAGS=-w -PROGS=shell simple brainfuck add checker +PROGS=shell simple brainfuck add checker ls ext2.img: $(PROGS) dd if=/dev/zero of=ext2.img bs=512 count=5000 diff --git a/userspace/ls.c b/userspace/ls.c new file mode 100644 index 0000000..50c733b --- /dev/null +++ b/userspace/ls.c @@ -0,0 +1,28 @@ +#include "../fs/fs.h" + +void usage() +{ + puts("ls [inode_nr]"); +} + +int main(int argc, char **argv) +{ + fs_dirent *dirs=malloc(sizeof(fs_dirent)*25); + + if(argc!=2) + { + usage(); + return 0; + } + + int ls=readdir(atoi(argv[1]),dirs,25); + + + int i; + for(i=0;i #include -#include "../fs/fs.h" -void hello() { +void hello() +{ puts( "Welcome to FoolShell v0.1" ); } -void prompt() { +void prompt() +{ printf( "$ " ); @@ -87,20 +88,7 @@ int process(char *buf) if(!strcmp(command,"help")) { - puts("foolshell: supported built-in commands: 'help', 'echo [string]', 'ls [inode_nr]', exec [inode_nr],'malloc [bytes]', 'free [address]', 'getenv [var]', 'putenv [var] [val]'"); - } - else if(!strcmp(command,"ls")) - { - fs_dirent *dirs=malloc(sizeof(fs_dirent)*25); - - int ls=readdir(atoi(token[1]),dirs,25); - - int i; - for(i=0;i