summaryrefslogtreecommitdiff
path: root/userspace
diff options
context:
space:
mode:
Diffstat (limited to 'userspace')
-rw-r--r--userspace/Makefile2
-rw-r--r--userspace/foolshell.c8
-rw-r--r--userspace/ls.c46
3 files changed, 35 insertions, 21 deletions
diff --git a/userspace/Makefile b/userspace/Makefile
index 3327375..3de83ea 100644
--- a/userspace/Makefile
+++ b/userspace/Makefile
@@ -16,7 +16,7 @@ ext2.img: $(PROGS)
echo "hello one" > mnt/home/miguel/test1.txt
mkdir -p mnt/bin
cp $^ mnt/bin
- cp ~/temp/fool-os-stuff/binutils-build-host-foolos/binutils/readelf mnt/bin
+# cp ~/temp/fool-os-stuff/binutils-build-host-foolos/binutils/readelf mnt/bin
mkdir -p mnt/etc
echo "127.0.0.1 localhost" > mnt/etc/hosts
sync
diff --git a/userspace/foolshell.c b/userspace/foolshell.c
index 2a70940..29e8438 100644
--- a/userspace/foolshell.c
+++ b/userspace/foolshell.c
@@ -25,7 +25,7 @@ void hello()
void prompt()
{
- printf("%s",getenv("PS1"));
+ printf("%s%s",getenv("PWD"),getenv("PS1"));
}
int main(int argc, char **argv)
@@ -105,7 +105,11 @@ int process(char *buf)
if(!strcmp(command,"help"))
{
- puts("foolshell: supported built-in commands: 'help', 'echo [string]', 'malloc [bytes]', 'free [address]', 'getenv [var]', 'putenv [var] [val]', 'env'");
+ puts("foolshell: supported built-in commands: 'help', 'echo [string]', 'malloc [bytes]', 'free [address]', 'getenv [var]', 'putenv [var] [val]', 'env' 'cd [dir]'");
+ }
+ else if(!strcmp(command,"cd"))
+ {
+
}
else if(!strcmp(command,"echo"))
{
diff --git a/userspace/ls.c b/userspace/ls.c
index 5b5034b..4cbcb6d 100644
--- a/userspace/ls.c
+++ b/userspace/ls.c
@@ -7,28 +7,38 @@ void usage()
int main(int argc, char **argv)
{
- fs_dirent *dirs=malloc(sizeof(fs_dirent)*25);
+ char *dir;
+ fs_dirent *dirs=malloc(sizeof(fs_dirent)*25);
- if(argc!=2)
+ if(argc!=2)
+ {
+ dir=getenv("PWD");
+ }
+ else
+ {
+ if(argv[1][0]=="/")dir=argv[1];
+ else
{
- usage();
- return 0;
- }
-
- char *dir=argv[1];
- int ls=readdir(dir,dirs,25);
- if(ls==-1)
- {
- printf("%s: file or directory '%s' not found.\n",argv[0],dir);
- return 0;
- }
-
+ char buf[256];
+ sprintf(buf,"%s/%s",getenv("PWD"),argv[1]);
+ dir=buf;
- 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)?'/':' '));
}
+ }
+ int ls=readdir(dir,dirs,25);
+ if(ls==-1)
+ {
+ printf("%s: file or directory '%s' not found.\n",argv[0],dir);
return 0;
+ }
+
+
+ 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;
}