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 --- fs/ext2.c | 7 +++++++ fs/fs.h | 2 ++ kernel/config.h | 2 +- userspace/Makefile | 2 +- userspace/ls.c | 28 ++++++++++++++++++++++++++++ userspace/shell.c | 34 ++++++++++------------------------ 6 files changed, 49 insertions(+), 26 deletions(-) create mode 100644 userspace/ls.c diff --git a/fs/ext2.c b/fs/ext2.c index 7322da2..6920b40 100644 --- a/fs/ext2.c +++ b/fs/ext2.c @@ -238,6 +238,13 @@ int ext2_inode_content(char *ram,int inode_nr,uint8_t *ramdest,int max) } log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"Fool Check Sum: 0x%08X for %d bytes",sum,count); +} + +//TODO!!! +int ext2_filename_to_inode(char *path) +{ + + } int ext2_read_dir(uint8_t *ram, int inode_nr,fs_dirent *dirs,int max) diff --git a/fs/fs.h b/fs/fs.h index 07127be..77b53ad 100644 --- a/fs/fs.h +++ b/fs/fs.h @@ -1,6 +1,8 @@ #ifndef FOOLOS_FS #define FOOLOS_FS +#include + #define EXT2_RAM_ADDRESS 0x168800 enum FS_FILE_TYPE{ diff --git a/kernel/config.h b/kernel/config.h index ef0fa71..e48c63c 100644 --- a/kernel/config.h +++ b/kernel/config.h @@ -6,7 +6,7 @@ //#define FOOLOS_COMPILE_FLOPPY // compile floppy drivers #define FOOLOS_CONSOLE_AUTOBREAK // add newline automatically at end of line -//#define FOOLOS_LOG_OFF // do not log anything +#define FOOLOS_LOG_OFF // do not log anything #define FOOLOS_CONSOLE // otherwise VESA will be used! #define MEM_PRINT_MEMORYMAP #define LOG_BUF_SIZE 4069 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