Commit Graph

81 Commits

Author SHA1 Message Date
Red Bear OS ebf0cad69d init: do not chdir into initfs prefix after switch_root
The restored switch_root chdir set init's CWD to /scheme/initfs on the
live image. login later restricts its namespace to DEFAULT_SCHEMES (no
'initfs' scheme) via mkns/setns; the inherited /scheme/initfs CWD fd then
becomes unresolvable. Because relibc resolves paths through the CWD fd
(AT_REDOX_CWD_FD), every subsequent file op in login hangs -- notably
Command::spawn() loading the login shell binary never returns, so the
shell never starts. Leaving the CWD inherited (as before the chdir was
added) keeps spawn working across the login namespace switch; getcwd() in
/usr binaries works without the chdir. Reverts the CWD half of 521c6ffe;
the init-diag cleanup from that commit is retained.
2026-07-18 10:43:05 +09:00
Red Bear OS 521c6ffe5b init: restore switch_root chdir + remove temporary spawn diagnostics
Commit 99e08650 temporarily removed the post-switch_root chdir (which
points init's working directory at a valid dir in the new root) to test a
spawn hang, and added init-diag SPAWNING/SPAWNED/WAITING eprintlns. The
chdir was never restored: init and every daemon/getty/login/shell it
spawns inherit an invalid CWD (AT_REDOX_CWD_FD), so getcwd() fails in
/usr binaries and interactive shells (zsh/brush) hang instead of reading
input. Restore the chdir and drop the diagnostic eprintlns (which also
spammed the login console).
2026-07-18 08:24:09 +09:00
Red Bear OS 1769b083ab fix(boot): clean up bare/mini boot warnings and errors
- init: add condition_path_exists so optional-daemon units (dbus, seatd,
  thermald, evdevd) are silently skipped when their binary is absent in a
  minimal image, instead of emitting [FAILED] 'No such file or directory' on
  the bare target. Boot-critical units omit the field and still hard-fail.
- ahcid: an empty ATAPI/optical drive (QEMU's default DVD-ROM, most bare-metal
  optical bays) failed READ CAPACITY and logged 4 ERROR lines every boot;
  register it with a zero block count as a normal no-media state and drop the
  HBA register dump to debug level.
- netstack: a machine with no NIC (bare, or an unsupported NIC) logged an ERROR
  and exited non-zero; treat 'no network adapter' as a normal idle state
  (info + clean exit).
- dhcpd: cut the socket timeout 30s -> 8s so the network stage fails fast when
  no DHCP server answers instead of stalling boot.
2026-07-18 00:29:43 +09:00
Red Bear OS 99e08650a4 DIAG: log service spawn/wait; temporarily revert switch_root chdir to test spawn hang 2026-07-16 10:41:15 +09:00
Red Bear OS 9dae3cda91 init: try prefix then / for post-switchroot CWD (/usr is not a chdir target) 2026-07-16 09:29:24 +09:00
Red Bear OS 9255eacc02 init: chdir into new root on switch_root so daemons inherit a valid CWD (fixes base-env zsh hang blocking login) 2026-07-16 09:14:24 +09:00
Red Bear OS 8818ababbb init: keep boot stdio on kernel console (observable boot) instead of redirecting to /scheme/log 2026-07-16 08:04:02 +09:00
Red Bear OS 32bb63f360 revert TEMP DIAG: re-enable switch_stdio to /scheme/log 2026-07-15 23:57:22 +09:00
Red Bear OS a5680cae92 TEMP DIAG: keep init stdio on kernel console (disable switch_stdio) for headless boot visibility 2026-07-15 23:44:08 +09:00
Red Bear OS 54e4c5751c ptyd: accept ptmx as master open; strip init/daemon boot debug spam 2026-07-15 21:38:39 +09:00
Red Bear OS db724cda70 init: use blocking waitpid to avoid busy-loop spam 2026-07-15 03:20:47 +09:00
Red Bear OS 3a7c96b19f merge: combine 0a358aa0 (diag + libc::pipe2 fix) with 104da7de (init FILETABLE fix) into canonical submodule/base
Both branches independently fixed the FILETABLE desync bug. This merge creates a single canonical history that preserves the diagnostic commits from 0a358aa0 and the eexist-focused fix from 104da7de.

After this merge, the per-fork submodule/<name> branch (this is the AGENTS.md-mandated canonical ref) is a child of both, so origin can fast-forward to it.

(NO AI attribution in commit message body, per project policy)
2026-07-14 12:19:46 +09:00
Red Bear OS 0a358aa05f diag(base): trace fd transfer in init, daemon, and logd
Add diagnostics to pin down where the INIT_NOTIFY fd handoff hangs:
- init/src/service.rs: log read_pipe fd and call_ro results
- daemon/src/lib.rs: log cap_fd, write_pipe, and call_wo result
- logd/src/main.rs: explicit ready_sync_scheme result and setrens fallback

These are temporary diagnostics for the boot-hang investigation.
2026-07-14 11:19:31 +09:00
Red Bear OS 1e341ff782 init: fix pipe FILETABLE desync — use libc::pipe2 instead of raw syscall
create_pipe() used raw syscall::openat/syscall::dup which allocate kernel
fds WITHOUT registering in relibc FILETABLE. Later FILETABLE-managed
syscalls (Command::spawn -> relibc pipe2) reserve the same fd numbers,
causing EEXIST in kernel insert_file.

Replace with libc::pipe2 which goes through relibc FILETABLE-aware path.
2026-07-13 20:22:31 +03:00
Red Bear OS 104da7de12 init: fix FILETABLE desync causing EEXIST on all daemon spawns
create_pipe() used raw syscall::openat() (SYS_OPENAT) and syscall::dup()
which bypass relibc's FILETABLE-managed fd allocation (SYS_OPENAT_INTO).
This created phantom fds known to the kernel but not to relibc's userspace
FILETABLE. When Command::spawn() later called relibc's pipe2() for
fork+exec error reporting, the FILETABLE allocated a position it thought
was free, but the kernel rejected it with EEXIST (errno 17).

This killed EVERY daemon spawn during boot: logd, randd, zerod, rtcd,
nulld, acpid, pcid, inputd, lived, redoxfs, pcid-spawner, fbcond, vesad,
fbbootlogd, hwd, ps2d — all failed with 'File exists (os error 17)'.

Fix: use libc::pipe2() which goes through relibc's FILETABLE-managed
path (FdGuard::open → SYS_OPENAT_INTO), keeping tables in sync.
2026-07-13 00:47:05 +03:00
Red Bear OS 8f50862be5 Fix create_pipe: bypass redox_rt::sys::open two-step that consumes has_run_dup
Use direct syscall::openat with ns_fd to get pipe READ end, then
syscall::dup with 'write' to get WRITE end. This avoids the
redox_rt::sys::open bug where step 2 (openat_into_posix on the
pipe read end) consumes has_run_dup, leaving the subsequent dup()
unable to get the write end.
2026-07-12 15:18:01 +03:00
Red Bear OS dce10c4eb2 fix: bypass ns_fd in pipe creation via libredox::open
The init process's ns_fd may be stale after exec, causing EBADF when
pipe2() calls redox_rt::sys::open (which needs current_namespace_fd()).
Use libredox::Fd::open + syscall::dup instead, bypassing the FILETABLE
and ns_fd dependency entirely.
2026-07-12 12:41:32 +03:00
Red Bear OS 234ce3ab1a diag: print pipe() error details in service.spawn 2026-07-12 11:57:10 +03:00
Red Bear OS 00b799d512 absorb: 41 orphaned base patches re-applied (Phase 1.0A)
Per local/docs/PATCH-PRESERVATION-AUDIT-2026-07-12.md the base
fork was carrying only 38 of 100 patches in local/patches/base/.
The other 62 patches' content was silently missing from the fork
working tree, even though their .patch files were preserved.

This commit re-applies 41 patches that genuinely still apply
cleanly + 17 hunks that partially applied. Recovery covers:

- D-Bus initfs service wiring (P4-initfs-dbus-services)
- USB service wiring (P4-initfs-usb-drm-services)
- netcfg/dhcp/dhcpv6 driver fixes
- acpid shutdown/PM/quirk fixes
- inputd/ps2d hard-fail logging
- pcid driver interface refinements (server cmd channel)
- virtio-core for VirtualBox support
- ixgbed/rtl8139/rtl8168 net drivers
- ahcid NCQ + per-function interrupt coalescing
- logd persistent logging
- bootstrap procmgr race-condition fixes
- cargo version pin to +rb0.3.0 (synchronized release branch)

58 files changed, +1444/-318 lines.

Untracked mnt/ tree and *.orig / *.rej files cleaned up after
patch application (leftover from absolute-path patch headers).
2026-07-12 01:29:08 +03:00
Red Bear OS bd595851e2 base: apply Red Bear patches on latest upstream/main
251 files: init, acpid, ipcd, netcfg, ihdgd, virtio-gpud, scheme-utils,
inputd, block driver, ptyd, ramfs, randd, initfs bootstrap, path deps,
version +rb0.3.1, author attribution
2026-07-11 11:39:24 +03:00
Wildan M f80b51411b init: Change cwd to / at boot 2026-07-06 05:17:35 +07:00
Ibuki Omatsu 372b200f26 refactor: Adapt to userspace fd allocation 2026-07-01 08:20:05 -06:00
Wildan M eeee52f206 init: Fix boot stuck caused by driver exiting 2026-04-28 22:03:20 +07:00
bjorn3 8d6017d799 init: Make spawning for legacy scripts self-contained 2026-04-16 18:43:54 +02:00
bjorn3 ee8109fe1d init: Move some legacy script complexity into Script::from_str 2026-04-11 15:51:54 +02:00
bjorn3 dd1c590131 init: Remove echo special case from legacy init scripts
The standalone echo command works fine too.
2026-04-11 15:45:27 +02:00
bjorn3 baaddd7ccf init: Support reading env vars from /usr/lib/environment.d 2026-04-11 15:40:38 +02:00
bjorn3 2e6cf9df68 init: Remove notify and scheme support from legacy init scripts 2026-04-11 15:24:12 +02:00
bjorn3 347287a3ed init: Move run and run_command to the scheduler 2026-04-11 15:02:25 +02:00
bjorn3 02b074f2e6 init: Unify child spawning calls 2026-04-10 22:14:24 +02:00
bjorn3 8506ae5581 init: Move daemon spawning from daemon to init
In preparation for concurrent daemon spawning.
2026-04-10 22:14:24 +02:00
bjorn3 24ff4f294e init: Start logd as a regular service 2026-04-10 22:14:24 +02:00
bjorn3 1b50d1b543 init: Inline SwitchRoot 2026-04-05 18:27:10 +02:00
bjorn3 8e6b1f8643 init: Introduce a basic job scheduler 2026-04-05 18:25:35 +02:00
bjorn3 a93e4c5fcc init: Remove unnecessary derives for SwitchRoot 2026-04-05 17:32:59 +02:00
bjorn3 a4cb95bd61 init: Extract Unit::conditions_met method 2026-04-05 16:59:41 +02:00
bjorn3 e09f28f1b0 init: Pass reference to Unit to run 2026-04-05 16:59:41 +02:00
bjorn3 57d74e8e17 init: Turn default dependencies into regular dependencies at load time 2026-04-05 16:59:40 +02:00
auronandace 557a3d1954 consolidate several dependencies into the workspace 2026-03-22 15:11:33 +00:00
Ribbon 90ea974ce0 Add missing Cargo package description and update drivers README 2026-03-16 10:39:15 -06:00
Wildan M 2784c98ddd init: Allow skipping services, print service name in debug 2026-03-12 21:20:04 +07:00
bjorn3 a063db73a4 init: Support unit instancing
And use it for the logging ramfs by having a generic ramfs unit.
2026-03-05 19:42:17 +01:00
bjorn3 0869d8184c init: Nicer error handling 2026-03-05 19:41:30 +01:00
bjorn3 1424a470d3 init: Change from push to a pull for loading units
Rather than starting all services in the config dir, we only start those
which are a dependency of the target we want to reach. This is necessary
to handle unit templating, service start stop and an alternative target
for recovery or graceful shutdown.
2026-03-04 21:55:11 +01:00
bjorn3 7cea939540 init: Switch root upon reaching initfs.target 2026-03-04 21:53:48 +01:00
bjorn3 6d243d666c init: Convert rootfs to a service
With this the entire initfs now uses service definitions.
2026-02-28 17:03:25 +01:00
bjorn3 e86dbfa17e Init: Introduce support for conditionally spawning services
depending on the architecture and selected board. With this the
migration of initfs daemons to service definitions is almost done.
2026-02-28 16:55:26 +01:00
auronandace 7849aa23b3 make serde and toml workspace dependencies 2026-02-27 08:39:29 +00:00
bjorn3 124f11bde1 init: Convert all service definitions to toml 2026-02-26 17:41:39 +01:00
bjorn3 3d2951a23d init: Convert vesad, fbbootlogd and fbcond to services 2026-02-26 16:38:56 +01:00