kboot: add minmalist init functionality
authorWarner Losh <imp@FreeBSD.org>
Thu, 1 Sep 2022 17:06:43 +0000 (11:06 -0600)
committerWarner Losh <imp@FreeBSD.org>
Thu, 1 Sep 2022 17:08:24 +0000 (11:08 -0600)
commit57f90cf81338ca9d1e403fdfeac16f21def72763
tree90d592c5a4823b0ed0cbb45b5f075ca961d8b0d1
parent29fc4075e69fd27de0cded313ac6000165d99f8b
kboot: add minmalist init functionality

It is desirable to run kboot as the first program in some LinuxBoot
environments. This is the traditional "pid 1" or "init" program. When
running as pid 1. rovide a minimal environment based on what sysvinit,
u-root, initramfs-tools and other like projects do. We mount /dev, /sys,
/proc, make symlinks from /dev/fd to /dev/proc, and create /tmp, /run,
and /var. We also setup stdin/out/err to the console, set the tty
characteristics of same and block the appropriate signals.

This is indended as an environment that never does a fork/exec. If
that's required, the process groups, session leaders and all things
POSIX terminal handlers will need to be added.

Unlike the general purpose linux projects in this area, no attempt is
made to support very old kernels.

When not pid 1, we skip all of the above.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D36368
stand/kboot/Makefile
stand/kboot/init.c [new file with mode: 0644]
stand/kboot/kboot.h [new file with mode: 0644]
stand/kboot/main.c