From: Christophe Varoqui Date: Tue, 30 Sep 2008 21:39:27 +0000 (+0200) Subject: [multipathd] add "quit" cli command X-Git-Tag: 0.4.9~186 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c1cbbb91cb3ef9fe40a1f63d65edf381fad82b0b;p=platform%2Fupstream%2Fmultipath-tools.git [multipathd] add "quit" cli command "exit" or "quit" may be more straight-forward than CTRL-D Put dummy cli commands in place for auto-generated help, even if we exit from the socket client code before sending the command packet to the daemon. --- diff --git a/multipathd/cli.c b/multipathd/cli.c index 34ae07c..b4b4d1e 100644 --- a/multipathd/cli.c +++ b/multipathd/cli.c @@ -171,6 +171,8 @@ load_keys (void) r += add_key(keys, "devices", DEVICES, 0); r += add_key(keys, "format", FMT, 1); r += add_key(keys, "wildcards", WILDCARDS, 0); + r += add_key(keys, "quit", QUIT, 0); + r += add_key(keys, "exit", QUIT, 0); if (r) { free_keys(keys); @@ -428,6 +430,7 @@ cli_init (void) { add_handler(RESUME+MAP, NULL); add_handler(REINSTATE+PATH, NULL); add_handler(FAIL+PATH, NULL); + add_handler(QUIT, NULL); return 0; } diff --git a/multipathd/cli.h b/multipathd/cli.h index 9932d96..d58a200 100644 --- a/multipathd/cli.h +++ b/multipathd/cli.h @@ -21,6 +21,7 @@ enum { __DEVICES, __FMT, __WILDCARDS, + __QUIT, }; #define LIST (1 << __LIST) @@ -45,6 +46,7 @@ enum { #define DEVICES (1 << __DEVICES) #define FMT (1 << __FMT) #define WILDCARDS (1 << __WILDCARDS) +#define QUIT (1 << __QUIT) #define INITIAL_REPLY_LEN 1000 @@ -56,7 +58,7 @@ struct key { }; struct handler { - int fingerprint; + unsigned long fingerprint; int (*fn)(void *, char **, int *, void *); }; diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index 36a4968..e453220 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -596,3 +596,9 @@ cli_list_devices (void * v, char ** reply, int * len, void * data) return show_devices(reply, len, vecs); } + +int +cli_quit (void * v, char ** reply, int * len, void * data) +{ + return 0; +} diff --git a/multipathd/cli_handlers.h b/multipathd/cli_handlers.h index 703a925..cef9864 100644 --- a/multipathd/cli_handlers.h +++ b/multipathd/cli_handlers.h @@ -20,3 +20,4 @@ int cli_suspend(void * v, char ** reply, int * len, void * data); int cli_resume(void * v, char ** reply, int * len, void * data); int cli_reinstate(void * v, char ** reply, int * len, void * data); int cli_fail(void * v, char ** reply, int * len, void * data); +int cli_quit(void * v, char ** reply, int * len, void * data); diff --git a/multipathd/main.c b/multipathd/main.c index 84fb5c4..7879758 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -714,6 +714,7 @@ uxlsnrloop (void * ap) set_handler_callback(RESUME+MAP, cli_resume); set_handler_callback(REINSTATE+PATH, cli_reinstate); set_handler_callback(FAIL+PATH, cli_fail); + set_handler_callback(QUIT, cli_quit); uxsock_listen(&uxsock_trigger, ap); diff --git a/multipathd/uxclnt.c b/multipathd/uxclnt.c index 009e5cb..bc89294 100644 --- a/multipathd/uxclnt.c +++ b/multipathd/uxclnt.c @@ -43,6 +43,10 @@ static void process(int fd) free(line); continue; } + if (!strncmp(line, "exit", 4) && llen == 4) + break; + if (!strncmp(line, "quit", 4) && llen == 4) + break; if (send_packet(fd, line, llen + 1) != 0) break; if (recv_packet(fd, &reply, &len) != 0) break;