4 # Exercise the xfs_io inode command
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2016 Red Hat, Inc. All Rights Reserved.
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #-----------------------------------------------------------------------
25 seqres=$RESULT_DIR/$seq
26 echo "QA output created by $seq"
30 status=1 # failure is the default!
31 trap "_cleanup; exit \$status" 0 1 2 3 15
39 # get standard environment, filters and checks
43 # remove previous $seqres.full before test
46 # real QA test starts here
48 # Modify as appropriate.
52 _require_xfs_io_command "inode"
54 # We know the root inode is there
55 ROOT_INO=`ls -id $TEST_DIR | awk '{print $1}'`
59 $XFS_IO_PROG -c "inode" $TEST_DIR/file
60 $XFS_IO_PROG -c "inode -v" $TEST_DIR/file | \
61 grep -vw "^$ROOT_INO" | sed -e s/.*:/LAST:/
63 # These should fail, -n requires an inode
64 $XFS_IO_PROG -c "inode -n" $TEST_DIR/file 2>&1 | grep -q Query \
65 || echo "bare -n succeeded"
66 $XFS_IO_PROG -c "inode -nv" $TEST_DIR/file 2>&1 | grep -q Query \
67 || echo "bare -nv succeeded"
68 $XFS_IO_PROG -c "inode -n -v" $TEST_DIR/file 2>&1 | grep -q Query \
69 || echo "bare -n -v succeeded"
71 # These fail too, requires a valid inode number
72 $XFS_IO_PROG -c "inode badnumber" $TEST_DIR/file | grep -q numeric \
73 || echo "Bad inode number succeeded"
74 $XFS_IO_PROG -c "inode -v badnumber" $TEST_DIR/file | grep -q numeric \
75 || echo "Bad inode number succeeded"
76 $XFS_IO_PROG -c "inode -n badnumber" $TEST_DIR/file | grep -q numeric \
77 || echo "Bad inode number succeeded"
78 $XFS_IO_PROG -c "inode -nv badnumber" $TEST_DIR/file | grep -q numeric \
79 || echo "Bad inode number succeeded"
80 $XFS_IO_PROG -c "inode -n -v badnumber" $TEST_DIR/file | grep -q numeric \
81 || echo "Bad inode number succeeded"
83 # These should all work, and return $ROOT_INO or the next inode...
84 # grep out ROOT_INO (which is incorrect) when we should be getting next inode
85 $XFS_IO_PROG -c "inode $ROOT_INO" $TEST_DIR/file | \
86 sed -e s/$ROOT_INO/ROOT_INO/
87 $XFS_IO_PROG -c "inode -v $ROOT_INO" $TEST_DIR/file | \
88 sed -e s/$ROOT_INO/ROOT_INO/
89 $XFS_IO_PROG -c "inode -n $ROOT_INO" $TEST_DIR/file | \
90 grep -vw "^$ROOT_INO" | sed -e s/.*/NEXT/
91 $XFS_IO_PROG -c "inode -nv $ROOT_INO" $TEST_DIR/file | \
92 grep -vw "^$ROOT_INO" | sed -e s/.*:/NEXT:/
93 $XFS_IO_PROG -c "inode -n -v $ROOT_INO" $TEST_DIR/file | \
94 grep -vw "^$ROOT_INO" | sed -e s/.*:/NEXT:/
96 # Try one that doesn't exist, 2^64-2? Should get 0
97 $XFS_IO_PROG -c "inode 18446744073709551614" $TEST_DIR/file
98 $XFS_IO_PROG -c "inode -v 18446744073709551614" $TEST_DIR/file
99 $XFS_IO_PROG -c "inode -n 18446744073709551614" $TEST_DIR/file
100 $XFS_IO_PROG -c "inode -nv 18446744073709551614" $TEST_DIR/file
101 $XFS_IO_PROG -c "inode -n -v 18446744073709551614" $TEST_DIR/file