fstests: convert remaining tests to SPDX license tags
[xfstests-dev.git] / tests / generic / 477
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2018 CTERA Networks. All Rights Reserved.
4 #
5 # FS QA Test No. 477
6 #
7 # Check open by file handle after cycle mount.
8 #
9 # This test uses load and store of file handles from a temp file to test
10 # decoding file handles after cycle mount and after directory renames.
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23         cd /
24         rm -f $tmp.*
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30
31 # real QA test starts here
32
33 # Modify as appropriate.
34 _supported_fs generic
35 _supported_os Linux
36 _require_test
37 # _require_exportfs already requires open_by_handle, but let's not count on it
38 _require_test_program "open_by_handle"
39 _require_exportfs
40
41 NUMFILES=10
42 testroot=$TEST_DIR/$seq-dir
43 testdir=$testroot/testdir
44
45 # Create test dir and test files, encode file handles and store to tmp file
46 create_test_files()
47 {
48         rm -rf $testdir
49         mkdir -p $testdir
50         $here/src/open_by_handle -cwp -o $tmp.handles_file $testdir $NUMFILES
51 }
52
53 # Decode file handles loaded from tmp file
54 test_file_handles()
55 {
56         local opt=$1
57         local when=$2
58
59         echo test_file_handles after $when
60         $here/src/open_by_handle $opt -i $tmp.handles_file $TEST_DIR $NUMFILES
61 }
62
63 # Decode file handles of files/dir after cycle mount
64 create_test_files
65 _test_cycle_mount
66 test_file_handles -rp "cycle mount"
67
68 # Decode file handles of files/dir after rename of parent and cycle mount
69 create_test_files $testdir
70 rm -rf $testdir.renamed
71 mv $testdir $testdir.renamed/
72 _test_cycle_mount
73 test_file_handles -rp "rename parent"
74
75 # Decode file handles of files/dir after rename of grandparent and cycle mount
76 create_test_files $testdir
77 rm -rf $testroot.renamed
78 mv $testroot $testroot.renamed/
79 _test_cycle_mount
80 test_file_handles -rp "rename grandparent"
81
82 # Decode file handles of files/dir after move to new parent and cycle mount
83 create_test_files $testdir
84 rm -rf $testdir.new
85 mkdir -p $testdir.new
86 mv $testdir/* $testdir.new/
87 _test_cycle_mount
88 test_file_handles -r "move to new parent"
89
90 status=0
91 exit