generic/554: hide permision warning on exfat
[xfstests-dev.git] / tests / generic / 467
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. 467
6 #
7 # Check open by file handle.
8 # This is a variant of test generic/426 that tests with less
9 # files and more use cases:
10 # - open directory by file handle
11 # - verify content integrity of file after opening by file handle
12 # - open by file handle of unlinked open files
13 # - open by file handle of renamed files
14 #
15 seq=`basename $0`
16 seqres=$RESULT_DIR/$seq
17 echo "QA output created by $seq"
18
19 here=`pwd`
20 tmp=/tmp/$$
21 status=1        # failure is the default!
22 trap "_cleanup; exit \$status" 0 1 2 3 15
23
24 _cleanup()
25 {
26         cd /
27         rm -f $tmp.*
28 }
29
30 # get standard environment, filters and checks
31 . ./common/rc
32 . ./common/filter
33
34 # real QA test starts here
35
36 # Modify as appropriate.
37 _supported_fs generic
38 _require_test
39 # _require_exportfs already requires open_by_handle, but let's not count on it
40 _require_test_program "open_by_handle"
41 _require_exportfs
42
43 NUMFILES=10
44 testdir=$TEST_DIR/$seq-dir
45
46 # Create test dir and non-empty test files
47 create_test_files()
48 {
49         local dir=$1
50         local opt=$2
51
52         rm -rf $dir
53         $here/src/open_by_handle -cwp $dir $NUMFILES
54 }
55
56 # Test encode/decode file handles
57 test_file_handles()
58 {
59         local dir=$1
60         local opt=$2
61
62         echo test_file_handles $* | _filter_test_dir
63         $here/src/open_by_handle $opt $dir $NUMFILES
64 }
65
66 # Check stale handles to deleted files/dir
67 create_test_files $testdir
68 test_file_handles $testdir -dp
69
70 # Check non-stale handles to linked files/dir
71 create_test_files $testdir
72 test_file_handles $testdir -rp
73
74 # Check non-stale handles to unlinked open files
75 create_test_files $testdir
76 test_file_handles $testdir -dkr
77
78 # Check non-stale handles to files that were hardlinked and original deleted
79 create_test_files $testdir
80 test_file_handles $testdir -lr
81 test_file_handles $testdir -ur
82
83 # Check non-stale file handles of renamed files
84 create_test_files $testdir
85 test_file_handles $testdir -mr
86
87 # Check non-stale file handles after rename of parent
88 create_test_files $testdir
89 rm -rf $testdir.renamed
90 mv $testdir $testdir.renamed/
91 test_file_handles $testdir.renamed -rp
92
93 # Check non-stale file handles after move to new parent
94 create_test_files $testdir
95 rm -rf $testdir.new
96 mkdir -p $testdir.new
97 mv $testdir/* $testdir.new/
98 test_file_handles $testdir.new -rp
99
100 status=0
101 exit