File: test.sh

package info (click to toggle)
btrfs-progs 5.10.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 16,028 kB
  • sloc: ansic: 96,117; sh: 8,146; python: 1,149; makefile: 811
file content (32 lines) | stat: -rwxr-xr-x 738 bytes parent folder | download | duplicates (2)
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
#!/bin/bash
# recognize partitioned loop devices

source "$TEST_TOP/common"

if ! losetup --help | grep -q 'partscan'; then
	_not_run "losetup --partscan not available"
	exit 0
fi

check_prereq mkfs.btrfs

setup_root_helper

run_check truncate -s0 img
chmod a+w img
cp partition-1g-1g img
run_check truncate -s2g img

loopdev=$(run_check_stdout $SUDO_HELPER losetup --partscan --find --show img)
base=$(basename "$loopdev")

# expect partitions named like loop0p1 etc
for looppart in $(ls /dev/"$base"?*); do
	run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$looppart"
	run_check $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-super "$looppart"
done

# cleanup
run_check $SUDO_HELPER losetup -d "$loopdev"
run_check truncate -s0 img
rm img