blob: c815940fbbef39fb9078c5529a6f9c36dff281d9 [file] [log] [blame]
Andrew Geisslercc589282020-09-18 13:34:40 -05001#!/bin/sh
2
3dmverity_enabled() {
4 return 0
5}
6
7dmverity_run() {
8 DATA_SIZE="__not_set__"
Patrick Williams93c203f2021-10-06 16:15:23 -05009 DATA_BLOCK_SIZE="__not_set__"
Andrew Geisslercc589282020-09-18 13:34:40 -050010 ROOT_HASH="__not_set__"
11
12 . /usr/share/misc/dm-verity.env
13
Andrew Geisslerd1d22e62020-10-16 10:14:32 -050014 C=0
15 delay=${bootparam_rootdelay:-1}
16 timeout=${bootparam_roottimeout:-5}
17 RDEV="$(realpath /dev/disk/by-partuuid/${bootparam_root#PARTUUID=})"
18 while [ ! -b "${RDEV}" ]; do
19 if [ $(( $C * $delay )) -gt $timeout ]; then
20 fatal "Root device resolution failed"
21 exit 1
22 fi
Andrew Geisslercc589282020-09-18 13:34:40 -050023
Andrew Geisslerd1d22e62020-10-16 10:14:32 -050024 case "${bootparam_root}" in
25 ID=*)
26 RDEV="$(realpath /dev/disk/by-id/${bootparam_root#ID=})"
27 ;;
28 LABEL=*)
29 RDEV="$(realpath /dev/disk/by-label/${bootparam_root#LABEL=})"
30 ;;
31 PARTLABEL=*)
32 RDEV="$(realpath /dev/disk/by-partlabel/${bootparam_root#PARTLABEL=})"
33 ;;
34 PARTUUID=*)
35 RDEV="$(realpath /dev/disk/by-partuuid/${bootparam_root#PARTUUID=})"
36 ;;
37 PATH=*)
38 RDEV="$(realpath /dev/disk/by-path/${bootparam_root#PATH=})"
39 ;;
40 UUID=*)
41 RDEV="$(realpath /dev/disk/by-uuid/${bootparam_root#UUID=})"
42 ;;
43 *)
44 RDEV="${bootparam_root}"
45 esac
46 debug "Sleeping for $delay second(s) to wait root to settle..."
47 sleep $delay
48 C=$(( $C + 1 ))
49
50 done
Andrew Geisslercc589282020-09-18 13:34:40 -050051
52 veritysetup \
Patrick Williams93c203f2021-10-06 16:15:23 -050053 --data-block-size=${DATA_BLOCK_SIZE} \
Andrew Geisslercc589282020-09-18 13:34:40 -050054 --hash-offset=${DATA_SIZE} \
55 create rootfs \
56 ${RDEV} \
57 ${RDEV} \
58 ${ROOT_HASH}
59
60 mount \
61 -o ro \
62 /dev/mapper/rootfs \
63 ${ROOTFS_DIR} || exit 2
64}