From patchwork Thu May 16 10:47:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yang Xu X-Patchwork-Id: 1100476 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=cn.fujitsu.com Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 454Smg50ssz9s7h for ; Thu, 16 May 2019 20:47:31 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 8E5353EA37A for ; Thu, 16 May 2019 12:47:27 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [IPv6:2001:4b78:1:20::4]) by picard.linux.it (Postfix) with ESMTP id D6BFB3EA0B7 for ; Thu, 16 May 2019 12:47:24 +0200 (CEST) Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by in-4.smtp.seeweb.it (Postfix) with ESMTP id 4CEB61000DF4 for ; Thu, 16 May 2019 12:47:18 +0200 (CEST) X-IronPort-AV: E=Sophos; i="5.60,476,1549900800"; d="scan'208,223"; a="63325693" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 16 May 2019 18:47:18 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id B8C994CDAD75; Thu, 16 May 2019 18:47:18 +0800 (CST) Received: from [10.167.215.30] (10.167.215.30) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.439.0; Thu, 16 May 2019 18:47:17 +0800 Message-ID: <5CDD3FB4.50502@cn.fujitsu.com> Date: Thu, 16 May 2019 18:47:16 +0800 From: xuyang User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11 MIME-Version: 1.0 To: X-Originating-IP: [10.167.215.30] X-yoursite-MailScanner-ID: B8C994CDAD75.A0C78 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: xuyang2018.jy@cn.fujitsu.com X-Spam-Status: No, score=0.0 required=7.0 tests=none autolearn=disabled version=3.4.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-4.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-4.smtp.seeweb.it Subject: [LTP] increase quotactl01.c coverage X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Hi Current, most distros enable QFMT_V2([1]) and disable QFMT_V1. So when we run quotaclt01.c ,it uses quota_v2 (format id 2, /mntpoint/aquota.user,/mointpoint/aquota.group) But if we enable CONFIG_QFMT_V2 and CONFIG_QFMT_V1 in kernel, the following combinations also take effect and succeed. 1. format id 1(QFMT_VFS_OLD), /mntpoint/quota.user,/mointpoint/quota.group,using quotacheck -ug --format=vfsold 2. format id 2(QFMT_VFS_V0), /mntpoint/aquota.user,/mointpoint/aquota.group,using quotacheck -ug --format=vfsv0 3. format id 4(QFMT_VFS_V1), /mntpoint/aquota.user,/mointpoint/aquota.group,using quotacheck -ug --format=vfsv1 But I don't find a good way to test the above three format in quotaclt01.c . Does anyone have a good way? By the way, I think ltp-quota.m4 can be rewrite or remove because it is confused. I think we can only check Q_GETINFO and sys/quota.h in ltp-quota.m4. If someone is interested in this case, you can use this attached patch. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/quota/Kconfig From a493d84c0085fb87d747bebec08ee014e32fc81a Mon Sep 17 00:00:00 2001 From: Yang Xu Date: Thu, 16 May 2019 18:35:19 +0800 Subject: [PATCH] syscalls/quotactl01.c: add vfsold and vfsv1 format check Signed-off-by: Yang Xu --- m4/ltp-quota.m4 | 29 ++-------- .../kernel/syscalls/quotactl/quotactl01.c | 54 ++++++++----------- 2 files changed, 27 insertions(+), 56 deletions(-) diff --git a/m4/ltp-quota.m4 b/m4/ltp-quota.m4 index a25e34a83..5618c769e 100644 --- a/m4/ltp-quota.m4 +++ b/m4/ltp-quota.m4 @@ -20,9 +20,10 @@ dnl dnl LTP_CHECK_SYSCALL_QUOTACTL dnl ---------------------------- dnl -AC_DEFUN([LTP_CHECK_SYSCALL_QUOTACTL],[dnl +AC_DEFUN([LTP_CHECK_SYSCALL_QUOTACTL],[ +AC_CHECK_HEADERS([sys/quota.h],[quota_header_prefix="sys"]) +if test "x$quota_header_prefix" != x; then AC_LINK_IFELSE([AC_LANG_SOURCE([ -#define _LINUX_QUOTA_VERSION 2 #include #include #include @@ -31,28 +32,8 @@ int main(void) { return quotactl(QCMD(Q_GETINFO, USRQUOTA), (const char *) "/dev/null", geteuid(), (caddr_t) &dq); }])],[has_quotav2="yes"]) - +fi if test "x$has_quotav2" = xyes; then - AC_DEFINE(HAVE_QUOTAV2,1,[Define to 1 if you have quota v2]) -else - - # got quota v1? - AC_LINK_IFELSE([AC_LANG_SOURCE([ -#define _LINUX_QUOTA_VERSION 1 -#include -#include -#include -int main(void) { - struct dqblk dq; - return quotactl(QCMD(Q_GETQUOTA, USRQUOTA), (const char *) "/dev/null", - geteuid(), (caddr_t) &dq); -}])],[has_quotav1="yes"]) - - if test "x$has_quotav1" = xyes; then - AC_DEFINE(HAVE_QUOTAV1,1,[Define to 1 if you have quota v1]) - else - AC_MSG_WARN(Couldn't determine quota version (please submit config.log and manpage to ltp@lists.linux.it)) - fi - + AC_DEFINE(HAVE_QUOTA_Q_GETINFO,1,[Define to 1 if you have quota Q_GETINFO]) fi ]) diff --git a/testcases/kernel/syscalls/quotactl/quotactl01.c b/testcases/kernel/syscalls/quotactl/quotactl01.c index 92b654eba..7c5a1c401 100644 --- a/testcases/kernel/syscalls/quotactl/quotactl01.c +++ b/testcases/kernel/syscalls/quotactl/quotactl01.c @@ -55,44 +55,29 @@ #include "tst_test.h" -#if defined(HAVE_QUOTAV2) || defined(HAVE_QUOTAV1) -# include - -# if defined(HAVE_QUOTAV2) -# define _LINUX_QUOTA_VERSION 2 -# ifndef QFMT_VFS_V0 -# define QFMT_VFS_V0 2 -# endif -# define USRPATH MNTPOINT "/aquota.user" -# define GRPPATH MNTPOINT "/aquota.group" -# define FMTID QFMT_VFS_V0 -# else -# define _LINUX_QUOTA_VERSION 1 -# ifndef QFMT_VFS_OLD -# define QFMT_VFS_OLD 1 -# endif -# define USRPATH MNTPOINT "/quota.user" -# define GRPPATH MNTPOINT "/quota.group" -# define FMTID QFMT_VFS_OLD -# endif +#if HAVE_SYS_QUOTA_H +#include -# define MNTPOINT "mntpoint" +#define MNTPOINT "mntpoint" -static int32_t fmt_id = FMTID; +char USRPATH[32]; +char GRPPATH[32]; +static int32_t fmt_id; static int test_id; static struct dqblk set_dq = { .dqb_bsoftlimit = 100, .dqb_valid = QIF_BLIMITS }; static struct dqblk res_dq; -# if defined(HAVE_QUOTAV2) + +# if HAVE_QUOTA_Q_GETINFO static struct dqinfo set_qf = { .dqi_bgrace = 80, .dqi_valid = IIF_BGRACE }; static struct dqinfo res_qf; static int32_t fmt_buf; -# endif +#endif static struct tcase { int cmd; @@ -112,7 +97,7 @@ static struct tcase { {QCMD(Q_GETQUOTA, USRQUOTA), &test_id, &res_dq, &set_dq.dqb_bsoftlimit, &res_dq.dqb_bsoftlimit, sizeof(res_dq.dqb_bsoftlimit), "get disk quota limit for user"}, -# if defined(HAVE_QUOTAV2) +# if HAVE_QUOTA_Q_GETINFO {QCMD(Q_SETINFO, USRQUOTA), &test_id, &set_qf, NULL, NULL, 0, "set information about quotafile for user"}, @@ -139,7 +124,7 @@ static struct tcase { {QCMD(Q_GETQUOTA, GRPQUOTA), &test_id, &res_dq, &set_dq.dqb_bsoftlimit, &res_dq.dqb_bsoftlimit, sizeof(res_dq.dqb_bsoftlimit), "set disk quota limit for group"}, -# if defined(HAVE_QUOTAV2) +# if HAVE_QUOTA_Q_GETINFO {QCMD(Q_SETINFO, GRPQUOTA), &test_id, &set_qf, NULL, NULL, 0, "set information about quotafile for group"}, @@ -159,18 +144,22 @@ static struct tcase { static void setup(void) { - const char *const cmd[] = {"quotacheck", "-ug", MNTPOINT, NULL}; + const char *const cmd[] = {"quotacheck", "-ug", "--format=vfsv0", MNTPOINT, NULL}; int ret; - ret = tst_run_cmd(cmd, NULL, NULL, 1); switch (ret) { case 255: - tst_brk(TCONF, "quotacheck binary not installed"); + tst_brk(TBROK, "quotacheck binary not installed"); + case 0: + sprintf(USRPATH, "%s/aquota.user", MNTPOINT); + sprintf(GRPPATH, "%s/aquota.group", MNTPOINT); + fmt_id = 2; + tst_res(TINFO, "%s %s %d", USRPATH, GRPPATH, fmt_id); + break; default: tst_brk(TBROK, "quotacheck exited with %i", ret); - case 0: - break; + break; } test_id = geteuid(); @@ -187,9 +176,10 @@ static void verify_quota(unsigned int n) struct tcase *tc = &tcases[n]; res_dq.dqb_bsoftlimit = 0; +# if HAVE_QUOTA_Q_GETINFO res_qf.dqi_igrace = 0; fmt_buf = 0; - +#endif TEST(quotactl(tc->cmd, tst_device->dev, *tc->id, tc->addr)); if (TST_RET == -1) { tst_res(TFAIL | TTERRNO, "quotactl failed to %s", tc->des);