On Tue, Aug 30, 2022 at 09:27:11PM +0200, mwilck@xxxxxxxx wrote: > From: Martin Wilck <mwilck@xxxxxxxx> > > A previous patch disabled interactive mode in multipathd, because > uxclnt() would return immediately without an input command. > > With this patch, we reinstate interactive mode for "multipath -k", > by just exec()ing the multipathc client. > > Signed-off-by: Martin Wilck <mwilck@xxxxxxxx> Reviewed-by: Benjamin Marzinski <bmarzins@xxxxxxxxxx> > --- > multipathd/Makefile | 3 ++- > multipathd/main.c | 15 +++++++++++++-- > multipathd/multipathc.c | 25 +++++++++++++++++++++---- > 3 files changed, 36 insertions(+), 7 deletions(-) > > diff --git a/multipathd/Makefile b/multipathd/Makefile > index 19ab2e9..8a56304 100644 > --- a/multipathd/Makefile > +++ b/multipathd/Makefile > @@ -17,7 +17,8 @@ endif > > CPPFLAGS += -I$(multipathdir) -I$(mpathutildir) -I$(mpathpersistdir) -I$(mpathcmddir) -I$(thirdpartydir) \ > $(shell $(PKGCONFIG) --modversion liburcu 2>/dev/null | \ > - awk -F. '{ printf("-DURCU_VERSION=0x%06x", 256 * ( 256 * $$1 + $$2) + $$3); }') > + awk -F. '{ printf("-DURCU_VERSION=0x%06x", 256 * ( 256 * $$1 + $$2) + $$3); }') \ > + -DBINDIR='"$(bindir)"' > CFLAGS += $(BIN_CFLAGS) > LDFLAGS += $(BIN_LDFLAGS) > > diff --git a/multipathd/main.c b/multipathd/main.c > index 5a40894..66177cd 100644 > --- a/multipathd/main.c > +++ b/multipathd/main.c > @@ -3616,7 +3616,7 @@ main (int argc, char *argv[]) > extern char *optarg; > extern int optind; > int arg; > - int err; > + int err = 0; > int foreground = 0; > struct config *conf; > char *opt_k_arg = NULL; > @@ -3710,7 +3710,18 @@ main (int argc, char *argv[]) > } > c += snprintf(c, s + CMDSIZE - c, "\n"); > } > - err = uxclnt(s, uxsock_timeout + 100); > + if (!s) { > + char tmo_buf[16]; > + > + snprintf(tmo_buf, sizeof(tmo_buf), "%d", > + uxsock_timeout + 100); > + if (execl(BINDIR "/multipathc", "multipathc", > + tmo_buf, NULL) == -1) { > + condlog(0, "ERROR: failed to execute multipathc: %m"); > + err = 1; > + } > + } else > + err = uxclnt(s, uxsock_timeout + 100); > free_config(conf); > return err; > } > diff --git a/multipathd/multipathc.c b/multipathd/multipathc.c > index a4f9023..9d49655 100644 > --- a/multipathd/multipathc.c > +++ b/multipathd/multipathc.c > @@ -246,14 +246,31 @@ static void process(int fd, unsigned int timeout) > } > } > > -int main (void) > +int main (int argc, const char * const argv[]) > { > - int fd = mpath_connect(); > + int fd; > + int tmo = DEFAULT_REPLY_TIMEOUT + 100; > + char *ep; > > - if (fd == -1) > + if (argc > 2) { > + fprintf(stderr, "Usage: %s [timeout]\n", argv[0]); > return 1; > + } > + if (argc == 2) { > + tmo = strtol(argv[1], &ep, 10); > + if (*argv[1] == '\0' || *ep != '\0' || tmo < 0) { > + fprintf(stderr, "ERROR: invalid timeout value\n"); > + return 1; > + } > + } > > - process(fd, DEFAULT_REPLY_TIMEOUT + 100); > + fd = mpath_connect(); > + if (fd == -1) { > + fprintf(stderr, "ERROR: failed to connect to multipathd\n"); > + return 1; > + } > + > + process(fd, tmo); > mpath_disconnect(fd); > return 0; > } > -- > 2.37.1 -- dm-devel mailing list dm-devel@xxxxxxxxxx https://listman.redhat.com/mailman/listinfo/dm-devel