1 Index: multipath-tools/libmultipath/uevent.c
2 ===================================================================
3 --- multipath-tools.orig/libmultipath/uevent.c
4 +++ multipath-tools/libmultipath/uevent.c
5 @@ -52,6 +52,12 @@ pthread_mutex_t uevc_lock, *uevc_lockp =
6 pthread_cond_t uev_cond, *uev_condp = &uev_cond;
7 uev_trigger *my_uev_trigger;
8 void * my_trigger_data;
11 +int is_uevent_busy(void)
13 + return (uevqhp != NULL || servicing_uev);
16 static struct uevent * alloc_uevent (void)
18 @@ -96,7 +102,9 @@ uevq_thread(void * et)
21 pthread_mutex_lock(uevc_lockp);
23 pthread_cond_wait(uev_condp, uevc_lockp);
25 pthread_mutex_unlock(uevc_lockp);
28 Index: multipath-tools/libmultipath/uevent.h
29 ===================================================================
30 --- multipath-tools.orig/libmultipath/uevent.h
31 +++ multipath-tools/libmultipath/uevent.h
32 @@ -17,3 +17,4 @@ struct uevent {
34 int uevent_listen(int (*store_uev)(struct uevent *, void * trigger_data),
36 +int is_uevent_busy(void);
37 Index: multipath-tools/multipathd/cli.c
38 ===================================================================
39 --- multipath-tools.orig/multipathd/cli.c
40 +++ multipath-tools/multipathd/cli.c
41 @@ -174,6 +174,7 @@ load_keys (void)
42 r += add_key(keys, "devices", DEVICES, 0);
43 r += add_key(keys, "format", FMT, 1);
44 r += add_key(keys, "wildcards", WILDCARDS, 0);
45 + r += add_key(keys, "count", COUNT, 0);
46 r += add_key(keys, "quit", QUIT, 0);
47 r += add_key(keys, "exit", QUIT, 0);
49 @@ -443,6 +444,7 @@ cli_init (void) {
50 add_handler(RESTOREQ+MAPS, NULL);
51 add_handler(REINSTATE+PATH, NULL);
52 add_handler(FAIL+PATH, NULL);
53 + add_handler(COUNT+PATHS, NULL);
54 add_handler(QUIT, NULL);
57 Index: multipath-tools/multipathd/cli_handlers.h
58 ===================================================================
59 --- multipath-tools.orig/multipathd/cli_handlers.h
60 +++ multipath-tools/multipathd/cli_handlers.h
61 @@ -25,5 +25,6 @@ int cli_restore_all_queueing(void * v, c
62 int cli_suspend(void * v, char ** reply, int * len, void * data);
63 int cli_resume(void * v, char ** reply, int * len, void * data);
64 int cli_reinstate(void * v, char ** reply, int * len, void * data);
65 +int cli_count_paths(void * v, char ** reply, int * len, void * data);
66 int cli_fail(void * v, char ** reply, int * len, void * data);
67 int cli_quit(void * v, char ** reply, int * len, void * data);
68 Index: multipath-tools/multipathd/main.c
69 ===================================================================
70 --- multipath-tools.orig/multipathd/main.c
71 +++ multipath-tools/multipathd/main.c
72 @@ -768,6 +768,7 @@ uxlsnrloop (void * ap)
73 set_handler_callback(RESTOREQ+MAP, cli_restore_queueing);
74 set_handler_callback(DISABLEQ+MAPS, cli_disable_all_queueing);
75 set_handler_callback(RESTOREQ+MAPS, cli_restore_all_queueing);
76 + set_handler_callback(COUNT+PATHS, cli_count_paths);
77 set_handler_callback(QUIT, cli_quit);
80 Index: multipath-tools/multipathd/cli.h
81 ===================================================================
82 --- multipath-tools.orig/multipathd/cli.h
83 +++ multipath-tools/multipathd/cli.h
84 @@ -23,6 +23,7 @@ enum {
92 @@ -51,6 +52,7 @@ enum {
93 #define BLACKLIST (1 << __BLACKLIST)
94 #define DEVICES (1 << __DEVICES)
95 #define FMT (1 << __FMT)
96 +#define COUNT (1 << __COUNT)
97 #define WILDCARDS (1 << __WILDCARDS)
98 #define QUIT (1 << __QUIT)
100 Index: multipath-tools/multipathd/cli_handlers.c
101 ===================================================================
102 --- multipath-tools.orig/multipathd/cli_handlers.c
103 +++ multipath-tools/multipathd/cli_handlers.c
111 +count_paths(char **r, int *l, struct vectors *vecs)
116 + unsigned int maxlen = INITIAL_REPLY_LEN;
117 + int monitored_count = 0;
119 + reply = MALLOC(maxlen);
122 + vector_foreach_slot(vecs->pathvec, pp, i)
125 + len = sprintf(reply, "Paths: %d\nBusy: %s\n", monitored_count,
126 + is_uevent_busy()? "True" : "False");
133 show_paths (char ** r, int * len, struct vectors * vecs, char * style)
134 @@ -176,6 +199,16 @@ cli_list_config (void * v, char ** reply
138 +cli_count_paths (void * v, char ** reply, int * len, void * data)
140 + struct vectors * vecs = (struct vectors *)data;
142 + condlog(3, "count paths (operator)");
144 + return count_paths(reply, len, vecs);
148 cli_list_paths (void * v, char ** reply, int * len, void * data)
150 struct vectors * vecs = (struct vectors *)data;