Commit Graph

67 Commits

Author SHA1 Message Date
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 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
bjorn3 fb051cd486 init: Special case logd
Logd is a special case. Every other service effectively has an implicit
dependency on it for sending log messages to it and even init itself
depends on it for it's own log messages.
2026-02-26 15:18:19 +01:00
Jeremy Soller 75b9f07a92 Merge branch 'init_rework3' into 'main'
Introduce dependency handling to init

See merge request redox-os/base!133
2026-02-25 15:02:54 -07:00
bjorn3 bb2a00114f init: Introduce dependency handling 2026-02-25 22:43:11 +01:00
bjorn3 6fcb07e7dd init: Introduce UnitStore
This will be necessary to store persistent information about units like
if they are currently started and which process is associated with them.
2026-02-25 22:06:25 +01:00
bjorn3 73cc0b0a07 init: Begin introducing units
Dependencies are not yet functional.
2026-02-25 20:57:47 +01:00
bjorn3 f364bf1f60 init: Introduce a json format for services
While I would have like to use toml, something inside the toml crate
seems to be using randomness, which is not yet available when init
starts.
2026-02-25 20:18:42 +01:00
auronandace 5ffce47607 add clippy precedence lint 2026-02-20 13:43:48 +00:00
bjorn3 4e772728ad init: Introduce Service type
A future commit will use it to define services in toml format.
2026-02-19 22:18:29 +01:00
bjorn3 c9d691fa29 init: Remove export and unset commands
They manipulate global state and none of the init scripts use them anymore.
2026-02-19 21:57:45 +01:00
bjorn3 87abd3fb70 init: Maintain default service env vars separate from init env vars
With this only the env vars set using export or explicitly specify for a
service are passed to services (in addition to RUST_BACKTRACE, PATH and
LD_LIBRARY_PATH). As such we no longer need to manually unset bootloader
env vars to keep the environment clean. And finally this means that env
var substitutions in shell scripts always use the bootloader provided
env vars rather than locally specified ones.

This does regress multi monitor support when there is no proper graphics
driver.
2026-02-19 21:06:53 +01:00
bjorn3 b7524c3a65 init: Allow passing env vars to individual services 2026-02-19 20:50:48 +01:00
bjorn3 029f56eebe init: Remove cd command
The working directory doesn't matter for services and login sessions
already cd to the user home directory. This removes one source of global
state manipulation.
2026-02-19 20:26:51 +01:00
bjorn3 0227c0677c init: Introduce switchroot command
This sets PATH, LD_LIBRARY_PATH and runs init scripts for the new root.
In the future this could replace the entire set of services that should
run, restarting any services for which a newer executable is available
in the new root and stopping any services which don't exist in the new
root. This behavior could also be useful for soft-reboots in the future
to handle updates without rebooting the entire system.
2026-02-19 20:18:07 +01:00
bjorn3 7ebeceb41d init: Allow init to register the scheme for a daemon
Unfortunately the scheme still has to be created by the daemon due to a
kernel bug, but once that is fixed, it would allow delayed spawning of
scheme daemons.
2026-02-18 22:40:09 +01:00