uvol: yet another small compatibility hack
authorDaniel Golle <daniel@makrotopia.org>
Mon, 4 Apr 2022 10:57:29 +0000 (11:57 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Mon, 4 Apr 2022 10:58:37 +0000 (11:58 +0100)
Shift ARGV until actual parameters start to compensate for older
versions of ucode passing the complete cmdline.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
utils/uvol/files/uvol

index 6a5a82c138cf9b1cb76e6735161924cc9025e415..a4f023ffd78133c85a81d09a452f33c05fceb348 100644 (file)
@@ -64,7 +64,18 @@ if (!backend) {
        exit(2);
 }
 
-let cmd = shift(ARGV);
+// The below code is needed as older versions of ucode pass the complete cmdline via ARGV
+// Once we can rely in more recent ucode the while loop can be replaced by simply
+// let cmd = shift(ARGV);
+let skip = null;
+let cmd = null;
+let skip_argv = ["/usr/bin/ucode", "-R", "/usr/sbin/uvol"];
+while (skip = shift(ARGV)) {
+       if (skip != shift(skip_argv)) {
+               cmd = skip;
+               break;
+       }
+}
 
 if (!cmd || cmd == "-h" || cmd == "help") {
        printf("%s", help_output);