libmultipath: print correct default for delay_*_checks
[multipath-tools/.git] / libmultipath / dict.c
1 /*
2  * Based on Alexandre Cassen template for keepalived
3  * Copyright (c) 2004, 2005, 2006  Christophe Varoqui
4  * Copyright (c) 2005 Benjamin Marzinski, Redhat
5  * Copyright (c) 2005 Kiyoshi Ueda, NEC
6  */
7 #include <sys/types.h>
8 #include <pwd.h>
9 #include <string.h>
10 #include "checkers.h"
11 #include "vector.h"
12 #include "hwtable.h"
13 #include "structs.h"
14 #include "parser.h"
15 #include "config.h"
16 #include "debug.h"
17 #include "memory.h"
18 #include "pgpolicies.h"
19 #include "blacklist.h"
20 #include "defaults.h"
21 #include "prio.h"
22 #include "util.h"
23 #include <errno.h>
24 #include <inttypes.h>
25 #include <libudev.h>
26 #include <mpath_persist.h>
27 #include "mpath_cmd.h"
28 #include "dict.h"
29
30 static int
31 set_int(vector strvec, void *ptr)
32 {
33         int *int_ptr = (int *)ptr;
34         char * buff;
35
36         buff = VECTOR_SLOT(strvec, 1);
37         *int_ptr = atoi(buff);
38
39         return 0;
40 }
41
42 static int
43 set_str(vector strvec, void *ptr)
44 {
45         char **str_ptr = (char **)ptr;
46
47         if (*str_ptr)
48                 FREE(*str_ptr);
49         *str_ptr = set_value(strvec);
50
51         if (!*str_ptr)
52                 return 1;
53
54         return 0;
55 }
56
57 static int
58 set_yes_no(vector strvec, void *ptr)
59 {
60         char * buff;
61         int *int_ptr = (int *)ptr;
62
63         buff = set_value(strvec);
64         if (!buff)
65                 return 1;
66
67         if (strcmp(buff, "yes") == 0 || strcmp(buff, "1") == 0)
68                 *int_ptr = YN_YES;
69         else
70                 *int_ptr = YN_NO;
71
72         FREE(buff);
73         return 0;
74 }
75
76 static int
77 set_yes_no_undef(vector strvec, void *ptr)
78 {
79         char * buff;
80         int *int_ptr = (int *)ptr;
81
82         buff = set_value(strvec);
83         if (!buff)
84                 return 1;
85
86         if (strcmp(buff, "no") == 0 || strcmp(buff, "0") == 0)
87                 *int_ptr = YNU_NO;
88         else if (strcmp(buff, "yes") == 0 || strcmp(buff, "1") == 0)
89                 *int_ptr = YNU_YES;
90         else
91                 *int_ptr = YNU_UNDEF;
92
93         FREE(buff);
94         return 0;
95 }
96
97 static int
98 print_int (char *buff, int len, long v)
99 {
100         return snprintf(buff, len, "%li", v);
101 }
102
103 static int
104 print_nonzero (char *buff, int len, long v)
105 {
106         if (!v)
107                 return 0;
108         return snprintf(buff, len, "%li", v);
109 }
110
111 static int
112 print_str (char *buff, int len, const char *ptr)
113 {
114         char *p;
115         char *last;
116         const char *q;
117
118         if (!ptr || len <= 0)
119                 return 0;
120
121         q = strchr(ptr, '"');
122         if (q == NULL)
123                 return snprintf(buff, len, "\"%s\"", ptr);
124
125         last = buff + len - 1;
126         p = buff;
127         if (p >= last)
128                 goto out;
129         *p++ = '"';
130         if (p >= last)
131                 goto out;
132         for (; q; q = strchr(ptr, '"')) {
133                 if (q + 1 - ptr < last - p)
134                         p = mempcpy(p, ptr, q + 1 - ptr);
135                 else {
136                         p = mempcpy(p, ptr, last - p);
137                         goto out;
138                 }
139                 *p++ = '"';
140                 if (p >= last)
141                         goto out;
142                 ptr = q + 1;
143         }
144         p += strlcpy(p, ptr, last - p);
145         if (p >= last)
146                 goto out;
147         *p++ = '"';
148         *p = '\0';
149         return p - buff;
150 out:
151         *p = '\0';
152         return len;
153 }
154
155 static int
156 print_yes_no (char *buff, int len, long v)
157 {
158         return snprintf(buff, len, "\"%s\"",
159                         (v == YN_NO)? "no" : "yes");
160 }
161
162 static int
163 print_yes_no_undef (char *buff, int len, long v)
164 {
165         if (!v)
166                 return 0;
167         return snprintf(buff, len, "\"%s\"",
168                         (v == YNU_NO)? "no" : "yes");
169 }
170
171 #define declare_def_handler(option, function)                           \
172 static int                                                              \
173 def_ ## option ## _handler (struct config *conf, vector strvec)         \
174 {                                                                       \
175         return function (strvec, &conf->option);                        \
176 }
177
178 #define declare_def_snprint(option, function)                           \
179 static int                                                              \
180 snprint_def_ ## option (struct config *conf, char * buff, int len,      \
181                         const void * data)                              \
182 {                                                                       \
183         return function (buff, len, conf->option);                      \
184 }
185
186 #define declare_def_snprint_defint(option, function, value)             \
187 static int                                                              \
188 snprint_def_ ## option (struct config *conf, char * buff, int len,      \
189                         const void * data)                              \
190 {                                                                       \
191         int i = value;                                                  \
192         if (!conf->option)                                              \
193                 return function (buff, len, i);                         \
194         return function (buff, len, conf->option);                      \
195 }
196
197 #define declare_def_snprint_defstr(option, function, value)             \
198 static int                                                              \
199 snprint_def_ ## option (struct config *conf, char * buff, int len,      \
200                         const void * data)                              \
201 {                                                                       \
202         static const char *s = value;                                   \
203         if (!conf->option)                                              \
204                 return function (buff, len, s);                         \
205         return function (buff, len, conf->option);                      \
206 }
207
208 #define declare_hw_handler(option, function)                            \
209 static int                                                              \
210 hw_ ## option ## _handler (struct config *conf, vector strvec)          \
211 {                                                                       \
212         struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);         \
213         if (!hwe)                                                       \
214                 return 1;                                               \
215         return function (strvec, &hwe->option);                         \
216 }
217
218 #define declare_hw_snprint(option, function)                            \
219 static int                                                              \
220 snprint_hw_ ## option (struct config *conf, char * buff, int len,       \
221                        const void * data)                               \
222 {                                                                       \
223         const struct hwentry * hwe = (const struct hwentry *)data;      \
224         return function (buff, len, hwe->option);                       \
225 }
226
227 #define declare_ovr_handler(option, function)                           \
228 static int                                                              \
229 ovr_ ## option ## _handler (struct config *conf, vector strvec)         \
230 {                                                                       \
231         if (!conf->overrides)                                           \
232                 return 1;                                               \
233         return function (strvec, &conf->overrides->option);             \
234 }
235
236 #define declare_ovr_snprint(option, function)                           \
237 static int                                                              \
238 snprint_ovr_ ## option (struct config *conf, char * buff, int len,      \
239                         const void * data)                              \
240 {                                                                       \
241         return function (buff, len, conf->overrides->option);           \
242 }
243
244 #define declare_mp_handler(option, function)                            \
245 static int                                                              \
246 mp_ ## option ## _handler (struct config *conf, vector strvec)          \
247 {                                                                       \
248         struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable);         \
249         if (!mpe)                                                       \
250                 return 1;                                               \
251         return function (strvec, &mpe->option);                         \
252 }
253
254 #define declare_mp_snprint(option, function)                            \
255 static int                                                              \
256 snprint_mp_ ## option (struct config *conf, char * buff, int len,       \
257                        const void * data)                               \
258 {                                                                       \
259         const struct mpentry * mpe = (const struct mpentry *)data;      \
260         return function (buff, len, mpe->option);                       \
261 }
262
263 declare_def_handler(checkint, set_int)
264 declare_def_snprint(checkint, print_int)
265
266 declare_def_handler(max_checkint, set_int)
267 declare_def_snprint(max_checkint, print_int)
268
269 declare_def_handler(verbosity, set_int)
270 declare_def_snprint(verbosity, print_int)
271
272 declare_def_handler(reassign_maps, set_yes_no)
273 declare_def_snprint(reassign_maps, print_yes_no)
274
275 declare_def_handler(multipath_dir, set_str)
276 declare_def_snprint(multipath_dir, print_str)
277
278 declare_def_handler(partition_delim, set_str)
279 declare_def_snprint(partition_delim, print_str)
280
281 static const char * const find_multipaths_optvals[] = {
282         [FIND_MULTIPATHS_OFF] = "off",
283         [FIND_MULTIPATHS_ON] = "on",
284         [FIND_MULTIPATHS_STRICT] = "strict",
285         [FIND_MULTIPATHS_GREEDY] = "greedy",
286         [FIND_MULTIPATHS_SMART] = "smart",
287 };
288
289 static int
290 def_find_multipaths_handler(struct config *conf, vector strvec)
291 {
292         char *buff;
293         int i;
294
295         if (set_yes_no_undef(strvec, &conf->find_multipaths) == 0 &&
296             conf->find_multipaths != YNU_UNDEF)
297                 return 0;
298
299         buff = set_value(strvec);
300         if (!buff)
301                 return 1;
302
303         for (i = FIND_MULTIPATHS_OFF; i < __FIND_MULTIPATHS_LAST; i++) {
304                 if (find_multipaths_optvals[i] != NULL &&
305                     !strcmp(buff, find_multipaths_optvals[i])) {
306                         conf->find_multipaths = i;
307                         break;
308                 }
309         }
310
311         if (conf->find_multipaths == YNU_UNDEF) {
312                 condlog(0, "illegal value for find_multipaths: %s", buff);
313                 conf->find_multipaths = DEFAULT_FIND_MULTIPATHS;
314         }
315
316         FREE(buff);
317         return 0;
318 }
319
320 static int
321 snprint_def_find_multipaths(struct config *conf, char *buff, int len,
322                             const void *data)
323 {
324         return print_str(buff, len,
325                          find_multipaths_optvals[conf->find_multipaths]);
326 }
327
328 declare_def_handler(selector, set_str)
329 declare_def_snprint_defstr(selector, print_str, DEFAULT_SELECTOR)
330 declare_hw_handler(selector, set_str)
331 declare_hw_snprint(selector, print_str)
332 declare_ovr_handler(selector, set_str)
333 declare_ovr_snprint(selector, print_str)
334 declare_mp_handler(selector, set_str)
335 declare_mp_snprint(selector, print_str)
336
337 declare_def_handler(uid_attrs, set_str)
338 declare_def_snprint(uid_attrs, print_str)
339 declare_def_handler(uid_attribute, set_str)
340 declare_def_snprint_defstr(uid_attribute, print_str, DEFAULT_UID_ATTRIBUTE)
341 declare_ovr_handler(uid_attribute, set_str)
342 declare_ovr_snprint(uid_attribute, print_str)
343 declare_hw_handler(uid_attribute, set_str)
344 declare_hw_snprint(uid_attribute, print_str)
345
346 declare_def_handler(getuid, set_str)
347 declare_def_snprint(getuid, print_str)
348 declare_ovr_handler(getuid, set_str)
349 declare_ovr_snprint(getuid, print_str)
350 declare_hw_handler(getuid, set_str)
351 declare_hw_snprint(getuid, print_str)
352
353 declare_def_handler(prio_name, set_str)
354 declare_def_snprint_defstr(prio_name, print_str, DEFAULT_PRIO)
355 declare_ovr_handler(prio_name, set_str)
356 declare_ovr_snprint(prio_name, print_str)
357 declare_hw_handler(prio_name, set_str)
358 declare_hw_snprint(prio_name, print_str)
359 declare_mp_handler(prio_name, set_str)
360 declare_mp_snprint(prio_name, print_str)
361
362 declare_def_handler(alias_prefix, set_str)
363 declare_def_snprint_defstr(alias_prefix, print_str, DEFAULT_ALIAS_PREFIX)
364 declare_ovr_handler(alias_prefix, set_str)
365 declare_ovr_snprint(alias_prefix, print_str)
366 declare_hw_handler(alias_prefix, set_str)
367 declare_hw_snprint(alias_prefix, print_str)
368
369 declare_def_handler(prio_args, set_str)
370 declare_def_snprint_defstr(prio_args, print_str, DEFAULT_PRIO_ARGS)
371 declare_ovr_handler(prio_args, set_str)
372 declare_ovr_snprint(prio_args, print_str)
373 declare_hw_handler(prio_args, set_str)
374 declare_hw_snprint(prio_args, print_str)
375 declare_mp_handler(prio_args, set_str)
376 declare_mp_snprint(prio_args, print_str)
377
378 declare_def_handler(features, set_str)
379 declare_def_snprint_defstr(features, print_str, DEFAULT_FEATURES)
380 declare_ovr_handler(features, set_str)
381 declare_ovr_snprint(features, print_str)
382 declare_hw_handler(features, set_str)
383 declare_hw_snprint(features, print_str)
384 declare_mp_handler(features, set_str)
385 declare_mp_snprint(features, print_str)
386
387 declare_def_handler(checker_name, set_str)
388 declare_def_snprint_defstr(checker_name, print_str, DEFAULT_CHECKER)
389 declare_ovr_handler(checker_name, set_str)
390 declare_ovr_snprint(checker_name, print_str)
391 declare_hw_handler(checker_name, set_str)
392 declare_hw_snprint(checker_name, print_str)
393
394 declare_def_handler(minio, set_int)
395 declare_def_snprint_defint(minio, print_int, DEFAULT_MINIO)
396 declare_ovr_handler(minio, set_int)
397 declare_ovr_snprint(minio, print_nonzero)
398 declare_hw_handler(minio, set_int)
399 declare_hw_snprint(minio, print_nonzero)
400 declare_mp_handler(minio, set_int)
401 declare_mp_snprint(minio, print_nonzero)
402
403 declare_def_handler(minio_rq, set_int)
404 declare_def_snprint_defint(minio_rq, print_int, DEFAULT_MINIO_RQ)
405 declare_ovr_handler(minio_rq, set_int)
406 declare_ovr_snprint(minio_rq, print_nonzero)
407 declare_hw_handler(minio_rq, set_int)
408 declare_hw_snprint(minio_rq, print_nonzero)
409 declare_mp_handler(minio_rq, set_int)
410 declare_mp_snprint(minio_rq, print_nonzero)
411
412 declare_def_handler(queue_without_daemon, set_yes_no)
413 static int
414 snprint_def_queue_without_daemon (struct config *conf,
415                                   char * buff, int len, const void * data)
416 {
417         switch (conf->queue_without_daemon) {
418         case QUE_NO_DAEMON_OFF:
419                 return snprintf(buff, len, "\"no\"");
420         case QUE_NO_DAEMON_ON:
421                 return snprintf(buff, len, "\"yes\"");
422         case QUE_NO_DAEMON_FORCE:
423                 return snprintf(buff, len, "\"forced\"");
424         }
425         return 0;
426 }
427
428 declare_def_handler(checker_timeout, set_int)
429 declare_def_snprint(checker_timeout, print_nonzero)
430
431 declare_def_handler(flush_on_last_del, set_yes_no_undef)
432 declare_def_snprint_defint(flush_on_last_del, print_yes_no_undef, DEFAULT_FLUSH)
433 declare_ovr_handler(flush_on_last_del, set_yes_no_undef)
434 declare_ovr_snprint(flush_on_last_del, print_yes_no_undef)
435 declare_hw_handler(flush_on_last_del, set_yes_no_undef)
436 declare_hw_snprint(flush_on_last_del, print_yes_no_undef)
437 declare_mp_handler(flush_on_last_del, set_yes_no_undef)
438 declare_mp_snprint(flush_on_last_del, print_yes_no_undef)
439
440 declare_def_handler(user_friendly_names, set_yes_no_undef)
441 declare_def_snprint_defint(user_friendly_names, print_yes_no_undef,
442                            DEFAULT_USER_FRIENDLY_NAMES)
443 declare_ovr_handler(user_friendly_names, set_yes_no_undef)
444 declare_ovr_snprint(user_friendly_names, print_yes_no_undef)
445 declare_hw_handler(user_friendly_names, set_yes_no_undef)
446 declare_hw_snprint(user_friendly_names, print_yes_no_undef)
447 declare_mp_handler(user_friendly_names, set_yes_no_undef)
448 declare_mp_snprint(user_friendly_names, print_yes_no_undef)
449
450 declare_def_handler(bindings_file, set_str)
451 declare_def_snprint(bindings_file, print_str)
452
453 declare_def_handler(wwids_file, set_str)
454 declare_def_snprint(wwids_file, print_str)
455
456 declare_def_handler(prkeys_file, set_str)
457 declare_def_snprint(prkeys_file, print_str)
458
459 declare_def_handler(retain_hwhandler, set_yes_no_undef)
460 declare_def_snprint_defint(retain_hwhandler, print_yes_no_undef,
461                            DEFAULT_RETAIN_HWHANDLER)
462 declare_ovr_handler(retain_hwhandler, set_yes_no_undef)
463 declare_ovr_snprint(retain_hwhandler, print_yes_no_undef)
464 declare_hw_handler(retain_hwhandler, set_yes_no_undef)
465 declare_hw_snprint(retain_hwhandler, print_yes_no_undef)
466
467 declare_def_handler(detect_prio, set_yes_no_undef)
468 declare_def_snprint_defint(detect_prio, print_yes_no_undef,
469                            DEFAULT_DETECT_PRIO)
470 declare_ovr_handler(detect_prio, set_yes_no_undef)
471 declare_ovr_snprint(detect_prio, print_yes_no_undef)
472 declare_hw_handler(detect_prio, set_yes_no_undef)
473 declare_hw_snprint(detect_prio, print_yes_no_undef)
474
475 declare_def_handler(detect_checker, set_yes_no_undef)
476 declare_def_snprint_defint(detect_checker, print_yes_no_undef,
477                            DEFAULT_DETECT_CHECKER)
478 declare_ovr_handler(detect_checker, set_yes_no_undef)
479 declare_ovr_snprint(detect_checker, print_yes_no_undef)
480 declare_hw_handler(detect_checker, set_yes_no_undef)
481 declare_hw_snprint(detect_checker, print_yes_no_undef)
482
483 declare_def_handler(force_sync, set_yes_no)
484 declare_def_snprint(force_sync, print_yes_no)
485
486 declare_def_handler(deferred_remove, set_yes_no_undef)
487 declare_def_snprint_defint(deferred_remove, print_yes_no_undef,
488                            DEFAULT_DEFERRED_REMOVE)
489 declare_ovr_handler(deferred_remove, set_yes_no_undef)
490 declare_ovr_snprint(deferred_remove, print_yes_no_undef)
491 declare_hw_handler(deferred_remove, set_yes_no_undef)
492 declare_hw_snprint(deferred_remove, print_yes_no_undef)
493 declare_mp_handler(deferred_remove, set_yes_no_undef)
494 declare_mp_snprint(deferred_remove, print_yes_no_undef)
495
496 declare_def_handler(retrigger_tries, set_int)
497 declare_def_snprint(retrigger_tries, print_int)
498
499 declare_def_handler(retrigger_delay, set_int)
500 declare_def_snprint(retrigger_delay, print_int)
501
502 declare_def_handler(uev_wait_timeout, set_int)
503 declare_def_snprint(uev_wait_timeout, print_int)
504
505 declare_def_handler(strict_timing, set_yes_no)
506 declare_def_snprint(strict_timing, print_yes_no)
507
508 declare_def_handler(skip_kpartx, set_yes_no_undef)
509 declare_def_snprint_defint(skip_kpartx, print_yes_no_undef,
510                            DEFAULT_SKIP_KPARTX)
511 declare_ovr_handler(skip_kpartx, set_yes_no_undef)
512 declare_ovr_snprint(skip_kpartx, print_yes_no_undef)
513 declare_hw_handler(skip_kpartx, set_yes_no_undef)
514 declare_hw_snprint(skip_kpartx, print_yes_no_undef)
515 declare_mp_handler(skip_kpartx, set_yes_no_undef)
516 declare_mp_snprint(skip_kpartx, print_yes_no_undef)
517
518 declare_def_handler(disable_changed_wwids, set_yes_no)
519 declare_def_snprint(disable_changed_wwids, print_yes_no)
520
521 declare_def_handler(remove_retries, set_int)
522 declare_def_snprint(remove_retries, print_int)
523
524 declare_def_handler(max_sectors_kb, set_int)
525 declare_def_snprint(max_sectors_kb, print_nonzero)
526 declare_ovr_handler(max_sectors_kb, set_int)
527 declare_ovr_snprint(max_sectors_kb, print_nonzero)
528 declare_hw_handler(max_sectors_kb, set_int)
529 declare_hw_snprint(max_sectors_kb, print_nonzero)
530 declare_mp_handler(max_sectors_kb, set_int)
531 declare_mp_snprint(max_sectors_kb, print_nonzero)
532
533 declare_def_handler(find_multipaths_timeout, set_int)
534 declare_def_snprint_defint(find_multipaths_timeout, print_int,
535                            DEFAULT_FIND_MULTIPATHS_TIMEOUT)
536
537 static int
538 def_config_dir_handler(struct config *conf, vector strvec)
539 {
540         /* this is only valid in the main config file */
541         if (conf->processed_main_config)
542                 return 0;
543         return set_str(strvec, &conf->config_dir);
544 }
545 declare_def_snprint(config_dir, print_str)
546
547 #define declare_def_attr_handler(option, function)                      \
548 static int                                                              \
549 def_ ## option ## _handler (struct config *conf, vector strvec)         \
550 {                                                                       \
551         return function (strvec, &conf->option, &conf->attribute_flags);\
552 }
553
554 #define declare_def_attr_snprint(option, function)                      \
555 static int                                                              \
556 snprint_def_ ## option (struct config *conf, char * buff, int len,      \
557                         const void * data)                              \
558 {                                                                       \
559         return function (buff, len, conf->option,                       \
560                          conf->attribute_flags);                        \
561 }
562
563 #define declare_mp_attr_handler(option, function)                       \
564 static int                                                              \
565 mp_ ## option ## _handler (struct config *conf, vector strvec)          \
566 {                                                                       \
567         struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable);         \
568         if (!mpe)                                                       \
569                 return 1;                                               \
570         return function (strvec, &mpe->option, &mpe->attribute_flags);  \
571 }
572
573 #define declare_mp_attr_snprint(option, function)                       \
574 static int                                                              \
575 snprint_mp_ ## option (struct config *conf, char * buff, int len,       \
576                        const void * data)                               \
577 {                                                                       \
578         const struct mpentry * mpe = (const struct mpentry *)data;      \
579         return function (buff, len, mpe->option,                        \
580                          mpe->attribute_flags);                         \
581 }
582
583 static int
584 set_mode(vector strvec, void *ptr, int *flags)
585 {
586         mode_t mode;
587         mode_t *mode_ptr = (mode_t *)ptr;
588         char *buff;
589
590         buff = set_value(strvec);
591
592         if (!buff)
593                 return 1;
594
595         if (sscanf(buff, "%o", &mode) == 1 && mode <= 0777) {
596                 *flags |= (1 << ATTR_MODE);
597                 *mode_ptr = mode;
598         }
599
600         FREE(buff);
601         return 0;
602 }
603
604 static int
605 set_uid(vector strvec, void *ptr, int *flags)
606 {
607         uid_t uid;
608         uid_t *uid_ptr = (uid_t *)ptr;
609         char *buff;
610         char passwd_buf[1024];
611         struct passwd info, *found;
612
613         buff = set_value(strvec);
614         if (!buff)
615                 return 1;
616         if (getpwnam_r(buff, &info, passwd_buf, 1024, &found) == 0 && found) {
617                 *flags |= (1 << ATTR_UID);
618                 *uid_ptr = info.pw_uid;
619         }
620         else if (sscanf(buff, "%u", &uid) == 1){
621                 *flags |= (1 << ATTR_UID);
622                 *uid_ptr = uid;
623         }
624
625         FREE(buff);
626         return 0;
627 }
628
629 static int
630 set_gid(vector strvec, void *ptr, int *flags)
631 {
632         gid_t gid;
633         gid_t *gid_ptr = (gid_t *)ptr;
634         char *buff;
635         char passwd_buf[1024];
636         struct passwd info, *found;
637
638         buff = set_value(strvec);
639         if (!buff)
640                 return 1;
641
642         if (getpwnam_r(buff, &info, passwd_buf, 1024, &found) == 0 && found) {
643                 *flags |= (1 << ATTR_GID);
644                 *gid_ptr = info.pw_gid;
645         }
646         else if (sscanf(buff, "%u", &gid) == 1){
647                 *flags |= (1 << ATTR_GID);
648                 *gid_ptr = gid;
649         }
650         FREE(buff);
651         return 0;
652 }
653
654 static int
655 print_mode(char * buff, int len, long v, int flags)
656 {
657         mode_t mode = (mode_t)v;
658         if ((flags & (1 << ATTR_MODE)) == 0)
659                 return 0;
660         return snprintf(buff, len, "0%o", mode);
661 }
662
663 static int
664 print_uid(char * buff, int len, long v, int flags)
665 {
666         uid_t uid = (uid_t)v;
667         if ((flags & (1 << ATTR_UID)) == 0)
668                 return 0;
669         return snprintf(buff, len, "0%o", uid);
670 }
671
672 static int
673 print_gid(char * buff, int len, long v, int flags)
674 {
675         gid_t gid = (gid_t)v;
676         if ((flags & (1 << ATTR_GID)) == 0)
677                 return 0;
678         return snprintf(buff, len, "0%o", gid);
679 }
680
681 declare_def_attr_handler(mode, set_mode)
682 declare_def_attr_snprint(mode, print_mode)
683 declare_mp_attr_handler(mode, set_mode)
684 declare_mp_attr_snprint(mode, print_mode)
685
686 declare_def_attr_handler(uid, set_uid)
687 declare_def_attr_snprint(uid, print_uid)
688 declare_mp_attr_handler(uid, set_uid)
689 declare_mp_attr_snprint(uid, print_uid)
690
691 declare_def_attr_handler(gid, set_gid)
692 declare_def_attr_snprint(gid, print_gid)
693 declare_mp_attr_handler(gid, set_gid)
694 declare_mp_attr_snprint(gid, print_gid)
695
696 static int
697 set_fast_io_fail(vector strvec, void *ptr)
698 {
699         char * buff;
700         int *int_ptr = (int *)ptr;
701
702         buff = set_value(strvec);
703         if (!buff)
704                 return 1;
705
706         if (strcmp(buff, "off") == 0)
707                 *int_ptr = MP_FAST_IO_FAIL_OFF;
708         else if (sscanf(buff, "%d", int_ptr) != 1 ||
709                  *int_ptr < MP_FAST_IO_FAIL_ZERO)
710                 *int_ptr = MP_FAST_IO_FAIL_UNSET;
711         else if (*int_ptr == 0)
712                 *int_ptr = MP_FAST_IO_FAIL_ZERO;
713
714         FREE(buff);
715         return 0;
716 }
717
718 int
719 print_fast_io_fail(char * buff, int len, long v)
720 {
721         if (v == MP_FAST_IO_FAIL_UNSET)
722                 return 0;
723         if (v == MP_FAST_IO_FAIL_OFF)
724                 return snprintf(buff, len, "\"off\"");
725         if (v == MP_FAST_IO_FAIL_ZERO)
726                 return snprintf(buff, len, "0");
727         return snprintf(buff, len, "%ld", v);
728 }
729
730 declare_def_handler(fast_io_fail, set_fast_io_fail)
731 declare_def_snprint_defint(fast_io_fail, print_fast_io_fail,
732                            DEFAULT_FAST_IO_FAIL)
733 declare_ovr_handler(fast_io_fail, set_fast_io_fail)
734 declare_ovr_snprint(fast_io_fail, print_fast_io_fail)
735 declare_hw_handler(fast_io_fail, set_fast_io_fail)
736 declare_hw_snprint(fast_io_fail, print_fast_io_fail)
737
738 static int
739 set_dev_loss(vector strvec, void *ptr)
740 {
741         char * buff;
742         unsigned int *uint_ptr = (unsigned int *)ptr;
743
744         buff = set_value(strvec);
745         if (!buff)
746                 return 1;
747
748         if (!strcmp(buff, "infinity"))
749                 *uint_ptr = MAX_DEV_LOSS_TMO;
750         else if (sscanf(buff, "%u", uint_ptr) != 1)
751                 *uint_ptr = 0;
752
753         FREE(buff);
754         return 0;
755 }
756
757 int
758 print_dev_loss(char * buff, int len, unsigned long v)
759 {
760         if (!v)
761                 return 0;
762         if (v >= MAX_DEV_LOSS_TMO)
763                 return snprintf(buff, len, "\"infinity\"");
764         return snprintf(buff, len, "%lu", v);
765 }
766
767 declare_def_handler(dev_loss, set_dev_loss)
768 declare_def_snprint(dev_loss, print_dev_loss)
769 declare_ovr_handler(dev_loss, set_dev_loss)
770 declare_ovr_snprint(dev_loss, print_dev_loss)
771 declare_hw_handler(dev_loss, set_dev_loss)
772 declare_hw_snprint(dev_loss, print_dev_loss)
773
774 static int
775 set_pgpolicy(vector strvec, void *ptr)
776 {
777         char * buff;
778         int *int_ptr = (int *)ptr;
779
780         buff = set_value(strvec);
781         if (!buff)
782                 return 1;
783
784         *int_ptr = get_pgpolicy_id(buff);
785         FREE(buff);
786
787         return 0;
788 }
789
790 int
791 print_pgpolicy(char * buff, int len, long pgpolicy)
792 {
793         char str[POLICY_NAME_SIZE];
794
795         if (!pgpolicy)
796                 return 0;
797
798         get_pgpolicy_name(str, POLICY_NAME_SIZE, pgpolicy);
799
800         return snprintf(buff, len, "\"%s\"", str);
801 }
802
803 declare_def_handler(pgpolicy, set_pgpolicy)
804 declare_def_snprint_defint(pgpolicy, print_pgpolicy, DEFAULT_PGPOLICY)
805 declare_ovr_handler(pgpolicy, set_pgpolicy)
806 declare_ovr_snprint(pgpolicy, print_pgpolicy)
807 declare_hw_handler(pgpolicy, set_pgpolicy)
808 declare_hw_snprint(pgpolicy, print_pgpolicy)
809 declare_mp_handler(pgpolicy, set_pgpolicy)
810 declare_mp_snprint(pgpolicy, print_pgpolicy)
811
812 int
813 get_sys_max_fds(int *max_fds)
814 {
815         FILE *file;
816         int nr_open;
817         int ret = 1;
818
819         file = fopen("/proc/sys/fs/nr_open", "r");
820         if (!file) {
821                 fprintf(stderr, "Cannot open /proc/sys/fs/nr_open : %s\n",
822                         strerror(errno));
823                 return 1;
824         }
825         if (fscanf(file, "%d", &nr_open) != 1) {
826                 fprintf(stderr, "Cannot read max open fds from /proc/sys/fs/nr_open");
827                 if (ferror(file))
828                         fprintf(stderr, " : %s\n", strerror(errno));
829                 else
830                         fprintf(stderr, "\n");
831         } else {
832                 *max_fds = nr_open;
833                 ret = 0;
834         }
835         fclose(file);
836         return ret;
837 }
838
839
840 static int
841 max_fds_handler(struct config *conf, vector strvec)
842 {
843         char * buff;
844         int r = 0, max_fds;
845
846         buff = set_value(strvec);
847
848         if (!buff)
849                 return 1;
850
851         r = get_sys_max_fds(&max_fds);
852         if (r) {
853                 /* Assume safe limit */
854                 max_fds = 4096;
855         }
856         if (strlen(buff) == 3 &&
857             !strcmp(buff, "max"))
858                 conf->max_fds = max_fds;
859         else
860                 conf->max_fds = atoi(buff);
861
862         if (conf->max_fds > max_fds)
863                 conf->max_fds = max_fds;
864
865         FREE(buff);
866
867         return r;
868 }
869
870 static int
871 snprint_max_fds (struct config *conf, char * buff, int len, const void * data)
872 {
873         int r = 0, max_fds;
874
875         if (!conf->max_fds)
876                 return 0;
877
878         r = get_sys_max_fds(&max_fds);
879         if (!r && conf->max_fds >= max_fds)
880                 return snprintf(buff, len, "\"max\"");
881         else
882                 return snprintf(buff, len, "%d", conf->max_fds);
883 }
884
885 static int
886 set_rr_weight(vector strvec, void *ptr)
887 {
888         int *int_ptr = (int *)ptr;
889         char * buff;
890
891         buff = set_value(strvec);
892
893         if (!buff)
894                 return 1;
895
896         if (!strcmp(buff, "priorities"))
897                 *int_ptr = RR_WEIGHT_PRIO;
898
899         if (!strcmp(buff, "uniform"))
900                 *int_ptr = RR_WEIGHT_NONE;
901
902         FREE(buff);
903
904         return 0;
905 }
906
907 int
908 print_rr_weight (char * buff, int len, long v)
909 {
910         if (!v)
911                 return 0;
912         if (v == RR_WEIGHT_PRIO)
913                 return snprintf(buff, len, "\"priorities\"");
914         if (v == RR_WEIGHT_NONE)
915                 return snprintf(buff, len, "\"uniform\"");
916
917         return 0;
918 }
919
920 declare_def_handler(rr_weight, set_rr_weight)
921 declare_def_snprint_defint(rr_weight, print_rr_weight, DEFAULT_RR_WEIGHT)
922 declare_ovr_handler(rr_weight, set_rr_weight)
923 declare_ovr_snprint(rr_weight, print_rr_weight)
924 declare_hw_handler(rr_weight, set_rr_weight)
925 declare_hw_snprint(rr_weight, print_rr_weight)
926 declare_mp_handler(rr_weight, set_rr_weight)
927 declare_mp_snprint(rr_weight, print_rr_weight)
928
929 static int
930 set_pgfailback(vector strvec, void *ptr)
931 {
932         int *int_ptr = (int *)ptr;
933         char * buff;
934
935         buff = set_value(strvec);
936         if (!buff)
937                 return 1;
938
939         if (strlen(buff) == 6 && !strcmp(buff, "manual"))
940                 *int_ptr = -FAILBACK_MANUAL;
941         else if (strlen(buff) == 9 && !strcmp(buff, "immediate"))
942                 *int_ptr = -FAILBACK_IMMEDIATE;
943         else if (strlen(buff) == 10 && !strcmp(buff, "followover"))
944                 *int_ptr = -FAILBACK_FOLLOWOVER;
945         else
946                 *int_ptr = atoi(buff);
947
948         FREE(buff);
949
950         return 0;
951 }
952
953 int
954 print_pgfailback (char * buff, int len, long v)
955 {
956         switch(v) {
957         case  FAILBACK_UNDEF:
958                 return 0;
959         case -FAILBACK_MANUAL:
960                 return snprintf(buff, len, "\"manual\"");
961         case -FAILBACK_IMMEDIATE:
962                 return snprintf(buff, len, "\"immediate\"");
963         case -FAILBACK_FOLLOWOVER:
964                 return snprintf(buff, len, "\"followover\"");
965         default:
966                 return snprintf(buff, len, "%li", v);
967         }
968 }
969
970 declare_def_handler(pgfailback, set_pgfailback)
971 declare_def_snprint_defint(pgfailback, print_pgfailback, DEFAULT_FAILBACK)
972 declare_ovr_handler(pgfailback, set_pgfailback)
973 declare_ovr_snprint(pgfailback, print_pgfailback)
974 declare_hw_handler(pgfailback, set_pgfailback)
975 declare_hw_snprint(pgfailback, print_pgfailback)
976 declare_mp_handler(pgfailback, set_pgfailback)
977 declare_mp_snprint(pgfailback, print_pgfailback)
978
979 static int
980 set_no_path_retry(vector strvec, void *ptr)
981 {
982         int *int_ptr = (int *)ptr;
983         char * buff;
984
985         buff = set_value(strvec);
986         if (!buff)
987                 return 1;
988
989         if (!strcmp(buff, "fail") || !strcmp(buff, "0"))
990                 *int_ptr = NO_PATH_RETRY_FAIL;
991         else if (!strcmp(buff, "queue"))
992                 *int_ptr = NO_PATH_RETRY_QUEUE;
993         else if ((*int_ptr = atoi(buff)) < 1)
994                 *int_ptr = NO_PATH_RETRY_UNDEF;
995
996         FREE(buff);
997         return 0;
998 }
999
1000 int
1001 print_no_path_retry(char * buff, int len, long v)
1002 {
1003         switch(v) {
1004         case NO_PATH_RETRY_UNDEF:
1005                 return 0;
1006         case NO_PATH_RETRY_FAIL:
1007                 return snprintf(buff, len, "\"fail\"");
1008         case NO_PATH_RETRY_QUEUE:
1009                 return snprintf(buff, len, "\"queue\"");
1010         default:
1011                 return snprintf(buff, len, "%li", v);
1012         }
1013 }
1014
1015 declare_def_handler(no_path_retry, set_no_path_retry)
1016 declare_def_snprint(no_path_retry, print_no_path_retry)
1017 declare_ovr_handler(no_path_retry, set_no_path_retry)
1018 declare_ovr_snprint(no_path_retry, print_no_path_retry)
1019 declare_hw_handler(no_path_retry, set_no_path_retry)
1020 declare_hw_snprint(no_path_retry, print_no_path_retry)
1021 declare_mp_handler(no_path_retry, set_no_path_retry)
1022 declare_mp_snprint(no_path_retry, print_no_path_retry)
1023
1024 static int
1025 def_log_checker_err_handler(struct config *conf, vector strvec)
1026 {
1027         char * buff;
1028
1029         buff = set_value(strvec);
1030
1031         if (!buff)
1032                 return 1;
1033
1034         if (strlen(buff) == 4 && !strcmp(buff, "once"))
1035                 conf->log_checker_err = LOG_CHKR_ERR_ONCE;
1036         else if (strlen(buff) == 6 && !strcmp(buff, "always"))
1037                 conf->log_checker_err = LOG_CHKR_ERR_ALWAYS;
1038
1039         free(buff);
1040         return 0;
1041 }
1042
1043 static int
1044 snprint_def_log_checker_err (struct config *conf, char * buff, int len,
1045                              const void * data)
1046 {
1047         if (conf->log_checker_err == LOG_CHKR_ERR_ONCE)
1048                 return snprintf(buff, len, "once");
1049         return snprintf(buff, len, "always");
1050 }
1051
1052 static int
1053 set_reservation_key(vector strvec, struct be64 *be64_ptr, uint8_t *flags_ptr,
1054                     int *source_ptr)
1055 {
1056         char *buff;
1057         uint64_t prkey;
1058         uint8_t sa_flags;
1059
1060         buff = set_value(strvec);
1061         if (!buff)
1062                 return 1;
1063
1064         if (strcmp(buff, "file") == 0) {
1065                 *source_ptr = PRKEY_SOURCE_FILE;
1066                 *flags_ptr = 0;
1067                 put_be64(*be64_ptr, 0);
1068                 FREE(buff);
1069                 return 0;
1070         }
1071
1072         if (parse_prkey_flags(buff, &prkey, &sa_flags) != 0) {
1073                 FREE(buff);
1074                 return 1;
1075         }
1076         *source_ptr = PRKEY_SOURCE_CONF;
1077         *flags_ptr = sa_flags;
1078         put_be64(*be64_ptr, prkey);
1079         FREE(buff);
1080         return 0;
1081 }
1082
1083 int
1084 print_reservation_key(char * buff, int len, struct be64 key, uint8_t flags,
1085                       int source)
1086 {
1087         char *flagstr = "";
1088         if (source == PRKEY_SOURCE_NONE)
1089                 return 0;
1090         if (source == PRKEY_SOURCE_FILE)
1091                 return snprintf(buff, len, "file");
1092         if (flags & MPATH_F_APTPL_MASK)
1093                 flagstr = ":aptpl";
1094         return snprintf(buff, len, "0x%" PRIx64 "%s", get_be64(key),
1095                         flagstr);
1096 }
1097
1098 static int
1099 def_reservation_key_handler(struct config *conf, vector strvec)
1100 {
1101         return set_reservation_key(strvec, &conf->reservation_key,
1102                                    &conf->sa_flags,
1103                                    &conf->prkey_source);
1104 }
1105
1106 static int
1107 snprint_def_reservation_key (struct config *conf, char * buff, int len,
1108                              const void * data)
1109 {
1110         return print_reservation_key(buff, len, conf->reservation_key,
1111                                      conf->sa_flags,
1112                                      conf->prkey_source);
1113 }
1114
1115 static int
1116 mp_reservation_key_handler(struct config *conf, vector strvec)
1117 {
1118         struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable);
1119         if (!mpe)
1120                 return 1;
1121         return set_reservation_key(strvec, &mpe->reservation_key,
1122                                    &mpe->sa_flags,
1123                                    &mpe->prkey_source);
1124 }
1125
1126 static int
1127 snprint_mp_reservation_key (struct config *conf, char * buff, int len,
1128                             const void * data)
1129 {
1130         const struct mpentry * mpe = (const struct mpentry *)data;
1131         return print_reservation_key(buff, len, mpe->reservation_key,
1132                                      mpe->sa_flags,
1133                                      mpe->prkey_source);
1134 }
1135
1136 static int
1137 set_off_int_undef(vector strvec, void *ptr)
1138 {
1139         int *int_ptr = (int *)ptr;
1140         char * buff;
1141
1142         buff = set_value(strvec);
1143         if (!buff)
1144                 return 1;
1145
1146         if (!strcmp(buff, "no") || !strcmp(buff, "0"))
1147                 *int_ptr = NU_NO;
1148         else if ((*int_ptr = atoi(buff)) < 1)
1149                 *int_ptr = NU_UNDEF;
1150
1151         FREE(buff);
1152         return 0;
1153 }
1154
1155 int
1156 print_off_int_undef(char * buff, int len, long v)
1157 {
1158         switch(v) {
1159         case NU_UNDEF:
1160                 return 0;
1161         case NU_NO:
1162                 return snprintf(buff, len, "\"no\"");
1163         default:
1164                 return snprintf(buff, len, "%li", v);
1165         }
1166 }
1167
1168 declare_def_handler(delay_watch_checks, set_off_int_undef)
1169 declare_def_snprint_defint(delay_watch_checks, print_off_int_undef,
1170                            DEFAULT_DELAY_CHECKS)
1171 declare_ovr_handler(delay_watch_checks, set_off_int_undef)
1172 declare_ovr_snprint(delay_watch_checks, print_off_int_undef)
1173 declare_hw_handler(delay_watch_checks, set_off_int_undef)
1174 declare_hw_snprint(delay_watch_checks, print_off_int_undef)
1175 declare_mp_handler(delay_watch_checks, set_off_int_undef)
1176 declare_mp_snprint(delay_watch_checks, print_off_int_undef)
1177 declare_def_handler(delay_wait_checks, set_off_int_undef)
1178 declare_def_snprint_defint(delay_wait_checks, print_off_int_undef,
1179                            DEFAULT_DELAY_CHECKS)
1180 declare_ovr_handler(delay_wait_checks, set_off_int_undef)
1181 declare_ovr_snprint(delay_wait_checks, print_off_int_undef)
1182 declare_hw_handler(delay_wait_checks, set_off_int_undef)
1183 declare_hw_snprint(delay_wait_checks, print_off_int_undef)
1184 declare_mp_handler(delay_wait_checks, set_off_int_undef)
1185 declare_mp_snprint(delay_wait_checks, print_off_int_undef)
1186 declare_def_handler(marginal_path_err_sample_time, set_off_int_undef)
1187 declare_def_snprint_defint(marginal_path_err_sample_time, print_off_int_undef,
1188                            DEFAULT_ERR_CHECKS)
1189 declare_ovr_handler(marginal_path_err_sample_time, set_off_int_undef)
1190 declare_ovr_snprint(marginal_path_err_sample_time, print_off_int_undef)
1191 declare_hw_handler(marginal_path_err_sample_time, set_off_int_undef)
1192 declare_hw_snprint(marginal_path_err_sample_time, print_off_int_undef)
1193 declare_mp_handler(marginal_path_err_sample_time, set_off_int_undef)
1194 declare_mp_snprint(marginal_path_err_sample_time, print_off_int_undef)
1195 declare_def_handler(marginal_path_err_rate_threshold, set_off_int_undef)
1196 declare_def_snprint_defint(marginal_path_err_rate_threshold, print_off_int_undef,
1197                            DEFAULT_ERR_CHECKS)
1198 declare_ovr_handler(marginal_path_err_rate_threshold, set_off_int_undef)
1199 declare_ovr_snprint(marginal_path_err_rate_threshold, print_off_int_undef)
1200 declare_hw_handler(marginal_path_err_rate_threshold, set_off_int_undef)
1201 declare_hw_snprint(marginal_path_err_rate_threshold, print_off_int_undef)
1202 declare_mp_handler(marginal_path_err_rate_threshold, set_off_int_undef)
1203 declare_mp_snprint(marginal_path_err_rate_threshold, print_off_int_undef)
1204 declare_def_handler(marginal_path_err_recheck_gap_time, set_off_int_undef)
1205 declare_def_snprint_defint(marginal_path_err_recheck_gap_time, print_off_int_undef,
1206                            DEFAULT_ERR_CHECKS)
1207 declare_ovr_handler(marginal_path_err_recheck_gap_time, set_off_int_undef)
1208 declare_ovr_snprint(marginal_path_err_recheck_gap_time, print_off_int_undef)
1209 declare_hw_handler(marginal_path_err_recheck_gap_time, set_off_int_undef)
1210 declare_hw_snprint(marginal_path_err_recheck_gap_time, print_off_int_undef)
1211 declare_mp_handler(marginal_path_err_recheck_gap_time, set_off_int_undef)
1212 declare_mp_snprint(marginal_path_err_recheck_gap_time, print_off_int_undef)
1213 declare_def_handler(marginal_path_double_failed_time, set_off_int_undef)
1214 declare_def_snprint_defint(marginal_path_double_failed_time, print_off_int_undef,
1215                            DEFAULT_ERR_CHECKS)
1216 declare_ovr_handler(marginal_path_double_failed_time, set_off_int_undef)
1217 declare_ovr_snprint(marginal_path_double_failed_time, print_off_int_undef)
1218 declare_hw_handler(marginal_path_double_failed_time, set_off_int_undef)
1219 declare_hw_snprint(marginal_path_double_failed_time, print_off_int_undef)
1220 declare_mp_handler(marginal_path_double_failed_time, set_off_int_undef)
1221 declare_mp_snprint(marginal_path_double_failed_time, print_off_int_undef)
1222
1223 declare_def_handler(ghost_delay, set_off_int_undef)
1224 declare_def_snprint(ghost_delay, print_off_int_undef)
1225 declare_ovr_handler(ghost_delay, set_off_int_undef)
1226 declare_ovr_snprint(ghost_delay, print_off_int_undef)
1227 declare_hw_handler(ghost_delay, set_off_int_undef)
1228 declare_hw_snprint(ghost_delay, print_off_int_undef)
1229 declare_mp_handler(ghost_delay, set_off_int_undef)
1230 declare_mp_snprint(ghost_delay, print_off_int_undef)
1231
1232 declare_def_handler(all_tg_pt, set_yes_no_undef)
1233 declare_def_snprint_defint(all_tg_pt, print_yes_no_undef, DEFAULT_ALL_TG_PT)
1234 declare_ovr_handler(all_tg_pt, set_yes_no_undef)
1235 declare_ovr_snprint(all_tg_pt, print_yes_no_undef)
1236 declare_hw_handler(all_tg_pt, set_yes_no_undef)
1237 declare_hw_snprint(all_tg_pt, print_yes_no_undef)
1238
1239
1240 static int
1241 def_uxsock_timeout_handler(struct config *conf, vector strvec)
1242 {
1243         unsigned int uxsock_timeout;
1244         char *buff;
1245
1246         buff = set_value(strvec);
1247         if (!buff)
1248                 return 1;
1249
1250         if (sscanf(buff, "%u", &uxsock_timeout) == 1 &&
1251             uxsock_timeout > DEFAULT_REPLY_TIMEOUT)
1252                 conf->uxsock_timeout = uxsock_timeout;
1253         else
1254                 conf->uxsock_timeout = DEFAULT_REPLY_TIMEOUT;
1255
1256         free(buff);
1257         return 0;
1258 }
1259
1260 /*
1261  * blacklist block handlers
1262  */
1263 static int
1264 blacklist_handler(struct config *conf, vector strvec)
1265 {
1266         if (!conf->blist_devnode)
1267                 conf->blist_devnode = vector_alloc();
1268         if (!conf->blist_wwid)
1269                 conf->blist_wwid = vector_alloc();
1270         if (!conf->blist_device)
1271                 conf->blist_device = vector_alloc();
1272         if (!conf->blist_property)
1273                 conf->blist_property = vector_alloc();
1274
1275         if (!conf->blist_devnode || !conf->blist_wwid ||
1276             !conf->blist_device || !conf->blist_property)
1277                 return 1;
1278
1279         return 0;
1280 }
1281
1282 static int
1283 blacklist_exceptions_handler(struct config *conf, vector strvec)
1284 {
1285         if (!conf->elist_devnode)
1286                 conf->elist_devnode = vector_alloc();
1287         if (!conf->elist_wwid)
1288                 conf->elist_wwid = vector_alloc();
1289         if (!conf->elist_device)
1290                 conf->elist_device = vector_alloc();
1291         if (!conf->elist_property)
1292                 conf->elist_property = vector_alloc();
1293
1294         if (!conf->elist_devnode || !conf->elist_wwid ||
1295             !conf->elist_device || !conf->elist_property)
1296                 return 1;
1297
1298         return 0;
1299 }
1300
1301 #define declare_ble_handler(option)                                     \
1302 static int                                                              \
1303 ble_ ## option ## _handler (struct config *conf, vector strvec)         \
1304 {                                                                       \
1305         char * buff;                                                    \
1306                                                                         \
1307         if (!conf->option)                                              \
1308                 return 1;                                               \
1309                                                                         \
1310         buff = set_value(strvec);                                       \
1311         if (!buff)                                                      \
1312                 return 1;                                               \
1313                                                                         \
1314         return store_ble(conf->option, buff, ORIGIN_CONFIG);            \
1315 }
1316
1317 #define declare_ble_device_handler(name, option, vend, prod)            \
1318 static int                                                              \
1319 ble_ ## option ## _ ## name ## _handler (struct config *conf, vector strvec) \
1320 {                                                                       \
1321         char * buff;                                                    \
1322                                                                         \
1323         if (!conf->option)                                              \
1324                 return 1;                                               \
1325                                                                         \
1326         buff = set_value(strvec);                                       \
1327         if (!buff)                                                      \
1328                 return 1;                                               \
1329                                                                         \
1330         return set_ble_device(conf->option, vend, prod, ORIGIN_CONFIG); \
1331 }
1332
1333 declare_ble_handler(blist_devnode)
1334 declare_ble_handler(elist_devnode)
1335 declare_ble_handler(blist_wwid)
1336 declare_ble_handler(elist_wwid)
1337 declare_ble_handler(blist_property)
1338 declare_ble_handler(elist_property)
1339
1340 static int
1341 snprint_def_uxsock_timeout(struct config *conf, char * buff, int len,
1342                            const void * data)
1343 {
1344         return snprintf(buff, len, "%u", conf->uxsock_timeout);
1345 }
1346
1347 static int
1348 snprint_ble_simple (struct config *conf, char * buff, int len,
1349                     const void * data)
1350 {
1351         const struct blentry * ble = (const struct blentry *)data;
1352
1353         return snprintf(buff, len, "\"%s\"", ble->str);
1354 }
1355
1356 static int
1357 ble_device_handler(struct config *conf, vector strvec)
1358 {
1359         return alloc_ble_device(conf->blist_device);
1360 }
1361
1362 static int
1363 ble_except_device_handler(struct config *conf, vector strvec)
1364 {
1365         return alloc_ble_device(conf->elist_device);
1366 }
1367
1368 declare_ble_device_handler(vendor, blist_device, buff, NULL)
1369 declare_ble_device_handler(vendor, elist_device, buff, NULL)
1370 declare_ble_device_handler(product, blist_device, NULL, buff)
1371 declare_ble_device_handler(product, elist_device, NULL, buff)
1372
1373 static int
1374 snprint_bled_vendor (struct config *conf, char * buff, int len,
1375                      const void * data)
1376 {
1377         const struct blentry_device * bled =
1378                 (const struct blentry_device *)data;
1379
1380         return snprintf(buff, len, "\"%s\"", bled->vendor);
1381 }
1382
1383 static int
1384 snprint_bled_product (struct config *conf, char * buff, int len,
1385                       const void * data)
1386 {
1387         const struct blentry_device * bled =
1388                 (const struct blentry_device *)data;
1389
1390         return snprintf(buff, len, "\"%s\"", bled->product);
1391 }
1392
1393 /*
1394  * devices block handlers
1395  */
1396 static int
1397 devices_handler(struct config *conf, vector strvec)
1398 {
1399         if (!conf->hwtable)
1400                 conf->hwtable = vector_alloc();
1401
1402         if (!conf->hwtable)
1403                 return 1;
1404
1405         return 0;
1406 }
1407
1408 static int
1409 device_handler(struct config *conf, vector strvec)
1410 {
1411         struct hwentry * hwe;
1412
1413         hwe = alloc_hwe();
1414
1415         if (!hwe)
1416                 return 1;
1417
1418         if (!vector_alloc_slot(conf->hwtable)) {
1419                 free_hwe(hwe);
1420                 return 1;
1421         }
1422         vector_set_slot(conf->hwtable, hwe);
1423
1424         return 0;
1425 }
1426
1427 declare_hw_handler(vendor, set_str)
1428 declare_hw_snprint(vendor, print_str)
1429
1430 declare_hw_handler(product, set_str)
1431 declare_hw_snprint(product, print_str)
1432
1433 declare_hw_handler(revision, set_str)
1434 declare_hw_snprint(revision, print_str)
1435
1436 declare_hw_handler(bl_product, set_str)
1437 declare_hw_snprint(bl_product, print_str)
1438
1439 declare_hw_handler(hwhandler, set_str)
1440 declare_hw_snprint(hwhandler, print_str)
1441
1442 /*
1443  * overrides handlers
1444  */
1445 static int
1446 overrides_handler(struct config *conf, vector strvec)
1447 {
1448         if (!conf->overrides)
1449                 conf->overrides = alloc_hwe();
1450
1451         if (!conf->overrides)
1452                 return 1;
1453
1454         return 0;
1455 }
1456
1457
1458
1459 /*
1460  * multipaths block handlers
1461  */
1462 static int
1463 multipaths_handler(struct config *conf, vector strvec)
1464 {
1465         if (!conf->mptable)
1466                 conf->mptable = vector_alloc();
1467
1468         if (!conf->mptable)
1469                 return 1;
1470
1471         return 0;
1472 }
1473
1474 static int
1475 multipath_handler(struct config *conf, vector strvec)
1476 {
1477         struct mpentry * mpe;
1478
1479         mpe = alloc_mpe();
1480
1481         if (!mpe)
1482                 return 1;
1483
1484         if (!vector_alloc_slot(conf->mptable)) {
1485                 free_mpe(mpe);
1486                 return 1;
1487         }
1488         vector_set_slot(conf->mptable, mpe);
1489
1490         return 0;
1491 }
1492
1493 declare_mp_handler(wwid, set_str)
1494 declare_mp_snprint(wwid, print_str)
1495
1496 declare_mp_handler(alias, set_str)
1497 declare_mp_snprint(alias, print_str)
1498
1499 /*
1500  * deprecated handlers
1501  */
1502
1503 static int
1504 deprecated_handler(struct config *conf, vector strvec)
1505 {
1506         char * buff;
1507
1508         buff = set_value(strvec);
1509
1510         if (!buff)
1511                 return 1;
1512
1513         FREE(buff);
1514         return 0;
1515 }
1516
1517 static int
1518 snprint_deprecated (struct config *conf, char * buff, int len,
1519                     const void * data)
1520 {
1521         return 0;
1522 }
1523
1524 #define __deprecated
1525
1526 /*
1527  * If you add or remove a keyword also update multipath/multipath.conf.5
1528  */
1529 void
1530 init_keywords(vector keywords)
1531 {
1532         install_keyword_root("defaults", NULL);
1533         install_keyword("verbosity", &def_verbosity_handler, &snprint_def_verbosity);
1534         install_keyword("polling_interval", &def_checkint_handler, &snprint_def_checkint);
1535         install_keyword("max_polling_interval", &def_max_checkint_handler, &snprint_def_max_checkint);
1536         install_keyword("reassign_maps", &def_reassign_maps_handler, &snprint_def_reassign_maps);
1537         install_keyword("multipath_dir", &def_multipath_dir_handler, &snprint_def_multipath_dir);
1538         install_keyword("path_selector", &def_selector_handler, &snprint_def_selector);
1539         install_keyword("path_grouping_policy", &def_pgpolicy_handler, &snprint_def_pgpolicy);
1540         install_keyword("uid_attrs", &def_uid_attrs_handler, &snprint_def_uid_attrs);
1541         install_keyword("uid_attribute", &def_uid_attribute_handler, &snprint_def_uid_attribute);
1542         install_keyword("getuid_callout", &def_getuid_handler, &snprint_def_getuid);
1543         install_keyword("prio", &def_prio_name_handler, &snprint_def_prio_name);
1544         install_keyword("prio_args", &def_prio_args_handler, &snprint_def_prio_args);
1545         install_keyword("features", &def_features_handler, &snprint_def_features);
1546         install_keyword("path_checker", &def_checker_name_handler, &snprint_def_checker_name);
1547         install_keyword("checker", &def_checker_name_handler, NULL);
1548         install_keyword("alias_prefix", &def_alias_prefix_handler, &snprint_def_alias_prefix);
1549         install_keyword("failback", &def_pgfailback_handler, &snprint_def_pgfailback);
1550         install_keyword("rr_min_io", &def_minio_handler, &snprint_def_minio);
1551         install_keyword("rr_min_io_rq", &def_minio_rq_handler, &snprint_def_minio_rq);
1552         install_keyword("max_fds", &max_fds_handler, &snprint_max_fds);
1553         install_keyword("rr_weight", &def_rr_weight_handler, &snprint_def_rr_weight);
1554         install_keyword("no_path_retry", &def_no_path_retry_handler, &snprint_def_no_path_retry);
1555         install_keyword("queue_without_daemon", &def_queue_without_daemon_handler, &snprint_def_queue_without_daemon);
1556         install_keyword("checker_timeout", &def_checker_timeout_handler, &snprint_def_checker_timeout);
1557         install_keyword("pg_timeout", &deprecated_handler, &snprint_deprecated);
1558         install_keyword("flush_on_last_del", &def_flush_on_last_del_handler, &snprint_def_flush_on_last_del);
1559         install_keyword("user_friendly_names", &def_user_friendly_names_handler, &snprint_def_user_friendly_names);
1560         install_keyword("mode", &def_mode_handler, &snprint_def_mode);
1561         install_keyword("uid", &def_uid_handler, &snprint_def_uid);
1562         install_keyword("gid", &def_gid_handler, &snprint_def_gid);
1563         install_keyword("fast_io_fail_tmo", &def_fast_io_fail_handler, &snprint_def_fast_io_fail);
1564         install_keyword("dev_loss_tmo", &def_dev_loss_handler, &snprint_def_dev_loss);
1565         install_keyword("bindings_file", &def_bindings_file_handler, &snprint_def_bindings_file);
1566         install_keyword("wwids_file", &def_wwids_file_handler, &snprint_def_wwids_file);
1567         install_keyword("prkeys_file", &def_prkeys_file_handler, &snprint_def_prkeys_file);
1568         install_keyword("log_checker_err", &def_log_checker_err_handler, &snprint_def_log_checker_err);
1569         install_keyword("reservation_key", &def_reservation_key_handler, &snprint_def_reservation_key);
1570         install_keyword("all_tg_pt", &def_all_tg_pt_handler, &snprint_def_all_tg_pt);
1571         install_keyword("retain_attached_hw_handler", &def_retain_hwhandler_handler, &snprint_def_retain_hwhandler);
1572         install_keyword("detect_prio", &def_detect_prio_handler, &snprint_def_detect_prio);
1573         install_keyword("detect_checker", &def_detect_checker_handler, &snprint_def_detect_checker);
1574         install_keyword("force_sync", &def_force_sync_handler, &snprint_def_force_sync);
1575         install_keyword("strict_timing", &def_strict_timing_handler, &snprint_def_strict_timing);
1576         install_keyword("deferred_remove", &def_deferred_remove_handler, &snprint_def_deferred_remove);
1577         install_keyword("partition_delimiter", &def_partition_delim_handler, &snprint_def_partition_delim);
1578         install_keyword("config_dir", &def_config_dir_handler, &snprint_def_config_dir);
1579         install_keyword("delay_watch_checks", &def_delay_watch_checks_handler, &snprint_def_delay_watch_checks);
1580         install_keyword("delay_wait_checks", &def_delay_wait_checks_handler, &snprint_def_delay_wait_checks);
1581         install_keyword("marginal_path_err_sample_time", &def_marginal_path_err_sample_time_handler, &snprint_def_marginal_path_err_sample_time);
1582         install_keyword("marginal_path_err_rate_threshold", &def_marginal_path_err_rate_threshold_handler, &snprint_def_marginal_path_err_rate_threshold);
1583         install_keyword("marginal_path_err_recheck_gap_time", &def_marginal_path_err_recheck_gap_time_handler, &snprint_def_marginal_path_err_recheck_gap_time);
1584         install_keyword("marginal_path_double_failed_time", &def_marginal_path_double_failed_time_handler, &snprint_def_marginal_path_double_failed_time);
1585
1586         install_keyword("find_multipaths", &def_find_multipaths_handler, &snprint_def_find_multipaths);
1587         install_keyword("uxsock_timeout", &def_uxsock_timeout_handler, &snprint_def_uxsock_timeout);
1588         install_keyword("retrigger_tries", &def_retrigger_tries_handler, &snprint_def_retrigger_tries);
1589         install_keyword("retrigger_delay", &def_retrigger_delay_handler, &snprint_def_retrigger_delay);
1590         install_keyword("missing_uev_wait_timeout", &def_uev_wait_timeout_handler, &snprint_def_uev_wait_timeout);
1591         install_keyword("skip_kpartx", &def_skip_kpartx_handler, &snprint_def_skip_kpartx);
1592         install_keyword("disable_changed_wwids", &def_disable_changed_wwids_handler, &snprint_def_disable_changed_wwids);
1593         install_keyword("remove_retries", &def_remove_retries_handler, &snprint_def_remove_retries);
1594         install_keyword("max_sectors_kb", &def_max_sectors_kb_handler, &snprint_def_max_sectors_kb);
1595         install_keyword("ghost_delay", &def_ghost_delay_handler, &snprint_def_ghost_delay);
1596         install_keyword("find_multipaths_timeout",
1597                         &def_find_multipaths_timeout_handler,
1598                         &snprint_def_find_multipaths_timeout);
1599         __deprecated install_keyword("default_selector", &def_selector_handler, NULL);
1600         __deprecated install_keyword("default_path_grouping_policy", &def_pgpolicy_handler, NULL);
1601         __deprecated install_keyword("default_uid_attribute", &def_uid_attribute_handler, NULL);
1602         __deprecated install_keyword("default_getuid_callout", &def_getuid_handler, NULL);
1603         __deprecated install_keyword("default_features", &def_features_handler, NULL);
1604         __deprecated install_keyword("default_path_checker", &def_checker_name_handler, NULL);
1605
1606         install_keyword_root("blacklist", &blacklist_handler);
1607         install_keyword_multi("devnode", &ble_blist_devnode_handler, &snprint_ble_simple);
1608         install_keyword_multi("wwid", &ble_blist_wwid_handler, &snprint_ble_simple);
1609         install_keyword_multi("property", &ble_blist_property_handler, &snprint_ble_simple);
1610         install_keyword_multi("device", &ble_device_handler, NULL);
1611         install_sublevel();
1612         install_keyword("vendor", &ble_blist_device_vendor_handler, &snprint_bled_vendor);
1613         install_keyword("product", &ble_blist_device_product_handler, &snprint_bled_product);
1614         install_sublevel_end();
1615         install_keyword_root("blacklist_exceptions", &blacklist_exceptions_handler);
1616         install_keyword_multi("devnode", &ble_elist_devnode_handler, &snprint_ble_simple);
1617         install_keyword_multi("wwid", &ble_elist_wwid_handler, &snprint_ble_simple);
1618         install_keyword_multi("property", &ble_elist_property_handler, &snprint_ble_simple);
1619         install_keyword_multi("device", &ble_except_device_handler, NULL);
1620         install_sublevel();
1621         install_keyword("vendor", &ble_elist_device_vendor_handler, &snprint_bled_vendor);
1622         install_keyword("product", &ble_elist_device_product_handler, &snprint_bled_product);
1623         install_sublevel_end();
1624
1625 #if 0
1626         __deprecated install_keyword_root("devnode_blacklist", &blacklist_handler);
1627         __deprecated install_keyword("devnode", &ble_devnode_handler, &snprint_ble_simple);
1628         __deprecated install_keyword("wwid", &ble_wwid_handler, &snprint_ble_simple);
1629         __deprecated install_keyword("device", &ble_device_handler, NULL);
1630         __deprecated install_sublevel();
1631         __deprecated install_keyword("vendor", &ble_vendor_handler, &snprint_bled_vendor);
1632         __deprecated install_keyword("product", &ble_product_handler, &snprint_bled_product);
1633         __deprecated install_sublevel_end();
1634 #endif
1635 /*
1636  * If you add or remove a "device subsection" keyword also update
1637  * multipath/multipath.conf.5 and the TEMPLATE in libmultipath/hwtable.c
1638  */
1639         install_keyword_root("devices", &devices_handler);
1640         install_keyword_multi("device", &device_handler, NULL);
1641         install_sublevel();
1642         install_keyword("vendor", &hw_vendor_handler, &snprint_hw_vendor);
1643         install_keyword("product", &hw_product_handler, &snprint_hw_product);
1644         install_keyword("revision", &hw_revision_handler, &snprint_hw_revision);
1645         install_keyword("product_blacklist", &hw_bl_product_handler, &snprint_hw_bl_product);
1646         install_keyword("path_grouping_policy", &hw_pgpolicy_handler, &snprint_hw_pgpolicy);
1647         install_keyword("uid_attribute", &hw_uid_attribute_handler, &snprint_hw_uid_attribute);
1648         install_keyword("getuid_callout", &hw_getuid_handler, &snprint_hw_getuid);
1649         install_keyword("path_selector", &hw_selector_handler, &snprint_hw_selector);
1650         install_keyword("path_checker", &hw_checker_name_handler, &snprint_hw_checker_name);
1651         install_keyword("checker", &hw_checker_name_handler, NULL);
1652         install_keyword("alias_prefix", &hw_alias_prefix_handler, &snprint_hw_alias_prefix);
1653         install_keyword("features", &hw_features_handler, &snprint_hw_features);
1654         install_keyword("hardware_handler", &hw_hwhandler_handler, &snprint_hw_hwhandler);
1655         install_keyword("prio", &hw_prio_name_handler, &snprint_hw_prio_name);
1656         install_keyword("prio_args", &hw_prio_args_handler, &snprint_hw_prio_args);
1657         install_keyword("failback", &hw_pgfailback_handler, &snprint_hw_pgfailback);
1658         install_keyword("rr_weight", &hw_rr_weight_handler, &snprint_hw_rr_weight);
1659         install_keyword("no_path_retry", &hw_no_path_retry_handler, &snprint_hw_no_path_retry);
1660         install_keyword("rr_min_io", &hw_minio_handler, &snprint_hw_minio);
1661         install_keyword("rr_min_io_rq", &hw_minio_rq_handler, &snprint_hw_minio_rq);
1662         install_keyword("pg_timeout", &deprecated_handler, &snprint_deprecated);
1663         install_keyword("flush_on_last_del", &hw_flush_on_last_del_handler, &snprint_hw_flush_on_last_del);
1664         install_keyword("fast_io_fail_tmo", &hw_fast_io_fail_handler, &snprint_hw_fast_io_fail);
1665         install_keyword("dev_loss_tmo", &hw_dev_loss_handler, &snprint_hw_dev_loss);
1666         install_keyword("user_friendly_names", &hw_user_friendly_names_handler, &snprint_hw_user_friendly_names);
1667         install_keyword("retain_attached_hw_handler", &hw_retain_hwhandler_handler, &snprint_hw_retain_hwhandler);
1668         install_keyword("detect_prio", &hw_detect_prio_handler, &snprint_hw_detect_prio);
1669         install_keyword("detect_checker", &hw_detect_checker_handler, &snprint_hw_detect_checker);
1670         install_keyword("deferred_remove", &hw_deferred_remove_handler, &snprint_hw_deferred_remove);
1671         install_keyword("delay_watch_checks", &hw_delay_watch_checks_handler, &snprint_hw_delay_watch_checks);
1672         install_keyword("delay_wait_checks", &hw_delay_wait_checks_handler, &snprint_hw_delay_wait_checks);
1673         install_keyword("marginal_path_err_sample_time", &hw_marginal_path_err_sample_time_handler, &snprint_hw_marginal_path_err_sample_time);
1674         install_keyword("marginal_path_err_rate_threshold", &hw_marginal_path_err_rate_threshold_handler, &snprint_hw_marginal_path_err_rate_threshold);
1675         install_keyword("marginal_path_err_recheck_gap_time", &hw_marginal_path_err_recheck_gap_time_handler, &snprint_hw_marginal_path_err_recheck_gap_time);
1676         install_keyword("marginal_path_double_failed_time", &hw_marginal_path_double_failed_time_handler, &snprint_hw_marginal_path_double_failed_time);
1677         install_keyword("skip_kpartx", &hw_skip_kpartx_handler, &snprint_hw_skip_kpartx);
1678         install_keyword("max_sectors_kb", &hw_max_sectors_kb_handler, &snprint_hw_max_sectors_kb);
1679         install_keyword("ghost_delay", &hw_ghost_delay_handler, &snprint_hw_ghost_delay);
1680         install_keyword("all_tg_pt", &hw_all_tg_pt_handler, &snprint_hw_all_tg_pt);
1681         install_sublevel_end();
1682
1683         install_keyword_root("overrides", &overrides_handler);
1684         install_keyword("path_grouping_policy", &ovr_pgpolicy_handler, &snprint_ovr_pgpolicy);
1685         install_keyword("uid_attribute", &ovr_uid_attribute_handler, &snprint_ovr_uid_attribute);
1686         install_keyword("getuid_callout", &ovr_getuid_handler, &snprint_ovr_getuid);
1687         install_keyword("path_selector", &ovr_selector_handler, &snprint_ovr_selector);
1688         install_keyword("path_checker", &ovr_checker_name_handler, &snprint_ovr_checker_name);
1689         install_keyword("checker", &ovr_checker_name_handler, NULL);
1690         install_keyword("alias_prefix", &ovr_alias_prefix_handler, &snprint_ovr_alias_prefix);
1691         install_keyword("features", &ovr_features_handler, &snprint_ovr_features);
1692         install_keyword("prio", &ovr_prio_name_handler, &snprint_ovr_prio_name);
1693         install_keyword("prio_args", &ovr_prio_args_handler, &snprint_ovr_prio_args);
1694         install_keyword("failback", &ovr_pgfailback_handler, &snprint_ovr_pgfailback);
1695         install_keyword("rr_weight", &ovr_rr_weight_handler, &snprint_ovr_rr_weight);
1696         install_keyword("no_path_retry", &ovr_no_path_retry_handler, &snprint_ovr_no_path_retry);
1697         install_keyword("rr_min_io", &ovr_minio_handler, &snprint_ovr_minio);
1698         install_keyword("rr_min_io_rq", &ovr_minio_rq_handler, &snprint_ovr_minio_rq);
1699         install_keyword("flush_on_last_del", &ovr_flush_on_last_del_handler, &snprint_ovr_flush_on_last_del);
1700         install_keyword("fast_io_fail_tmo", &ovr_fast_io_fail_handler, &snprint_ovr_fast_io_fail);
1701         install_keyword("dev_loss_tmo", &ovr_dev_loss_handler, &snprint_ovr_dev_loss);
1702         install_keyword("user_friendly_names", &ovr_user_friendly_names_handler, &snprint_ovr_user_friendly_names);
1703         install_keyword("retain_attached_hw_handler", &ovr_retain_hwhandler_handler, &snprint_ovr_retain_hwhandler);
1704         install_keyword("detect_prio", &ovr_detect_prio_handler, &snprint_ovr_detect_prio);
1705         install_keyword("detect_checker", &ovr_detect_checker_handler, &snprint_ovr_detect_checker);
1706         install_keyword("deferred_remove", &ovr_deferred_remove_handler, &snprint_ovr_deferred_remove);
1707         install_keyword("delay_watch_checks", &ovr_delay_watch_checks_handler, &snprint_ovr_delay_watch_checks);
1708         install_keyword("delay_wait_checks", &ovr_delay_wait_checks_handler, &snprint_ovr_delay_wait_checks);
1709         install_keyword("marginal_path_err_sample_time", &ovr_marginal_path_err_sample_time_handler, &snprint_ovr_marginal_path_err_sample_time);
1710         install_keyword("marginal_path_err_rate_threshold", &ovr_marginal_path_err_rate_threshold_handler, &snprint_ovr_marginal_path_err_rate_threshold);
1711         install_keyword("marginal_path_err_recheck_gap_time", &ovr_marginal_path_err_recheck_gap_time_handler, &snprint_ovr_marginal_path_err_recheck_gap_time);
1712         install_keyword("marginal_path_double_failed_time", &ovr_marginal_path_double_failed_time_handler, &snprint_ovr_marginal_path_double_failed_time);
1713
1714         install_keyword("skip_kpartx", &ovr_skip_kpartx_handler, &snprint_ovr_skip_kpartx);
1715         install_keyword("max_sectors_kb", &ovr_max_sectors_kb_handler, &snprint_ovr_max_sectors_kb);
1716         install_keyword("ghost_delay", &ovr_ghost_delay_handler, &snprint_ovr_ghost_delay);
1717         install_keyword("all_tg_pt", &ovr_all_tg_pt_handler, &snprint_ovr_all_tg_pt);
1718
1719         install_keyword_root("multipaths", &multipaths_handler);
1720         install_keyword_multi("multipath", &multipath_handler, NULL);
1721         install_sublevel();
1722         install_keyword("wwid", &mp_wwid_handler, &snprint_mp_wwid);
1723         install_keyword("alias", &mp_alias_handler, &snprint_mp_alias);
1724         install_keyword("path_grouping_policy", &mp_pgpolicy_handler, &snprint_mp_pgpolicy);
1725         install_keyword("path_selector", &mp_selector_handler, &snprint_mp_selector);
1726         install_keyword("prio", &mp_prio_name_handler, &snprint_mp_prio_name);
1727         install_keyword("prio_args", &mp_prio_args_handler, &snprint_mp_prio_args);
1728         install_keyword("failback", &mp_pgfailback_handler, &snprint_mp_pgfailback);
1729         install_keyword("rr_weight", &mp_rr_weight_handler, &snprint_mp_rr_weight);
1730         install_keyword("no_path_retry", &mp_no_path_retry_handler, &snprint_mp_no_path_retry);
1731         install_keyword("rr_min_io", &mp_minio_handler, &snprint_mp_minio);
1732         install_keyword("rr_min_io_rq", &mp_minio_rq_handler, &snprint_mp_minio_rq);
1733         install_keyword("pg_timeout", &deprecated_handler, &snprint_deprecated);
1734         install_keyword("flush_on_last_del", &mp_flush_on_last_del_handler, &snprint_mp_flush_on_last_del);
1735         install_keyword("features", &mp_features_handler, &snprint_mp_features);
1736         install_keyword("mode", &mp_mode_handler, &snprint_mp_mode);
1737         install_keyword("uid", &mp_uid_handler, &snprint_mp_uid);
1738         install_keyword("gid", &mp_gid_handler, &snprint_mp_gid);
1739         install_keyword("reservation_key", &mp_reservation_key_handler, &snprint_mp_reservation_key);
1740         install_keyword("user_friendly_names", &mp_user_friendly_names_handler, &snprint_mp_user_friendly_names);
1741         install_keyword("deferred_remove", &mp_deferred_remove_handler, &snprint_mp_deferred_remove);
1742         install_keyword("delay_watch_checks", &mp_delay_watch_checks_handler, &snprint_mp_delay_watch_checks);
1743         install_keyword("delay_wait_checks", &mp_delay_wait_checks_handler, &snprint_mp_delay_wait_checks);
1744         install_keyword("marginal_path_err_sample_time", &mp_marginal_path_err_sample_time_handler, &snprint_mp_marginal_path_err_sample_time);
1745         install_keyword("marginal_path_err_rate_threshold", &mp_marginal_path_err_rate_threshold_handler, &snprint_mp_marginal_path_err_rate_threshold);
1746         install_keyword("marginal_path_err_recheck_gap_time", &mp_marginal_path_err_recheck_gap_time_handler, &snprint_mp_marginal_path_err_recheck_gap_time);
1747         install_keyword("marginal_path_double_failed_time", &mp_marginal_path_double_failed_time_handler, &snprint_mp_marginal_path_double_failed_time);
1748         install_keyword("skip_kpartx", &mp_skip_kpartx_handler, &snprint_mp_skip_kpartx);
1749         install_keyword("max_sectors_kb", &mp_max_sectors_kb_handler, &snprint_mp_max_sectors_kb);
1750         install_keyword("ghost_delay", &mp_ghost_delay_handler, &snprint_mp_ghost_delay);
1751         install_sublevel_end();
1752 }