2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Red Hat, Inc. All Rights Reserved.
7 # Exercise the xfs_io inode command
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
24 # get standard environment, filters and checks
28 # remove previous $seqres.full before test
31 # real QA test starts here
33 # Modify as appropriate.
37 _require_xfs_io_command "inode"
39 # We know the root inode is there
40 ROOT_INO=`ls -id $TEST_DIR | awk '{print $1}'`
44 $XFS_IO_PROG -c "inode" $TEST_DIR/file
45 $XFS_IO_PROG -c "inode -v" $TEST_DIR/file | \
46 grep -vw "^$ROOT_INO" | sed -e s/.*:/LAST:/
48 # These should fail, -n requires an inode
49 $XFS_IO_PROG -c "inode -n" $TEST_DIR/file 2>&1 | grep -q Query \
50 || echo "bare -n succeeded"
51 $XFS_IO_PROG -c "inode -nv" $TEST_DIR/file 2>&1 | grep -q Query \
52 || echo "bare -nv succeeded"
53 $XFS_IO_PROG -c "inode -n -v" $TEST_DIR/file 2>&1 | grep -q Query \
54 || echo "bare -n -v succeeded"
56 # These fail too, requires a valid inode number
57 $XFS_IO_PROG -c "inode badnumber" $TEST_DIR/file | grep -q numeric \
58 || echo "Bad inode number succeeded"
59 $XFS_IO_PROG -c "inode -v badnumber" $TEST_DIR/file | grep -q numeric \
60 || echo "Bad inode number succeeded"
61 $XFS_IO_PROG -c "inode -n badnumber" $TEST_DIR/file | grep -q numeric \
62 || echo "Bad inode number succeeded"
63 $XFS_IO_PROG -c "inode -nv badnumber" $TEST_DIR/file | grep -q numeric \
64 || echo "Bad inode number succeeded"
65 $XFS_IO_PROG -c "inode -n -v badnumber" $TEST_DIR/file | grep -q numeric \
66 || echo "Bad inode number succeeded"
68 # These should all work, and return $ROOT_INO or the next inode...
69 # grep out ROOT_INO (which is incorrect) when we should be getting next inode
70 $XFS_IO_PROG -c "inode $ROOT_INO" $TEST_DIR/file | \
71 sed -e s/$ROOT_INO/ROOT_INO/
72 $XFS_IO_PROG -c "inode -v $ROOT_INO" $TEST_DIR/file | \
73 sed -e s/$ROOT_INO/ROOT_INO/
74 $XFS_IO_PROG -c "inode -n $ROOT_INO" $TEST_DIR/file | \
75 grep -vw "^$ROOT_INO" | sed -e s/.*/NEXT/
76 $XFS_IO_PROG -c "inode -nv $ROOT_INO" $TEST_DIR/file | \
77 grep -vw "^$ROOT_INO" | sed -e s/.*:/NEXT:/
78 $XFS_IO_PROG -c "inode -n -v $ROOT_INO" $TEST_DIR/file | \
79 grep -vw "^$ROOT_INO" | sed -e s/.*:/NEXT:/
81 # Try one that doesn't exist, 2^64-2? Should get 0
82 $XFS_IO_PROG -c "inode 18446744073709551614" $TEST_DIR/file
83 $XFS_IO_PROG -c "inode -v 18446744073709551614" $TEST_DIR/file
84 $XFS_IO_PROG -c "inode -n 18446744073709551614" $TEST_DIR/file
85 $XFS_IO_PROG -c "inode -nv 18446744073709551614" $TEST_DIR/file
86 $XFS_IO_PROG -c "inode -n -v 18446744073709551614" $TEST_DIR/file