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