2 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Copyright (c) 2021 Oracle. All Rights Reserved.
7 # Make sure the xfs_db path command works the way the author thinks it does.
8 # This means that it can navigate to random inodes, fails on paths that don't
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
17 status=1 # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
26 # get standard environment, filters and checks
30 # real QA test starts here
32 _require_xfs_db_command "path"
35 echo "Format filesystem and populate"
36 _scratch_mkfs > $seqres.full
37 _scratch_mount >> $seqres.full
40 mkdir $SCRATCH_MNT/a/b
41 $XFS_IO_PROG -f -c 'pwrite 0 61' $SCRATCH_MNT/a/c >> $seqres.full
42 ln -s -f c $SCRATCH_MNT/a/d
43 mknod $SCRATCH_MNT/a/e b 8 0
44 ln -s -f b $SCRATCH_MNT/a/f
48 echo "Check xfs_db path on directories"
49 _scratch_xfs_db -c 'path /a' -c print | grep -q 'sfdir.*count.* 5$' || \
50 echo "Did not find directory /a"
52 _scratch_xfs_db -c 'path /a/b' -c print | grep -q sfdir || \
53 echo "Did not find empty sf directory /a/b"
55 echo "Check xfs_db path on files"
56 _scratch_xfs_db -c 'path /a/c' -c print | grep -q 'core.size.*61' || \
57 echo "Did not find 61-byte file /a/c"
59 echo "Check xfs_db path on file symlinks"
60 _scratch_xfs_db -c 'path /a/d' -c print | grep -q symlink || \
61 echo "Did not find symlink /a/d"
63 echo "Check xfs_db path on bdevs"
64 _scratch_xfs_db -c 'path /a/e' -c print | grep -q 'format.*dev' || \
65 echo "Did not find bdev /a/e"
67 echo "Check xfs_db path on dir symlinks"
68 _scratch_xfs_db -c 'path /a/f' -c print | grep -q symlink || \
69 echo "Did not find symlink /a/f"
71 echo "Check nonexistent path"
72 _scratch_xfs_db -c 'path /does/not/exist'
74 echo "Check xfs_db path on file path with multiple slashes"
75 _scratch_xfs_db -c 'path /a////////c' -c print | grep -q 'core.size.*61' || \
76 echo "Did not find 61-byte file /a////////c"
78 echo "Check xfs_db path on file path going in and out of /a to get to /a/c"
79 _scratch_xfs_db -c 'path /a/.././a/.././a/c' -c print | grep -q 'core.size.*61' || \
80 echo "Did not find 61-byte file /a/.././a/.././a/c"
82 echo "Check xfs_db path on file path going above the root to get to /a/c"
83 _scratch_xfs_db -c 'path /../../../a/c' -c print | grep -q 'core.size.*61' || \
84 echo "Did not find 61-byte file /../../../a/c"
86 echo "Check xfs_db path on file path going to then above the root to get to /a/c"
87 _scratch_xfs_db -c 'path /a/../../../a/c' -c print | grep -q 'core.size.*61' || \
88 echo "Did not find 61-byte file /a/../../../a/c"
90 echo "Check xfs_db path component that isn't a directory"
91 _scratch_xfs_db -c 'path /a/c/b' -c print
93 echo "Check xfs_db path on a dot-dot applied to a non-directory"
94 _scratch_xfs_db -c 'path /a/c/../b' -c print