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 /usr/gbos.h | |
| 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 'usr/gbos.h')
| -rw-r--r-- | usr/gbos.h | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -20,6 +20,9 @@ unsigned char pollin(void); /* poll OSK for a typed char, or 0 */ unsigned char pollcon(void); /* poll console ring (link-injected input, filled by net pumps), or 0 */ unsigned char sys_net(void *req); /* socket layer trap (see sock.h) */ +unsigned char sys_stat(void *req); /* stat trap (see stat.h) */ +unsigned char sys_fsstat(void *buf); /* free blocks/inodes (see stat.h) */ +unsigned char isatty(void); /* 1 if stdin is the console */ void gsleep(unsigned char units); /* delay units*(1/64)s (raw trap) */ void gticks(unsigned char buf[4]); /* 64 Hz uptime ticks, 32-bit LE */ void msleep(unsigned int ms); /* delay ~ms milliseconds */ @@ -42,8 +45,9 @@ unsigned char mkdir(const char *path); unsigned char chdir(const char *path); unsigned char opendir(const char *path); void poweroff(void); /* clean emulator shutdown (saves) */ -#define O_READ 0 -#define O_WRITE 1 +#define O_READ 0 +#define O_WRITE 1 +#define O_APPEND 2 /* write at the end, keeping the existing contents */ #define NOFD 0xFF #define EISDIR 0xFE /* open() failed: path is a directory */ |
