diff options
| author | user <user@clank> | 2026-07-16 12:49:19 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-07-16 12:49:19 +0200 |
| commit | 5fefd233769a56caefdb2ffecaa9fb8b9ec6db86 (patch) | |
| tree | 99f5b285a45c7b3792bb64e79fe58f70a6d01cab /include | |
| parent | fs rewrite stage 2: inodes + root directory (block-based, persistent) (diff) | |
| download | gbos-5fefd233769a56caefdb2ffecaa9fb8b9ec6db86.tar.gz gbos-5fefd233769a56caefdb2ffecaa9fb8b9ec6db86.tar.xz gbos-5fefd233769a56caefdb2ffecaa9fb8b9ec6db86.zip | |
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 <dir>' 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.
Diffstat (limited to 'include')
| -rw-r--r-- | include/gbos.inc | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/include/gbos.inc b/include/gbos.inc index 770bd55..c4804c4 100644 --- a/include/gbos.inc +++ b/include/gbos.inc @@ -85,6 +85,7 @@ DEF PROC_EXIT RB 1 ; exit code (valid when PS_ZOMBIE) DEF PROC_STDIN RB 1 ; $FF = console, else an open-file fd DEF PROC_STDOUT RB 1 ; $FF = console, else an open-file fd DEF PROC_PROG RB 1 ; program id currently running ($FF = none), for ps +DEF PROC_CWD RB 1 ; current working directory (inode #) DEF PROC_SIZE RB 0 DEF KILL_CODE EQU 137 ; exit status of a killed process (128 + SIGKILL) @@ -118,8 +119,11 @@ DEF SYS_PS EQU 20 ; process table entry (B=slot, DE=buf3 -> A= DEF SYS_PROGNAME EQU 21 ; program id -> name (B=id, DE=namebuf) DEF SYS_REAP EQU 22 ; reap a zombie child, nohang (-> A=pid or 0) DEF SYS_BFILL EQU 23 ; [debug] fill a disk block (B=block, E=byte) -DEF SYS_BPEEK EQU 24 ; [debug] read a disk block[0] (B=block -> A) -DEF SYS_MAX EQU 25 +DEF SYS_BPEEK EQU 24 ; [debug] read a disk block (B=block, E=off -> A) +DEF SYS_MKDIR EQU 25 ; make a directory (DE=path -> A=0/$FF) +DEF SYS_CHDIR EQU 26 ; change directory (DE=path -> A=0/$FF) +DEF SYS_OPENDIR EQU 27 ; point ls at a directory (DE=path -> A=0/$FF) +DEF SYS_MAX EQU 28 ; SYS_KILL (9) is now implemented (B=pid -> A=0/$FF; pid 1 is immortal) ; (SYS_OPEN=4 / SYS_CLOSE=5 are now implemented by the filesystem) @@ -136,7 +140,7 @@ DEF BLK_SUPER EQU 0 DEF BLK_BITMAP EQU 1 DEF BLK_INODE0 EQU 2 ; inode table = blocks 2,3 DEF BLK_DATA0 EQU 4 ; first data block -DEF FS_VERSION EQU 2 +DEF FS_VERSION EQU 3 ; bumped: dirs now carry "."/".." entries DEF NINODES EQU 32 DEF ROOT_INO EQU 1 DEF NDIRECT EQU 8 ; direct block pointers per inode -> files <= 2 KiB @@ -196,5 +200,6 @@ DEF PROG_PS EQU 16 DEF PROG_KILL EQU 17 DEF PROG_SPIN EQU 18 DEF PROG_BLK EQU 19 +DEF PROG_MKDIR EQU 20 ENDC |
