generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / xfs / 150
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Copyright (c) 2021 Oracle.  All Rights Reserved.
4 #
5 # FS QA Test No. 150
6 #
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
9 # resolve.
10 #
11 . ./common/preamble
12 _begin_fstest auto quick db
13
14 # Import common functions.
15 . ./common/filter
16
17 # real QA test starts here
18 _supported_fs xfs
19 _require_xfs_db_command "path"
20 _require_scratch
21
22 echo "Format filesystem and populate"
23 _scratch_mkfs > $seqres.full
24 _scratch_mount >> $seqres.full
25
26 mkdir $SCRATCH_MNT/a
27 mkdir $SCRATCH_MNT/a/b
28 $XFS_IO_PROG -f -c 'pwrite 0 61' $SCRATCH_MNT/a/c >> $seqres.full
29 ln -s -f c $SCRATCH_MNT/a/d
30 mknod $SCRATCH_MNT/a/e b 8 0
31 ln -s -f b $SCRATCH_MNT/a/f
32
33 _scratch_unmount
34
35 echo "Check xfs_db path on directories"
36 _scratch_xfs_db -c 'path /a' -c print | grep -q 'sfdir.*count.* 5$' || \
37         echo "Did not find directory /a"
38
39 _scratch_xfs_db -c 'path /a/b' -c print | grep -q sfdir || \
40         echo "Did not find empty sf directory /a/b"
41
42 echo "Check xfs_db path on files"
43 _scratch_xfs_db -c 'path /a/c' -c print | grep -q 'core.size.*61' || \
44         echo "Did not find 61-byte file /a/c"
45
46 echo "Check xfs_db path on file symlinks"
47 _scratch_xfs_db -c 'path /a/d' -c print | grep -q symlink || \
48         echo "Did not find symlink /a/d"
49
50 echo "Check xfs_db path on bdevs"
51 _scratch_xfs_db -c 'path /a/e' -c print | grep -q 'format.*dev' || \
52         echo "Did not find bdev /a/e"
53
54 echo "Check xfs_db path on dir symlinks"
55 _scratch_xfs_db -c 'path /a/f' -c print | grep -q symlink || \
56         echo "Did not find symlink /a/f"
57
58 echo "Check nonexistent path"
59 _scratch_xfs_db -c 'path /does/not/exist'
60
61 echo "Check xfs_db path on file path with multiple slashes"
62 _scratch_xfs_db -c 'path /a////////c' -c print | grep -q 'core.size.*61' || \
63         echo "Did not find 61-byte file /a////////c"
64
65 echo "Check xfs_db path on file path going in and out of /a to get to /a/c"
66 _scratch_xfs_db -c 'path /a/.././a/.././a/c' -c print | grep -q 'core.size.*61' || \
67         echo "Did not find 61-byte file /a/.././a/.././a/c"
68
69 echo "Check xfs_db path on file path going above the root to get to /a/c"
70 _scratch_xfs_db -c 'path /../../../a/c' -c print | grep -q 'core.size.*61' || \
71         echo "Did not find 61-byte file  /../../../a/c"
72
73 echo "Check xfs_db path on file path going to then above the root to get to /a/c"
74 _scratch_xfs_db -c 'path /a/../../../a/c' -c print | grep -q 'core.size.*61' || \
75         echo "Did not find 61-byte file  /a/../../../a/c"
76
77 echo "Check xfs_db path component that isn't a directory"
78 _scratch_xfs_db -c 'path /a/c/b' -c print
79
80 echo "Check xfs_db path on a dot-dot applied to a non-directory"
81 _scratch_xfs_db -c 'path /a/c/../b' -c print
82
83 # success, all done
84 status=0
85 exit