[multipathd] add "quit" cli command
authorChristophe Varoqui <christophe.varoqui@free.fr>
Tue, 30 Sep 2008 21:39:27 +0000 (23:39 +0200)
committerChristophe Varoqui <christophe.varoqui@free.fr>
Tue, 30 Sep 2008 21:39:27 +0000 (23:39 +0200)
"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.

multipathd/cli.c
multipathd/cli.h
multipathd/cli_handlers.c
multipathd/cli_handlers.h
multipathd/main.c
multipathd/uxclnt.c

index 34ae07c..b4b4d1e 100644 (file)
@@ -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;
 }
index 9932d96..d58a200 100644 (file)
@@ -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 *);
 };
 
index 36a4968..e453220 100644 (file)
@@ -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;
+}
index 703a925..cef9864 100644 (file)
@@ -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);
index 84fb5c4..7879758 100644 (file)
@@ -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);
 
index 009e5cb..bc89294 100644 (file)
@@ -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;