summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fs/ext2.c7
-rw-r--r--fs/fs.h2
-rw-r--r--kernel/config.h2
-rw-r--r--userspace/Makefile2
-rw-r--r--userspace/ls.c28
-rw-r--r--userspace/shell.c34
6 files changed, 49 insertions, 26 deletions
diff --git a/fs/ext2.c b/fs/ext2.c
index 7322da2..6920b40 100644
--- a/fs/ext2.c
+++ b/fs/ext2.c
@@ -240,6 +240,13 @@ int ext2_inode_content(char *ram,int inode_nr,uint8_t *ramdest,int max)
}
+//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 <stdint.h>
+
#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<ls;i++)
+ {
+ printf("%i %s%c\n",dirs[i].inode, dirs[i].name, ((dirs[i].type==FS_FILE_TYPE_DIR)?'/':' '));
+ }
+
+ return 0;
+}
diff --git a/userspace/shell.c b/userspace/shell.c
index 06a03d2..83f1e6f 100644
--- a/userspace/shell.c
+++ b/userspace/shell.c
@@ -2,15 +2,16 @@
#include <stdint.h>
#include <string.h>
-#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<ls;i++)
- {
- printf("foolshell: %i %s%c\n",dirs[i].inode, dirs[i].name, ((dirs[i].type==FS_FILE_TYPE_DIR)?'/':' '));
- }
-
+ puts("foolshell: supported built-in commands: 'help', 'echo [string]', exec [inode_nr],'malloc [bytes]', 'free [address]', 'getenv [var]', 'putenv [var] [val]'");
}
else if(!strcmp(command,"exec"))
{
@@ -109,37 +97,35 @@ int process(char *buf)
}
else if(!strcmp(command,"echo"))
{
- printf("foolshell: \"%s\"\n",token[1]);
+ printf("\"%s\"\n",token[1]);
}
else if(!strcmp(command,"malloc"))
{
uint8_t *mall=malloc(atoi(token[1]));
- printf("foolshell: allocated %d bytes at 0x%08X (%i).\n",atoi(token[1]),mall,mall);
+ printf("allocated %d bytes at 0x%08X (%i).\n",atoi(token[1]),mall,mall);
}
else if(!strcmp(command,"free"))
{
free(atoi(token[1]));
- printf("foolshell: called free(0x%08X).\n",atoi(token[1]));
+ printf("called free(0x%08X).\n",atoi(token[1]));
}
else if(!strcmp(command,"getenv"))
{
- printf("foolshell: %s = %s \n",token[1],getenv(token[1]));
+ printf("%s = %s \n",token[1],getenv(token[1]));
}
else if(!strcmp(command,"putenv"))
{
char buf[256];
sprintf(buf,"%s=%s",token[1],token[2]);
putenv(buf);
- printf("foolshell: %s = %s \n",token[1],getenv(token[1]));
+ printf("set: %s = %s \n",token[1],getenv(token[1]));
}
else
{
puts("foolshell: command not found");
}
-
- //
}