linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: linux-xfs@vger.kernel.org
Subject: [PATCH 4/6] libxcmd: don't check generic library commands
Date: Fri, 16 Dec 2016 15:41:13 +1100	[thread overview]
Message-ID: <20161216044115.21287-5-david@fromorbit.com> (raw)
In-Reply-To: <20161216044115.21287-1-david@fromorbit.com>

From: Dave Chinner <dchinner@redhat.com>

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 <dchinner@redhat.com>
---
 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;
-- 
2.10.2


  parent reply	other threads:[~2016-12-16  4:45 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-16  4:41 [PATCH v2 0/6] xfs_io: fix up command iteration Dave Chinner
2016-12-16  4:41 ` [PATCH 1/6] libxcmd: check CMD_FLAG_GLOBAL inside args_command() Dave Chinner
2016-12-20  8:26   ` Christoph Hellwig
2016-12-16  4:41 ` [PATCH 2/6] libxcmd: rename args_command to command_iterator Dave Chinner
2016-12-20  8:27   ` Christoph Hellwig
2016-12-16  4:41 ` [PATCH 3/6] libxcmd: merge command() and iterate_command() Dave Chinner
2016-12-20  8:31   ` Christoph Hellwig
2016-12-20 20:11     ` Eric Sandeen
2016-12-21  9:38       ` Christoph Hellwig
2016-12-16  4:41 ` Dave Chinner [this message]
2016-12-20  8:34   ` [PATCH 4/6] libxcmd: don't check generic library commands Christoph Hellwig
2016-12-16  4:41 ` [PATCH 5/6] xfs_io: make various commands one-shot only Dave Chinner
2016-12-20  8:44   ` Christoph Hellwig
2016-12-16  4:41 ` [PATCH 6/6] libxcmd: add non-iterating user commands Dave Chinner
2016-12-16  6:39   ` Amir Goldstein
  -- strict thread matches above, loose matches on Subject: below --
2016-12-07  3:47 [PATCH 0/6] xfs_io: fix up command iteration Dave Chinner
2016-12-07  3:47 ` [PATCH 4/6] libxcmd: don't check generic library commands Dave Chinner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161216044115.21287-5-david@fromorbit.com \
    --to=david@fromorbit.com \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).