* [PATCH]multipath: Allow whitespace before or after exit and quit command in multipathd
@ 2013-09-23 6:33 Zheng Huai Cheng
0 siblings, 0 replies; only message in thread
From: Zheng Huai Cheng @ 2013-09-23 6:33 UTC (permalink / raw)
To: device-mapper development; +Cc: Christophe Varoqui
This problem is reported by IBM internal test team.
In multipathd interactive mode, commands allow preceding and appending
whitespace while quit and exit do not. If we have whitespace before or
after quit|exit command, multipathd won't recognize exit and quit
command and exit the interactive mode.
This patch provide support whitespace in the quit and exit command.
Signed-off-by: Zheng Huai Cheng <zhenghch@linux.vnet.ibm.com>
---
multipathd/uxclnt.c | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/multipathd/uxclnt.c b/multipathd/uxclnt.c
index 4e3ed26..b0567bd 100644
--- a/multipathd/uxclnt.c
+++ b/multipathd/uxclnt.c
@@ -37,6 +37,29 @@ static void print_reply(char *s)
putchar(*s++);
}
}
+
+static int need_quit(char *str, size_t len)
+{
+ char *ptr, *start;
+ size_t trimed_len = len;
+
+ for (ptr = str; trimed_len && isspace(*ptr);
+ trimed_len--, ptr++)
+ ;
+
+ start = ptr;
+
+ for (ptr = str + len - 1; trimed_len && isspace(*ptr);
+ trimed_len--, ptr--)
+ ;
+
+ if ((trimed_len == 4 && !strncmp(start, "exit", 4)) ||
+ (trimed_len == 4 && !strncmp(start, "quit", 4)))
+ return 1;
+
+ return 0;
+}
+
/*
* process the client
*/
@@ -56,9 +79,8 @@ static void process(int fd)
free(line);
continue;
}
- if (!strncmp(line, "exit", 4) && llen == 4)
- break;
- if (!strncmp(line, "quit", 4) && llen == 4)
+
+ if (need_quit(line, llen))
break;
if (send_packet(fd, line, llen + 1) != 0) break;
--
1.7.9.5
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2013-09-23 6:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-23 6:33 [PATCH]multipath: Allow whitespace before or after exit and quit command in multipathd Zheng Huai Cheng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).