lib/: spdx license conversion
[xfstests-dev.git] / tests / shared / 001
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Red Hat Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 001
6 #
7 # Test truncate orphan inodes when mounting extN.
8 # ext4 used to hit WARNING, this commit fixed the issue
9 #
10 # 721e3eb ext4: lock i_mutex when truncating orphan inodes
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 _supported_fs ext2 ext3 ext4
33 _supported_os Linux
34 _require_scratch
35
36 rm -f $seqres.full
37 echo "Silence is golden"
38
39 _scratch_mkfs_sized $((16*1024*1024)) >>$seqres.full 2>&1
40 _scratch_mount
41
42 # create a file and get its inode number, usually it's 12, but to be accurate
43 testfile=$SCRATCH_MNT/testfile
44 touch $testfile
45 inode=`ls -i $testfile | awk '{print $1}'`
46
47 # add the inode in orphan inode list
48 _scratch_unmount
49 debugfs -w -R "set_super_value last_orphan $inode" $SCRATCH_DEV \
50         >>$seqres.full 2>&1
51
52 # mount again to truncate orphan inode, _check_dmesg will catch the WARNING
53 _scratch_mount
54
55 status=0
56 exit