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