fprintf (stderr, " %s [-d] [-r] [-v lvl] [-p pol] [-b fil] [dev]\n", progname);
fprintf (stderr, " %s -l|-ll|-f [-v lvl] [-b fil] [dev]\n", progname);
fprintf (stderr, " %s -F [-v lvl]\n", progname);
+ fprintf (stderr, " %s -t\n", progname);
fprintf (stderr, " %s -h\n", progname);
fprintf (stderr,
"\n"
" -f flush a multipath device map\n" \
" -F flush all multipath device maps\n" \
" -d dry run, do not create or update devmaps\n" \
+ " -t dump internal hardware table\n" \
" -r force devmap reload\n" \
" -p policy failover|multibus|group_by_serial|group_by_prio\n" \
" -b fil bindings file location\n" \
else
dev = conf->dev;
}
-
+
/*
* if we have a blacklisted device parameter, exit early
*/
- if (dev &&
+ if (dev &&
(filter_devnode(conf->blist_devnode, conf->elist_devnode, dev) > 0))
goto out;
-
+
/*
* scope limiting must be translated into a wwid
* failing the translation is fatal (by policy)
return r;
}
+static int
+dump_config (void)
+{
+ char * c;
+ char * reply;
+ unsigned int maxlen = 256;
+ int again = 1;
+
+ reply = MALLOC(maxlen);
+
+ while (again) {
+ if (!reply)
+ return 1;
+ c = reply;
+ c += snprint_defaults(c, reply + maxlen - c);
+ again = ((c - reply) == maxlen);
+ if (again) {
+ reply = REALLOC(reply, maxlen *= 2);
+ continue;
+ }
+ c += snprint_blacklist(c, reply + maxlen - c);
+ again = ((c - reply) == maxlen);
+ if (again) {
+ reply = REALLOC(reply, maxlen *= 2);
+ continue;
+ }
+ c += snprint_blacklist_except(c, reply + maxlen - c);
+ again = ((c - reply) == maxlen);
+ if (again) {
+ reply = REALLOC(reply, maxlen *= 2);
+ continue;
+ }
+ c += snprint_hwtable(c, reply + maxlen - c, conf->hwtable);
+ again = ((c - reply) == maxlen);
+ if (again) {
+ reply = REALLOC(reply, maxlen *= 2);
+ continue;
+ }
+ c += snprint_mptable(c, reply + maxlen - c, conf->mptable);
+ again = ((c - reply) == maxlen);
+ if (again)
+ reply = REALLOC(reply, maxlen *= 2);
+ }
+
+ printf("%s", reply);
+ FREE(reply);
+ return 0;
+}
+
int
main (int argc, char *argv[])
{
if (load_config(DEFAULT_CONFIGFILE))
exit(1);
- if (init_checkers()) {
- condlog(0, "failed to initialize checkers");
- exit(1);
- }
- if (init_prio()) {
- condlog(0, "failed to initialize prioritizers");
- exit(1);
- }
if (sysfs_init(conf->sysfs_dir, FILE_NAME_SIZE)) {
condlog(0, "multipath tools need sysfs mounted");
exit(1);
}
- while ((arg = getopt(argc, argv, ":dhl::FfM:v:p:b:Br")) != EOF ) {
+ while ((arg = getopt(argc, argv, ":dhl::FfM:v:p:b:Brt")) != EOF ) {
switch(arg) {
case 1: printf("optarg : %s\n",optarg);
break;
conf->verbosity = atoi(optarg);
break;
case 'b':
- conf->bindings_file = optarg;
+ conf->bindings_file = strdup(optarg);
break;
case 'B':
conf->bindings_read_only = 1;
if (conf->pgpolicy_flag == -1) {
printf("'%s' is not a valid policy\n", optarg);
usage(argv[0]);
- }
+ }
break;
case 'r':
conf->force_reload = 1;
break;
+ case 't':
+ dump_config();
+ goto out;
case 'h':
usage(argv[0]);
case ':':
fprintf(stderr, "Missing option arguement\n");
- usage(argv[0]);
+ usage(argv[0]);
case '?':
fprintf(stderr, "Unknown switch: %s\n", optarg);
usage(argv[0]);
default:
usage(argv[0]);
}
- }
+ }
if (optind < argc) {
conf->dev = MALLOC(FILE_NAME_SIZE);
conf->max_fds, strerror(errno));
}
+ if (init_checkers()) {
+ condlog(0, "failed to initialize checkers");
+ exit(1);
+ }
+ if (init_prio()) {
+ condlog(0, "failed to initialize prioritizers");
+ exit(1);
+ }
dm_init();
if (conf->remove == FLUSH_ONE) {