generic: test adding filesystem-level fscrypt key via key_id
[xfstests-dev.git] / tests / generic / 002
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2001 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 002
6 #
7 # simple inode link count test for a regular file
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 # get standard environment, filters and checks
14 . ./common/rc
15 . ./common/filter
16
17 tmp=/tmp/$$
18 here=`pwd`
19 status=0        # success is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21
22 _cleanup()
23 {
24     rm -f $tmp.*
25 }
26
27 # real QA test starts here
28 _supported_fs generic
29 _supported_os Linux
30 _require_test
31
32 rm -f $seqres.full
33
34 echo "Silence is goodness ..."
35
36 # ensure target directory exists
37 mkdir `dirname $TEST_DIR/$tmp` 2>/dev/null
38
39 touch $TEST_DIR/$tmp.1
40 for l in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
41 do
42     ln $TEST_DIR/$tmp.1 $TEST_DIR/$tmp.$l
43     x=`$here/src/lstat64 $TEST_DIR/$tmp.1 | sed -n -e '/ Links: /s/.*Links: *//p'`
44     if [ "$l" -ne $x ]
45     then
46         echo "Arrgh, created link #$l and lstat64 looks like ..."
47         $here/src/lstat64 $TEST_DIR/$tmp.1
48         status=1
49     fi
50 done
51
52 for l in 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
53 do
54     x=`$here/src/lstat64 $TEST_DIR/$tmp.1 | sed -n -e '/ Links: /s/.*Links: *//p'`
55     if [ "$l" -ne $x ]
56     then
57         echo "Arrgh, about to remove link #$l and lstat64 looks like ..."
58         $here/src/lstat64 $TEST_DIR/$tmp.1
59         status=1
60     fi
61     rm -f $TEST_DIR/$tmp.$l
62 done
63
64 # success, all done
65 exit