From d8eaa13f2efc1eeca4e5f230d5a2d535aaf27338 Mon Sep 17 00:00:00 2001 From: Richard Qin Date: Fri, 2 Jan 2026 00:47:16 +0800 Subject: dev(file-system): establish VFS and Read-only FAT32 File System --- src/user/init.cc | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'src/user/init.cc') diff --git a/src/user/init.cc b/src/user/init.cc index 1646f6b..27c1e2f 100644 --- a/src/user/init.cc +++ b/src/user/init.cc @@ -1,4 +1,5 @@ #include "user/user.h" +#include "common/fcntl.h" int strlen(const char *s) { @@ -149,7 +150,40 @@ void test_syscalls() int main() { - print("\n[Lume Shell] Ready.\n"); + print("\n[Lume Shell] Init process started.\n"); + print("[Test] Opening test.txt...\n"); + int fd = open("test.txt", O_RDONLY); + if (fd < 0) + { + print("[Test] Open failed (Is test.txt in fs.img?)\n"); + } + else + { + print("[Test] Open success! fd="); + print_int(fd); + print("\n"); + + char buf[64]; + int n = read(fd, buf, 63); + if (n > 0) + { + buf[n] = 0; + print("[Test] Read content:\n---\n"); + print(buf); + print("\n---\n"); + } + else + { + print("[Test] Read returned "); + print_int(n); + print("\n"); + } + close(fd); + print("[Test] File closed.\n"); + } + + + print("Commands:\n"); print(" s: Run System Call Tests (fork, wait, mm)\n"); print(" t: Run Disk Driver Test (VirtIO)\n"); -- cgit v1.2.3