Skip to content

Commit 8fe9580

Browse files
sinkapkernel-patches-bot
authored andcommitted
selftests/bpf: Update ima test helper's losetup commands
Update the commands to use the bare minimum options so that it works in busybox environments. Fixes: 34b82d3 ("bpf: Add a selftest for bpf_ima_inode_hash") Reported-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: KP Singh <kpsingh@google.com>
1 parent 82318f3 commit 8fe9580

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tools/testing/selftests/bpf/ima_setup.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
set -e
55
set -u
6+
set -o pipefail
67

78
IMA_POLICY_FILE="/sys/kernel/security/ima/policy"
89
TEST_BINARY="/bin/true"
@@ -23,9 +24,10 @@ setup()
2324

2425
dd if=/dev/zero of="${mount_img}" bs=1M count=10
2526

26-
local loop_device="$(losetup --find --show ${mount_img})"
27+
losetup -f "${mount_img}"
28+
local loop_device=$(losetup -a | grep ${mount_img:?} | cut -d ":" -f1)
2729

28-
mkfs.ext4 "${loop_device}"
30+
mkfs.ext4 "${loop_device:?}"
2931
mount "${loop_device}" "${mount_dir}"
3032

3133
cp "${TEST_BINARY}" "${mount_dir}"
@@ -38,7 +40,8 @@ cleanup() {
3840
local mount_img="${tmp_dir}/test.img"
3941
local mount_dir="${tmp_dir}/mnt"
4042

41-
local loop_devices=$(losetup -j ${mount_img} -O NAME --noheadings)
43+
local loop_devices=$(losetup -a | grep ${mount_img:?} | cut -d ":" -f1)
44+
4245
for loop_dev in "${loop_devices}"; do
4346
losetup -d $loop_dev
4447
done

0 commit comments

Comments
 (0)