overlay: test immutable and append-only upper files
[xfstests-dev.git] / tests / overlay / 030
1 #! /bin/bash
2 # FS QA Test No. 030
3 #
4 # Run the t_immutable test program for immutable/append-only files
5 # and directories in an overlayfs upper directory.
6 #
7 # This test is similar and was derived from generic/079, but
8 # the original test is _notrun on overlay mount because FS_IOC_GETFLAGS
9 # FS_IOC_SETFLAGS ioctls fail on overlay directory inodes.
10 #
11 #-----------------------------------------------------------------------
12 # Copyright (C) 2017 CTERA Networks. All Rights Reserved.
13 # Author: Amir Goldstein <amir73il@gmail.com>
14 #
15 # This program is free software; you can redistribute it and/or
16 # modify it under the terms of the GNU General Public License as
17 # published by the Free Software Foundation.
18 #
19 # This program is distributed in the hope that it would be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 # GNU General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write the Free Software Foundation,
26 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
27 #
28 #-----------------------------------------------------------------------
29 #
30
31 seq=`basename $0`
32 seqres=$RESULT_DIR/$seq
33 echo "QA output created by $seq"
34
35 here=`pwd`
36 timmutable=$here/src/t_immutable
37 upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
38 tmp=/tmp/$$
39 status=1        # failure is the default!
40 trap "_cleanup; exit \$status" 0 1 2 3 15
41
42 _cleanup()
43 {
44         $timmutable -r $upperdir/t_immutable &> /dev/null
45         rm -f $tmp.*
46 }
47
48 # get standard environment, filters and checks
49 . ./common/rc
50 . ./common/filter
51
52 _supported_fs overlay
53 _supported_os Linux
54
55 _require_chattr ia
56 _require_test_program "t_immutable"
57 _require_scratch
58
59 _scratch_mkfs
60
61 # Preparing immutable files in uppper dir
62 mkdir -p $upperdir
63 $timmutable -C $upperdir/t_immutable >$tmp.out 2>&1
64 if grep -q -e 'Operation not supported' -e "Inappropriate ioctl" $tmp.out; then
65         _notrun "Setting immutable/append flag not supported"
66 fi
67
68 _scratch_mount
69
70 # Test immutability of files in overlay
71 $timmutable $SCRATCH_MNT/t_immutable 2>&1
72 status=$?
73 exit