]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libxcmd: don't check generic library commands
authorDave Chinner <dchinner@redhat.com>
Thu, 12 Jan 2017 20:12:41 +0000 (14:12 -0600)
committerEric Sandeen <sandeen@redhat.com>
Thu, 12 Jan 2017 20:12:41 +0000 (14:12 -0600)
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.

[ sandeen: remove CMD_ALL_FSTYPES definition ]

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
include/command.h
io/init.c
libxcmd/command.c
libxcmd/help.c
libxcmd/quit.c
quota/init.c
quota/init.h

index 637ee06e6e9aff40f092bf1fb3eebb3ce4d863c1..348002cbe3eddca46f9f8d040fdfe353f683ccf6 100644 (file)
@@ -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);
index a382d9baeaca1d4560a2ab23f6379cccf5509d37..28a7d6005d49b1d5086bcb1a2dc2f531df69c888 100644 (file)
--- a/io/init.c
+++ b/io/init.c
@@ -110,9 +110,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;
index 03fb219e936500a198d524848fe7adcfaff9692e..ce434479c15e2ae63009982daeb1e95803e49a97 100644 (file)
@@ -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;
index bc31d6df1d8a410129e175269607a3e7fa92dff4..f888377cabf7acf01712c98b554d12c81d9781b1 100644 (file)
@@ -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");
 
index 19431015aee28ddaec3e82b3bc0a523f73cf12c3..1e1ba986f2bafcb900e4ce1153b6217275170028 100644 (file)
@@ -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);
index 193f6421fd597c2f004a14fca4480bc539234541..d45dc4c5461ead672c5394546ac2a8874e1dcdd0 100644 (file)
@@ -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;
index 4eb44c4d7ea8dc066dfed18439c9ba5a7146d84d..6879855578f03adcf5bc220a8e076813abe76920 100644 (file)
@@ -31,5 +31,3 @@ extern void   report_init(void);
 extern void    state_init(void);
 
 extern void init_cvtnum(unsigned int *, unsigned int *);
-
-#define CMD_ALL_FSTYPES        (1<<0) /* command is always available */