3 # test commands of inspect-internal rootid
5 source "$TEST_TOP/common"
7 check_prereq mkfs.btrfs
12 run_check "$TOP/mkfs.btrfs" -f "$TEST_DEV"
13 run_check_mount_test_dev
14 run_check $SUDO_HELPER chmod a+rw "$TEST_MNT"
17 run_check "$TOP/btrfs" subvolume create sub
18 run_check "$TOP/btrfs" subvolume create sub/subsub
21 run_check touch dir/file2
22 run_check touch sub/file3
24 id1=$(run_check_stdout "$TOP/btrfs" inspect-internal rootid .) \
25 || { echo $id1; exit 1; }
26 id2=$(run_check_stdout "$TOP/btrfs" inspect-internal rootid sub) \
27 || { echo $id2; exit 1; }
28 id3=$(run_check_stdout "$TOP/btrfs" inspect-internal rootid sub/subsub) \
29 || { echo $id3; exit 1; }
30 id4=$(run_check_stdout "$TOP/btrfs" inspect-internal rootid dir) \
31 || { echo $id4; exit 1; }
32 id5=$(run_check_stdout "$TOP/btrfs" inspect-internal rootid file1) \
33 || { echo $id5; exit 1; }
34 id6=$(run_check_stdout "$TOP/btrfs" inspect-internal rootid dir/file2) \
35 || { echo $id6; exit 1; }
36 id7=$(run_check_stdout "$TOP/btrfs" inspect-internal rootid sub/file3) \
37 || { echo $id7; exit 1; }
39 if ! ([ $id1 -ne $id2 ] && [ $id1 -ne $id3 ] && [ $id2 -ne $id3 ]); then
40 _fail "inspect-internal rootid: each subvolume must have different id"
43 if ! ([ $id1 -eq $id4 ] && [ $id1 -eq $id5 ] && [ $id1 -eq $id6 ]); then
44 _fail "inspect-internal rootid: rootid mismatch found"
47 if ! ([ $id2 -eq $id7 ]); then
48 _fail "inspect-internal rootid: rootid mismatch found"
51 run_mustfail "should fail for non existent file" \
52 "$TOP/btrfs" inspect-internal rootid no_such_file
53 run_mustfail "should fail for non-btrfs filesystem" \
54 "$TOP/btrfs" inspect-internal rootid /dev/null
57 run_check_umount_test_dev