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.
36 _require_xfs_io_command "inode"
38 # We know the root inode is there
39 ROOT_INO=`ls -id $TEST_DIR | awk '{print $1}'`
43 $XFS_IO_PROG -c "inode" $TEST_DIR/file
44 $XFS_IO_PROG -c "inode -v" $TEST_DIR/file | \
45 grep -vw "^$ROOT_INO" | sed -e s/.*:/LAST:/
47 # These should fail, -n requires an inode
48 $XFS_IO_PROG -c "inode -n" $TEST_DIR/file 2>&1 | grep -q Query \
49 || echo "bare -n succeeded"
50 $XFS_IO_PROG -c "inode -nv" $TEST_DIR/file 2>&1 | grep -q Query \
51 || echo "bare -nv succeeded"
52 $XFS_IO_PROG -c "inode -n -v" $TEST_DIR/file 2>&1 | grep -q Query \
53 || echo "bare -n -v succeeded"
55 # These fail too, requires a valid inode number
56 $XFS_IO_PROG -c "inode badnumber" $TEST_DIR/file | grep -q numeric \
57 || echo "Bad inode number succeeded"
58 $XFS_IO_PROG -c "inode -v badnumber" $TEST_DIR/file | grep -q numeric \
59 || echo "Bad inode number succeeded"
60 $XFS_IO_PROG -c "inode -n badnumber" $TEST_DIR/file | grep -q numeric \
61 || echo "Bad inode number succeeded"
62 $XFS_IO_PROG -c "inode -nv badnumber" $TEST_DIR/file | grep -q numeric \
63 || echo "Bad inode number succeeded"
64 $XFS_IO_PROG -c "inode -n -v badnumber" $TEST_DIR/file | grep -q numeric \
65 || echo "Bad inode number succeeded"
67 # These should all work, and return $ROOT_INO or the next inode...
68 # grep out ROOT_INO (which is incorrect) when we should be getting next inode
69 $XFS_IO_PROG -c "inode $ROOT_INO" $TEST_DIR/file | \
70 sed -e s/$ROOT_INO/ROOT_INO/
71 $XFS_IO_PROG -c "inode -v $ROOT_INO" $TEST_DIR/file | \
72 sed -e s/$ROOT_INO/ROOT_INO/
73 $XFS_IO_PROG -c "inode -n $ROOT_INO" $TEST_DIR/file | \
74 grep -vw "^$ROOT_INO" | sed -e s/.*/NEXT/
75 $XFS_IO_PROG -c "inode -nv $ROOT_INO" $TEST_DIR/file | \
76 grep -vw "^$ROOT_INO" | sed -e s/.*:/NEXT:/
77 $XFS_IO_PROG -c "inode -n -v $ROOT_INO" $TEST_DIR/file | \
78 grep -vw "^$ROOT_INO" | sed -e s/.*:/NEXT:/
80 # Try one that doesn't exist, 2^64-2? Should get 0
81 $XFS_IO_PROG -c "inode 18446744073709551614" $TEST_DIR/file
82 $XFS_IO_PROG -c "inode -v 18446744073709551614" $TEST_DIR/file
83 $XFS_IO_PROG -c "inode -n 18446744073709551614" $TEST_DIR/file
84 $XFS_IO_PROG -c "inode -nv 18446744073709551614" $TEST_DIR/file
85 $XFS_IO_PROG -c "inode -n -v 18446744073709551614" $TEST_DIR/file