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