]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_quota: certain commands must always be available
authorBill O'Donnell <billodo@redhat.com>
Fri, 26 Aug 2016 01:20:37 +0000 (11:20 +1000)
committerDave Chinner <david@fromorbit.com>
Fri, 26 Aug 2016 01:20:37 +0000 (11:20 +1000)
Add CMD_ALL_FSTYPES to enable basic xfs_quota commands (e.g. help,
quit) to be run regardless of the filesystem type we are operating
on.

Use CMD_FLAG_FOREIGN_OK on commands suitable for foreign filesystems.
Refactor init_check_command in quota/init.c for clarity.

[ dchinner: CMD_SKIP_CHECK -> CMD_ALL_FSTYPES ]

Signed-off-by: Bill O'Donnell <billodo@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
libxcmd/help.c
libxcmd/quit.c
quota/init.c
quota/init.h

index fad0ab98f8b71e765d8f61d0fae7438437b16a31..8894c7931f89f481c9f1dfe3beec00daadbb15cb 100644 (file)
@@ -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,7 @@ 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_ALL_FSTYPES;
        help_cmd.args = _("[command]");
        help_cmd.oneline = _("help for one or all commands");
 
index 0183b8f78882c3375728c8b6ccf447de4a9e35de..e0af91629b810a4b6f188de5756a7896afa6ab79 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "platform_defs.h"
 #include "command.h"
+#include "../quota/init.h"
 
 static cmdinfo_t quit_cmd;
 
@@ -38,7 +39,7 @@ 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_ALL_FSTYPES;
        quit_cmd.oneline = _("exit the program");
 
        add_command(&quit_cmd);
index 137cd6852eeb08d5c1a805b6ef1ce588502b0ad9..44be3222bd992f5ed11f8a100b6da8ce2a6b520e 100644 (file)
@@ -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_ALL_FSTYPES)
+               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 not a valid command! */
+       fprintf(stderr, _("%s command is for XFS filesystems only\n"),
+               ct->name);
+       return 0;
 }
 
 static void
index 6879855578f03adcf5bc220a8e076813abe76920..4eb44c4d7ea8dc066dfed18439c9ba5a7146d84d 100644 (file)
@@ -31,3 +31,5 @@ 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 */