xref: /aosp_15_r20/external/e2fsprogs/tests/f_verity/mkimage.sh (revision 6a54128f25917bfc36a8a6e9d722c04a0b4641b6)
1*6a54128fSAndroid Build Coastguard Worker#!/bin/bash
2*6a54128fSAndroid Build Coastguard Worker
3*6a54128fSAndroid Build Coastguard Worker# This is the script that was used to create the image.gz in this directory.
4*6a54128fSAndroid Build Coastguard Worker
5*6a54128fSAndroid Build Coastguard Workerset -e -u
6*6a54128fSAndroid Build Coastguard Worker
7*6a54128fSAndroid Build Coastguard Workermkdir -p mnt
8*6a54128fSAndroid Build Coastguard Workerumount mnt &> /dev/null || true
9*6a54128fSAndroid Build Coastguard Worker
10*6a54128fSAndroid Build Coastguard Workerdd if=/dev/zero of=image bs=4096 count=128
11*6a54128fSAndroid Build Coastguard Workermke2fs -O 'verity,extents' -b 4096 -N 128 image
12*6a54128fSAndroid Build Coastguard Workermount image mnt
13*6a54128fSAndroid Build Coastguard Worker
14*6a54128fSAndroid Build Coastguard Worker# Create a verity file, but make it fragmented so that it needs at least one
15*6a54128fSAndroid Build Coastguard Worker# extent tree index node, in order to cover the scan_extent_node() case.
16*6a54128fSAndroid Build Coastguard Workerfor i in {1..80}; do
17*6a54128fSAndroid Build Coastguard Worker	head -c 4096 /dev/zero > mnt/tmp_$i
18*6a54128fSAndroid Build Coastguard Workerdone
19*6a54128fSAndroid Build Coastguard Workerfor i in {1..80..2}; do
20*6a54128fSAndroid Build Coastguard Worker	rm mnt/tmp_$i
21*6a54128fSAndroid Build Coastguard Workerdone
22*6a54128fSAndroid Build Coastguard Workerhead -c $((40 * 4096)) /dev/zero > mnt/file
23*6a54128fSAndroid Build Coastguard Workerfsverity enable mnt/file
24*6a54128fSAndroid Build Coastguard Workerrm mnt/tmp_*
25*6a54128fSAndroid Build Coastguard Worker
26*6a54128fSAndroid Build Coastguard Workerumount mnt
27*6a54128fSAndroid Build Coastguard Workerrmdir mnt
28*6a54128fSAndroid Build Coastguard Workergzip -9 -f image
29