a34a43c747fbc8fbadd504e5808d77d2f87c8876
[multipath-tools/.git] / libmultipath / config.c
1 /*
2  * Copyright (c) 2004, 2005 Christophe Varoqui
3  * Copyright (c) 2005 Benjamin Marzinski, Redhat
4  * Copyright (c) 2005 Edward Goggin, EMC
5  */
6 #include <stdio.h>
7 #include <string.h>
8 #include <libudev.h>
9 #include <dirent.h>
10 #include <limits.h>
11 #include <errno.h>
12
13 #include "checkers.h"
14 #include "memory.h"
15 #include "util.h"
16 #include "debug.h"
17 #include "parser.h"
18 #include "dict.h"
19 #include "hwtable.h"
20 #include "vector.h"
21 #include "structs.h"
22 #include "config.h"
23 #include "blacklist.h"
24 #include "defaults.h"
25 #include "prio.h"
26 #include "devmapper.h"
27 #include "mpath_cmd.h"
28 #include "propsel.h"
29
30 static int
31 hwe_strmatch (const struct hwentry *hwe1, const struct hwentry *hwe2)
32 {
33         if ((hwe2->vendor && !hwe1->vendor) ||
34             (hwe1->vendor && (!hwe2->vendor ||
35                               strcmp(hwe1->vendor, hwe2->vendor))))
36                 return 1;
37
38         if ((hwe2->product && !hwe1->product) ||
39             (hwe1->product && (!hwe2->product ||
40                               strcmp(hwe1->product, hwe2->product))))
41                 return 1;
42
43         if ((hwe2->revision && !hwe1->revision) ||
44             (hwe1->revision && (!hwe2->revision ||
45                               strcmp(hwe1->revision, hwe2->revision))))
46                 return 1;
47
48         return 0;
49 }
50
51 static struct hwentry *
52 find_hwe_strmatch (const struct _vector *hwtable, const struct hwentry *hwe)
53 {
54         int i;
55         struct hwentry *tmp, *ret = NULL;
56
57         vector_foreach_slot (hwtable, tmp, i) {
58                 if (hwe_strmatch(tmp, hwe))
59                         continue;
60                 ret = tmp;
61                 break;
62         }
63         return ret;
64 }
65
66 static int
67 hwe_regmatch (const struct hwentry *hwe1, const char *vendor,
68               const char *product, const char *revision)
69 {
70         regex_t vre, pre, rre;
71         int retval = 1;
72
73         if (hwe1->vendor &&
74             regcomp(&vre, hwe1->vendor, REG_EXTENDED|REG_NOSUB))
75                 goto out;
76
77         if (hwe1->product &&
78             regcomp(&pre, hwe1->product, REG_EXTENDED|REG_NOSUB))
79                 goto out_vre;
80
81         if (hwe1->revision &&
82             regcomp(&rre, hwe1->revision, REG_EXTENDED|REG_NOSUB))
83                 goto out_pre;
84
85         if ((vendor || product || revision) &&
86             (!hwe1->vendor || !vendor ||
87              !regexec(&vre, vendor, 0, NULL, 0)) &&
88             (!hwe1->product || !product ||
89              !regexec(&pre, product, 0, NULL, 0)) &&
90             (!hwe1->revision || !revision ||
91              !regexec(&rre, revision, 0, NULL, 0)))
92                 retval = 0;
93
94         if (hwe1->revision)
95                 regfree(&rre);
96 out_pre:
97         if (hwe1->product)
98                 regfree(&pre);
99 out_vre:
100         if (hwe1->vendor)
101                 regfree(&vre);
102 out:
103         return retval;
104 }
105
106 static void _log_match(const char *fn, const struct hwentry *h,
107                        const char *vendor, const char *product,
108                        const char *revision)
109 {
110         condlog(4, "%s: found match /%s:%s:%s/ for '%s:%s:%s'", fn,
111                 h->vendor, h->product, h->revision,
112                 vendor, product, revision);
113 }
114 #define log_match(h, v, p, r) _log_match(__func__, (h), (v), (p), (r))
115
116 int
117 find_hwe (const struct _vector *hwtable,
118           const char * vendor, const char * product, const char * revision,
119           vector result)
120 {
121         int i, n = 0;
122         struct hwentry *tmp;
123
124         /*
125          * Search backwards here, and add forward.
126          * User modified entries are attached at the end of
127          * the list, so we have to check them first before
128          * continuing to the generic entries
129          */
130         vector_reset(result);
131         vector_foreach_slot_backwards (hwtable, tmp, i) {
132                 if (hwe_regmatch(tmp, vendor, product, revision))
133                         continue;
134                 if (vector_alloc_slot(result) != NULL) {
135                         vector_set_slot(result, tmp);
136                         n++;
137                 }
138                 log_match(tmp, vendor, product, revision);
139         }
140         condlog(n > 1 ? 3 : 4, "%s: found %d hwtable matches for %s:%s:%s",
141                 __func__, n, vendor, product, revision);
142         return n;
143 }
144
145 struct mpentry *find_mpe(vector mptable, char *wwid)
146 {
147         int i;
148         struct mpentry * mpe;
149
150         if (!wwid)
151                 return NULL;
152
153         vector_foreach_slot (mptable, mpe, i)
154                 if (mpe->wwid && !strcmp(mpe->wwid, wwid))
155                         return mpe;
156
157         return NULL;
158 }
159
160 char *get_mpe_wwid(vector mptable, char *alias)
161 {
162         int i;
163         struct mpentry * mpe;
164
165         if (!alias)
166                 return NULL;
167
168         vector_foreach_slot (mptable, mpe, i)
169                 if (mpe->alias && strcmp(mpe->alias, alias) == 0)
170                         return mpe->wwid;
171
172         return NULL;
173 }
174
175 void
176 free_hwe (struct hwentry * hwe)
177 {
178         if (!hwe)
179                 return;
180
181         if (hwe->vendor)
182                 FREE(hwe->vendor);
183
184         if (hwe->product)
185                 FREE(hwe->product);
186
187         if (hwe->revision)
188                 FREE(hwe->revision);
189
190         if (hwe->getuid)
191                 FREE(hwe->getuid);
192
193         if (hwe->uid_attribute)
194                 FREE(hwe->uid_attribute);
195
196         if (hwe->features)
197                 FREE(hwe->features);
198
199         if (hwe->hwhandler)
200                 FREE(hwe->hwhandler);
201
202         if (hwe->selector)
203                 FREE(hwe->selector);
204
205         if (hwe->checker_name)
206                 FREE(hwe->checker_name);
207
208         if (hwe->prio_name)
209                 FREE(hwe->prio_name);
210
211         if (hwe->prio_args)
212                 FREE(hwe->prio_args);
213
214         if (hwe->alias_prefix)
215                 FREE(hwe->alias_prefix);
216
217         if (hwe->bl_product)
218                 FREE(hwe->bl_product);
219
220         FREE(hwe);
221 }
222
223 void
224 free_hwtable (vector hwtable)
225 {
226         int i;
227         struct hwentry * hwe;
228
229         if (!hwtable)
230                 return;
231
232         vector_foreach_slot (hwtable, hwe, i)
233                 free_hwe(hwe);
234
235         vector_free(hwtable);
236 }
237
238 void
239 free_mpe (struct mpentry * mpe)
240 {
241         if (!mpe)
242                 return;
243
244         if (mpe->wwid)
245                 FREE(mpe->wwid);
246
247         if (mpe->selector)
248                 FREE(mpe->selector);
249
250         if (mpe->getuid)
251                 FREE(mpe->getuid);
252
253         if (mpe->uid_attribute)
254                 FREE(mpe->uid_attribute);
255
256         if (mpe->alias)
257                 FREE(mpe->alias);
258
259         if (mpe->prio_name)
260                 FREE(mpe->prio_name);
261
262         if (mpe->prio_args)
263                 FREE(mpe->prio_args);
264
265         FREE(mpe);
266 }
267
268 void
269 free_mptable (vector mptable)
270 {
271         int i;
272         struct mpentry * mpe;
273
274         if (!mptable)
275                 return;
276
277         vector_foreach_slot (mptable, mpe, i)
278                 free_mpe(mpe);
279
280         vector_free(mptable);
281 }
282
283 struct mpentry *
284 alloc_mpe (void)
285 {
286         struct mpentry * mpe = (struct mpentry *)
287                                 MALLOC(sizeof(struct mpentry));
288
289         return mpe;
290 }
291
292 struct hwentry *
293 alloc_hwe (void)
294 {
295         struct hwentry * hwe = (struct hwentry *)
296                                 MALLOC(sizeof(struct hwentry));
297
298         return hwe;
299 }
300
301 static char *
302 set_param_str(const char * str)
303 {
304         char * dst;
305         int len;
306
307         if (!str)
308                 return NULL;
309
310         len = strlen(str);
311
312         if (!len)
313                 return NULL;
314
315         dst = (char *)MALLOC(len + 1);
316
317         if (!dst)
318                 return NULL;
319
320         strcpy(dst, str);
321         return dst;
322 }
323
324 #define merge_str(s) \
325         if (!dst->s && src->s) { \
326                 if (!(dst->s = set_param_str(src->s))) \
327                         return 1; \
328         }
329
330 #define merge_num(s) \
331         if (!dst->s && src->s) \
332                 dst->s = src->s
333
334
335 static int
336 merge_hwe (struct hwentry * dst, struct hwentry * src)
337 {
338         char id[SCSI_VENDOR_SIZE+PATH_PRODUCT_SIZE];
339         merge_str(vendor);
340         merge_str(product);
341         merge_str(revision);
342         merge_str(getuid);
343         merge_str(uid_attribute);
344         merge_str(features);
345         merge_str(hwhandler);
346         merge_str(selector);
347         merge_str(checker_name);
348         merge_str(prio_name);
349         merge_str(prio_args);
350         merge_str(alias_prefix);
351         merge_str(bl_product);
352         merge_num(pgpolicy);
353         merge_num(pgfailback);
354         merge_num(rr_weight);
355         merge_num(no_path_retry);
356         merge_num(minio);
357         merge_num(minio_rq);
358         merge_num(flush_on_last_del);
359         merge_num(fast_io_fail);
360         merge_num(dev_loss);
361         merge_num(user_friendly_names);
362         merge_num(retain_hwhandler);
363         merge_num(detect_prio);
364         merge_num(detect_checker);
365         merge_num(deferred_remove);
366         merge_num(delay_watch_checks);
367         merge_num(delay_wait_checks);
368         merge_num(skip_kpartx);
369         merge_num(max_sectors_kb);
370         merge_num(ghost_delay);
371         merge_num(all_tg_pt);
372
373         snprintf(id, sizeof(id), "%s/%s", dst->vendor, dst->product);
374         reconcile_features_with_options(id, &dst->features,
375                                         &dst->no_path_retry,
376                                         &dst->retain_hwhandler);
377         return 0;
378 }
379
380 static int
381 merge_mpe(struct mpentry *dst, struct mpentry *src)
382 {
383         if (!dst || !src)
384                 return 1;
385
386         merge_str(alias);
387         merge_str(uid_attribute);
388         merge_str(getuid);
389         merge_str(selector);
390         merge_str(features);
391         merge_str(prio_name);
392         merge_str(prio_args);
393
394         if (dst->prkey_source == PRKEY_SOURCE_NONE &&
395             src->prkey_source != PRKEY_SOURCE_NONE) {
396                 dst->prkey_source = src->prkey_source;
397                 memcpy(&dst->reservation_key, &src->reservation_key,
398                        sizeof(dst->reservation_key));
399         }
400
401         merge_num(pgpolicy);
402         merge_num(pgfailback);
403         merge_num(rr_weight);
404         merge_num(no_path_retry);
405         merge_num(minio);
406         merge_num(minio_rq);
407         merge_num(flush_on_last_del);
408         merge_num(attribute_flags);
409         merge_num(user_friendly_names);
410         merge_num(deferred_remove);
411         merge_num(delay_watch_checks);
412         merge_num(delay_wait_checks);
413         merge_num(marginal_path_err_sample_time);
414         merge_num(marginal_path_err_rate_threshold);
415         merge_num(marginal_path_err_recheck_gap_time);
416         merge_num(marginal_path_double_failed_time);
417         merge_num(skip_kpartx);
418         merge_num(max_sectors_kb);
419         merge_num(ghost_delay);
420         merge_num(uid);
421         merge_num(gid);
422         merge_num(mode);
423
424         return 0;
425 }
426
427 void merge_mptable(vector mptable)
428 {
429         struct mpentry *mp1, *mp2;
430         int i, j;
431
432         vector_foreach_slot(mptable, mp1, i) {
433                 j = i + 1;
434                 vector_foreach_slot_after(mptable, mp2, j) {
435                         if (strcmp(mp1->wwid, mp2->wwid))
436                                 continue;
437                         condlog(1, "%s: duplicate multipath config section for %s",
438                                 __func__, mp1->wwid);
439                         merge_mpe(mp2, mp1);
440                         free_mpe(mp1);
441                         vector_del_slot(mptable, i);
442                         i--;
443                         break;
444                 }
445         }
446 }
447
448 int
449 store_hwe (vector hwtable, struct hwentry * dhwe)
450 {
451         struct hwentry * hwe;
452
453         if (find_hwe_strmatch(hwtable, dhwe))
454                 return 0;
455
456         if (!(hwe = alloc_hwe()))
457                 return 1;
458
459         if (!dhwe->vendor || !(hwe->vendor = set_param_str(dhwe->vendor)))
460                 goto out;
461
462         if (!dhwe->product || !(hwe->product = set_param_str(dhwe->product)))
463                 goto out;
464
465         if (dhwe->revision && !(hwe->revision = set_param_str(dhwe->revision)))
466                 goto out;
467
468         if (dhwe->uid_attribute && !(hwe->uid_attribute = set_param_str(dhwe->uid_attribute)))
469                 goto out;
470
471         if (dhwe->getuid && !(hwe->getuid = set_param_str(dhwe->getuid)))
472                 goto out;
473
474         if (dhwe->features && !(hwe->features = set_param_str(dhwe->features)))
475                 goto out;
476
477         if (dhwe->hwhandler && !(hwe->hwhandler = set_param_str(dhwe->hwhandler)))
478                 goto out;
479
480         if (dhwe->selector && !(hwe->selector = set_param_str(dhwe->selector)))
481                 goto out;
482
483         if (dhwe->checker_name && !(hwe->checker_name = set_param_str(dhwe->checker_name)))
484                 goto out;
485
486         if (dhwe->prio_name && !(hwe->prio_name = set_param_str(dhwe->prio_name)))
487                 goto out;
488
489         if (dhwe->prio_args && !(hwe->prio_args = set_param_str(dhwe->prio_args)))
490                 goto out;
491
492         if (dhwe->alias_prefix && !(hwe->alias_prefix = set_param_str(dhwe->alias_prefix)))
493                 goto out;
494
495         hwe->pgpolicy = dhwe->pgpolicy;
496         hwe->pgfailback = dhwe->pgfailback;
497         hwe->rr_weight = dhwe->rr_weight;
498         hwe->no_path_retry = dhwe->no_path_retry;
499         hwe->minio = dhwe->minio;
500         hwe->minio_rq = dhwe->minio_rq;
501         hwe->flush_on_last_del = dhwe->flush_on_last_del;
502         hwe->fast_io_fail = dhwe->fast_io_fail;
503         hwe->dev_loss = dhwe->dev_loss;
504         hwe->user_friendly_names = dhwe->user_friendly_names;
505         hwe->retain_hwhandler = dhwe->retain_hwhandler;
506         hwe->detect_prio = dhwe->detect_prio;
507         hwe->detect_checker = dhwe->detect_checker;
508         hwe->ghost_delay = dhwe->ghost_delay;
509
510         if (dhwe->bl_product && !(hwe->bl_product = set_param_str(dhwe->bl_product)))
511                 goto out;
512
513         if (!vector_alloc_slot(hwtable))
514                 goto out;
515
516         vector_set_slot(hwtable, hwe);
517         return 0;
518 out:
519         free_hwe(hwe);
520         return 1;
521 }
522
523 static void
524 factorize_hwtable (vector hw, int n, const char *table_desc)
525 {
526         struct hwentry *hwe1, *hwe2;
527         int i, j;
528
529 restart:
530         vector_foreach_slot(hw, hwe1, i) {
531                 if (i == n)
532                         break;
533                 j = n;
534                 /* drop invalid device configs */
535                 if (i >= n && (!hwe1->vendor || !hwe1->product)) {
536                         condlog(0, "device config in %s missing vendor or product parameter",
537                                 table_desc);
538                         vector_del_slot(hw, i--);
539                         free_hwe(hwe1);
540                         continue;
541                 }
542                 j = n > i + 1 ? n : i + 1;
543                 vector_foreach_slot_after(hw, hwe2, j) {
544                         if (hwe_strmatch(hwe2, hwe1) == 0) {
545                                 condlog(i >= n ? 1 : 3,
546                                         "%s: duplicate device section for %s:%s:%s in %s",
547                                         __func__, hwe1->vendor, hwe1->product,
548                                         hwe1->revision, table_desc);
549                                 vector_del_slot(hw, i);
550                                 merge_hwe(hwe2, hwe1);
551                                 free_hwe(hwe1);
552                                 if (i < n)
553                                         n -= 1;
554                                 /*
555                                  * Play safe here; we have modified
556                                  * the original vector so the outer
557                                  * vector_foreach_slot() might
558                                  * become confused.
559                                  */
560                                 goto restart;
561                         }
562                 }
563         }
564         return;
565 }
566
567 struct config *
568 alloc_config (void)
569 {
570         return (struct config *)MALLOC(sizeof(struct config));
571 }
572
573 void
574 free_config (struct config * conf)
575 {
576         if (!conf)
577                 return;
578
579         if (conf->multipath_dir)
580                 FREE(conf->multipath_dir);
581
582         if (conf->selector)
583                 FREE(conf->selector);
584
585         if (conf->uid_attribute)
586                 FREE(conf->uid_attribute);
587
588         if (conf->uid_attrs)
589                 FREE(conf->uid_attrs);
590
591         if (conf->getuid)
592                 FREE(conf->getuid);
593
594         if (conf->features)
595                 FREE(conf->features);
596
597         if (conf->hwhandler)
598                 FREE(conf->hwhandler);
599
600         if (conf->bindings_file)
601                 FREE(conf->bindings_file);
602
603         if (conf->wwids_file)
604                 FREE(conf->wwids_file);
605
606         if (conf->prkeys_file)
607                 FREE(conf->prkeys_file);
608
609         if (conf->prio_name)
610                 FREE(conf->prio_name);
611
612         if (conf->alias_prefix)
613                 FREE(conf->alias_prefix);
614         if (conf->partition_delim)
615                 FREE(conf->partition_delim);
616
617         if (conf->prio_args)
618                 FREE(conf->prio_args);
619
620         if (conf->checker_name)
621                 FREE(conf->checker_name);
622
623         if (conf->config_dir)
624                 FREE(conf->config_dir);
625
626         free_blacklist(conf->blist_devnode);
627         free_blacklist(conf->blist_wwid);
628         free_blacklist(conf->blist_property);
629         free_blacklist_device(conf->blist_device);
630
631         free_blacklist(conf->elist_devnode);
632         free_blacklist(conf->elist_wwid);
633         free_blacklist(conf->elist_property);
634         free_blacklist_device(conf->elist_device);
635
636         free_mptable(conf->mptable);
637         free_hwtable(conf->hwtable);
638         free_hwe(conf->overrides);
639         free_keywords(conf->keywords);
640         FREE(conf);
641 }
642
643 static void free_namelist(void *nl)
644 {
645         free(nl);
646 }
647
648 /* if multipath fails to process the config directory, it should continue,
649  * with just a warning message */
650 static void
651 process_config_dir(struct config *conf, vector keywords, char *dir)
652 {
653         struct dirent **namelist;
654         int i, n;
655         char path[LINE_MAX];
656         int old_hwtable_size;
657
658         if (dir[0] != '/') {
659                 condlog(1, "config_dir '%s' must be a fully qualified path",
660                         dir);
661                 return;
662         }
663         n = scandir(dir, &namelist, NULL, alphasort);
664         if (n < 0) {
665                 if (errno == ENOENT)
666                         condlog(3, "No configuration dir '%s'", dir);
667                 else
668                         condlog(0, "couldn't open configuration dir '%s': %s",
669                                 dir, strerror(errno));
670                 return;
671         } else if (n == 0)
672                 return;
673         pthread_cleanup_push(free_namelist, namelist);
674         for (i = 0; i < n; i++) {
675                 if (!strstr(namelist[i]->d_name, ".conf"))
676                         continue;
677                 old_hwtable_size = VECTOR_SIZE(conf->hwtable);
678                 snprintf(path, LINE_MAX, "%s/%s", dir, namelist[i]->d_name);
679                 path[LINE_MAX-1] = '\0';
680                 process_file(conf, path);
681                 factorize_hwtable(conf->hwtable, old_hwtable_size,
682                                   namelist[i]->d_name);
683         }
684         pthread_cleanup_pop(1);
685 }
686
687 struct config *
688 load_config (char * file)
689 {
690         struct config *conf = alloc_config();
691
692         if (!conf)
693                 return NULL;
694
695         /*
696          * internal defaults
697          */
698         conf->verbosity = DEFAULT_VERBOSITY;
699
700         get_sys_max_fds(&conf->max_fds);
701         conf->bindings_file = set_default(DEFAULT_BINDINGS_FILE);
702         conf->wwids_file = set_default(DEFAULT_WWIDS_FILE);
703         conf->prkeys_file = set_default(DEFAULT_PRKEYS_FILE);
704         conf->multipath_dir = set_default(DEFAULT_MULTIPATHDIR);
705         conf->attribute_flags = 0;
706         conf->reassign_maps = DEFAULT_REASSIGN_MAPS;
707         conf->checkint = DEFAULT_CHECKINT;
708         conf->max_checkint = 0;
709         conf->force_sync = DEFAULT_FORCE_SYNC;
710         conf->partition_delim = DEFAULT_PARTITION_DELIM;
711         conf->processed_main_config = 0;
712         conf->find_multipaths = DEFAULT_FIND_MULTIPATHS;
713         conf->uxsock_timeout = DEFAULT_REPLY_TIMEOUT;
714         conf->retrigger_tries = DEFAULT_RETRIGGER_TRIES;
715         conf->retrigger_delay = DEFAULT_RETRIGGER_DELAY;
716         conf->uev_wait_timeout = DEFAULT_UEV_WAIT_TIMEOUT;
717         conf->disable_changed_wwids = DEFAULT_DISABLE_CHANGED_WWIDS;
718         conf->remove_retries = 0;
719         conf->ghost_delay = DEFAULT_GHOST_DELAY;
720         conf->all_tg_pt = DEFAULT_ALL_TG_PT;
721
722         /*
723          * preload default hwtable
724          */
725         conf->hwtable = vector_alloc();
726         if (!conf->hwtable)
727                         goto out;
728         if (setup_default_hwtable(conf->hwtable))
729                 goto out;
730
731 #ifdef CHECK_BUILTIN_HWTABLE
732         factorize_hwtable(conf->hwtable, 0, "builtin");
733 #endif
734         /*
735          * read the config file
736          */
737         conf->keywords = vector_alloc();
738         init_keywords(conf->keywords);
739         if (filepresent(file)) {
740                 int builtin_hwtable_size;
741
742                 builtin_hwtable_size = VECTOR_SIZE(conf->hwtable);
743                 if (process_file(conf, file)) {
744                         condlog(0, "error parsing config file");
745                         goto out;
746                 }
747                 factorize_hwtable(conf->hwtable, builtin_hwtable_size, file);
748         }
749
750         conf->processed_main_config = 1;
751         if (conf->config_dir == NULL)
752                 conf->config_dir = set_default(DEFAULT_CONFIG_DIR);
753         if (conf->config_dir && conf->config_dir[0] != '\0')
754                 process_config_dir(conf, conf->keywords, conf->config_dir);
755
756         /*
757          * fill the voids left in the config file
758          */
759         if (conf->max_checkint == 0)
760                 conf->max_checkint = MAX_CHECKINT(conf->checkint);
761         if (conf->blist_devnode == NULL) {
762                 conf->blist_devnode = vector_alloc();
763
764                 if (!conf->blist_devnode)
765                         goto out;
766         }
767         if (conf->blist_wwid == NULL) {
768                 conf->blist_wwid = vector_alloc();
769
770                 if (!conf->blist_wwid)
771                         goto out;
772         }
773         if (conf->blist_device == NULL) {
774                 conf->blist_device = vector_alloc();
775
776                 if (!conf->blist_device)
777                         goto out;
778         }
779         if (conf->blist_property == NULL) {
780                 conf->blist_property = vector_alloc();
781
782                 if (!conf->blist_property)
783                         goto out;
784         }
785
786         if (conf->elist_devnode == NULL) {
787                 conf->elist_devnode = vector_alloc();
788
789                 if (!conf->elist_devnode)
790                         goto out;
791         }
792         if (conf->elist_wwid == NULL) {
793                 conf->elist_wwid = vector_alloc();
794
795                 if (!conf->elist_wwid)
796                         goto out;
797         }
798
799         if (conf->elist_device == NULL) {
800                 conf->elist_device = vector_alloc();
801
802                 if (!conf->elist_device)
803                         goto out;
804         }
805
806         if (conf->elist_property == NULL) {
807                 conf->elist_property = vector_alloc();
808
809                 if (!conf->elist_property)
810                         goto out;
811         }
812         if (setup_default_blist(conf))
813                 goto out;
814
815         if (conf->mptable == NULL) {
816                 conf->mptable = vector_alloc();
817                 if (!conf->mptable)
818                         goto out;
819         }
820
821         merge_mptable(conf->mptable);
822         merge_blacklist(conf->blist_devnode);
823         merge_blacklist(conf->blist_property);
824         merge_blacklist(conf->blist_wwid);
825         merge_blacklist_device(conf->blist_device);
826         merge_blacklist(conf->elist_devnode);
827         merge_blacklist(conf->elist_property);
828         merge_blacklist(conf->elist_wwid);
829         merge_blacklist_device(conf->elist_device);
830
831         if (conf->bindings_file == NULL)
832                 conf->bindings_file = set_default(DEFAULT_BINDINGS_FILE);
833
834         if (!conf->multipath_dir || !conf->bindings_file ||
835             !conf->wwids_file || !conf->prkeys_file)
836                 goto out;
837
838         return conf;
839 out:
840         free_config(conf);
841         return NULL;
842 }