multipath.conf: add "enable_foreign" parameter
[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 declare_def_handler(enable_foreign, set_str)
614 declare_def_snprint_defstr(enable_foreign, print_str,
615                            DEFAULT_ENABLE_FOREIGN)
616
617 static int
618 def_config_dir_handler(struct config *conf, vector strvec)
619 {
620         /* this is only valid in the main config file */
621         if (conf->processed_main_config)
622                 return 0;
623         return set_str(strvec, &conf->config_dir);
624 }
625 declare_def_snprint(config_dir, print_str)
626
627 #define declare_def_attr_handler(option, function)                      \
628 static int                                                              \
629 def_ ## option ## _handler (struct config *conf, vector strvec)         \
630 {                                                                       \
631         return function (strvec, &conf->option, &conf->attribute_flags);\
632 }
633
634 #define declare_def_attr_snprint(option, function)                      \
635 static int                                                              \
636 snprint_def_ ## option (struct config *conf, char * buff, int len,      \
637                         const void * data)                              \
638 {                                                                       \
639         return function (buff, len, conf->option,                       \
640                          conf->attribute_flags);                        \
641 }
642
643 #define declare_mp_attr_handler(option, function)                       \
644 static int                                                              \
645 mp_ ## option ## _handler (struct config *conf, vector strvec)          \
646 {                                                                       \
647         struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable);         \
648         if (!mpe)                                                       \
649                 return 1;                                               \
650         return function (strvec, &mpe->option, &mpe->attribute_flags);  \
651 }
652
653 #define declare_mp_attr_snprint(option, function)                       \
654 static int                                                              \
655 snprint_mp_ ## option (struct config *conf, char * buff, int len,       \
656                        const void * data)                               \
657 {                                                                       \
658         const struct mpentry * mpe = (const struct mpentry *)data;      \
659         return function (buff, len, mpe->option,                        \
660                          mpe->attribute_flags);                         \
661 }
662
663 static int
664 set_mode(vector strvec, void *ptr, int *flags)
665 {
666         mode_t mode;
667         mode_t *mode_ptr = (mode_t *)ptr;
668         char *buff;
669
670         buff = set_value(strvec);
671
672         if (!buff)
673                 return 1;
674
675         if (sscanf(buff, "%o", &mode) == 1 && mode <= 0777) {
676                 *flags |= (1 << ATTR_MODE);
677                 *mode_ptr = mode;
678         }
679
680         FREE(buff);
681         return 0;
682 }
683
684 static int
685 set_uid(vector strvec, void *ptr, int *flags)
686 {
687         uid_t uid;
688         uid_t *uid_ptr = (uid_t *)ptr;
689         char *buff;
690         char passwd_buf[1024];
691         struct passwd info, *found;
692
693         buff = set_value(strvec);
694         if (!buff)
695                 return 1;
696         if (getpwnam_r(buff, &info, passwd_buf, 1024, &found) == 0 && found) {
697                 *flags |= (1 << ATTR_UID);
698                 *uid_ptr = info.pw_uid;
699         }
700         else if (sscanf(buff, "%u", &uid) == 1){
701                 *flags |= (1 << ATTR_UID);
702                 *uid_ptr = uid;
703         }
704
705         FREE(buff);
706         return 0;
707 }
708
709 static int
710 set_gid(vector strvec, void *ptr, int *flags)
711 {
712         gid_t gid;
713         gid_t *gid_ptr = (gid_t *)ptr;
714         char *buff;
715         char passwd_buf[1024];
716         struct passwd info, *found;
717
718         buff = set_value(strvec);
719         if (!buff)
720                 return 1;
721
722         if (getpwnam_r(buff, &info, passwd_buf, 1024, &found) == 0 && found) {
723                 *flags |= (1 << ATTR_GID);
724                 *gid_ptr = info.pw_gid;
725         }
726         else if (sscanf(buff, "%u", &gid) == 1){
727                 *flags |= (1 << ATTR_GID);
728                 *gid_ptr = gid;
729         }
730         FREE(buff);
731         return 0;
732 }
733
734 static int
735 print_mode(char * buff, int len, long v, int flags)
736 {
737         mode_t mode = (mode_t)v;
738         if ((flags & (1 << ATTR_MODE)) == 0)
739                 return 0;
740         return snprintf(buff, len, "0%o", mode);
741 }
742
743 static int
744 print_uid(char * buff, int len, long v, int flags)
745 {
746         uid_t uid = (uid_t)v;
747         if ((flags & (1 << ATTR_UID)) == 0)
748                 return 0;
749         return snprintf(buff, len, "0%o", uid);
750 }
751
752 static int
753 print_gid(char * buff, int len, long v, int flags)
754 {
755         gid_t gid = (gid_t)v;
756         if ((flags & (1 << ATTR_GID)) == 0)
757                 return 0;
758         return snprintf(buff, len, "0%o", gid);
759 }
760
761 declare_def_attr_handler(mode, set_mode)
762 declare_def_attr_snprint(mode, print_mode)
763 declare_mp_attr_handler(mode, set_mode)
764 declare_mp_attr_snprint(mode, print_mode)
765
766 declare_def_attr_handler(uid, set_uid)
767 declare_def_attr_snprint(uid, print_uid)
768 declare_mp_attr_handler(uid, set_uid)
769 declare_mp_attr_snprint(uid, print_uid)
770
771 declare_def_attr_handler(gid, set_gid)
772 declare_def_attr_snprint(gid, print_gid)
773 declare_mp_attr_handler(gid, set_gid)
774 declare_mp_attr_snprint(gid, print_gid)
775
776 static int
777 set_fast_io_fail(vector strvec, void *ptr)
778 {
779         char * buff;
780         int *int_ptr = (int *)ptr;
781
782         buff = set_value(strvec);
783         if (!buff)
784                 return 1;
785
786         if (strcmp(buff, "off") == 0)
787                 *int_ptr = MP_FAST_IO_FAIL_OFF;
788         else if (sscanf(buff, "%d", int_ptr) != 1 ||
789                  *int_ptr < MP_FAST_IO_FAIL_ZERO)
790                 *int_ptr = MP_FAST_IO_FAIL_UNSET;
791         else if (*int_ptr == 0)
792                 *int_ptr = MP_FAST_IO_FAIL_ZERO;
793
794         FREE(buff);
795         return 0;
796 }
797
798 int
799 print_fast_io_fail(char * buff, int len, long v)
800 {
801         if (v == MP_FAST_IO_FAIL_UNSET)
802                 return 0;
803         if (v == MP_FAST_IO_FAIL_OFF)
804                 return snprintf(buff, len, "\"off\"");
805         if (v == MP_FAST_IO_FAIL_ZERO)
806                 return snprintf(buff, len, "0");
807         return snprintf(buff, len, "%ld", v);
808 }
809
810 declare_def_handler(fast_io_fail, set_fast_io_fail)
811 declare_def_snprint_defint(fast_io_fail, print_fast_io_fail,
812                            DEFAULT_FAST_IO_FAIL)
813 declare_ovr_handler(fast_io_fail, set_fast_io_fail)
814 declare_ovr_snprint(fast_io_fail, print_fast_io_fail)
815 declare_hw_handler(fast_io_fail, set_fast_io_fail)
816 declare_hw_snprint(fast_io_fail, print_fast_io_fail)
817
818 static int
819 set_dev_loss(vector strvec, void *ptr)
820 {
821         char * buff;
822         unsigned int *uint_ptr = (unsigned int *)ptr;
823
824         buff = set_value(strvec);
825         if (!buff)
826                 return 1;
827
828         if (!strcmp(buff, "infinity"))
829                 *uint_ptr = MAX_DEV_LOSS_TMO;
830         else if (sscanf(buff, "%u", uint_ptr) != 1)
831                 *uint_ptr = 0;
832
833         FREE(buff);
834         return 0;
835 }
836
837 int
838 print_dev_loss(char * buff, int len, unsigned long v)
839 {
840         if (!v)
841                 return 0;
842         if (v >= MAX_DEV_LOSS_TMO)
843                 return snprintf(buff, len, "\"infinity\"");
844         return snprintf(buff, len, "%lu", v);
845 }
846
847 declare_def_handler(dev_loss, set_dev_loss)
848 declare_def_snprint(dev_loss, print_dev_loss)
849 declare_ovr_handler(dev_loss, set_dev_loss)
850 declare_ovr_snprint(dev_loss, print_dev_loss)
851 declare_hw_handler(dev_loss, set_dev_loss)
852 declare_hw_snprint(dev_loss, print_dev_loss)
853
854 static int
855 set_pgpolicy(vector strvec, void *ptr)
856 {
857         char * buff;
858         int *int_ptr = (int *)ptr;
859
860         buff = set_value(strvec);
861         if (!buff)
862                 return 1;
863
864         *int_ptr = get_pgpolicy_id(buff);
865         FREE(buff);
866
867         return 0;
868 }
869
870 int
871 print_pgpolicy(char * buff, int len, long pgpolicy)
872 {
873         char str[POLICY_NAME_SIZE];
874
875         if (!pgpolicy)
876                 return 0;
877
878         get_pgpolicy_name(str, POLICY_NAME_SIZE, pgpolicy);
879
880         return snprintf(buff, len, "\"%s\"", str);
881 }
882
883 declare_def_handler(pgpolicy, set_pgpolicy)
884 declare_def_snprint_defint(pgpolicy, print_pgpolicy, DEFAULT_PGPOLICY)
885 declare_ovr_handler(pgpolicy, set_pgpolicy)
886 declare_ovr_snprint(pgpolicy, print_pgpolicy)
887 declare_hw_handler(pgpolicy, set_pgpolicy)
888 declare_hw_snprint(pgpolicy, print_pgpolicy)
889 declare_mp_handler(pgpolicy, set_pgpolicy)
890 declare_mp_snprint(pgpolicy, print_pgpolicy)
891
892 int
893 get_sys_max_fds(int *max_fds)
894 {
895         FILE *file;
896         int nr_open;
897         int ret = 1;
898
899         file = fopen("/proc/sys/fs/nr_open", "r");
900         if (!file) {
901                 fprintf(stderr, "Cannot open /proc/sys/fs/nr_open : %s\n",
902                         strerror(errno));
903                 return 1;
904         }
905         if (fscanf(file, "%d", &nr_open) != 1) {
906                 fprintf(stderr, "Cannot read max open fds from /proc/sys/fs/nr_open");
907                 if (ferror(file))
908                         fprintf(stderr, " : %s\n", strerror(errno));
909                 else
910                         fprintf(stderr, "\n");
911         } else {
912                 *max_fds = nr_open;
913                 ret = 0;
914         }
915         fclose(file);
916         return ret;
917 }
918
919
920 static int
921 max_fds_handler(struct config *conf, vector strvec)
922 {
923         char * buff;
924         int r = 0, max_fds;
925
926         buff = set_value(strvec);
927
928         if (!buff)
929                 return 1;
930
931         r = get_sys_max_fds(&max_fds);
932         if (r) {
933                 /* Assume safe limit */
934                 max_fds = 4096;
935         }
936         if (strlen(buff) == 3 &&
937             !strcmp(buff, "max"))
938                 conf->max_fds = max_fds;
939         else
940                 conf->max_fds = atoi(buff);
941
942         if (conf->max_fds > max_fds)
943                 conf->max_fds = max_fds;
944
945         FREE(buff);
946
947         return r;
948 }
949
950 static int
951 snprint_max_fds (struct config *conf, char * buff, int len, const void * data)
952 {
953         int r = 0, max_fds;
954
955         if (!conf->max_fds)
956                 return 0;
957
958         r = get_sys_max_fds(&max_fds);
959         if (!r && conf->max_fds >= max_fds)
960                 return snprintf(buff, len, "\"max\"");
961         else
962                 return snprintf(buff, len, "%d", conf->max_fds);
963 }
964
965 static int
966 set_rr_weight(vector strvec, void *ptr)
967 {
968         int *int_ptr = (int *)ptr;
969         char * buff;
970
971         buff = set_value(strvec);
972
973         if (!buff)
974                 return 1;
975
976         if (!strcmp(buff, "priorities"))
977                 *int_ptr = RR_WEIGHT_PRIO;
978
979         if (!strcmp(buff, "uniform"))
980                 *int_ptr = RR_WEIGHT_NONE;
981
982         FREE(buff);
983
984         return 0;
985 }
986
987 int
988 print_rr_weight (char * buff, int len, long v)
989 {
990         if (!v)
991                 return 0;
992         if (v == RR_WEIGHT_PRIO)
993                 return snprintf(buff, len, "\"priorities\"");
994         if (v == RR_WEIGHT_NONE)
995                 return snprintf(buff, len, "\"uniform\"");
996
997         return 0;
998 }
999
1000 declare_def_handler(rr_weight, set_rr_weight)
1001 declare_def_snprint_defint(rr_weight, print_rr_weight, DEFAULT_RR_WEIGHT)
1002 declare_ovr_handler(rr_weight, set_rr_weight)
1003 declare_ovr_snprint(rr_weight, print_rr_weight)
1004 declare_hw_handler(rr_weight, set_rr_weight)
1005 declare_hw_snprint(rr_weight, print_rr_weight)
1006 declare_mp_handler(rr_weight, set_rr_weight)
1007 declare_mp_snprint(rr_weight, print_rr_weight)
1008
1009 static int
1010 set_pgfailback(vector strvec, void *ptr)
1011 {
1012         int *int_ptr = (int *)ptr;
1013         char * buff;
1014
1015         buff = set_value(strvec);
1016         if (!buff)
1017                 return 1;
1018
1019         if (strlen(buff) == 6 && !strcmp(buff, "manual"))
1020                 *int_ptr = -FAILBACK_MANUAL;
1021         else if (strlen(buff) == 9 && !strcmp(buff, "immediate"))
1022                 *int_ptr = -FAILBACK_IMMEDIATE;
1023         else if (strlen(buff) == 10 && !strcmp(buff, "followover"))
1024                 *int_ptr = -FAILBACK_FOLLOWOVER;
1025         else
1026                 *int_ptr = atoi(buff);
1027
1028         FREE(buff);
1029
1030         return 0;
1031 }
1032
1033 int
1034 print_pgfailback (char * buff, int len, long v)
1035 {
1036         switch(v) {
1037         case  FAILBACK_UNDEF:
1038                 return 0;
1039         case -FAILBACK_MANUAL:
1040                 return snprintf(buff, len, "\"manual\"");
1041         case -FAILBACK_IMMEDIATE:
1042                 return snprintf(buff, len, "\"immediate\"");
1043         case -FAILBACK_FOLLOWOVER:
1044                 return snprintf(buff, len, "\"followover\"");
1045         default:
1046                 return snprintf(buff, len, "%li", v);
1047         }
1048 }
1049
1050 declare_def_handler(pgfailback, set_pgfailback)
1051 declare_def_snprint_defint(pgfailback, print_pgfailback, DEFAULT_FAILBACK)
1052 declare_ovr_handler(pgfailback, set_pgfailback)
1053 declare_ovr_snprint(pgfailback, print_pgfailback)
1054 declare_hw_handler(pgfailback, set_pgfailback)
1055 declare_hw_snprint(pgfailback, print_pgfailback)
1056 declare_mp_handler(pgfailback, set_pgfailback)
1057 declare_mp_snprint(pgfailback, print_pgfailback)
1058
1059 static int
1060 set_no_path_retry(vector strvec, void *ptr)
1061 {
1062         int *int_ptr = (int *)ptr;
1063         char * buff;
1064
1065         buff = set_value(strvec);
1066         if (!buff)
1067                 return 1;
1068
1069         if (!strcmp(buff, "fail") || !strcmp(buff, "0"))
1070                 *int_ptr = NO_PATH_RETRY_FAIL;
1071         else if (!strcmp(buff, "queue"))
1072                 *int_ptr = NO_PATH_RETRY_QUEUE;
1073         else if ((*int_ptr = atoi(buff)) < 1)
1074                 *int_ptr = NO_PATH_RETRY_UNDEF;
1075
1076         FREE(buff);
1077         return 0;
1078 }
1079
1080 int
1081 print_no_path_retry(char * buff, int len, long v)
1082 {
1083         switch(v) {
1084         case NO_PATH_RETRY_UNDEF:
1085                 return 0;
1086         case NO_PATH_RETRY_FAIL:
1087                 return snprintf(buff, len, "\"fail\"");
1088         case NO_PATH_RETRY_QUEUE:
1089                 return snprintf(buff, len, "\"queue\"");
1090         default:
1091                 return snprintf(buff, len, "%li", v);
1092         }
1093 }
1094
1095 declare_def_handler(no_path_retry, set_no_path_retry)
1096 declare_def_snprint(no_path_retry, print_no_path_retry)
1097 declare_ovr_handler(no_path_retry, set_no_path_retry)
1098 declare_ovr_snprint(no_path_retry, print_no_path_retry)
1099 declare_hw_handler(no_path_retry, set_no_path_retry)
1100 declare_hw_snprint(no_path_retry, print_no_path_retry)
1101 declare_mp_handler(no_path_retry, set_no_path_retry)
1102 declare_mp_snprint(no_path_retry, print_no_path_retry)
1103
1104 static int
1105 def_log_checker_err_handler(struct config *conf, vector strvec)
1106 {
1107         char * buff;
1108
1109         buff = set_value(strvec);
1110
1111         if (!buff)
1112                 return 1;
1113
1114         if (strlen(buff) == 4 && !strcmp(buff, "once"))
1115                 conf->log_checker_err = LOG_CHKR_ERR_ONCE;
1116         else if (strlen(buff) == 6 && !strcmp(buff, "always"))
1117                 conf->log_checker_err = LOG_CHKR_ERR_ALWAYS;
1118
1119         free(buff);
1120         return 0;
1121 }
1122
1123 static int
1124 snprint_def_log_checker_err (struct config *conf, char * buff, int len,
1125                              const void * data)
1126 {
1127         if (conf->log_checker_err == LOG_CHKR_ERR_ONCE)
1128                 return snprintf(buff, len, "once");
1129         return snprintf(buff, len, "always");
1130 }
1131
1132 static int
1133 set_reservation_key(vector strvec, struct be64 *be64_ptr, uint8_t *flags_ptr,
1134                     int *source_ptr)
1135 {
1136         char *buff;
1137         uint64_t prkey;
1138         uint8_t sa_flags;
1139
1140         buff = set_value(strvec);
1141         if (!buff)
1142                 return 1;
1143
1144         if (strcmp(buff, "file") == 0) {
1145                 *source_ptr = PRKEY_SOURCE_FILE;
1146                 *flags_ptr = 0;
1147                 put_be64(*be64_ptr, 0);
1148                 FREE(buff);
1149                 return 0;
1150         }
1151
1152         if (parse_prkey_flags(buff, &prkey, &sa_flags) != 0) {
1153                 FREE(buff);
1154                 return 1;
1155         }
1156         *source_ptr = PRKEY_SOURCE_CONF;
1157         *flags_ptr = sa_flags;
1158         put_be64(*be64_ptr, prkey);
1159         FREE(buff);
1160         return 0;
1161 }
1162
1163 int
1164 print_reservation_key(char * buff, int len, struct be64 key, uint8_t flags,
1165                       int source)
1166 {
1167         char *flagstr = "";
1168         if (source == PRKEY_SOURCE_NONE)
1169                 return 0;
1170         if (source == PRKEY_SOURCE_FILE)
1171                 return snprintf(buff, len, "file");
1172         if (flags & MPATH_F_APTPL_MASK)
1173                 flagstr = ":aptpl";
1174         return snprintf(buff, len, "0x%" PRIx64 "%s", get_be64(key),
1175                         flagstr);
1176 }
1177
1178 static int
1179 def_reservation_key_handler(struct config *conf, vector strvec)
1180 {
1181         return set_reservation_key(strvec, &conf->reservation_key,
1182                                    &conf->sa_flags,
1183                                    &conf->prkey_source);
1184 }
1185
1186 static int
1187 snprint_def_reservation_key (struct config *conf, char * buff, int len,
1188                              const void * data)
1189 {
1190         return print_reservation_key(buff, len, conf->reservation_key,
1191                                      conf->sa_flags,
1192                                      conf->prkey_source);
1193 }
1194
1195 static int
1196 mp_reservation_key_handler(struct config *conf, vector strvec)
1197 {
1198         struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable);
1199         if (!mpe)
1200                 return 1;
1201         return set_reservation_key(strvec, &mpe->reservation_key,
1202                                    &mpe->sa_flags,
1203                                    &mpe->prkey_source);
1204 }
1205
1206 static int
1207 snprint_mp_reservation_key (struct config *conf, char * buff, int len,
1208                             const void * data)
1209 {
1210         const struct mpentry * mpe = (const struct mpentry *)data;
1211         return print_reservation_key(buff, len, mpe->reservation_key,
1212                                      mpe->sa_flags,
1213                                      mpe->prkey_source);
1214 }
1215
1216 static int
1217 set_off_int_undef(vector strvec, void *ptr)
1218 {
1219         int *int_ptr = (int *)ptr;
1220         char * buff;
1221
1222         buff = set_value(strvec);
1223         if (!buff)
1224                 return 1;
1225
1226         if (!strcmp(buff, "no") || !strcmp(buff, "0"))
1227                 *int_ptr = NU_NO;
1228         else if ((*int_ptr = atoi(buff)) < 1)
1229                 *int_ptr = NU_UNDEF;
1230
1231         FREE(buff);
1232         return 0;
1233 }
1234
1235 int
1236 print_off_int_undef(char * buff, int len, long v)
1237 {
1238         switch(v) {
1239         case NU_UNDEF:
1240                 return 0;
1241         case NU_NO:
1242                 return snprintf(buff, len, "\"no\"");
1243         default:
1244                 return snprintf(buff, len, "%li", v);
1245         }
1246 }
1247
1248 declare_def_handler(delay_watch_checks, set_off_int_undef)
1249 declare_def_snprint_defint(delay_watch_checks, print_off_int_undef,
1250                            DEFAULT_DELAY_CHECKS)
1251 declare_ovr_handler(delay_watch_checks, set_off_int_undef)
1252 declare_ovr_snprint(delay_watch_checks, print_off_int_undef)
1253 declare_hw_handler(delay_watch_checks, set_off_int_undef)
1254 declare_hw_snprint(delay_watch_checks, print_off_int_undef)
1255 declare_mp_handler(delay_watch_checks, set_off_int_undef)
1256 declare_mp_snprint(delay_watch_checks, print_off_int_undef)
1257 declare_def_handler(delay_wait_checks, set_off_int_undef)
1258 declare_def_snprint_defint(delay_wait_checks, print_off_int_undef,
1259                            DEFAULT_DELAY_CHECKS)
1260 declare_ovr_handler(delay_wait_checks, set_off_int_undef)
1261 declare_ovr_snprint(delay_wait_checks, print_off_int_undef)
1262 declare_hw_handler(delay_wait_checks, set_off_int_undef)
1263 declare_hw_snprint(delay_wait_checks, print_off_int_undef)
1264 declare_mp_handler(delay_wait_checks, set_off_int_undef)
1265 declare_mp_snprint(delay_wait_checks, print_off_int_undef)
1266 declare_def_handler(san_path_err_threshold, set_off_int_undef)
1267 declare_def_snprint_defint(san_path_err_threshold, print_off_int_undef,
1268                            DEFAULT_ERR_CHECKS)
1269 declare_ovr_handler(san_path_err_threshold, set_off_int_undef)
1270 declare_ovr_snprint(san_path_err_threshold, print_off_int_undef)
1271 declare_hw_handler(san_path_err_threshold, set_off_int_undef)
1272 declare_hw_snprint(san_path_err_threshold, print_off_int_undef)
1273 declare_mp_handler(san_path_err_threshold, set_off_int_undef)
1274 declare_mp_snprint(san_path_err_threshold, print_off_int_undef)
1275 declare_def_handler(san_path_err_forget_rate, set_off_int_undef)
1276 declare_def_snprint_defint(san_path_err_forget_rate, print_off_int_undef,
1277                            DEFAULT_ERR_CHECKS)
1278 declare_ovr_handler(san_path_err_forget_rate, set_off_int_undef)
1279 declare_ovr_snprint(san_path_err_forget_rate, print_off_int_undef)
1280 declare_hw_handler(san_path_err_forget_rate, set_off_int_undef)
1281 declare_hw_snprint(san_path_err_forget_rate, print_off_int_undef)
1282 declare_mp_handler(san_path_err_forget_rate, set_off_int_undef)
1283 declare_mp_snprint(san_path_err_forget_rate, print_off_int_undef)
1284 declare_def_handler(san_path_err_recovery_time, set_off_int_undef)
1285 declare_def_snprint_defint(san_path_err_recovery_time, print_off_int_undef,
1286                            DEFAULT_ERR_CHECKS)
1287 declare_ovr_handler(san_path_err_recovery_time, set_off_int_undef)
1288 declare_ovr_snprint(san_path_err_recovery_time, print_off_int_undef)
1289 declare_hw_handler(san_path_err_recovery_time, set_off_int_undef)
1290 declare_hw_snprint(san_path_err_recovery_time, print_off_int_undef)
1291 declare_mp_handler(san_path_err_recovery_time, set_off_int_undef)
1292 declare_mp_snprint(san_path_err_recovery_time, print_off_int_undef)
1293 declare_def_handler(marginal_path_err_sample_time, set_off_int_undef)
1294 declare_def_snprint_defint(marginal_path_err_sample_time, print_off_int_undef,
1295                            DEFAULT_ERR_CHECKS)
1296 declare_ovr_handler(marginal_path_err_sample_time, set_off_int_undef)
1297 declare_ovr_snprint(marginal_path_err_sample_time, print_off_int_undef)
1298 declare_hw_handler(marginal_path_err_sample_time, set_off_int_undef)
1299 declare_hw_snprint(marginal_path_err_sample_time, print_off_int_undef)
1300 declare_mp_handler(marginal_path_err_sample_time, set_off_int_undef)
1301 declare_mp_snprint(marginal_path_err_sample_time, print_off_int_undef)
1302 declare_def_handler(marginal_path_err_rate_threshold, set_off_int_undef)
1303 declare_def_snprint_defint(marginal_path_err_rate_threshold, print_off_int_undef,
1304                            DEFAULT_ERR_CHECKS)
1305 declare_ovr_handler(marginal_path_err_rate_threshold, set_off_int_undef)
1306 declare_ovr_snprint(marginal_path_err_rate_threshold, print_off_int_undef)
1307 declare_hw_handler(marginal_path_err_rate_threshold, set_off_int_undef)
1308 declare_hw_snprint(marginal_path_err_rate_threshold, print_off_int_undef)
1309 declare_mp_handler(marginal_path_err_rate_threshold, set_off_int_undef)
1310 declare_mp_snprint(marginal_path_err_rate_threshold, print_off_int_undef)
1311 declare_def_handler(marginal_path_err_recheck_gap_time, set_off_int_undef)
1312 declare_def_snprint_defint(marginal_path_err_recheck_gap_time, print_off_int_undef,
1313                            DEFAULT_ERR_CHECKS)
1314 declare_ovr_handler(marginal_path_err_recheck_gap_time, set_off_int_undef)
1315 declare_ovr_snprint(marginal_path_err_recheck_gap_time, print_off_int_undef)
1316 declare_hw_handler(marginal_path_err_recheck_gap_time, set_off_int_undef)
1317 declare_hw_snprint(marginal_path_err_recheck_gap_time, print_off_int_undef)
1318 declare_mp_handler(marginal_path_err_recheck_gap_time, set_off_int_undef)
1319 declare_mp_snprint(marginal_path_err_recheck_gap_time, print_off_int_undef)
1320 declare_def_handler(marginal_path_double_failed_time, set_off_int_undef)
1321 declare_def_snprint_defint(marginal_path_double_failed_time, print_off_int_undef,
1322                            DEFAULT_ERR_CHECKS)
1323 declare_ovr_handler(marginal_path_double_failed_time, set_off_int_undef)
1324 declare_ovr_snprint(marginal_path_double_failed_time, print_off_int_undef)
1325 declare_hw_handler(marginal_path_double_failed_time, set_off_int_undef)
1326 declare_hw_snprint(marginal_path_double_failed_time, print_off_int_undef)
1327 declare_mp_handler(marginal_path_double_failed_time, set_off_int_undef)
1328 declare_mp_snprint(marginal_path_double_failed_time, print_off_int_undef)
1329
1330 declare_def_handler(ghost_delay, set_off_int_undef)
1331 declare_def_snprint(ghost_delay, print_off_int_undef)
1332 declare_ovr_handler(ghost_delay, set_off_int_undef)
1333 declare_ovr_snprint(ghost_delay, print_off_int_undef)
1334 declare_hw_handler(ghost_delay, set_off_int_undef)
1335 declare_hw_snprint(ghost_delay, print_off_int_undef)
1336 declare_mp_handler(ghost_delay, set_off_int_undef)
1337 declare_mp_snprint(ghost_delay, print_off_int_undef)
1338
1339 declare_def_handler(all_tg_pt, set_yes_no_undef)
1340 declare_def_snprint_defint(all_tg_pt, print_yes_no_undef, DEFAULT_ALL_TG_PT)
1341 declare_ovr_handler(all_tg_pt, set_yes_no_undef)
1342 declare_ovr_snprint(all_tg_pt, print_yes_no_undef)
1343 declare_hw_handler(all_tg_pt, set_yes_no_undef)
1344 declare_hw_snprint(all_tg_pt, print_yes_no_undef)
1345
1346 declare_def_handler(marginal_pathgroups, set_yes_no)
1347 declare_def_snprint(marginal_pathgroups, print_yes_no)
1348
1349 static int
1350 def_uxsock_timeout_handler(struct config *conf, vector strvec)
1351 {
1352         unsigned int uxsock_timeout;
1353         char *buff;
1354
1355         buff = set_value(strvec);
1356         if (!buff)
1357                 return 1;
1358
1359         if (sscanf(buff, "%u", &uxsock_timeout) == 1 &&
1360             uxsock_timeout > DEFAULT_REPLY_TIMEOUT)
1361                 conf->uxsock_timeout = uxsock_timeout;
1362         else
1363                 conf->uxsock_timeout = DEFAULT_REPLY_TIMEOUT;
1364
1365         free(buff);
1366         return 0;
1367 }
1368
1369 /*
1370  * blacklist block handlers
1371  */
1372 static int
1373 blacklist_handler(struct config *conf, vector strvec)
1374 {
1375         if (!conf->blist_devnode)
1376                 conf->blist_devnode = vector_alloc();
1377         if (!conf->blist_wwid)
1378                 conf->blist_wwid = vector_alloc();
1379         if (!conf->blist_device)
1380                 conf->blist_device = vector_alloc();
1381         if (!conf->blist_property)
1382                 conf->blist_property = vector_alloc();
1383         if (!conf->blist_protocol)
1384                 conf->blist_protocol = vector_alloc();
1385
1386         if (!conf->blist_devnode || !conf->blist_wwid ||
1387             !conf->blist_device || !conf->blist_property ||
1388             !conf->blist_protocol)
1389                 return 1;
1390
1391         return 0;
1392 }
1393
1394 static int
1395 blacklist_exceptions_handler(struct config *conf, vector strvec)
1396 {
1397         if (!conf->elist_devnode)
1398                 conf->elist_devnode = vector_alloc();
1399         if (!conf->elist_wwid)
1400                 conf->elist_wwid = vector_alloc();
1401         if (!conf->elist_device)
1402                 conf->elist_device = vector_alloc();
1403         if (!conf->elist_property)
1404                 conf->elist_property = vector_alloc();
1405         if (!conf->elist_protocol)
1406                 conf->elist_protocol = vector_alloc();
1407
1408         if (!conf->elist_devnode || !conf->elist_wwid ||
1409             !conf->elist_device || !conf->elist_property ||
1410             !conf->elist_protocol)
1411                 return 1;
1412
1413         return 0;
1414 }
1415
1416 #define declare_ble_handler(option)                                     \
1417 static int                                                              \
1418 ble_ ## option ## _handler (struct config *conf, vector strvec)         \
1419 {                                                                       \
1420         char * buff;                                                    \
1421                                                                         \
1422         if (!conf->option)                                              \
1423                 return 1;                                               \
1424                                                                         \
1425         buff = set_value(strvec);                                       \
1426         if (!buff)                                                      \
1427                 return 1;                                               \
1428                                                                         \
1429         return store_ble(conf->option, buff, ORIGIN_CONFIG);            \
1430 }
1431
1432 #define declare_ble_device_handler(name, option, vend, prod)            \
1433 static int                                                              \
1434 ble_ ## option ## _ ## name ## _handler (struct config *conf, vector strvec) \
1435 {                                                                       \
1436         char * buff;                                                    \
1437                                                                         \
1438         if (!conf->option)                                              \
1439                 return 1;                                               \
1440                                                                         \
1441         buff = set_value(strvec);                                       \
1442         if (!buff)                                                      \
1443                 return 1;                                               \
1444                                                                         \
1445         return set_ble_device(conf->option, vend, prod, ORIGIN_CONFIG); \
1446 }
1447
1448 declare_ble_handler(blist_devnode)
1449 declare_ble_handler(elist_devnode)
1450 declare_ble_handler(blist_wwid)
1451 declare_ble_handler(elist_wwid)
1452 declare_ble_handler(blist_property)
1453 declare_ble_handler(elist_property)
1454 declare_ble_handler(blist_protocol)
1455 declare_ble_handler(elist_protocol)
1456
1457 static int
1458 snprint_def_uxsock_timeout(struct config *conf, char * buff, int len,
1459                            const void * data)
1460 {
1461         return snprintf(buff, len, "%u", conf->uxsock_timeout);
1462 }
1463
1464 static int
1465 snprint_ble_simple (struct config *conf, char * buff, int len,
1466                     const void * data)
1467 {
1468         const struct blentry * ble = (const struct blentry *)data;
1469
1470         return snprintf(buff, len, "\"%s\"", ble->str);
1471 }
1472
1473 static int
1474 ble_device_handler(struct config *conf, vector strvec)
1475 {
1476         return alloc_ble_device(conf->blist_device);
1477 }
1478
1479 static int
1480 ble_except_device_handler(struct config *conf, vector strvec)
1481 {
1482         return alloc_ble_device(conf->elist_device);
1483 }
1484
1485 declare_ble_device_handler(vendor, blist_device, buff, NULL)
1486 declare_ble_device_handler(vendor, elist_device, buff, NULL)
1487 declare_ble_device_handler(product, blist_device, NULL, buff)
1488 declare_ble_device_handler(product, elist_device, NULL, buff)
1489
1490 static int
1491 snprint_bled_vendor (struct config *conf, char * buff, int len,
1492                      const void * data)
1493 {
1494         const struct blentry_device * bled =
1495                 (const struct blentry_device *)data;
1496
1497         return snprintf(buff, len, "\"%s\"", bled->vendor);
1498 }
1499
1500 static int
1501 snprint_bled_product (struct config *conf, char * buff, int len,
1502                       const void * data)
1503 {
1504         const struct blentry_device * bled =
1505                 (const struct blentry_device *)data;
1506
1507         return snprintf(buff, len, "\"%s\"", bled->product);
1508 }
1509
1510 /*
1511  * devices block handlers
1512  */
1513 static int
1514 devices_handler(struct config *conf, vector strvec)
1515 {
1516         if (!conf->hwtable)
1517                 conf->hwtable = vector_alloc();
1518
1519         if (!conf->hwtable)
1520                 return 1;
1521
1522         return 0;
1523 }
1524
1525 static int
1526 device_handler(struct config *conf, vector strvec)
1527 {
1528         struct hwentry * hwe;
1529
1530         hwe = alloc_hwe();
1531
1532         if (!hwe)
1533                 return 1;
1534
1535         if (!vector_alloc_slot(conf->hwtable)) {
1536                 free_hwe(hwe);
1537                 return 1;
1538         }
1539         vector_set_slot(conf->hwtable, hwe);
1540
1541         return 0;
1542 }
1543
1544 declare_hw_handler(vendor, set_str)
1545 declare_hw_snprint(vendor, print_str)
1546
1547 declare_hw_handler(product, set_str)
1548 declare_hw_snprint(product, print_str)
1549
1550 declare_hw_handler(revision, set_str)
1551 declare_hw_snprint(revision, print_str)
1552
1553 declare_hw_handler(bl_product, set_str)
1554 declare_hw_snprint(bl_product, print_str)
1555
1556 declare_hw_handler(hwhandler, set_str)
1557 declare_hw_snprint(hwhandler, print_str)
1558
1559 /*
1560  * overrides handlers
1561  */
1562 static int
1563 overrides_handler(struct config *conf, vector strvec)
1564 {
1565         if (!conf->overrides)
1566                 conf->overrides = alloc_hwe();
1567
1568         if (!conf->overrides)
1569                 return 1;
1570
1571         return 0;
1572 }
1573
1574
1575
1576 /*
1577  * multipaths block handlers
1578  */
1579 static int
1580 multipaths_handler(struct config *conf, vector strvec)
1581 {
1582         if (!conf->mptable)
1583                 conf->mptable = vector_alloc();
1584
1585         if (!conf->mptable)
1586                 return 1;
1587
1588         return 0;
1589 }
1590
1591 static int
1592 multipath_handler(struct config *conf, vector strvec)
1593 {
1594         struct mpentry * mpe;
1595
1596         mpe = alloc_mpe();
1597
1598         if (!mpe)
1599                 return 1;
1600
1601         if (!vector_alloc_slot(conf->mptable)) {
1602                 free_mpe(mpe);
1603                 return 1;
1604         }
1605         vector_set_slot(conf->mptable, mpe);
1606
1607         return 0;
1608 }
1609
1610 declare_mp_handler(wwid, set_str)
1611 declare_mp_snprint(wwid, print_str)
1612
1613 declare_mp_handler(alias, set_str)
1614 declare_mp_snprint(alias, print_str)
1615
1616 /*
1617  * deprecated handlers
1618  */
1619
1620 static int
1621 deprecated_handler(struct config *conf, vector strvec)
1622 {
1623         char * buff;
1624
1625         buff = set_value(strvec);
1626
1627         if (!buff)
1628                 return 1;
1629
1630         FREE(buff);
1631         return 0;
1632 }
1633
1634 static int
1635 snprint_deprecated (struct config *conf, char * buff, int len,
1636                     const void * data)
1637 {
1638         return 0;
1639 }
1640
1641 #define __deprecated
1642
1643 /*
1644  * If you add or remove a keyword also update multipath/multipath.conf.5
1645  */
1646 void
1647 init_keywords(vector keywords)
1648 {
1649         install_keyword_root("defaults", NULL);
1650         install_keyword("verbosity", &def_verbosity_handler, &snprint_def_verbosity);
1651         install_keyword("polling_interval", &checkint_handler, &snprint_def_checkint);
1652         install_keyword("max_polling_interval", &def_max_checkint_handler, &snprint_def_max_checkint);
1653         install_keyword("reassign_maps", &def_reassign_maps_handler, &snprint_def_reassign_maps);
1654         install_keyword("multipath_dir", &def_multipath_dir_handler, &snprint_def_multipath_dir);
1655         install_keyword("path_selector", &def_selector_handler, &snprint_def_selector);
1656         install_keyword("path_grouping_policy", &def_pgpolicy_handler, &snprint_def_pgpolicy);
1657         install_keyword("uid_attrs", &uid_attrs_handler, &snprint_uid_attrs);
1658         install_keyword("uid_attribute", &def_uid_attribute_handler, &snprint_def_uid_attribute);
1659         install_keyword("getuid_callout", &def_getuid_handler, &snprint_def_getuid);
1660         install_keyword("prio", &def_prio_name_handler, &snprint_def_prio_name);
1661         install_keyword("prio_args", &def_prio_args_handler, &snprint_def_prio_args);
1662         install_keyword("features", &def_features_handler, &snprint_def_features);
1663         install_keyword("path_checker", &def_checker_name_handler, &snprint_def_checker_name);
1664         install_keyword("checker", &def_checker_name_handler, NULL);
1665         install_keyword("alias_prefix", &def_alias_prefix_handler, &snprint_def_alias_prefix);
1666         install_keyword("failback", &def_pgfailback_handler, &snprint_def_pgfailback);
1667         install_keyword("rr_min_io", &def_minio_handler, &snprint_def_minio);
1668         install_keyword("rr_min_io_rq", &def_minio_rq_handler, &snprint_def_minio_rq);
1669         install_keyword("max_fds", &max_fds_handler, &snprint_max_fds);
1670         install_keyword("rr_weight", &def_rr_weight_handler, &snprint_def_rr_weight);
1671         install_keyword("no_path_retry", &def_no_path_retry_handler, &snprint_def_no_path_retry);
1672         install_keyword("queue_without_daemon", &def_queue_without_daemon_handler, &snprint_def_queue_without_daemon);
1673         install_keyword("checker_timeout", &def_checker_timeout_handler, &snprint_def_checker_timeout);
1674         install_keyword("pg_timeout", &deprecated_handler, &snprint_deprecated);
1675         install_keyword("flush_on_last_del", &def_flush_on_last_del_handler, &snprint_def_flush_on_last_del);
1676         install_keyword("user_friendly_names", &def_user_friendly_names_handler, &snprint_def_user_friendly_names);
1677         install_keyword("mode", &def_mode_handler, &snprint_def_mode);
1678         install_keyword("uid", &def_uid_handler, &snprint_def_uid);
1679         install_keyword("gid", &def_gid_handler, &snprint_def_gid);
1680         install_keyword("fast_io_fail_tmo", &def_fast_io_fail_handler, &snprint_def_fast_io_fail);
1681         install_keyword("dev_loss_tmo", &def_dev_loss_handler, &snprint_def_dev_loss);
1682         install_keyword("bindings_file", &def_bindings_file_handler, &snprint_def_bindings_file);
1683         install_keyword("wwids_file", &def_wwids_file_handler, &snprint_def_wwids_file);
1684         install_keyword("prkeys_file", &def_prkeys_file_handler, &snprint_def_prkeys_file);
1685         install_keyword("log_checker_err", &def_log_checker_err_handler, &snprint_def_log_checker_err);
1686         install_keyword("reservation_key", &def_reservation_key_handler, &snprint_def_reservation_key);
1687         install_keyword("all_tg_pt", &def_all_tg_pt_handler, &snprint_def_all_tg_pt);
1688         install_keyword("retain_attached_hw_handler", &def_retain_hwhandler_handler, &snprint_def_retain_hwhandler);
1689         install_keyword("detect_prio", &def_detect_prio_handler, &snprint_def_detect_prio);
1690         install_keyword("detect_checker", &def_detect_checker_handler, &snprint_def_detect_checker);
1691         install_keyword("force_sync", &def_force_sync_handler, &snprint_def_force_sync);
1692         install_keyword("strict_timing", &def_strict_timing_handler, &snprint_def_strict_timing);
1693         install_keyword("deferred_remove", &def_deferred_remove_handler, &snprint_def_deferred_remove);
1694         install_keyword("partition_delimiter", &def_partition_delim_handler, &snprint_def_partition_delim);
1695         install_keyword("config_dir", &def_config_dir_handler, &snprint_def_config_dir);
1696         install_keyword("delay_watch_checks", &def_delay_watch_checks_handler, &snprint_def_delay_watch_checks);
1697         install_keyword("delay_wait_checks", &def_delay_wait_checks_handler, &snprint_def_delay_wait_checks);
1698         install_keyword("san_path_err_threshold", &def_san_path_err_threshold_handler, &snprint_def_san_path_err_threshold);
1699         install_keyword("san_path_err_forget_rate", &def_san_path_err_forget_rate_handler, &snprint_def_san_path_err_forget_rate);
1700         install_keyword("san_path_err_recovery_time", &def_san_path_err_recovery_time_handler, &snprint_def_san_path_err_recovery_time);
1701         install_keyword("marginal_path_err_sample_time", &def_marginal_path_err_sample_time_handler, &snprint_def_marginal_path_err_sample_time);
1702         install_keyword("marginal_path_err_rate_threshold", &def_marginal_path_err_rate_threshold_handler, &snprint_def_marginal_path_err_rate_threshold);
1703         install_keyword("marginal_path_err_recheck_gap_time", &def_marginal_path_err_recheck_gap_time_handler, &snprint_def_marginal_path_err_recheck_gap_time);
1704         install_keyword("marginal_path_double_failed_time", &def_marginal_path_double_failed_time_handler, &snprint_def_marginal_path_double_failed_time);
1705
1706         install_keyword("find_multipaths", &def_find_multipaths_handler, &snprint_def_find_multipaths);
1707         install_keyword("uxsock_timeout", &def_uxsock_timeout_handler, &snprint_def_uxsock_timeout);
1708         install_keyword("retrigger_tries", &def_retrigger_tries_handler, &snprint_def_retrigger_tries);
1709         install_keyword("retrigger_delay", &def_retrigger_delay_handler, &snprint_def_retrigger_delay);
1710         install_keyword("missing_uev_wait_timeout", &def_uev_wait_timeout_handler, &snprint_def_uev_wait_timeout);
1711         install_keyword("skip_kpartx", &def_skip_kpartx_handler, &snprint_def_skip_kpartx);
1712         install_keyword("disable_changed_wwids", &def_disable_changed_wwids_handler, &snprint_def_disable_changed_wwids);
1713         install_keyword("remove_retries", &def_remove_retries_handler, &snprint_def_remove_retries);
1714         install_keyword("max_sectors_kb", &def_max_sectors_kb_handler, &snprint_def_max_sectors_kb);
1715         install_keyword("ghost_delay", &def_ghost_delay_handler, &snprint_def_ghost_delay);
1716         install_keyword("find_multipaths_timeout",
1717                         &def_find_multipaths_timeout_handler,
1718                         &snprint_def_find_multipaths_timeout);
1719         install_keyword("enable_foreign", &def_enable_foreign_handler,
1720                         &snprint_def_enable_foreign);
1721         install_keyword("marginal_pathgroups", &def_marginal_pathgroups_handler, &snprint_def_marginal_pathgroups);
1722         __deprecated install_keyword("default_selector", &def_selector_handler, NULL);
1723         __deprecated install_keyword("default_path_grouping_policy", &def_pgpolicy_handler, NULL);
1724         __deprecated install_keyword("default_uid_attribute", &def_uid_attribute_handler, NULL);
1725         __deprecated install_keyword("default_getuid_callout", &def_getuid_handler, NULL);
1726         __deprecated install_keyword("default_features", &def_features_handler, NULL);
1727         __deprecated install_keyword("default_path_checker", &def_checker_name_handler, NULL);
1728
1729         install_keyword_root("blacklist", &blacklist_handler);
1730         install_keyword_multi("devnode", &ble_blist_devnode_handler, &snprint_ble_simple);
1731         install_keyword_multi("wwid", &ble_blist_wwid_handler, &snprint_ble_simple);
1732         install_keyword_multi("property", &ble_blist_property_handler, &snprint_ble_simple);
1733         install_keyword_multi("protocol", &ble_blist_protocol_handler, &snprint_ble_simple);
1734         install_keyword_multi("device", &ble_device_handler, NULL);
1735         install_sublevel();
1736         install_keyword("vendor", &ble_blist_device_vendor_handler, &snprint_bled_vendor);
1737         install_keyword("product", &ble_blist_device_product_handler, &snprint_bled_product);
1738         install_sublevel_end();
1739         install_keyword_root("blacklist_exceptions", &blacklist_exceptions_handler);
1740         install_keyword_multi("devnode", &ble_elist_devnode_handler, &snprint_ble_simple);
1741         install_keyword_multi("wwid", &ble_elist_wwid_handler, &snprint_ble_simple);
1742         install_keyword_multi("property", &ble_elist_property_handler, &snprint_ble_simple);
1743         install_keyword_multi("protocol", &ble_elist_protocol_handler, &snprint_ble_simple);
1744         install_keyword_multi("device", &ble_except_device_handler, NULL);
1745         install_sublevel();
1746         install_keyword("vendor", &ble_elist_device_vendor_handler, &snprint_bled_vendor);
1747         install_keyword("product", &ble_elist_device_product_handler, &snprint_bled_product);
1748         install_sublevel_end();
1749
1750 #if 0
1751         __deprecated install_keyword_root("devnode_blacklist", &blacklist_handler);
1752         __deprecated install_keyword("devnode", &ble_devnode_handler, &snprint_ble_simple);
1753         __deprecated install_keyword("wwid", &ble_wwid_handler, &snprint_ble_simple);
1754         __deprecated install_keyword("device", &ble_device_handler, NULL);
1755         __deprecated install_sublevel();
1756         __deprecated install_keyword("vendor", &ble_vendor_handler, &snprint_bled_vendor);
1757         __deprecated install_keyword("product", &ble_product_handler, &snprint_bled_product);
1758         __deprecated install_sublevel_end();
1759 #endif
1760 /*
1761  * If you add or remove a "device subsection" keyword also update
1762  * multipath/multipath.conf.5 and the TEMPLATE in libmultipath/hwtable.c
1763  */
1764         install_keyword_root("devices", &devices_handler);
1765         install_keyword_multi("device", &device_handler, NULL);
1766         install_sublevel();
1767         install_keyword("vendor", &hw_vendor_handler, &snprint_hw_vendor);
1768         install_keyword("product", &hw_product_handler, &snprint_hw_product);
1769         install_keyword("revision", &hw_revision_handler, &snprint_hw_revision);
1770         install_keyword("product_blacklist", &hw_bl_product_handler, &snprint_hw_bl_product);
1771         install_keyword("path_grouping_policy", &hw_pgpolicy_handler, &snprint_hw_pgpolicy);
1772         install_keyword("uid_attribute", &hw_uid_attribute_handler, &snprint_hw_uid_attribute);
1773         install_keyword("getuid_callout", &hw_getuid_handler, &snprint_hw_getuid);
1774         install_keyword("path_selector", &hw_selector_handler, &snprint_hw_selector);
1775         install_keyword("path_checker", &hw_checker_name_handler, &snprint_hw_checker_name);
1776         install_keyword("checker", &hw_checker_name_handler, NULL);
1777         install_keyword("alias_prefix", &hw_alias_prefix_handler, &snprint_hw_alias_prefix);
1778         install_keyword("features", &hw_features_handler, &snprint_hw_features);
1779         install_keyword("hardware_handler", &hw_hwhandler_handler, &snprint_hw_hwhandler);
1780         install_keyword("prio", &hw_prio_name_handler, &snprint_hw_prio_name);
1781         install_keyword("prio_args", &hw_prio_args_handler, &snprint_hw_prio_args);
1782         install_keyword("failback", &hw_pgfailback_handler, &snprint_hw_pgfailback);
1783         install_keyword("rr_weight", &hw_rr_weight_handler, &snprint_hw_rr_weight);
1784         install_keyword("no_path_retry", &hw_no_path_retry_handler, &snprint_hw_no_path_retry);
1785         install_keyword("rr_min_io", &hw_minio_handler, &snprint_hw_minio);
1786         install_keyword("rr_min_io_rq", &hw_minio_rq_handler, &snprint_hw_minio_rq);
1787         install_keyword("pg_timeout", &deprecated_handler, &snprint_deprecated);
1788         install_keyword("flush_on_last_del", &hw_flush_on_last_del_handler, &snprint_hw_flush_on_last_del);
1789         install_keyword("fast_io_fail_tmo", &hw_fast_io_fail_handler, &snprint_hw_fast_io_fail);
1790         install_keyword("dev_loss_tmo", &hw_dev_loss_handler, &snprint_hw_dev_loss);
1791         install_keyword("user_friendly_names", &hw_user_friendly_names_handler, &snprint_hw_user_friendly_names);
1792         install_keyword("retain_attached_hw_handler", &hw_retain_hwhandler_handler, &snprint_hw_retain_hwhandler);
1793         install_keyword("detect_prio", &hw_detect_prio_handler, &snprint_hw_detect_prio);
1794         install_keyword("detect_checker", &hw_detect_checker_handler, &snprint_hw_detect_checker);
1795         install_keyword("deferred_remove", &hw_deferred_remove_handler, &snprint_hw_deferred_remove);
1796         install_keyword("delay_watch_checks", &hw_delay_watch_checks_handler, &snprint_hw_delay_watch_checks);
1797         install_keyword("delay_wait_checks", &hw_delay_wait_checks_handler, &snprint_hw_delay_wait_checks);
1798         install_keyword("san_path_err_threshold", &hw_san_path_err_threshold_handler, &snprint_hw_san_path_err_threshold);
1799         install_keyword("san_path_err_forget_rate", &hw_san_path_err_forget_rate_handler, &snprint_hw_san_path_err_forget_rate);
1800         install_keyword("san_path_err_recovery_time", &hw_san_path_err_recovery_time_handler, &snprint_hw_san_path_err_recovery_time);
1801         install_keyword("marginal_path_err_sample_time", &hw_marginal_path_err_sample_time_handler, &snprint_hw_marginal_path_err_sample_time);
1802         install_keyword("marginal_path_err_rate_threshold", &hw_marginal_path_err_rate_threshold_handler, &snprint_hw_marginal_path_err_rate_threshold);
1803         install_keyword("marginal_path_err_recheck_gap_time", &hw_marginal_path_err_recheck_gap_time_handler, &snprint_hw_marginal_path_err_recheck_gap_time);
1804         install_keyword("marginal_path_double_failed_time", &hw_marginal_path_double_failed_time_handler, &snprint_hw_marginal_path_double_failed_time);
1805         install_keyword("skip_kpartx", &hw_skip_kpartx_handler, &snprint_hw_skip_kpartx);
1806         install_keyword("max_sectors_kb", &hw_max_sectors_kb_handler, &snprint_hw_max_sectors_kb);
1807         install_keyword("ghost_delay", &hw_ghost_delay_handler, &snprint_hw_ghost_delay);
1808         install_keyword("all_tg_pt", &hw_all_tg_pt_handler, &snprint_hw_all_tg_pt);
1809         install_sublevel_end();
1810
1811         install_keyword_root("overrides", &overrides_handler);
1812         install_keyword("path_grouping_policy", &ovr_pgpolicy_handler, &snprint_ovr_pgpolicy);
1813         install_keyword("uid_attribute", &ovr_uid_attribute_handler, &snprint_ovr_uid_attribute);
1814         install_keyword("getuid_callout", &ovr_getuid_handler, &snprint_ovr_getuid);
1815         install_keyword("path_selector", &ovr_selector_handler, &snprint_ovr_selector);
1816         install_keyword("path_checker", &ovr_checker_name_handler, &snprint_ovr_checker_name);
1817         install_keyword("checker", &ovr_checker_name_handler, NULL);
1818         install_keyword("alias_prefix", &ovr_alias_prefix_handler, &snprint_ovr_alias_prefix);
1819         install_keyword("features", &ovr_features_handler, &snprint_ovr_features);
1820         install_keyword("prio", &ovr_prio_name_handler, &snprint_ovr_prio_name);
1821         install_keyword("prio_args", &ovr_prio_args_handler, &snprint_ovr_prio_args);
1822         install_keyword("failback", &ovr_pgfailback_handler, &snprint_ovr_pgfailback);
1823         install_keyword("rr_weight", &ovr_rr_weight_handler, &snprint_ovr_rr_weight);
1824         install_keyword("no_path_retry", &ovr_no_path_retry_handler, &snprint_ovr_no_path_retry);
1825         install_keyword("rr_min_io", &ovr_minio_handler, &snprint_ovr_minio);
1826         install_keyword("rr_min_io_rq", &ovr_minio_rq_handler, &snprint_ovr_minio_rq);
1827         install_keyword("flush_on_last_del", &ovr_flush_on_last_del_handler, &snprint_ovr_flush_on_last_del);
1828         install_keyword("fast_io_fail_tmo", &ovr_fast_io_fail_handler, &snprint_ovr_fast_io_fail);
1829         install_keyword("dev_loss_tmo", &ovr_dev_loss_handler, &snprint_ovr_dev_loss);
1830         install_keyword("user_friendly_names", &ovr_user_friendly_names_handler, &snprint_ovr_user_friendly_names);
1831         install_keyword("retain_attached_hw_handler", &ovr_retain_hwhandler_handler, &snprint_ovr_retain_hwhandler);
1832         install_keyword("detect_prio", &ovr_detect_prio_handler, &snprint_ovr_detect_prio);
1833         install_keyword("detect_checker", &ovr_detect_checker_handler, &snprint_ovr_detect_checker);
1834         install_keyword("deferred_remove", &ovr_deferred_remove_handler, &snprint_ovr_deferred_remove);
1835         install_keyword("delay_watch_checks", &ovr_delay_watch_checks_handler, &snprint_ovr_delay_watch_checks);
1836         install_keyword("delay_wait_checks", &ovr_delay_wait_checks_handler, &snprint_ovr_delay_wait_checks);
1837         install_keyword("san_path_err_threshold", &ovr_san_path_err_threshold_handler, &snprint_ovr_san_path_err_threshold);
1838         install_keyword("san_path_err_forget_rate", &ovr_san_path_err_forget_rate_handler, &snprint_ovr_san_path_err_forget_rate);
1839         install_keyword("san_path_err_recovery_time", &ovr_san_path_err_recovery_time_handler, &snprint_ovr_san_path_err_recovery_time);
1840         install_keyword("marginal_path_err_sample_time", &ovr_marginal_path_err_sample_time_handler, &snprint_ovr_marginal_path_err_sample_time);
1841         install_keyword("marginal_path_err_rate_threshold", &ovr_marginal_path_err_rate_threshold_handler, &snprint_ovr_marginal_path_err_rate_threshold);
1842         install_keyword("marginal_path_err_recheck_gap_time", &ovr_marginal_path_err_recheck_gap_time_handler, &snprint_ovr_marginal_path_err_recheck_gap_time);
1843         install_keyword("marginal_path_double_failed_time", &ovr_marginal_path_double_failed_time_handler, &snprint_ovr_marginal_path_double_failed_time);
1844
1845         install_keyword("skip_kpartx", &ovr_skip_kpartx_handler, &snprint_ovr_skip_kpartx);
1846         install_keyword("max_sectors_kb", &ovr_max_sectors_kb_handler, &snprint_ovr_max_sectors_kb);
1847         install_keyword("ghost_delay", &ovr_ghost_delay_handler, &snprint_ovr_ghost_delay);
1848         install_keyword("all_tg_pt", &ovr_all_tg_pt_handler, &snprint_ovr_all_tg_pt);
1849
1850         install_keyword_root("multipaths", &multipaths_handler);
1851         install_keyword_multi("multipath", &multipath_handler, NULL);
1852         install_sublevel();
1853         install_keyword("wwid", &mp_wwid_handler, &snprint_mp_wwid);
1854         install_keyword("alias", &mp_alias_handler, &snprint_mp_alias);
1855         install_keyword("path_grouping_policy", &mp_pgpolicy_handler, &snprint_mp_pgpolicy);
1856         install_keyword("path_selector", &mp_selector_handler, &snprint_mp_selector);
1857         install_keyword("prio", &mp_prio_name_handler, &snprint_mp_prio_name);
1858         install_keyword("prio_args", &mp_prio_args_handler, &snprint_mp_prio_args);
1859         install_keyword("failback", &mp_pgfailback_handler, &snprint_mp_pgfailback);
1860         install_keyword("rr_weight", &mp_rr_weight_handler, &snprint_mp_rr_weight);
1861         install_keyword("no_path_retry", &mp_no_path_retry_handler, &snprint_mp_no_path_retry);
1862         install_keyword("rr_min_io", &mp_minio_handler, &snprint_mp_minio);
1863         install_keyword("rr_min_io_rq", &mp_minio_rq_handler, &snprint_mp_minio_rq);
1864         install_keyword("pg_timeout", &deprecated_handler, &snprint_deprecated);
1865         install_keyword("flush_on_last_del", &mp_flush_on_last_del_handler, &snprint_mp_flush_on_last_del);
1866         install_keyword("features", &mp_features_handler, &snprint_mp_features);
1867         install_keyword("mode", &mp_mode_handler, &snprint_mp_mode);
1868         install_keyword("uid", &mp_uid_handler, &snprint_mp_uid);
1869         install_keyword("gid", &mp_gid_handler, &snprint_mp_gid);
1870         install_keyword("reservation_key", &mp_reservation_key_handler, &snprint_mp_reservation_key);
1871         install_keyword("user_friendly_names", &mp_user_friendly_names_handler, &snprint_mp_user_friendly_names);
1872         install_keyword("deferred_remove", &mp_deferred_remove_handler, &snprint_mp_deferred_remove);
1873         install_keyword("delay_watch_checks", &mp_delay_watch_checks_handler, &snprint_mp_delay_watch_checks);
1874         install_keyword("delay_wait_checks", &mp_delay_wait_checks_handler, &snprint_mp_delay_wait_checks);
1875         install_keyword("san_path_err_threshold", &mp_san_path_err_threshold_handler, &snprint_mp_san_path_err_threshold);
1876         install_keyword("san_path_err_forget_rate", &mp_san_path_err_forget_rate_handler, &snprint_mp_san_path_err_forget_rate);
1877         install_keyword("san_path_err_recovery_time", &mp_san_path_err_recovery_time_handler, &snprint_mp_san_path_err_recovery_time);
1878         install_keyword("marginal_path_err_sample_time", &mp_marginal_path_err_sample_time_handler, &snprint_mp_marginal_path_err_sample_time);
1879         install_keyword("marginal_path_err_rate_threshold", &mp_marginal_path_err_rate_threshold_handler, &snprint_mp_marginal_path_err_rate_threshold);
1880         install_keyword("marginal_path_err_recheck_gap_time", &mp_marginal_path_err_recheck_gap_time_handler, &snprint_mp_marginal_path_err_recheck_gap_time);
1881         install_keyword("marginal_path_double_failed_time", &mp_marginal_path_double_failed_time_handler, &snprint_mp_marginal_path_double_failed_time);
1882         install_keyword("skip_kpartx", &mp_skip_kpartx_handler, &snprint_mp_skip_kpartx);
1883         install_keyword("max_sectors_kb", &mp_max_sectors_kb_handler, &snprint_mp_max_sectors_kb);
1884         install_keyword("ghost_delay", &mp_ghost_delay_handler, &snprint_mp_ghost_delay);
1885         install_sublevel_end();
1886 }