#include #include #include "syscalls.c" #include "../fs/fs.h" void hello() { puts( "Welcome to FoolShell v0.1" ); } void prompt() { printf( "$ " ); } int main(int argc, char **argv) { syscalls_init(); hello(); FILE *input; input=fopen(1,"r"); char *buf=malloc(256); while(1) { prompt(); fgets(buf,255,input); buf[strlen(buf)-1]=0; // remove \n process(buf); } return 0; } char **tokenize(char *buf) { char **token; token=malloc(10*sizeof(char*)); int l=strlen(buf); int i; int c=0; for(i=0;i\n",c, token[c]); c++; } return token; } int process(char *buf) { char **token=tokenize(buf); char *command=token[0]; // puts(command); // copied from trottelshell if(!strcmp(command,"help")) { puts("foolshell: supported built-in commands: 'help', 'echo [string]', 'ls [inode_nr]', exec [inode_nr],'malloc [bytes]', 'free [address]'"); } 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