Add sysfs VFS driver, SYS_OPEN/CLOSE syscalls, cat app

Sysfs:
- New VFS driver mounted at /sys that lets kernel drivers expose
  virtual text files via namespace registration
- Drivers call sysfs_register(name, ops, ctx) with list/read/write
  callbacks for their namespace
- IDE driver registers 'ide' namespace exposing per-device attributes:
  model, type, channel, drive, sectors, sector_size
- Tested: ls /sys -> ide, ls /sys/ide -> hdd1 cd1,
  cat /sys/ide/hdd1/model -> QEMU HARDDISK

Syscalls:
- Added SYS_OPEN (11) and SYS_CLOSE (12) for file I/O from userspace
- Extended SYS_READ/SYS_WRITE to handle VFS file descriptors (fd >= 3)
- Updated userspace syscalls.h with open()/close() wrappers

Apps:
- New 'cat' app: reads and displays file contents via open/read/close
- Updated 'ls' to accept path argument via ARG1 env var
- Updated shell to pass ARG1 env var to external commands
This commit is contained in:
AI
2026-02-23 14:26:52 +00:00
parent d064e67a8f
commit d1bf69ce0d
12 changed files with 729 additions and 10 deletions

View File

@@ -18,6 +18,7 @@
#include "vfs.h"
#include "initrd_fs.h"
#include "devicefs.h"
#include "sysfs.h"
#include "mbr.h"
#include "keyboard.h"
#include "framebuffer.h"
@@ -253,6 +254,10 @@ void kernel_main(uint32_t magic, uint32_t addr) {
EARLY_PRINT("DEV ");
offset_print("Devicefs initialized\n");
init_sysfs();
EARLY_PRINT("SYS ");
offset_print("Sysfs initialized\n");
init_tss();
EARLY_PRINT("TSS ");
offset_print("TSS initialized\n");