2 ################################################################################
4 ## Copyright (c) Jan Kara <jack@suse.cz>, 2008 ##
5 ## Copyright (c) International Business Machines Corp., 2009 ##
7 ## This program is free software; you can redistribute it and#or modify ##
8 ## it under the terms of the GNU General Public License as published by ##
9 ## the Free Software Foundation; either version 2 of the License, or ##
10 ## (at your option) any later version. ##
12 ## This program is distributed in the hope that it will be useful, but ##
13 ## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
14 ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ##
15 ## for more details. ##
17 ## You should have received a copy of the GNU General Public License ##
18 ## along with this program; if not, write to the Free Software ##
19 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ##
21 ################################################################################
23 # File : quota_remount_test01.sh ##
25 # Description: Test whether kernel properly supports remounting read-only ##
26 # with quota. This feature was added in kernel 2.6.26. Please ##
27 # see: http://kernelnewbies.org/Linux_2_6_26, and ##
28 # http://git.kernel.org/git/?p=linux/kernel/git/torvalds/ ##
29 # linux-2.6.git;a=commit; ##
30 # h=0ff5af8340aa6be44220d7237ef4a654314cf795 ##
33 # Author: Jan Kara <jack@suse.cz>, ##
35 # History: Sep 18 2008 - Created - Jan Kara <jack@suse.cz>. ##
36 # Feb 17 2009 - Ported to LTP, ##
37 # Subrata Modak <subrata@linux.vnet.ibm.com> ##
38 ################################################################################
40 export TCID
=quota_remount_test01
54 read MAJOR MINOR RELEASE REST
55 if [ "$MAJOR" -lt 2 -o "$MINOR" -lt 6 -o "$RELEASE" -lt 26 ]; then
60 tst_resm TCONF
"Remounting with quotas enabled is not supported!"
61 tst_resm TCONF
"You should have kernel 2.6.26 and above running....."
65 if [ ! -d /proc
/sys
/fs
/quota
]; then
66 tst_resm TCONF
"Quota not supported in kernel!"
73 umount
2>/dev
/null
$MNTDIR
75 rmdir 2>/dev
/null
$MNTDIR
76 tst_resm TFAIL
"Quota on Remount Failed"
80 cd $TMPDIR || die
2 "Cannot cd to $TMPDIR"
82 dd if=/dev
/zero of
=$IMAGE bs
=4096 count
=8000 2>/dev
/null || die
2 "Cannot create filesystem image"
83 mkfs.ext3
-q -F -b 4096 $IMAGE || die
2 "Could not create the filesystem"
84 mkdir
$MNTDIR || die
2 "Could not create the mountpoint"
85 mount
-t ext3
-o loop
,usrquota
,grpquota
$IMAGE $MNTDIR || die
2 "Could not mount the filesystem"
86 tst_resm TINFO
"Successfully mounted the File System"
88 quotacheck
-cug $MNTDIR || die
2 "Could not create quota files"
89 tst_resm TINFO
"Successfully Created Quota Files"
91 quotaon
-ug $MNTDIR || die
2 "Could not turn quota on"
92 tst_resm TINFO
"Successfully Turned on Quota"
94 echo "blah" >$MNTDIR/file || die
2 "Could not write to the filesystem"
95 tst_resm TINFO
"Successfully wrote to the filesystem"
97 # Get current quota usage
98 BLOCKS
=`quota -f $MNTDIR -v -w | tail -n 1 | sed -e 's/ *[^ ]* *\([0-9]*\) .*/\1/'`
99 mount
-o remount
,ro
$MNTDIR || die
1 "Could not remount read-only"
100 tst_resm TINFO
"Successfully Remounted Read-Only FS"
102 mount
-o remount
,rw
$MNTDIR || die
2 "Could not remount read-write"
103 tst_resm TINFO
"Successfully Remounted Read-Write FS"
106 # Get quota usage after removing the file
107 NEWBLOCKS
=`quota -f $MNTDIR -v -w | tail -n 1 | sed -e 's/ *[^ ]* *\([0-9]*\) .*/\1/'`
108 # Has quota usage changed properly?
109 if [ $BLOCKS -eq $NEWBLOCKS ]; then
110 die
1 "Usage did not change after remount"
112 tst_resm TINFO
"Usage successfully Changed after Remount"
113 tst_resm TPASS
"Quota on Remount Successfull"
115 umount
$MNTDIR || die
2 "Could not umount $MNTDIR"
116 rmdir $MNTDIR || die
2 "Could not remove $MNTDIR"