Skip to content

BooleOS 0.17.0 - Phase 17: Cleanup A (audit fixes, libnos/shell tools, test/build infrastructure)

Choose a tag to compare

@TheShannonDev TheShannonDev released this 25 Sep 22:30
· 68 commits to main since this release

BooleOS 0.17.0 - Phase 17: Cleanup A (audit fixes, libnos/shell tools, test/build infrastructure)

All you need to run it is QEMU; the exact command is in the README.txt inside the ISO package.

  • booleos-0.17.0-iso-img(originally-nullos).zip: the bootable ISO built from this tag (the image itself still says NullOS, because the project was renamed after this version), the blank disk image when this version has one, and a README.txt with the QEMU command and what this ISO does
  • booleos-0.17.0-docs-original.zip: the docs of this version, exactly as they were

Changes

Added

  • ROADMAP.md: granular phase table — one row per phase and
    sub-phase for completed Phases 0–16 (names taken from the README's
    completed-phases table, links to CHANGELOG versions and docs/
    files) and for planned Phases 17–31 including their sub-phases.
  • docs/TODO.md: header-only file for minimal "WIP: document X"
    stubs left during nightly development, resolved at each version's
    final polish (per the new CLAUDE.md documentation rule).
  • user/lib/nullos.c/h, user/shell.c, forktest.c, selftest.c,
    edit.c: libnos gained memcpy/memset/memmove/memcmp/strlen/
    strcmp/strncmp (standard libc names and signatures, so a call GCC
    emits by itself resolves) and nos_uitoa; the four per-program copies
    of strlen/uitoa, shell's strcmp/strncmp, selftest's st_bufeq
    and the inline zero/shift/copy loops in selftest and edit now call them.
  • user/selftest.c: new test "SYS_WRITE >128 bytes accumulates in a FAT16
    file" — writes 2100 bytes as two nos_write() calls (crossing the first
    2048-byte cluster) and reads them all back; the regression test for the
    chunked-write data loss. Suite is now 14 tests (st_big.txt is left on
    disk like the other test files).
  • pwd / SYS_GETCWD (30): fat16_get_path() rebuilds a cwd path from the
    cwd's cluster by walking up through .. (names in 8.3 uppercase).
    nos_getcwd(), shell pwd.
  • cat <file>: user/cat.c opens the file named by its argument and prints
    it; with no argument it still copies stdin (pipe sink). The shell's cat <file> launches it and waits. sys_exec_pipe() clears the global
    exec_arg so a piped/redirected cat never reads the argument left by an
    earlier plain exec().
  • cmd < file and cmd > file in the shell (run_redirected()): file fds
    through the existing SYS_EXEC_PIPE; > creates + truncates. External
    programs only, launched by name without arguments, not combinable with |.
  • kernel/power.c/h: power_reboot() (8042 reset, port 0x64 <- 0xFE) and
    power_shutdown() (PIIX4 PM base from PCI config 0x40, outw(base+4, 0x2000); prints "shutdown not supported on this hardware" when the PIIX4
    isn't in the PCI table). pci_find_device(). Syscalls SYS_REBOOT (31) and
    SYS_SHUTDOWN (32), nos_reboot()/nos_shutdown(), shell reboot/
    shutdown.
  • user/selftest.c: four new tests (18 total): a two-process pipeline
    (a fork()ed writer and cat launched with SYS_EXEC_PIPE, parent
    compares the output), waitpid with three children (each pid collected
    with the result that child reported, and gone afterwards), mkdir/cd
    three levels deep (pwd at every level, a file at the bottom, cd .. back
    to /), and a check for the Intel 440FX host bridge (8086:1237) next to
    the generic PCI count. The 440FX test is expected to fail once Phase 24
    moves QEMU to -machine q35 (see docs/TODO.md).
  • SYS_PCI_FIND (33) / nos_pci_find(vendor, device): 1 if a device with
    that ID is in the PCI table, 0 if not (pci_find_device() for userland).
  • tools/Makefile: make inject FILE=... [NAME=...] copies a file into the
    root of build/disk.img with mcopy, without rebuilding the ISO.
    Host-side only — the kernel still can't exec() from FAT16 (Phase 19).
  • tools/Makefile: make run-reboot-test runs QEMU without -no-reboot, so
    reboot really restarts the guest. run and debug keep -no-reboot on
    purpose (post-mortem state on a triple fault; it also turns a guest reset
    into a shutdown).

Changed

  • kernel/version.h: NULLOS_VERSION "0.17.0", NULLOS_PHASE "17",
    NULLOS_PHASE_DESC "Cleanup A".
  • user/shell.c: run has a single implementation, cmd_run(), shared by
    the foreground path and run_command(); it trims and validates the name.
  • ROADMAP.md: replaced the Phases 17–22 plan with the restructured
    Phases 17–31 sequence (Cleanup A, HAL + Safe Mode, SDK, COW fork,
    unlink/rmdir, process_exit() memory release, e1000, AHCI,
    xHCI, framebuffer/GUI, syscall deprecation, audit pass 2, polish,
    DOOM prerequisites, DOOM port / v1.0.0). Old Phases 17–22 renumbered
    to 20, 23, 24, 25, 26, 27, with a granular one-row-per-phase/sub-phase
    table (historical lettered phases as parent + child rows). No
    package-manager phase, by decision.
  • README.md: "Completed phases" table shows only whole phases (the old
    rows 2/2b and 3a/3b merged into one row each); the "planned phases" range
    is 17–31.
  • CLAUDE.md: new sections/rules for the nightly/main branch strategy,
    -nightly version suffix, sub-phases, HAL, centralized msg() text
    output, key=value system config file, and Safe Mode; serial-mirroring,
    exec()/fork() threading and docs-verification rules extended; Safe Mode
    rules name process_spawn_user.
  • PROGRESS.md: consolidated from 411 to ~150 lines (closed phases one
    line each, decisions tightened with links to docs/).
  • docs/: memory.md, filesystem.md, scheduler.md, pci.md,
    kernel.md, shell.md, pipes.md, testing.md, syscalls.md updated
    for everything above; docs/scheduler.md no longer describes the removed
    process_spawn().

Fixed

  • kernel/memory/pmm.c: pmm_init() computed the page count as
    (1024 + mem_upper) * 1024 / PAGE_SIZE, which overflows uint32_t
    for a huge mem_upper and wraps to a tiny total_pages, underflowing
    total_pages - 256. Now 256 + mem_upper / 4 (same value, no
    overflow), and freeing high memory is skipped with a warning when
    total_pages <= 256.

  • kernel/fs/fat16.c: fat16_init() now rejects a BPB with
    sectors_per_cluster == 0 (printing the reason) before it is used as
    a divisor, instead of dividing by zero.

  • kernel/process.c: next_pid++ (three places) now goes through
    alloc_pid(), which saves/restores EFLAGS around the increment
    instead of a bare cli/sti, since process_fork() calls it from
    inside its own cli section.

  • kernel/drivers/pci.c/pci.h: only the BARs a header type really
    has are read and printed (type 0: 6, type 1 PCI-PCI bridge: 2,
    type 2 CardBus: 1), with the multi-function bit (0x80) masked off
    first; the rest of bar[] stays 0.

  • kernel/memory/vmm.c/vmm.h: vmm_map_page() and
    vmm_map_user_page() now return int (0 = success, VMM_ERR_RANGE
    / VMM_ERR_NOMEM on failure) instead of failing silently as void;
    map_page_early() reports an exhausted page-table pool.
    vmm_map_user_page() also rejects virt < 0x800000 (the kernel's
    shared identity map) and frees a page-table page it can't use.
    Every call site checks the result: heap_expand() frees the page and
    returns 0; exec()'s user-stack loop prints an error and returns 0;
    elf_load() returns -1; process_fork() unwinds via its existing
    failed path. The three vmm_map_user_page sites also free the
    just-allocated physical page instead of leaking it.

  • kernel/keyboard.c, user/edit.c: Shift in the editor.
    The raw scancode path (SYS_READ_RAW) now carries a Shift bit
    (bit 9, next to Ctrl's bit 8), because the kernel consumes the Shift
    make/break scancodes itself and edit.c could never see them; the
    editor selects a new sc_map_shift[] table from it, so Shift+5 gives
    %, Shift+\ gives | and Shift+letter gives the capital.

  • kernel/fs/fat16.c: fat16_write_file() again refuses
    a directory entry (ATTR_DIRECTORY) — the Phase 15 switch to the
    shared dir_lookup() had dropped the old loop's directory skip — and
    no longer re-reads the dirent sector dir_lookup() just left in
    dir_buf. (The "duplicated dirent lookup" tech-debt item was already
    resolved by Phase 15; only these two leftovers remained.)

  • kernel/process.c, kernel/scheduler.c/h, kernel/process.h
    : process_spawn_user() now reserves its slot atomically
    (interrupts off via saved EFLAGS, slot marked PROCESS_BLOCKED, pid
    and waiting_for_pid reset in the same section), fills in every
    field, and only then publishes PROCESS_READY (or leaves it
    PROCESS_BLOCKED for start_blocked). This closes two races: two
    spawns picking the same free slot, and the scheduler running a slot
    whose esp/cr3 weren't built yet. New irq_save()/irq_restore()
    helpers, also used by alloc_pid().

  • kernel/fs/fat16.c, fat16.h, vfs.c, vfs.h, kernel/syscall.c:
    SYS_WRITE on a FAT16 fd lost data. sys_write() staged writes in
    128-byte chunks and each vfs_write() replaced the WHOLE file, so only
    the last chunk survived a write over 128 bytes. New fat16_write_at()
    (positional write: grows the chain, updates the dirent, data -> FAT ->
    dirent order) backs a stream vfs_write() that writes at fd->pos and
    advances it; the whole-file replace SYS_WRITE_FILE needs moved to
    vfs_write_all(), so the editor's save is unchanged.

  • user/shell.c: a bare edit or cat (no argument) printed command not found. nos_read() returns the line with its trailing newline, and the
    branches only match "name followed by a space or end of string". The
    shell now strips the trailing \n/\r right after reading the line.

  • Line editing echo (pre-existing): erasing a typed character did not
    erase it on the serial console. vga_putchar('\b') blanks the cell on
    screen, but its serial mirror sent a raw \b, which only moves a
    terminal's cursor left — retyping shutdown as reboot showed
    rebootdows. kernel/drivers/vga.c now mirrors an erasing backspace as
    \b \b (nothing if VGA erased nothing). Also sys_read() no longer
    echoes a backspace on an empty line, which used to blank the shell's own
    > prompt. The typed buffer itself was always right (a backspace just
    decrements the count).

Removed

  • tools/run_qemu.sh: it booted the ISO without attaching disk.img and had
    no users besides one hint in tools/setup_env.sh (now points at make run); its mentions in docs/setup.md and docs/filesystem.md are gone.
  • process_spawn(), scheduler_spawn() and the now-unused
    scheduler_task_bootstrap(): dead code (no callers anywhere, no
    future roadmap phase depends on them).

Full history: CHANGELOG.md