Make "new" script insert appropriate license on tests
[xfstests-dev.git] / 107
1 #! /bin/sh
2 # FS QA Test No. 107
3 #
4 # Project quota.
5 # Use of "sync" mount option here is an attempt to get deterministic
6 # allocator behaviour.
7 #
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2005 Silicon Graphics, Inc.  All Rights Reserved.
10 #
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
14 #
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
23 #
24 #-----------------------------------------------------------------------
25 #
26 # creator
27 owner=nathans@sgi.com
28
29 seq=`basename $0`
30 echo "QA output created by $seq"
31
32 here=`pwd`
33 tmp=/tmp/$$
34 status=1        # failure is the default!
35 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
36
37 # get standard environment, filters and checks
38 . ./common.rc
39 . ./common.filter
40 . ./common.quota
41
42 filter_xfs_quota()
43 {
44         perl -ne "
45 s,$target,[TARGET],;
46 s,$tmp.projects,[PROJECTS_FILE],;
47 s,$SCRATCH_MNT,[SCR_MNT],;
48 s,$SCRATCH_DEV,[SCR_DEV],;
49 s/Inode: \#\d+ \(0 blocks, 0 extents\)/Inode: #[INO] (0 blocks, 0 extents)/;
50 s/Inode: \#\d+ \(\d+ blocks, \d+ extents\)/Inode: #[INO] (X blocks, Y extents)/;
51         print;"
52 }
53
54 _supported_fs xfs
55 _supported_os Linux #IRIX
56 _require_scratch
57 _require_quota
58 _require_prjquota
59
60 # real QA test starts here
61 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
62 cat $tmp.mkfs >$seq.full
63 . $tmp.mkfs
64
65 # setup a default run
66 if [ -z "$MOUNT_OPTIONS" ]; then
67         export MOUNT_OPTIONS="-o pquota,sync"
68 else
69         export MOUNT_OPTIONS="$MOUNT_OPTIONS -o sync"
70 fi
71
72 _qmount
73 src/feature -p $SCRATCH_MNT && _notrun "Cannot run without project quota"
74
75 echo "### create projects file"
76 rm -f $tmp.projects
77 target=$SCRATCH_MNT/project
78 echo "6:$target" | tee -a $seq.full > $tmp.projects
79
80 echo "### populate filesystem"
81 mkdir $target           || exit
82 FSSTRESS_AVOID="$FSSTRESS_AVOID -fmknod=0 -fsymlink=0"
83 $FSSTRESS_PROG -s 0xfeed -m8 -w -p4 -n1000 $FSSTRESS_AVOID -d $target
84 $FSSTRESS_PROG -s 0xbabe -m8 -z -p4 -n500 -fsetxattr=250 -fchown=250 -d $target
85
86 QARGS="-x -D $tmp.projects -P /dev/null $SCRATCH_MNT"
87
88 echo "### initial report"
89 xfs_quota -c 'quot -p' -c 'quota -ip 6' $QARGS | filter_xfs_quota
90
91 echo "### check the project, should give warnings"
92 xfs_quota -c 'project -c 6' $QARGS | LC_COLLATE=POSIX sort | filter_xfs_quota
93
94 echo "### recursively setup the project"
95 xfs_quota -c 'project -s 6' $QARGS | LC_COLLATE=POSIX sort | filter_xfs_quota
96 xfs_quota -c 'quota -ip 6' $QARGS | filter_xfs_quota
97
98 echo "### check the project, should give no warnings now"
99 xfs_quota -c 'project -c 6' $QARGS | LC_COLLATE=POSIX sort | filter_xfs_quota
100
101 echo "### deny a hard link - wrong project ID"
102 rm -f $SCRATCH_MNT/outer $target/inner
103 $XFS_IO_PROG -f -c 'chproj 789' $SCRATCH_MNT/outer
104 ln $SCRATCH_MNT/outer $target/inner 2>/dev/null
105 if [ $? -eq 0 ]; then
106         echo hard link succeeded
107         ls -ld $SCRATCH_MNT/outer $target/inner
108 else
109         echo hard link failed
110 fi
111 xfs_quota -c 'quota -ip 6' $QARGS | filter_xfs_quota
112
113 echo "### allow a hard link - right project ID"
114 $XFS_IO_PROG -c 'chproj 6' $SCRATCH_MNT/outer
115 ln $SCRATCH_MNT/outer $target/inner
116 if [ $? -eq 0 ]; then
117         echo hard link succeeded
118 else
119         echo hard link failed
120         ls -ld $SCRATCH_MNT/outer $target/inner
121 fi
122 xfs_quota -c 'quota -ip 6' $QARGS | filter_xfs_quota
123
124 echo "### recursively clear the project"
125 xfs_quota -c 'project -C 6' $QARGS | LC_COLLATE=POSIX sort | filter_xfs_quota
126 #no output...
127 xfs_quota -c 'quota -ip 6' $QARGS | filter_xfs_quota
128
129 status=0
130 exit