Skip to content

feat(init): Start a program built into urunit - #1

Merged
ananos merged 1 commit into
nofirefrom
feat/init-embedded-telem-capture
Dec 1, 2026
Merged

ananos merged 1 commit into
nofirefrom
feat/init-embedded-telem-capture

Conversation

@ananos

@ananos ananos commented Nov 16, 2026 •

Copy link
Copy Markdown

make static EMBED=<path> builds a static program into urunit. The early init starts it before the root is mounted, from a memfd, so the root mount and the workload run after it and the initrd stays one file. It suits a tracing or monitoring helper that has to be in place first.

How

  • The program's bytes go into .rodata between two weak symbols (urunit_embed_blob, urunit_embed_blob_end), through an .incbin the Makefile writes. A build without EMBED leaves them null and starts nothing.
  • It runs through fexecve from a memfd, as a child of PID 1 that the reaping loop collects, with stdout and stderr on /dev/kmsg. tracefs is mounted at /sys/kernel/tracing first.
  • The build fixes when and how it runs:
    • EMBED_NAME: its argv[0] (default embedded)
    • EMBED_WHEN: a path that must exist for it to start, such as a device the kernel offers only when the feature is there (default: always)
    • EMBED_READY: a flag that takes a file descriptor, such as --ready-fd; the program gets the write end of a pipe through it and the init waits up to 3 s for one byte. A program that exits first or stalls is logged and the boot goes on (default: no wait).
  • It starts after the clock and the host name are set.

Verification

  • make check with glibc (Ubuntu) and musl (Alpine 3.21): PASS. test_embed_wait_ready covers the byte, end of file and the timeout.
  • make static EMBED=<37 KB static dummy> EMBED_NAME=probe-helper EMBED_WHEN=/dev/probe EMBED_READY=--ready-fd in Alpine: the binary grows by 40,960 bytes and carries the three configured strings; a plain make static is unchanged.

Base

Rebased onto nofire, the default branch, which carries the stack (up to the host name change) on top of upstream main.

- make EMBED=<path> builds a static program into urunit; the early init
  starts it from a memfd before the root is mounted, output to kmsg.
- EMBED_NAME, EMBED_WHEN (a path that must exist) and EMBED_READY (a
  ready-fd flag, waited on for up to 3 s) fix when and how it runs.

Signed-off-by: Anastassios Nanos <ananos@nofire.ai>
@ananos ananos closed this Dec 1, 2026
@ananos
ananos deleted the feat/init-embedded-telem-capture branch December 1, 2026 00:53
@ananos ananos reopened this Dec 1, 2026
@ananos
ananos changed the base branch from stack/10-acpi-power-button to nofire December 1, 2026 00:55
@ananos
ananos force-pushed the feat/init-embedded-telem-capture branch from 4e97444 to 7ace25a Compare December 1, 2026 00:55
@ananos ananos changed the title feat(init): Start the telemetry producer, embedded or from the initrd feat(init): Start a program built into urunit Dec 1, 2026
@ananos
ananos marked this pull request as ready for review December 1, 2026 01:34
@ananos
ananos merged commit 69b690a into nofire Dec 1, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant