generic/611: Use _getfattr instead of GETFATTR_PROG
[xfstests-dev.git] / tests / generic / 426
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2017 CTERA Networks. All Rights Reserved.
4 #
5 # FS QA Test No. 426
6 #
7 # Check stale handles pointing to unlinked files
8 # and non-stale handles pointing to linked files
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         rm -f $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28
29 # real QA test starts here
30
31 # Modify as appropriate.
32 _supported_fs generic
33 _require_test
34 # _require_exportfs already requires open_by_handle, but let's not count on it
35 _require_test_program "open_by_handle"
36 _require_exportfs
37
38 NUMFILES=1024
39 testdir=$TEST_DIR/$seq-dir
40 mkdir -p $testdir
41
42 # Create empty test files in test dir
43 create_test_files()
44 {
45         local dir=$1
46         local opt=$2
47
48         mkdir -p $dir
49         rm -f $dir/*
50         $here/src/open_by_handle -c $dir $NUMFILES
51 }
52
53 # Test encode/decode file handles
54 test_file_handles()
55 {
56         local dir=$1
57         local opt=$2
58
59         echo test_file_handles $* | _filter_test_dir
60         $here/src/open_by_handle $opt $dir $NUMFILES
61 }
62
63 # Check stale handles to deleted files
64 create_test_files $testdir
65 test_file_handles $testdir -d
66
67 # Check non-stale handles to linked files
68 create_test_files $testdir
69 test_file_handles $testdir
70
71 # Check non-stale handles to files that were hardlinked and original deleted
72 create_test_files $testdir
73 test_file_handles $testdir -l
74 test_file_handles $testdir -u
75
76 status=0
77 exit