patches and low-level development discussion
 help / color / mirror / code / Atom feed
blob 4e2df2b564cfb37d908038311a760b334ab5bef4 1414 bytes (raw)
name: vm/initramfs/etc/init 	 # note: path name is non-authoritative(*)

 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
54
55
56
57
58
 
#!/bin/execlineb -WS0
# SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
# SPDX-FileCopyrightText: 2026 Colby Russell <colby@colbyt.com>
# SPDX-License-Identifier: EUPL-1.2+

export PATH /bin

if { mount -a }

if { mkdir -p /sys/kernel/security }
foreground { mount -t securityfs securityfs /sys/kernel/security }

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 dm-mod }
if { modprobe dm-verity }

# 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 -Si roothash
  veritysetup open /dev/rootfs root-verity /dev/verity $roothash
}

background { rm /dev/rootfs /dev/verity }

if { mount -o ro,nosuid,nodev /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

debug log:

solving 4e2df2b ...
found 4e2df2b in https://inbox.spectrum-os.org/spectrum-devel/20260625202013.1417254-3-colby@colbyt.com/

applying [1/1] https://inbox.spectrum-os.org/spectrum-devel/20260625202013.1417254-3-colby@colbyt.com/
diff --git a/vm/initramfs/etc/init b/vm/initramfs/etc/init
new file mode 100755
index 0000000..4e2df2b

Checking patch vm/initramfs/etc/init...
Applied patch vm/initramfs/etc/init cleanly.

index at:
100755 4e2df2b564cfb37d908038311a760b334ab5bef4	vm/initramfs/etc/init

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/crosvm
	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/nixpkgs
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock
	https://spectrum-os.org/git/www

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).