From 5fefd233769a56caefdb2ffecaa9fb8b9ec6db86 Mon Sep 17 00:00:00 2001 From: user Date: Thu, 16 Jul 2026 12:49:19 +0200 Subject: fs rewrite stage 3: nested directories, paths, cwd (cd/mkdir/ls) - directories generalized: dir_find/dir_add/dir_remove take any dir inode; every dir carries '.'/'..'. Path resolution (resolve / resolve_parent) walks absolute or cwd-relative paths; open/mkdir/chdir/remove/opendir take paths. - per-process cwd: PROC_CWD in the PCB (root by default, inherited on fork); sys_chdir sets it, sys_opendir points ls at any directory. - shell: 'cd' builtin + cwd-aware prompt; 'mkdir'/'ls ' tools; 'exit'/'quit' and EOF call poweroff() (clean shutdown via the $ED opcode -> reliable save). - three HL/buffer-clobber bugs fixed along the way: resolve didn't preserve the path cursor across dir_find; cur_cwd clobbered HL; resolve_parent set the final name before resolve() overwrote wFsNameBuf (now copied after). - verified: nested mkdir/cd/save, multi-level paths (cat docs/sub/b), and the whole tree persists across a reboot. - README: document directories + the poweroff opcode. --- src/kdata.asm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/kdata.asm') diff --git a/src/kdata.asm b/src/kdata.asm index b239caa..6c520dd 100644 --- a/src/kdata.asm +++ b/src/kdata.asm @@ -48,7 +48,13 @@ wFsOFPtr:: DS 2 wFsCurBlk:: DS 1 ; data block currently in fs_datbuf ($FF = none) wFsDirty:: DS 1 ; fs_datbuf needs write-back wFsInode:: DS 1 ; working inode number -wFsNameBuf:: DS 16 ; kernel-side copy of a name argument +wFsNameBuf:: DS 16 ; kernel-side copy of a name/component +wFsDir:: DS 1 ; directory inode for dir_* ops +wFsDirBlk:: DS 1 ; that directory's data block (for write-back) +wFsCur:: DS 1 ; current inode during path resolution +wFsPath:: DS 40 ; kernel-side copy of a path argument +wFsSlashPtr::DS 2 ; last '/' seen while splitting a path +wListDir:: DS 1 ; directory sys_list enumerates wKChar:: DS 1 ; scratch for KPutc wKillParent::DS 1 ; scratch for sys_kill wPsBuf:: DS 2 ; scratch for sys_ps -- cgit v1.3.1-sl0p