2 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Copyright (c) 2021 Oracle. All Rights Reserved.
7 # Make sure the xfs_db ls command works the way the author thinks it does.
8 # This means that we can list the current directory, list an arbitrary path,
9 # and we can't list things that aren't directories.
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"
33 _require_xfs_db_command "ls"
36 echo "Format filesystem and populate"
37 _scratch_mkfs > $seqres.full
38 _scratch_mount >> $seqres.full
40 $XFS_INFO_PROG $SCRATCH_MNT | grep -q ftype=1 || \
41 _notrun "filesystem does not support ftype"
49 printf("+%d %s %s %s %s %s\n", $1 - cookie, $2, $3, $4, $5, $6);
52 sed -e "s/ $root_ino directory / root directory /g" \
53 -e "s/ $a_ino directory / a_ino directory /g" \
54 -e "s/ $b_ino directory / b_ino directory /g" \
55 -e "s/ $c_ino regular / c_ino regular /g" \
56 -e "s/ $d_ino symlink / d_ino symlink /g" \
57 -e "s/ $e_ino blkdev / e_ino blkdev /g" \
58 -e "s/ $f_ino chardev / f_ino chardev /g" \
59 -e "s/ $g_ino fifo / g_ino fifo /g" \
60 -e "s/ $big0_ino regular / big0_ino regular /g" \
61 -e "s/ $big1_ino regular / big1_ino regular /g" \
62 -e "s/ $h_ino regular / g_ino regular /g"
66 mkdir $SCRATCH_MNT/a/b
67 $XFS_IO_PROG -f -c 'pwrite 0 61' $SCRATCH_MNT/a/c >> $seqres.full
68 ln -s -f b $SCRATCH_MNT/a/d
69 mknod $SCRATCH_MNT/a/e b 0 0
70 mknod $SCRATCH_MNT/a/f c 0 0
71 mknod $SCRATCH_MNT/a/g p
72 touch $SCRATCH_MNT/a/averylongnameforadirectorysothatwecanpushthecookieforward
73 touch $SCRATCH_MNT/a/andmakethefirstcolumnlookmoreinterestingtopeoplelolwtfbbq
74 touch $SCRATCH_MNT/a/h
76 root_ino=$(stat -c '%i' $SCRATCH_MNT)
77 a_ino=$(stat -c '%i' $SCRATCH_MNT/a)
78 b_ino=$(stat -c '%i' $SCRATCH_MNT/a/b)
79 c_ino=$(stat -c '%i' $SCRATCH_MNT/a/c)
80 d_ino=$(stat -c '%i' $SCRATCH_MNT/a/d)
81 e_ino=$(stat -c '%i' $SCRATCH_MNT/a/e)
82 f_ino=$(stat -c '%i' $SCRATCH_MNT/a/f)
83 g_ino=$(stat -c '%i' $SCRATCH_MNT/a/g)
84 big0_ino=$(stat -c '%i' $SCRATCH_MNT/a/avery*)
85 big1_ino=$(stat -c '%i' $SCRATCH_MNT/a/andma*)
86 h_ino=$(stat -c '%i' $SCRATCH_MNT/a/h)
90 echo "Manually navigate to root dir then list"
91 _scratch_xfs_db -c 'sb 0' -c 'addr rootino' -c ls | filter_ls
93 echo "Use path to navigate to root dir then list"
94 _scratch_xfs_db -c 'path /' -c ls | filter_ls
96 echo "Use path to navigate to /a then list"
97 _scratch_xfs_db -c 'path /a' -c ls | filter_ls
99 echo "Use path to navigate to /a/b then list"
100 _scratch_xfs_db -c 'path /a/b' -c ls | filter_ls
102 echo "Use path to navigate to /a/c (non-dir) then list"
103 _scratch_xfs_db -c 'path /a/c' -c ls