diff options
| author | user <user@clank> | 2026-09-24 12:48:37 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-09-24 12:48:37 +0200 |
| commit | dc9dffb9069e32a1a0cf14883176544b234fc3e5 (patch) | |
| tree | 4877daa5f01e98ac5d7e64d98c4144c94fa94a91 /src/syscall.asm | |
| parent | term: write the palette attribute for every re-rendered tile, not just the cu... (diff) | |
| download | gbos-dc9dffb9069e32a1a0cf14883176544b234fc3e5.tar.gz gbos-dc9dffb9069e32a1a0cf14883176544b234fc3e5.tar.xz gbos-dc9dffb9069e32a1a0cf14883176544b234fc3e5.zip | |
kernel: stat/fsstat/isatty syscalls, and O_APPEND
Four things userland had no way to ask for:
- SYS_STAT: type, link count, size and inode for a path. The trap needs HL
for its dispatch table, so a call taking both a path and an output buffer
passes a request block - the shape SYS_NET already established. usr/stat.h
wraps it, header-only like sock.h, because the block must live in the
caller's RAM.
- SYS_FSSTAT: blocks/inodes, total and free. The bitmaps are already cached
write-through in fs_bmbuf, so this is the popcount boot_fs already prints.
- SYS_ISATTY: is this process's stdin the console? The shell needs it to tell
an interactive session from a script.
- O_APPEND: open a file positioned at EOF. There is no seek syscall, so this
is the only way to add to a file - without it nothing running ON the Game
Boy can build a multi-line file, shell scripts included.
Together these back ls -l, df, and `>>`.
Diffstat (limited to 'src/syscall.asm')
| -rw-r--r-- | src/syscall.asm | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/syscall.asm b/src/syscall.asm index 0ed9f85..9e5ca33 100644 --- a/src/syscall.asm +++ b/src/syscall.asm @@ -71,6 +71,9 @@ SyscallTable: dw sys_sleep ; 34 SLEEP dw sys_pollcon ; 35 POLLCON dw sys_uptime ; 36 UPTIME + dw sys_stat ; 37 STAT + dw sys_fsstat ; 38 FSSTAT + dw sys_isatty ; 39 ISATTY ; ----------------------------------------------------------------------------- sys_nosys: @@ -332,6 +335,19 @@ sys_sleep: ret ; ----------------------------------------------------------------------------- +; sys_isatty() -> A = 1 if this process's stdin is the console, 0 if it is a +; file or a pipe. The shell uses it to tell an interactive session from a +; script (`sh < file`): no prompt, no echo, and EOF is just the end. +; ----------------------------------------------------------------------------- +sys_isatty: + call CurStdin + cp STD_CONSOLE + ld a, 0 + ret nz + inc a + ret + +; ----------------------------------------------------------------------------- ; sys_exit(code=B) -- become a zombie awaiting reap; never returns. ; - store exit code, set PS_ZOMBIE ; - reparent any children to init (so they can still be waited on) |
