]> www.infradead.org Git - users/hch/nvme-cli.git/commitdiff
Allow hierarchy of similiarly named plugins
authorKeith Busch <keith.busch@intel.com>
Wed, 3 Jan 2018 23:03:36 +0000 (16:03 -0700)
committerKeith Busch <keith.busch@intel.com>
Wed, 3 Jan 2018 23:03:36 +0000 (16:03 -0700)
For historical reasons, we allow the user to write their command line
executing "vendor" plugin "command" as one of two ways:

  nvme vendor command

And

  nvme vendor-command

This was conflicting if a hierarchy of vendor additions exists, like
"vendor-oem".

So, this patch fixes that by first searching the entire builtin vendor
plugins before searching for matching substrings.

Signed-off-by: Keith Busch <keith.busch@intel.com>
plugin.c

index ba0f55b5b214274af662c501d82899d525bda6ea..a9bf6cd03aff4347c0e7cac6833bcbcd8e09e9b5 100644 (file)
--- a/plugin.c
+++ b/plugin.c
@@ -160,9 +160,13 @@ int handle_plugin(int argc, char **argv, struct plugin *plugin)
        while (extension) {
                if (!strcmp(str, extension->name))
                        return handle_plugin(argc - 1, &argv[1], extension);
+               extension = extension->next;
+       }
 
-               /* If the command is executed with the extension name and
-                * command together ("plugin-command"), run the plug in */
+       /* If the command is executed with the extension name and
+        * command together ("plugin-command"), run the plug in */
+       extension = plugin->next;
+       while (extension) {
                if (!strncmp(str, extension->name, strlen(extension->name))) {
                        argv[0] += strlen(extension->name);
                        while (*argv[0] == '-')