]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commitdiff
docs: update POSIX/Unix status (errno, devfs, getppid, WNOHANG)
authorTulio A M Mendes <[email protected]>
Sun, 8 Feb 2026 03:15:54 +0000 (00:15 -0300)
committerTulio A M Mendes <[email protected]>
Sun, 8 Feb 2026 03:15:54 +0000 (00:15 -0300)
Document recently implemented Unix/POSIX features: getppid, waitpid(WNOHANG), devfs (/dev/null,/dev/tty), kernel -errno convention, and uaccess hardening.

BUILD_GUIDE.md
README.md
docs/POSIX_ROADMAP.md

index 7356448b6d3c18ae4f01569682cf7557c7ed1de0..eaf0a99925f0d9cc798e4b128965d6f840770efd 100644 (file)
@@ -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
index 6e1e9090ea8fd49da9dbc53adbed54c634a5197c..9512e6e41d19bdc8f320945fb37bd7f1b0ed2b8b 100644 (file)
--- 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)
index f15df61094a6ee9b39bdc48c8fd79c6d31559471..4600a1fa70485620092d3590399d1023c8fcf5b1 100644 (file)
@@ -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