From: Tulio A M Mendes Date: Sun, 8 Feb 2026 03:15:54 +0000 (-0300) Subject: docs: update POSIX/Unix status (errno, devfs, getppid, WNOHANG) X-Git-Url: https://projects.tadryanom.me/?a=commitdiff_plain;h=53a54ae7ef14d633882ec94e5e827ff512414e76;p=AdrOS.git docs: update POSIX/Unix status (errno, devfs, getppid, WNOHANG) Document recently implemented Unix/POSIX features: getppid, waitpid(WNOHANG), devfs (/dev/null,/dev/tty), kernel -errno convention, and uaccess hardening. --- diff --git a/BUILD_GUIDE.md b/BUILD_GUIDE.md index 7356448..eaf0a99 100644 --- a/BUILD_GUIDE.md +++ b/BUILD_GUIDE.md @@ -58,6 +58,10 @@ Generated outputs/artifacts: - `serial.log`: UART log (primary kernel output) - `qemu.log`: only generated when QEMU debug logging is enabled (see below) +Syscall return convention note: +- The kernel follows a Linux-style convention: syscalls return `0`/positive values on success, and `-errno` (negative) on failure. +- A libc-style `errno` variable (per-thread) is not implemented yet. + Static analysis helper: ```bash make ARCH=x86 cppcheck diff --git a/README.md b/README.md index 6e1e909..9512e6e 100644 --- a/README.md +++ b/README.md @@ -44,19 +44,24 @@ AdrOS is a multi-architecture operating system developed for research and academ - Mount table support (`vfs_mount`) + `tmpfs` and `overlayfs` - **File descriptors + syscalls (x86)** - `int 0x80` syscall gate - - `SYSCALL_WRITE`, `SYSCALL_EXIT`, `SYSCALL_GETPID`, `SYSCALL_OPEN`, `SYSCALL_READ`, `SYSCALL_CLOSE` + - `SYSCALL_WRITE`, `SYSCALL_EXIT`, `SYSCALL_GETPID`, `SYSCALL_GETPPID`, `SYSCALL_OPEN`, `SYSCALL_READ`, `SYSCALL_CLOSE` - `SYSCALL_LSEEK`, `SYSCALL_STAT`, `SYSCALL_FSTAT` - `SYSCALL_DUP`, `SYSCALL_DUP2`, `SYSCALL_PIPE` - `SYSCALL_FORK`, `SYSCALL_EXECVE` (with minimal argv/envp stack setup) - Per-process fd table (starting at fd=3) - Centralized user-pointer access API (`user_range_ok`, `copy_from_user`, `copy_to_user`) - Ring3 init program (`/bin/init.elf`) exercising IO + process + exec smoke tests + - Error returns use negative errno codes (Linux-style) - **TTY (canonical line discipline)** - Keyboard -> TTY input path - Canonical mode input (line-buffered until `\n`) - Echo + backspace handling - Blocking reads with a simple wait queue (multiple waiters) - `fd=0` wired to `tty_read`, `fd=1/2` wired to `tty_write` +- **Devices (devfs)** + - `/dev` mount + - `/dev/null` + - `/dev/tty` - **W^X (Option 1) for user ELFs (x86)** - User segments are mapped RW during load, then write permissions are dropped for non-writable segments - This provides "text is read-only" hardening without requiring NX/PAE @@ -77,11 +82,11 @@ QEMU debug helpers: - Implement VMM/interrupts/scheduler for ARM/RISC-V/MIPS - Standardize arch entrypoint behavior (`arch_early_setup`) across architectures - **Userspace / POSIX process model** - - `getppid`, `brk`/`sbrk` + - `brk`/`sbrk` - Signals (at least `SIGKILL`/`SIGSEGV` basics) - **Syscalls / ABI** - `ioctl` (TTY), `getcwd`, `chdir` - - Error reporting via `errno` conventions + - Userspace `errno` variable + libc-style wrappers (`-1` return + `errno` set) - **Virtual memory hardening** - Option 2: PAE + NX enforcement (execute disable for data/stack) - Guard pages, and tighter user/kernel separation checks @@ -89,7 +94,7 @@ QEMU debug helpers: - Real persisted storage (ATA/AHCI/virtio-blk or similar) - Persisted storage (ATA/AHCI/virtio-blk or similar) - Permissions/ownership (`uid/gid`, mode bits) and `umask` - - Special files: char devices, block devices, `/dev`, `/proc` + - Special files: block devices, `/proc` - Real on-disk fs (ext2/fat) - **TTY / PTY** - Termios-like mode flags (canonical/raw, echo, erase, intr) diff --git a/docs/POSIX_ROADMAP.md b/docs/POSIX_ROADMAP.md index f15df61..4600a1f 100644 --- a/docs/POSIX_ROADMAP.md +++ b/docs/POSIX_ROADMAP.md @@ -46,12 +46,14 @@ Notes: - [x] `read()` (files + stdin) - [x] `close()` - [x] `waitpid()` +- [x] `waitpid(..., WNOHANG)` - [x] `lseek()` - [x] `stat()` / `fstat()` - [x] `dup()` / `dup2()` - [x] `pipe()` - [x] `fork()` - [~] `execve()` (loads ELF from InitRD; minimal argv/envp) +- [x] `getppid()` ### FD layer - [x] Per-process fd table (fd allocation starts at 3) @@ -89,7 +91,7 @@ Goal: make process termination and waiting work reliably; unblock shells and ser - [x] Add syscall number + userland wrapper - [x] `waitpid(-1, ...)` wait for any child - [x] `waitpid(pid, ...)` wait for specific child -- [ ] Non-blocking mode (optional early): `WNOHANG` +- [x] Non-blocking mode (optional early): `WNOHANG` - [~] Return semantics consistent with POSIX (pid on success, -1 on error) ### Tests @@ -109,7 +111,8 @@ Goal: move from a shared address space to per-process virtual memory, required f - [~] User/kernel separation rules enforced (uaccess checks + no user mappings in kernel range) ### Syscall/uaccess hardening -- [ ] Ensure `user_range_ok` is robust across per-process mappings +- [~] Ensure `user_range_ok` is robust across per-process mappings +- [x] `copy_to_user` requires writable user mappings (x86) - [ ] Page-fault handling for invalid user pointers (deliver `SIGSEGV` later) ### Userspace loader @@ -136,7 +139,8 @@ Goal: unlock standard libc-style IO patterns. - [x] Map InitRD node metadata to `stat` ### Error model -- [ ] Start introducing `errno`-style error returns (strategy decision: negative errno vs -1 + errno) +- [x] Negative errno returns in kernel/syscalls (`-errno`) +- [ ] Userspace `errno` + libc-style wrappers (`-1` + `errno`) ### Tests - [x] Userspace test: open -> fstat -> read -> lseek -> read @@ -159,9 +163,9 @@ Goal: get a writable filesystem (even if volatile) and a real VFS layout. - [x] Directories ### Devices (minimum Unix feel) -- [ ] `/dev` mount -- [ ] `/dev/tty` -- [ ] `/dev/null` +- [x] `/dev` mount +- [x] `/dev/tty` +- [x] `/dev/null` ### Tests - [x] Userspace test: create file in tmpfs, write, read back @@ -173,7 +177,7 @@ Goal: get a writable filesystem (even if volatile) and a real VFS layout. ### Process / POSIX expansion - [x] `fork()` - [~] `execve()` -- [ ] `getppid()` +- [x] `getppid()` - [ ] Signals + basic job control ### Pipes + IO multiplexing