@@ -274,7 +274,7 @@ _choose_prid()
_qmount()
{
- _scratch_unmount >/dev/null 2>&1
+ _scratch_unmount
_try_scratch_mount || _fail "qmount failed"
# xfs doesn't need these setups and quotacheck even fails on xfs
# redirect the output to $seqres.full for debug purpose and ignore results
@@ -432,39 +432,18 @@ _create_project_quota()
mkdir $prjdir
chmod ugo+rwx $prjdir
- if [ -f /etc/projects -a ! -f $tmp.projects.bk ];then
- cat /etc/projects > $tmp.projects.bk
- echo >/etc/projects
- fi
- if [ -f /etc/projid -a ! -f $tmp.projid.bk ];then
- cat /etc/projid > $tmp.projid.bk
- echo >/etc/projid
- fi
-
- cat >>/etc/projects <<EOF
-$id:$prjdir
-EOF
- cat >>/etc/projid <<EOF
-$name:$id
-EOF
+ echo "$id:$prjdir" >> /etc/project
+ echo "$name:$id" >> /etc/projid
$XFS_IO_PROG -r -c "chproj $id" -c "chattr +P" $prjdir
}
# If you've called _create_project_quota, then use this function in _cleanup
_restore_project_quota()
{
- if [ -f $tmp.projects.bk ];then
- cat $tmp.projects.bk > /etc/projects && \
- rm -f $tmp.projects.bk
- else
- rm -f /etc/projects
- fi
- if [ -f $tmp.projid.bk ];then
- cat $tmp.projid.bk > /etc/projid && \
- rm -f $tmp.projid.bk
- else
- rm -f /etc/projid
- fi
+ local id=$1
+
+ sed -i "/^$id:/d" /etc/project
+ sed -i "/:$id$/d" /etc/projid
}
# make sure this script returns success
@@ -10,10 +10,12 @@
. ./common/preamble
_begin_fstest auto quick quota
+projid=$seq
+
# Override the default cleanup function.
_cleanup()
{
- _restore_project_quota
+ _restore_project_quota $projid
cd /
rm -f $tmp.*
}
@@ -122,8 +124,8 @@ _require_prjquota $SCRATCH_DEV
BLOCK_SIZE=$(_get_file_block_size $SCRATCH_MNT)
rm -rf $SCRATCH_MNT/t
mkdir $SCRATCH_MNT/t
-$XFS_IO_PROG -r -c "chproj 100" -c "chattr +P" $SCRATCH_MNT/t
-_create_project_quota $SCRATCH_MNT/t 100 $qa_user
+$XFS_IO_PROG -r -c "chproj $projid" -c "chattr +P" $SCRATCH_MNT/t
+_create_project_quota $SCRATCH_MNT/t $projid $qa_user
echo "### Set up different grace timers to each type of quota"
UBGRACE=12
@@ -16,10 +16,12 @@
. ./common/preamble
_begin_fstest auto quota
+projid=$seq
+
# Override the default cleanup function.
_cleanup()
{
- _restore_project_quota
+ _restore_project_quota $projid
cd /
rm -r -f $tmp.*
}
@@ -65,7 +67,7 @@ exercise()
fi
_qmount
if [ "$type" = "P" ];then
- _create_project_quota $SCRATCH_MNT/t 100 $qa_user
+ _create_project_quota $SCRATCH_MNT/t $projid $qa_user
file=$SCRATCH_MNT/t/testfile
fi