From ce00d1677d7a419b427e7f11963eee982a55a231 Mon Sep 17 00:00:00 2001
From: dzwdz
Date: Thu, 4 Aug 2022 23:06:57 +0200
Subject: do some simple TODOs, organize the rest; general code maintainance

---
 src/user/app/find/find.c         |  5 +++--
 src/user/app/init/driver/tmpfs.c | 10 +++++-----
 src/user/app/shell/builtins.c    |  2 +-
 3 files changed, 9 insertions(+), 8 deletions(-)

(limited to 'src/user/app')

diff --git a/src/user/app/find/find.c b/src/user/app/find/find.c
index 502a190..6c5d31a 100644
--- a/src/user/app/find/find.c
+++ b/src/user/app/find/find.c
@@ -1,3 +1,4 @@
+#include <camellia/path.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -48,8 +49,8 @@ void recurse(char *path) {
 }
 
 void find(const char *path) {
-	// TODO export PATH_MAX
-	char *buf = malloc(4096);
+	// TODO bound checking
+	char *buf = malloc(PATH_MAX);
 	memcpy(buf, path, strlen(path)+1);
 	recurse(buf);
 	free(buf);
diff --git a/src/user/app/init/driver/tmpfs.c b/src/user/app/init/driver/tmpfs.c
index 5db78f1..96fdf39 100644
--- a/src/user/app/init/driver/tmpfs.c
+++ b/src/user/app/init/driver/tmpfs.c
@@ -53,11 +53,11 @@ static struct node *tmpfs_open(const char *path, struct fs_wait_response *res) {
 }
 
 void tmpfs_drv(void) {
-	// TODO replace all the static allocations in drivers with mallocs
-	static char buf[512];
+	const size_t buflen = 4096;
+	char *buf = malloc(buflen);
 	struct fs_wait_response res;
 	struct node *ptr;
-	while (!_syscall_fs_wait(buf, sizeof buf, &res)) {
+	while (!_syscall_fs_wait(buf, buflen, &res)) {
 		switch (res.op) {
 			case VFSOP_OPEN:
 				ptr = tmpfs_open(buf, &res);
@@ -68,7 +68,7 @@ void tmpfs_drv(void) {
 				ptr = (void*)res.id;
 				if (ptr == &special_root) {
 					struct dirbuild db;
-					dir_start(&db, res.offset, buf, sizeof buf);
+					dir_start(&db, res.offset, buf, buflen);
 					for (struct node *iter = root; iter; iter = iter->next)
 						dir_append(&db, iter->name);
 					_syscall_fs_respond(buf, dir_finish(&db), 0);
@@ -97,7 +97,7 @@ void tmpfs_drv(void) {
 
 				fs_normslice(&res.offset, &res.len, ptr->size, true);
 				if (res.offset + res.len >= ptr->capacity) {
-					// TODO
+					// TODO expanding files
 					_syscall_fs_respond(NULL, -1, 0);
 					break;
 				}
diff --git a/src/user/app/shell/builtins.c b/src/user/app/shell/builtins.c
index d4de354..d409bfd 100644
--- a/src/user/app/shell/builtins.c
+++ b/src/user/app/shell/builtins.c
@@ -89,7 +89,7 @@ static void cmd_ls(int argc, char **argv) {
 	const size_t buflen = 4096;
 	char *buf = malloc(buflen);
 
-	DEFAULT_ARGV("!stdin");
+	DEFAULT_ARGV("/");
 	for (int i = 1; i < argc; i++) {
 		char *path = (void*)argv[i];
 		int pathlen = strlen(path);
-- 
cgit v1.2.3