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 /c/libc.s | |
| 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 'c/libc.s')
| -rw-r--r-- | c/libc.s | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -221,3 +221,28 @@ _bpeek2: rst #0x30 ret + + .globl _mkdir, _chdir + ;; unsigned char mkdir(const char *path /*DE*/) -> A (0 ok / $FF) +_mkdir: + ld c, #25 ; SYS_MKDIR + rst #0x30 + ret + ;; unsigned char chdir(const char *path /*DE*/) -> A (0 ok / $FF) +_chdir: + ld c, #26 ; SYS_CHDIR + rst #0x30 + ret + + .globl _opendir + ;; unsigned char opendir(const char *path /*DE*/) -> A (0 ok / $FF) +_opendir: + ld c, #27 ; SYS_OPENDIR + rst #0x30 + ret + + .globl _poweroff + ;; void poweroff(void) - execute the emulator's clean-exit opcode ($ED) +_poweroff: + .db 0xED +1$: jr 1$ |
