schinit: a launchd-shaped process 1
Milestone 1 of three: manifests, RunAtLoad, KeepAlive with throttling,
and reaping. Replaces the hardcoded fork-a-shell loop in cmd/init, which
stays in the tree for now.
Jobs are sectioned key=value files in /etc/schinit/*.job, kept in the
repo under etc/ and installed into the sysroot -- sysroot/ is generated
and gitignored, so anything written only there is lost on a fresh clone,
which is already true of /etc/passwd and should not become true of the
boot configuration. Unknown keys and sections are ignored rather than
fatal: a manifest written for a newer schinit must not stop this one
booting the machine.
Socket sections are parsed and recorded but not yet held. That is
milestone 2 and it is the whole reason for copying launchd rather than
sysvinit -- the supervisor holds the listener and starts the job on first
connect, which inverts the dependency graph and makes runlevels a
non-concept. The key exists now so manifests need not change later.
getdents64 is exposed to userland for this. The kernel has had it since
the Linux ABI landed, but nothing declared it in user.h or lib/usys.S, so
first-party programs had no way to list a directory at all.
Two things found by testing rather than reasoning:
- setsid() gives a job its own session, and a session has no
controlling terminal. The console then delivers input only to the
foreground process group it tracks, so the shell came up, echoed
every keystroke through the line discipline, and executed none of
them -- indistinguishable from a hung shell. ControllingTerminal=yes
claims it with TIOCSCTTY/TIOCSPGRP; off by default, since a daemon
has no business seizing the console.
- the first bootstrap() dropped /dev/input/event0-1 and most of /proc,
because it was transcribed from the part of the old init that had
been read rather than all of it. -Evdev caught it.
build/usbstick.img is built by `all` now: without it QEMU refuses the
-drive and the entire -Usb run produces no output, which reads as a
broken USB driver.
Seven suites green: base 27, Tty 51, Ps 32, Sock 64, Fb 36, Usb 31,
Evdev 29. make schfs-check passes.
This commit is contained in:
parent
08a1a9033a
commit
baede13847
10 changed files with 664 additions and 7 deletions
|
|
@ -95,6 +95,24 @@ int getppid(void);
|
|||
int rt_sigaction(int, void*, void*, uint64);
|
||||
int mount(const char *src, const char *tgt, const char *fstype, uint64 flags, void *data);
|
||||
|
||||
// Directory reading. The kernel has had getdents64 since the Linux ABI landed,
|
||||
// but nothing declared it here, so first-party programs had no way to list a
|
||||
// directory at all -- which is what schinit needs to find its job files.
|
||||
//
|
||||
// Records are packed: step by d_reclen, never by sizeof, because d_name is a
|
||||
// flexible array and each record is only as long as its name needs.
|
||||
struct dirent64 {
|
||||
uint64 d_ino;
|
||||
int64 d_off;
|
||||
ushort d_reclen;
|
||||
uchar d_type;
|
||||
char d_name[];
|
||||
};
|
||||
#define DT_DIR 4
|
||||
#define DT_REG 8
|
||||
|
||||
int getdents64(int fd, void *buf, int count);
|
||||
|
||||
// Sockets. `struct sockaddr` and the AF_*/SOCK_* constants are in socket.h;
|
||||
// include it as well as this header to use them.
|
||||
struct sockaddr;
|
||||
|
|
|
|||
Loading…
Reference in a new issue