From 1a8563a05608b5b5e27eada44cf4790926001c68 Mon Sep 17 00:00:00 2001
From: Marvin Borner
Date: Wed, 6 May 2020 18:16:47 +0200
Subject: Removed vfs - ext2 ftw!

I should really start thinking before I implement features. Now I did
and I have quite a good plan for the future of Melvix (hint: not
unix/posix-compliant!).
---
 src/kernel/syscall/actions/sys_read.c  | 21 +++------------------
 src/kernel/syscall/actions/sys_write.c | 22 +++-------------------
 src/kernel/syscall/syscall.h           |  4 ++--
 3 files changed, 8 insertions(+), 39 deletions(-)

(limited to 'src/kernel/syscall')

diff --git a/src/kernel/syscall/actions/sys_read.c b/src/kernel/syscall/actions/sys_read.c
index 8931ede..492e5fd 100644
--- a/src/kernel/syscall/actions/sys_read.c
+++ b/src/kernel/syscall/actions/sys_read.c
@@ -1,22 +1,7 @@
 #include <stdint.h>
-#include <kernel/fs/vfs.h>
-#include <kernel/fs/ext2.h>
-#include <kernel/lib/stdlib.h>
-#include <kernel/memory/alloc.h>
+#include <kernel/fs/fs.h>
 
-uint32_t sys_read(char *path, uint32_t offset, uint32_t count, char *buf)
+uint32_t sys_read(char *path, uint32_t offset, uint32_t count, uint8_t *buf)
 {
-	struct fs_node *node = (struct fs_node *)umalloc(sizeof(struct fs_node));
-	strcpy(node->name, path);
-	fs_open(node);
-	if (node->inode != 0) {
-		uint32_t size = ((struct ext2_file *)node->impl)->inode.size;
-		fs_read(node, 0, size, buf);
-		buf[size - 1] = '\0';
-		fs_close(node);
-		return size;
-	} else {
-		fs_close(node);
-		return -1;
-	}
+	return read(path, offset, count, buf);
 }
\ No newline at end of file
diff --git a/src/kernel/syscall/actions/sys_write.c b/src/kernel/syscall/actions/sys_write.c
index 28a5929..b9b30f3 100644
--- a/src/kernel/syscall/actions/sys_write.c
+++ b/src/kernel/syscall/actions/sys_write.c
@@ -1,23 +1,7 @@
 #include <stdint.h>
-#include <kernel/fs/vfs.h>
-#include <kernel/fs/ext2.h>
-#include <kernel/lib/stdlib.h>
-#include <kernel/memory/alloc.h>
-#include <kernel/system.h>
+#include <kernel/fs/fs.h>
 
-uint32_t sys_write(char *path, uint32_t offset, uint32_t count, char *buf)
+uint32_t sys_write(char *path, uint32_t offset, uint32_t count, uint8_t *buf)
 {
-	struct fs_node *node = (struct fs_node *)umalloc(sizeof(struct fs_node));
-	strcpy(node->name, path);
-	fs_open(node);
-	if (node->inode != 0) {
-		uint32_t size = ((struct ext2_file *)node->impl)->inode.size;
-		fs_write(node, 0, size, buf);
-		buf[size - 1] = '\0';
-		fs_close(node);
-		return size;
-	} else {
-		fs_close(node);
-		return -1;
-	}
+	return write(path, offset, count, buf);
 }
\ No newline at end of file
diff --git a/src/kernel/syscall/syscall.h b/src/kernel/syscall/syscall.h
index 322e551..9af18e8 100644
--- a/src/kernel/syscall/syscall.h
+++ b/src/kernel/syscall/syscall.h
@@ -12,9 +12,9 @@ uint32_t sys_exit(uint32_t code);
 
 uint32_t sys_fork(struct regs *r);
 
-uint32_t sys_read(char *path, uint32_t offset, uint32_t count, char *buf);
+uint32_t sys_read(char *path, uint32_t offset, uint32_t count, uint8_t *buf);
 
-uint32_t sys_write(char *path, uint32_t offset, uint32_t count, char *buf);
+uint32_t sys_write(char *path, uint32_t offset, uint32_t count, uint8_t *buf);
 
 uint32_t sys_exec(char *path);
 
-- 
cgit v1.2.3