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