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 _begin_fstest auto quick
12 # Import common functions.
15 # real QA test starts here
17 # Modify as appropriate.
20 _require_xfs_io_command "inode"
22 # We know the root inode is there
23 ROOT_INO=`ls -id $TEST_DIR | awk '{print $1}'`
27 $XFS_IO_PROG -c "inode" $TEST_DIR/file
28 $XFS_IO_PROG -c "inode -v" $TEST_DIR/file | \
29 grep -vw "^$ROOT_INO" | sed -e s/.*:/LAST:/
31 # These should fail, -n requires an inode
32 $XFS_IO_PROG -c "inode -n" $TEST_DIR/file 2>&1 | grep -q Query \
33 || echo "bare -n succeeded"
34 $XFS_IO_PROG -c "inode -nv" $TEST_DIR/file 2>&1 | grep -q Query \
35 || echo "bare -nv succeeded"
36 $XFS_IO_PROG -c "inode -n -v" $TEST_DIR/file 2>&1 | grep -q Query \
37 || echo "bare -n -v succeeded"
39 # These fail too, requires a valid inode number
40 $XFS_IO_PROG -c "inode badnumber" $TEST_DIR/file | grep -q numeric \
41 || echo "Bad inode number succeeded"
42 $XFS_IO_PROG -c "inode -v badnumber" $TEST_DIR/file | grep -q numeric \
43 || echo "Bad inode number succeeded"
44 $XFS_IO_PROG -c "inode -n badnumber" $TEST_DIR/file | grep -q numeric \
45 || echo "Bad inode number succeeded"
46 $XFS_IO_PROG -c "inode -nv badnumber" $TEST_DIR/file | grep -q numeric \
47 || echo "Bad inode number succeeded"
48 $XFS_IO_PROG -c "inode -n -v badnumber" $TEST_DIR/file | grep -q numeric \
49 || echo "Bad inode number succeeded"
51 # These should all work, and return $ROOT_INO or the next inode...
52 # grep out ROOT_INO (which is incorrect) when we should be getting next inode
53 $XFS_IO_PROG -c "inode $ROOT_INO" $TEST_DIR/file | \
54 sed -e s/$ROOT_INO/ROOT_INO/
55 $XFS_IO_PROG -c "inode -v $ROOT_INO" $TEST_DIR/file | \
56 sed -e s/$ROOT_INO/ROOT_INO/
57 $XFS_IO_PROG -c "inode -n $ROOT_INO" $TEST_DIR/file | \
58 grep -vw "^$ROOT_INO" | sed -e s/.*/NEXT/
59 $XFS_IO_PROG -c "inode -nv $ROOT_INO" $TEST_DIR/file | \
60 grep -vw "^$ROOT_INO" | sed -e s/.*:/NEXT:/
61 $XFS_IO_PROG -c "inode -n -v $ROOT_INO" $TEST_DIR/file | \
62 grep -vw "^$ROOT_INO" | sed -e s/.*:/NEXT:/
64 # Try one that doesn't exist, 2^64-2? Should get 0
65 $XFS_IO_PROG -c "inode 18446744073709551614" $TEST_DIR/file
66 $XFS_IO_PROG -c "inode -v 18446744073709551614" $TEST_DIR/file
67 $XFS_IO_PROG -c "inode -n 18446744073709551614" $TEST_DIR/file
68 $XFS_IO_PROG -c "inode -nv 18446744073709551614" $TEST_DIR/file
69 $XFS_IO_PROG -c "inode -n -v 18446744073709551614" $TEST_DIR/file