From patchwork Wed Dec 7 03:47:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chinner X-Patchwork-Id: 9486749 X-Mozilla-Keys: nonjunk Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on sandeen.net X-Spam-Level: X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD autolearn=unavailable autolearn_force=no version=3.4.0 X-Spam-HP: BAYES_00=-1.9,HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_HI=-5,RP_MATCHES_RCVD=-0.1 X-Original-To: sandeen@sandeen.net Delivered-To: sandeen@sandeen.net Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by sandeen.net (Postfix) with ESMTP id 5881547968B for ; Tue, 6 Dec 2016 21:46:36 -0600 (CST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752538AbcLGDrf (ORCPT ); Tue, 6 Dec 2016 22:47:35 -0500 Received: from ipmail06.adl6.internode.on.net ([150.101.137.145]:56141 "EHLO ipmail06.adl6.internode.on.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751347AbcLGDre (ORCPT ); Tue, 6 Dec 2016 22:47:34 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2BHEgCUhUdYIGuWLHleHAEBBAEBCgEBgysOAQEBAQEfgWCGdJw4AQEBAQEBBoEdkm+EFoYeAgICgiNUAQIBAQEBAQIGAQEBAQEBOUWEaQYnLyMQCBgxOQMHFBmIbqpjPYs7ATCFdIlUhXoFmmaRC5BMkhGBThMOg1wcgXEqNIZSgjwBAQE Received: from ppp121-44-150-107.lns20.syd7.internode.on.net (HELO dastard) ([121.44.150.107]) by ipmail06.adl6.internode.on.net with ESMTP; 07 Dec 2016 14:17:29 +1030 Received: from discord.disaster.area ([192.168.1.111]) by dastard with esmtp (Exim 4.80) (envelope-from ) id 1cETCZ-00069R-7w; Wed, 07 Dec 2016 14:47:27 +1100 Received: from dave by discord.disaster.area with local (Exim 4.88) (envelope-from ) id 1cETCZ-0000bK-6o; Wed, 07 Dec 2016 14:47:27 +1100 From: Dave Chinner To: linux-xfs@vger.kernel.org Cc: fstests@vger.kernel.org, amir73il@gmail.com Subject: [PATCH 4/6] libxcmd: don't check generic library commands Date: Wed, 7 Dec 2016 14:47:22 +1100 Message-Id: <20161207034724.1613-5-david@fromorbit.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161207034724.1613-1-david@fromorbit.com> References: <20161207034724.1613-1-david@fromorbit.com> Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Dave Chinner The generic "help" and "quit" commands have different methods of skipping user provided command check functions that may prevent them from running. xfs_quota use CMD_ALL_FSTYPES and xfs_io uses CMD_FLAG_ONESHOT. Add a new CMD_FLAG_LIBRARY to indicate commands that should not be checked against application specific check functions so they are always present and can be run regardless of the context in which they are run. This gets rid of the CMD_ALL_FSTYPES flag, and enables us to remove the ONESHOT check in xfs_io so we use only app specific flags for determining if app commands should run or not. Signed-Off-By: Dave Chinner --- include/command.h | 1 + io/init.c | 3 --- libxcmd/command.c | 4 ++++ libxcmd/help.c | 2 +- libxcmd/quit.c | 2 +- quota/init.c | 4 ---- 6 files changed, 7 insertions(+), 9 deletions(-) diff --git a/include/command.h b/include/command.h index 637ee06e6e9a..348002cbe3ed 100644 --- a/include/command.h +++ b/include/command.h @@ -27,6 +27,7 @@ */ #define CMD_FLAG_ONESHOT (1<<31) #define CMD_FLAG_FOREIGN_OK (1<<30) /* command not restricted to XFS */ +#define CMD_FLAG_LIBRARY (1<<29) /* command provided by libxcmd */ typedef int (*cfunc_t)(int argc, char **argv); typedef void (*helpfunc_t)(void); diff --git a/io/init.c b/io/init.c index 34009b024833..5ce627ef22c9 100644 --- a/io/init.c +++ b/io/init.c @@ -109,9 +109,6 @@ static int init_check_command( const cmdinfo_t *ct) { - if (ct->flags & CMD_FLAG_ONESHOT) - return 1; - if (!file && !(ct->flags & CMD_NOFILE_OK)) { fprintf(stderr, _("no files are open, try 'help open'\n")); return 0; diff --git a/libxcmd/command.c b/libxcmd/command.c index 2c94a3199115..decc442a9d03 100644 --- a/libxcmd/command.c +++ b/libxcmd/command.c @@ -48,6 +48,10 @@ static int check_command( const cmdinfo_t *ci) { + /* always run internal library supplied commands */ + if (ci->flags & CMD_FLAG_LIBRARY) + return 1; + if (check_func) return check_func(ci); return 1; diff --git a/libxcmd/help.c b/libxcmd/help.c index bc31d6df1d8a..f888377cabf7 100644 --- a/libxcmd/help.c +++ b/libxcmd/help.c @@ -89,7 +89,7 @@ help_init(void) help_cmd.cfunc = help_f; help_cmd.argmin = 0; help_cmd.argmax = 1; - help_cmd.flags = CMD_FLAG_ONESHOT | CMD_ALL_FSTYPES; + help_cmd.flags = CMD_FLAG_ONESHOT | CMD_FLAG_LIBRARY; help_cmd.args = _("[command]"); help_cmd.oneline = _("help for one or all commands"); diff --git a/libxcmd/quit.c b/libxcmd/quit.c index 19431015aee2..1e1ba986f2ba 100644 --- a/libxcmd/quit.c +++ b/libxcmd/quit.c @@ -39,7 +39,7 @@ quit_init(void) quit_cmd.cfunc = quit_f; quit_cmd.argmin = -1; quit_cmd.argmax = -1; - quit_cmd.flags = CMD_FLAG_ONESHOT | CMD_ALL_FSTYPES; + quit_cmd.flags = CMD_FLAG_ONESHOT | CMD_FLAG_LIBRARY; quit_cmd.oneline = _("exit the program"); add_command(&quit_cmd); diff --git a/quota/init.c b/quota/init.c index 193f6421fd59..d45dc4c5461e 100644 --- a/quota/init.c +++ b/quota/init.c @@ -117,10 +117,6 @@ init_check_command( if (!fs_path) return 1; - /* Always run commands that are valid for all fs types. */ - if (ct->flags & CMD_ALL_FSTYPES) - return 1; - /* If it's an XFS filesystem, always run the command. */ if (!(fs_path->fs_flags & FS_FOREIGN)) return 1;