device-mapper-multipath/0065-multipathd-common-code-for-k-and-command-args.patch
Benjamin Marzinski b05147c356 device-mapper-multipath-0.8.5-6
Change patch format to remove Git version
  * Patches 0001-0122 only have the patch format modified
Update to the head of the upstream staging branch plus redhat patches
  * Patches 0123-0134 & 1036-0142 are from the upstream staging branch
  * Patches 0143-1046 have been submitted upstream
  * Patch 0156 is a Red Hat only patch. Red Hat udev rules set ID_SERIAL
    from 60-persistent-storage.rules instead of 55-scsi-sg3_id.rules.
    Multipath's parse_vpd_pg83() function needs to match the ID_SERIAL
    value from udev.
Rename files
  * Previous patches 0123-0132 are now patches 1035 & 0147-0155
2021-03-26 13:33:56 -05:00

85 lines
2.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Sat, 26 Sep 2020 00:43:12 +0200
Subject: [PATCH] multipathd: common code for "-k" and command args
'multipathd -k"cmd"' and 'multipath cmd' are the same thing.
Treat it with common code.
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
multipathd/main.c | 37 +++++++++++++++++++------------------
1 file changed, 19 insertions(+), 18 deletions(-)
diff --git a/multipathd/main.c b/multipathd/main.c
index 867f0f84..b6a5f5b7 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -3301,6 +3301,8 @@ main (int argc, char *argv[])
int err;
int foreground = 0;
struct config *conf;
+ char *opt_k_arg = NULL;
+ bool opt_k = false;
ANNOTATE_BENIGN_RACE_SIZED(&multipath_conf, sizeof(multipath_conf),
"Manipulated through RCU");
@@ -3348,16 +3350,9 @@ main (int argc, char *argv[])
logsink = LOGSINK_STDERR_WITHOUT_TIME;
break;
case 'k':
- logsink = 0;
- conf = load_config(DEFAULT_CONFIGFILE);
- if (!conf)
- exit(1);
- if (verbosity)
- libmp_verbosity = verbosity;
- uxsock_timeout = conf->uxsock_timeout;
- err = uxclnt(optarg, uxsock_timeout + 100);
- free_config(conf);
- return err;
+ opt_k = true;
+ opt_k_arg = optarg;
+ break;
case 'B':
bindings_read_only = 1;
break;
@@ -3373,7 +3368,7 @@ main (int argc, char *argv[])
exit(1);
}
}
- if (optind < argc) {
+ if (opt_k || optind < argc) {
char cmd[CMDSIZE];
char * s = cmd;
char * c = s;
@@ -3388,14 +3383,20 @@ main (int argc, char *argv[])
libmp_verbosity = verbosity;
uxsock_timeout = conf->uxsock_timeout;
memset(cmd, 0x0, CMDSIZE);
- while (optind < argc) {
- if (strchr(argv[optind], ' '))
- c += snprintf(c, s + CMDSIZE - c, "\"%s\" ", argv[optind]);
- else
- c += snprintf(c, s + CMDSIZE - c, "%s ", argv[optind]);
- optind++;
+ if (opt_k)
+ s = opt_k_arg;
+ else {
+ while (optind < argc) {
+ if (strchr(argv[optind], ' '))
+ c += snprintf(c, s + CMDSIZE - c,
+ "\"%s\" ", argv[optind]);
+ else
+ c += snprintf(c, s + CMDSIZE - c,
+ "%s ", argv[optind]);
+ optind++;
+ }
+ c += snprintf(c, s + CMDSIZE - c, "\n");
}
- c += snprintf(c, s + CMDSIZE - c, "\n");
err = uxclnt(s, uxsock_timeout + 100);
free_config(conf);
return err;