common/quota: move _qsetup() helper to common code
authorChristian Brauner <christian.brauner@ubuntu.com>
Mon, 12 Apr 2021 11:57:06 +0000 (13:57 +0200)
committerEryu Guan <guaneryu@gmail.com>
Sun, 18 Apr 2021 12:53:53 +0000 (20:53 +0800)
It's already used in two tests and will be used in a third.

Cc: Eryu Guan <guan@eryu.me>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Darrick J. Wong <djwong@kernel.org>
Cc: fstests@vger.kernel.org
Suggested-by: Eryu Guan <guan@eryu.me>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
common/quota
tests/xfs/050
tests/xfs/299

index 1437d5f..32a9a55 100644 (file)
@@ -329,5 +329,25 @@ _report_quota_inodes() {
        repquota $1 | egrep "^($qa_user|root|nobody)" | awk '{print $1, $6, $7, $8}' | sort -r
 }
 
+# Determine which type of quota we're using
+_qsetup()
+{
+       opt=$1
+       enforce=0
+       if [ $opt = "u" -o $opt = "uno" ]; then
+               type=u
+               eval `_choose_uid`
+       elif [ $opt = "g" -o $opt = "gno" ]; then
+               type=g
+               eval `_choose_gid`
+       elif [ $opt = "p" -o $opt = "pno" ]; then
+               type=p
+               eval `_choose_prid`
+       fi
+       [ $opt = "u" -o $opt = "g" -o $opt = "p" ] && enforce=1
+
+       echo "Using type=$type id=$id" >> $seqres.full
+}
+
 # make sure this script returns success
 /bin/true
index 1df9753..e7c81d0 100755 (executable)
@@ -69,25 +69,6 @@ _filter_and_check_blks()
        ' | _filter_quota_report
 }
 
-_qsetup()
-{
-       opt=$1
-       enforce=0
-       if [ $opt = "u" -o $opt = "uno" ]; then
-               type=u
-               eval `_choose_uid`
-       elif [ $opt = "g" -o $opt = "gno" ]; then
-               type=g
-               eval `_choose_gid`
-       elif [ $opt = "p" -o $opt = "pno" ]; then
-               type=p
-               eval `_choose_prid`
-       fi
-       [ $opt = "u" -o $opt = "g" -o $opt = "p" ] && enforce=1
-
-       echo "Using type=$type id=$id" >> $seqres.full
-}
-
 _exercise()
 {
        _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
index b862e67..26b7fcf 100755 (executable)
@@ -62,25 +62,6 @@ _filter_and_check_blks()
        ' | _filter_quota_report
 }
 
-_qsetup()
-{
-       opt=$1
-       enforce=0
-       if [ $opt = "u" -o $opt = "uno" ]; then
-               type=u
-               eval `_choose_uid`
-       elif [ $opt = "g" -o $opt = "gno" ]; then
-               type=g
-               eval `_choose_gid`
-       elif [ $opt = "p" -o $opt = "pno" ]; then
-               type=p
-               eval `_choose_prid`
-       fi
-       [ $opt = "u" -o $opt = "g" -o $opt = "p" ] && enforce=1
-
-       echo "Using type=$type id=$id" >> $seqres.full
-}
-
 _exercise()
 {