1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
| | #!/bin/execlineb -S0
# SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
# SPDX-License-Identifier: EUPL-1.2
export PATH /bin
if { mount -a }
piperw 3 4
if { fdmove 1 4 /etc/getuuids }
fdclose 4
# head -1 would be clearer, but it might use buffered I/O and consume
# too much from the fifo. Ideally we'd have line(1) from illumos.
backtick ROOTFS_UUID { fdmove 0 3 dd count=1 bs=37 status=none }
backtick VERITY_UUID { fdmove 0 3 dd count=1 bs=37 status=none }
fdclose 3
if { mkfifo /dev/rootfs.poll }
background {
fdclose 3
mdevd -C -b134217728
}
importas -iu mdevd_pid !
if { modprobe ext4 }
# Do a blocking read on the fifo to wait for mdevd to find the
# partition.
if {
redirfd -r 0 /dev/rootfs.poll
redirfd -w 1 /dev/null
head -c 1
}
background { kill $mdevd_pid }
background { rm /dev/rootfs.poll }
if {
importas -i roothash roothash
veritysetup open /dev/rootfs root-verity /dev/verity $roothash
}
background { rm /dev/rootfs /dev/verity }
if { mount /dev/mapper/root-verity /mnt/root }
wait { $mdevd_pid }
if { mount --move /proc /mnt/root/proc }
if { mount --move /sys /mnt/root/sys }
if { mount --move /dev /mnt/root/dev }
switch_root /mnt/root
/etc/init
|