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