2011-10-03 23:01:18 +00:00
|
|
|
#! /bin/bash
|
2018-06-09 11:35:45 +10:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
# Copyright (c) 2011 SGI. All Rights Reserved.
|
|
|
|
|
#
|
2011-10-03 23:01:18 +00:00
|
|
|
# FS QA Test No. 261
|
|
|
|
|
#
|
|
|
|
|
# This test exercises an issue in libxcmd where a problem with any
|
|
|
|
|
# mount point or project quota directory causes the program to exit
|
|
|
|
|
# complete. The effect of this is that one cannot operate on any
|
|
|
|
|
# directory, even if the problem directory is completely unrelated
|
|
|
|
|
# to the directory one wants to operate on.
|
|
|
|
|
#
|
|
|
|
|
seq=$(basename $0)
|
2013-03-15 12:28:02 +00:00
|
|
|
seqres=$RESULT_DIR/$seq
|
2011-10-03 23:01:18 +00:00
|
|
|
echo "QA output created by ${seq}"
|
|
|
|
|
|
|
|
|
|
here=$(pwd)
|
|
|
|
|
|
|
|
|
|
tmp=/tmp/$$
|
|
|
|
|
my_mtab=${tmp}.mtab
|
|
|
|
|
|
|
|
|
|
mtab=/proc/self/mounts
|
|
|
|
|
|
|
|
|
|
status=1 # failure is the default!
|
|
|
|
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
|
|
|
|
|
|
|
|
|
_cleanup()
|
|
|
|
|
{
|
|
|
|
|
cd /
|
|
|
|
|
rm -f ${tmp}.*
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# get standard environment, filters and checks
|
2013-03-15 12:28:04 +00:00
|
|
|
. ./common/rc
|
|
|
|
|
. ./common/filter
|
|
|
|
|
. ./common/quota
|
2011-10-03 23:01:18 +00:00
|
|
|
|
|
|
|
|
echo "Silence is golden."
|
2016-05-09 16:03:27 +10:00
|
|
|
rm -f $seqres.full
|
2011-10-03 23:01:18 +00:00
|
|
|
|
|
|
|
|
# real QA test starts here
|
|
|
|
|
|
|
|
|
|
# Modify as appropriate.
|
|
|
|
|
_supported_fs xfs
|
|
|
|
|
|
|
|
|
|
_require_quota
|
|
|
|
|
_require_scratch
|
|
|
|
|
|
2019-03-19 17:46:01 -07:00
|
|
|
_scratch_mkfs >> $seqres.full 2>&1
|
|
|
|
|
|
2011-10-03 23:01:18 +00:00
|
|
|
# Just use the current mount table as an example mtab file. Odds
|
|
|
|
|
# are good there's nothing wrong with it.
|
|
|
|
|
_setup_my_mtab() {
|
|
|
|
|
cp "${mtab}" "${my_mtab}"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Any bogus entry in the mtab file is enough to trigger the problem.
|
|
|
|
|
# So just append a bogus entry at the end of the private mtab file.
|
|
|
|
|
# This matches an actually-observed entry in a mount table (with a
|
|
|
|
|
# few characters in the paths changed to protect the innocent).
|
|
|
|
|
_perturb_my_mtab() {
|
|
|
|
|
cat <<-! >> "${my_mtab}"
|
|
|
|
|
/dev/disk/by-id/scsi-3600508e000000000c329ba1d8b0c391b-part3 /tmp/autoY8qcJ9\040(deleted) xfs rw 0 0
|
|
|
|
|
!
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_check() {
|
|
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|
|
export MOUNT_OPTIONS=""
|
|
|
|
|
elif [ $# -eq 1 ]; then
|
|
|
|
|
[ $1 = u -o $1 = g -o $1 = p ] || exit
|
|
|
|
|
export MOUNT_OPTIONS="-o${1}quota"
|
|
|
|
|
else
|
|
|
|
|
exit
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
_qmount
|
|
|
|
|
|
|
|
|
|
# Set up a private mount table file, then try out a simple quota
|
|
|
|
|
# command to show mounts
|
|
|
|
|
_setup_my_mtab
|
|
|
|
|
echo print | xfs_quota -t "${my_mtab}" > /dev/null || exit
|
|
|
|
|
|
|
|
|
|
# Do the same simple quota command after adding a bogus entry to the
|
|
|
|
|
# mount table. Old code will bail on this because it has trouble
|
|
|
|
|
# with the bogus entry.
|
|
|
|
|
_perturb_my_mtab
|
|
|
|
|
echo print | xfs_quota -t "${my_mtab}" > /dev/null || exit
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#########
|
|
|
|
|
|
|
|
|
|
# Mount SCRATCH with no quota options
|
|
|
|
|
_check
|
|
|
|
|
|
|
|
|
|
# user quota enabled
|
|
|
|
|
_check u
|
|
|
|
|
|
|
|
|
|
# group quota enabled
|
|
|
|
|
_check g
|
|
|
|
|
|
|
|
|
|
# user quota enabled
|
|
|
|
|
_check p
|
|
|
|
|
|
|
|
|
|
status=0 # success, all done
|