Commit graph

18 commits

Author SHA1 Message Date
Raito Bezarius
17355c3911 fix(preinit): scan multiple times the cmdline and rename altroot in rootalt
The way the parsing works is examining one character at a time.

First, if we had `rootfstype=... root=...`, the parsing would jump and
ignore `root=...`, which sucks.

To fix this, we scan multiple times a copy of the cmdline.

Now, we have a new problem: `root=... altroot=...` lead to opts.device
being equal to the altroot as we are looking one char at a time, so we
will arrive at a moment looking at `root=...` for `altroot=...`.

To avoid this, we rename `altroot` in `rootalt`, cheap, I know.

Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
2024-09-01 17:48:54 +02:00
Raito Bezarius
afb14d844b feat(preinit): support alternative roots
In A/B schemas, it is possible to have multiple rootfs.

Thus, it is necessary to let the B kernel preinitialize either the A
rootfs or the B rootfs failing to mount the A rootfs.

Ideally, we should also try to switch to the B rootfs if we cannot start
up the init on the A rootfs, but that's a FUTUREWORK.

Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
2024-04-21 17:26:37 +02:00
Daniel Barlow
228c0a1668 pass rootOptions config as rootflags= kernel cmdline opt 2024-01-08 18:54:49 +00:00
Daniel Barlow
63f034e362 preinit: parse rootflags= in kernel command line 2024-01-08 00:35:13 +00:00
Daniel Barlow
6971d03520 preinit: check return from write() 2024-01-07 21:24:16 +00:00
Daniel Barlow
a8891461aa use devtmpfs in initramfs
static device nodes don't work with virtio
2023-12-07 20:03:03 +00:00
Daniel Barlow
c3ccee6506 preinit: print errno (in hex, it's easier) for failures 2023-11-05 11:27:57 +00:00
Daniel Barlow
6db982f25f preinit: pause before exiting
as explained in the comment, this is to give us a
chance to see error messages before the kernel panics
2023-11-05 11:27:57 +00:00
Daniel Barlow
86a5224f3c preinit: fix compiler warnings 2023-11-05 11:27:43 +00:00
Daniel Barlow
155a29d9b3 preinit: strip trailing newline(s) on /proc/cmdline 2023-11-05 11:27:34 +00:00
Daniel Barlow
d2f517a4e9 preinit.c: reindent 2023-10-19 21:02:18 +01:00
Daniel Barlow
0f38ee0e9c remove PREINIT_USE_LIBC option as it is now the only option 2023-10-19 18:59:02 +01:00
Daniel Barlow
61dc5beca8 preinit: parse rootfstype from kernel command line 2023-10-19 18:56:09 +01:00
Daniel Barlow
0693cf23d8 preinit: improve error logging for fork_exec 2023-10-12 19:00:57 +01:00
Daniel Barlow
1a369ff3bf preinit: remove no-longer-used mips assembly 2023-10-12 18:57:54 +01:00
Daniel Barlow
6bc45c2b55 preinit: null-terminate argv array for execve 2023-06-22 09:29:44 +01:00
Daniel Barlow
a7e7146887 preinit: disable nolibc
- it stopped working with 22.11->23.05
- linking statically against musl is about 17k, so
  this is costing us 11k or so
2023-06-18 23:04:26 +01:00
Daniel Barlow
5dd0c6e3c0 rewrite preinit as very small C program
By using the kernel "nolibc" header to avoid requiring a C library, we
can bring the initramfs size to around 4k

This does involve a tiny bit of inline mips assembly which I'm not
sure about. gcc seems unwilling to generate the code to load $gp at
function entry of main(), so we do it by hand - but I'd rather find
out why gcc doesn't.
2023-04-15 18:27:39 +01:00