From patchwork Tue Aug 23 16:40:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill O'Donnell X-Patchwork-Id: 9295953 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1A1FC607F0 for ; Tue, 23 Aug 2016 16:40:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0ACE528C92 for ; Tue, 23 Aug 2016 16:40:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F3A6E28CBF; Tue, 23 Aug 2016 16:40:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from oss.sgi.com (oss.sgi.com [192.48.182.195]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7D0AA28C92 for ; Tue, 23 Aug 2016 16:40:45 +0000 (UTC) Received: from oss.sgi.com (localhost [IPv6:::1]) by oss.sgi.com (Postfix) with ESMTP id D20257CA2; Tue, 23 Aug 2016 11:40:43 -0500 (CDT) X-Original-To: xfs@oss.sgi.com Delivered-To: xfs@oss.sgi.com Received: from relay.sgi.com (relay1.corp.sgi.com [137.38.102.111]) by oss.sgi.com (Postfix) with ESMTP id 8A40D7CA0 for ; Tue, 23 Aug 2016 11:40:41 -0500 (CDT) Received: from cuda.sgi.com (cuda3.sgi.com [192.48.176.15]) by relay1.corp.sgi.com (Postfix) with ESMTP id 52D3D8F8039 for ; Tue, 23 Aug 2016 09:40:41 -0700 (PDT) X-ASG-Debug-ID: 1471970439-0bf57c55b11278e0001-NocioJ Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by cuda.sgi.com with ESMTP id ZcKrOtNfU7WkAJvc (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 23 Aug 2016 09:40:40 -0700 (PDT) X-Barracuda-Envelope-From: billodo@redhat.com X-Barracuda-Effective-Source-IP: mx1.redhat.com[209.132.183.28] X-Barracuda-Apparent-Source-IP: 209.132.183.28 X-ASG-Whitelist: Client Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B3E374E4D1 for ; Tue, 23 Aug 2016 16:40:39 +0000 (UTC) Received: from localhost.localdomain.com (vpn-62-210.rdu2.redhat.com [10.10.62.210]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u7NGeb4Z007416 for ; Tue, 23 Aug 2016 12:40:39 -0400 From: "Bill O'Donnell" To: xfs@oss.sgi.com Subject: [PATCH v3 2/2] xfs_quota: additional changes to allow use on ext4 Date: Tue, 23 Aug 2016 11:40:26 -0500 X-ASG-Orig-Subj: [PATCH v3 2/2] xfs_quota: additional changes to allow use on ext4 Message-Id: <1471970426-5509-3-git-send-email-billodo@redhat.com> In-Reply-To: <1471970426-5509-1-git-send-email-billodo@redhat.com> References: <1471970426-5509-1-git-send-email-billodo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 23 Aug 2016 16:40:39 +0000 (UTC) X-Barracuda-Connect: mx1.redhat.com[209.132.183.28] X-Barracuda-Start-Time: 1471970440 X-Barracuda-Encrypted: ECDHE-RSA-AES256-GCM-SHA384 X-Barracuda-URL: https://192.48.176.15:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 3194 X-Virus-Scanned: by bsmtpd at sgi.com X-Barracuda-BRTS-Status: 1 X-BeenThere: xfs@oss.sgi.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: XFS Filesystem from SGI List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xfs-bounces@oss.sgi.com Sender: xfs-bounces@oss.sgi.com X-Virus-Scanned: ClamAV using ClamSMTP Further changes to allow xfs_quota to be used on foreign filesystem(s) (e.g. ext4) for project quota testing in xfstests. Add CMD_SKIP_CHECK to enable "generic" xfs_quota commands (help and quit) when xfs_quota is run on foreign filesystems. Use CMD_FLAG_FOREIGN_OK on commands suitable for foreign filesystems. Refactor init_check_command in quota/init.c for clarity. Signed-off-by: Bill O'Donnell --- libxcmd/help.c | 4 +++- libxcmd/quit.c | 4 +++- quota/init.c | 29 ++++++++++++++++++++--------- quota/init.h | 2 ++ 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/libxcmd/help.c b/libxcmd/help.c index fad0ab9..d2e72a0 100644 --- a/libxcmd/help.c +++ b/libxcmd/help.c @@ -18,6 +18,7 @@ #include "platform_defs.h" #include "command.h" +#include "../quota/init.h" static cmdinfo_t help_cmd; static void help_onecmd(const char *cmd, const cmdinfo_t *ct); @@ -88,7 +89,8 @@ help_init(void) help_cmd.cfunc = help_f; help_cmd.argmin = 0; help_cmd.argmax = 1; - help_cmd.flags = CMD_FLAG_GLOBAL; + help_cmd.flags = CMD_FLAG_GLOBAL | CMD_FLAG_FOREIGN_OK | + CMD_SKIP_CHECK; help_cmd.args = _("[command]"); help_cmd.oneline = _("help for one or all commands"); diff --git a/libxcmd/quit.c b/libxcmd/quit.c index 0183b8f..9dbd29a 100644 --- a/libxcmd/quit.c +++ b/libxcmd/quit.c @@ -18,6 +18,7 @@ #include "platform_defs.h" #include "command.h" +#include "../quota/init.h" static cmdinfo_t quit_cmd; @@ -38,7 +39,8 @@ quit_init(void) quit_cmd.cfunc = quit_f; quit_cmd.argmin = -1; quit_cmd.argmax = -1; - quit_cmd.flags = CMD_FLAG_GLOBAL; + quit_cmd.flags = CMD_FLAG_GLOBAL | CMD_FLAG_FOREIGN_OK | + CMD_SKIP_CHECK; quit_cmd.oneline = _("exit the program"); add_command(&quit_cmd); diff --git a/quota/init.c b/quota/init.c index 137cd68..b487dd5 100644 --- a/quota/init.c +++ b/quota/init.c @@ -109,15 +109,26 @@ static int init_check_command( const cmdinfo_t *ct) { - if (fs_path && - !(ct->flags & CMD_FLAG_FOREIGN_OK) && - (fs_path->fs_flags & FS_FOREIGN)) { - fprintf(stderr, - _("foreign mount active, %s command is for XFS filesystems only\n"), - ct->name); - return 0; - } - return 1; + if (!fs_path) + return 1; + + /* Always run commands that we are told to skip here */ + if (ct->flags & CMD_SKIP_CHECK) + return 1; + + /* if it's an XFS filesystem, always run the command */ + if (!(fs_path->fs_flags & FS_FOREIGN)) + return 1; + + /* If the user specified foreign filesysetms are ok, run it */ + if (foreign_allowed && + (ct->flags & CMD_FLAG_FOREIGN_OK)) + return 1; + + /* foreign filesystem and it's no a valid command! */ + fprintf(stderr, _("%s command is for XFS filesystems only\n"), + ct->name); + return 0; } static void diff --git a/quota/init.h b/quota/init.h index 6879855..aa1cc51 100644 --- a/quota/init.h +++ b/quota/init.h @@ -31,3 +31,5 @@ extern void report_init(void); extern void state_init(void); extern void init_cvtnum(unsigned int *, unsigned int *); + +#define CMD_SKIP_CHECK (1<<0) /* command is always run */