From patchwork Mon Mar 22 13:45:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 12154805 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBEECC433E6 for ; Mon, 22 Mar 2021 13:46:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C43FF6198C for ; Mon, 22 Mar 2021 13:46:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229730AbhCVNqI (ORCPT ); Mon, 22 Mar 2021 09:46:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:43600 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230227AbhCVNpp (ORCPT ); Mon, 22 Mar 2021 09:45:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 95E406198E; Mon, 22 Mar 2021 13:45:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616420745; bh=l4CephtTVHAvv5/9U+NlFEDUCkIpBFB3jtEKohhgrOg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K+R5acy/6OIYM1IrmjzGEWWLA7mrlplpUX/5LMNtl4pEfo8e1L4sLzTqoxkuS5a1G +XeBWE5cqTtCxw6nhfhCcZtliIZmmsv6VfyAZwl6GaOIZNFWhnzpKv1Z8xH2W9iISz kv/yxEsoiD3IG0ZyUaKQR8QQnEzq+2zgdIymdyoAIcoWzm9LIFafICSwmRw5hjkAw7 gFyOxg/W2zUBHjExMO5LOh0Ux1dLYWT0i9zVw/cTMuxNpojzhEnfZXWbKuLWPMd6nX ZCzuqOsW7avankJEbJ2E16uNDCOARAFT4BXm+/O8QarnemPX8MMv0dRmsSLY5ehCBH aEtR2Ha8U0HEQ== From: Christian Brauner To: Eryu Guan , fstests@vger.kernel.org, Christoph Hellwig Cc: "Darrick J . Wong" , David Howells , Christian Brauner Subject: [PATCH v10 4/6] common/quota: move _qsetup() helper to common code Date: Mon, 22 Mar 2021 14:45:20 +0100 Message-Id: <20210322134522.916512-5-brauner@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210322134522.916512-1-brauner@kernel.org> References: <20210322134522.916512-1-brauner@kernel.org> MIME-Version: 1.0 X-Patch-Hashes: v=1; h=sha256; i=wM9Q2AdFuvVYmj1+BgTxu13NVAXYIAuRDfZKkOg26xw=; m=G9up2oLwo++96UH6tgmgi4o4ese0pNaEOzVzPn2cm5o=; p=WU5/GGIh2yNDrbksNUPmm2Bl9QB12TJxW4HV+CzVmqw=; g=03a67e8d3f5d58609a3b5e24479cc8492106b35a X-Patch-Sig: m=pgp; i=christian.brauner@ubuntu.com; s=0x0x91C61BC06578DCA2; b=iHUEABYKAB0WIQRAhzRXHqcMeLMyaSiRxhvAZXjcogUCYFifaAAKCRCRxhvAZXjcovUTAP4nfHn ESghLwhfn75hGSROLLqPcZkyLETcOzpDGk8AgIgEA5QfztQMzkqhrq4z8u+V5DGDzZvj1nBlKd3aq CG2MvgM= Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org From: Christian Brauner It's already used in two tests and will be used in a third. Cc: Eryu Guan Cc: Christoph Hellwig Cc: Darrick J. Wong Cc: fstests@vger.kernel.org Suggested-by: Eryu Guan Signed-off-by: Christian Brauner --- common/quota | 20 ++++++++++++++++++++ tests/xfs/050 | 19 ------------------- tests/xfs/299 | 19 ------------------- 3 files changed, 20 insertions(+), 38 deletions(-) diff --git a/common/quota b/common/quota index 1437d5f7..32a9a555 100644 --- a/common/quota +++ b/common/quota @@ -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 diff --git a/tests/xfs/050 b/tests/xfs/050 index 1df97537..e7c81d0a 100755 --- a/tests/xfs/050 +++ b/tests/xfs/050 @@ -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 diff --git a/tests/xfs/299 b/tests/xfs/299 index b862e67e..26b7fcfd 100755 --- a/tests/xfs/299 +++ b/tests/xfs/299 @@ -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() {