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

@@ -10,12 +10,14 @@
#include "syscalls.h"
int main(void) {
/* Get the current working directory */
/* Check for an explicit path argument first */
char cwd[128];
if (getenv("CWD", cwd, sizeof(cwd)) < 0) {
/* Default to root if CWD not set */
cwd[0] = '/';
cwd[1] = '\0';
if (getenv("ARG1", cwd, sizeof(cwd)) < 0 || cwd[0] == '\0') {
/* No argument; use the current working directory */
if (getenv("CWD", cwd, sizeof(cwd)) < 0) {
cwd[0] = '/';
cwd[1] = '\0';
}
}
char name[128];