Mimics the 'multipath -ll' output in the CLI.
r += add_key(keys, "group", GROUP, 1);
r += add_key(keys, "reconfigure", RECONFIGURE, 0);
r += add_key(keys, "stats", STATS, 0);
+ r += add_key(keys, "multipaths", MULTIPATHS, 0);
if (r) {
free_keys(keys);
__GROUP,
__RECONFIGURE,
__STATS,
+ __MULTIPATHS,
};
#define LIST (1 << __LIST)
#define GROUP (1 << __GROUP)
#define RECONFIGURE (1 << __RECONFIGURE)
#define STATS (1 << __STATS)
+#define MULTIPATHS (1 << __MULTIPATHS)
#define INITIAL_REPLY_LEN 1000
}
int
+show_multipaths (char ** r, int * len, struct vectors * vecs)
+{
+ int i;
+ struct multipath * mpp;
+ char * c;
+ char * reply;
+ int maxlen = INITIAL_REPLY_LEN;
+ int again = 1;
+
+ reply = MALLOC(maxlen);
+
+ while (again) {
+ if (!reply)
+ return 1;
+
+ c = reply;
+
+ vector_foreach_slot(vecs->mpvec, mpp, i)
+ c += snprint_mp(c, reply + maxlen - c,
+ mpp, 2);
+
+ again = ((c - reply) == (maxlen - 1));
+
+ if (again)
+ reply = REALLOC(reply, maxlen *= 2);
+
+ }
+ *r = reply;
+ *len = (int)(c - reply + 1);
+ return 0;
+}
+
+int
cli_list_paths (void * v, char ** reply, int * len, void * data)
{
struct vectors * vecs = (struct vectors *)data;
}
int
+cli_list_multipaths (void * v, char ** reply, int * len, void * data)
+{
+ struct vectors * vecs = (struct vectors *)data;
+
+ condlog(3, "list multipaths (operator)");
+
+ return show_multipaths(reply, len, vecs);
+}
+
+int
show_maps (char ** r, int *len, struct vectors * vecs, char * style)
{
int i;
int cli_list_paths (void * v, char ** reply, int * len, void * data);
int cli_list_maps (void * v, char ** reply, int * len, void * data);
int cli_list_maps_stats (void * v, char ** reply, int * len, void * data);
+int cli_list_multipath (void * v, char ** reply, int * len, void * data);
+int cli_list_multipaths (void * v, char ** reply, int * len, void * data);
int cli_add_path (void * v, char ** reply, int * len, void * data);
int cli_del_path (void * v, char ** reply, int * len, void * data);
int cli_add_map (void * v, char ** reply, int * len, void * data);
add_handler(LIST+PATHS, cli_list_paths);
add_handler(LIST+MAPS, cli_list_maps);
add_handler(LIST+MAPS+STATS, cli_list_maps_stats);
+ add_handler(LIST+MULTIPATHS, cli_list_multipaths);
add_handler(ADD+PATH, cli_add_path);
add_handler(DEL+PATH, cli_del_path);
add_handler(ADD+MAP, cli_add_map);