multipath: Make sure we store all the hwentry attributes.
[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 "errno.h"
23 #include <inttypes.h>
24
25 /*
26  * default block handlers
27  */
28 static int
29 polling_interval_handler(vector strvec)
30 {
31         char * buff;
32
33         buff = VECTOR_SLOT(strvec, 1);
34         conf->checkint = atoi(buff);
35         conf->max_checkint = MAX_CHECKINT(conf->checkint);
36
37         return 0;
38 }
39
40 static int
41 def_fast_io_fail_handler(vector strvec)
42 {
43         char * buff;
44
45         buff = set_value(strvec);
46         if (strlen(buff) == 3 && !strcmp(buff, "off"))
47                 conf->fast_io_fail = MP_FAST_IO_FAIL_OFF;
48         else if (sscanf(buff, "%d", &conf->fast_io_fail) != 1 ||
49                  conf->fast_io_fail < MP_FAST_IO_FAIL_ZERO)
50                 conf->fast_io_fail = 0;
51         else if (conf->fast_io_fail == 0)
52                 conf->fast_io_fail = MP_FAST_IO_FAIL_ZERO;
53
54         FREE(buff);
55         return 0;
56 }
57
58 static int
59 def_dev_loss_handler(vector strvec)
60 {
61         char * buff;
62
63         buff = set_value(strvec);
64         if (!buff)
65                 return 1;
66
67         if (strlen(buff) == 8 && !strcmp(buff, "infinity"))
68                 conf->dev_loss = MAX_DEV_LOSS_TMO;
69         else if (sscanf(buff, "%u", &conf->dev_loss) != 1)
70                 conf->dev_loss = 0;
71
72         FREE(buff);
73         return 0;
74 }
75
76 static int
77 verbosity_handler(vector strvec)
78 {
79         char * buff;
80
81         buff = VECTOR_SLOT(strvec, 1);
82         conf->verbosity = atoi(buff);
83
84         return 0;
85 }
86
87 static int
88 max_polling_interval_handler(vector strvec)
89 {
90         char *buff;
91
92         buff = VECTOR_SLOT(strvec, 1);
93         conf->max_checkint = atoi(buff);
94
95         return 0;
96 }
97
98 static int
99 reassign_maps_handler(vector strvec)
100 {
101         char * buff;
102
103         buff = set_value(strvec);
104         if (!strcmp(buff, "yes"))
105                 conf->reassign_maps = 1;
106         else if (!strcmp(buff, "no"))
107                 conf->reassign_maps = 0;
108         else
109                 return 1;
110
111         return 0;
112 }
113
114 static int
115 multipath_dir_handler(vector strvec)
116 {
117         conf->multipath_dir = set_value(strvec);
118
119         if (!conf->multipath_dir)
120                 return 1;
121
122         return 0;
123 }
124
125 static int
126 def_selector_handler(vector strvec)
127 {
128         conf->selector = set_value(strvec);
129
130         if (!conf->selector)
131                 return 1;
132
133         return 0;
134 }
135
136 static int
137 def_pgpolicy_handler(vector strvec)
138 {
139         char * buff;
140
141         buff = set_value(strvec);
142
143         if (!buff)
144                 return 1;
145
146         conf->pgpolicy = get_pgpolicy_id(buff);
147         FREE(buff);
148
149         return 0;
150 }
151
152 static int
153 def_uid_attribute_handler(vector strvec)
154 {
155         conf->uid_attribute = set_value(strvec);
156
157         if (!conf->uid_attribute)
158                 return 1;
159
160         return 0;
161 }
162
163 static int
164 def_prio_handler(vector strvec)
165 {
166         conf->prio_name = set_value(strvec);
167
168         if (!conf->prio_name)
169                 return 1;
170
171         return 0;
172 }
173
174 static int
175 def_alias_prefix_handler(vector strvec)
176 {
177         conf->alias_prefix = set_value(strvec);
178
179         if (!conf->alias_prefix)
180                 return 1;
181
182         return 0;
183 }
184
185 static int
186 def_prio_args_handler(vector strvec)
187 {
188         conf->prio_args = set_value(strvec);
189
190         if (!conf->prio_args)
191                 return 1;
192
193         return 0;
194 }
195
196 static int
197 def_features_handler(vector strvec)
198 {
199         conf->features = set_value(strvec);
200
201         if (!conf->features)
202                 return 1;
203
204         return 0;
205 }
206
207 static int
208 def_path_checker_handler(vector strvec)
209 {
210         conf->checker_name = set_value(strvec);
211
212         if (!conf->checker_name)
213                 return 1;
214
215         return 0;
216 }
217
218 static int
219 def_minio_handler(vector strvec)
220 {
221         char * buff;
222
223         buff = set_value(strvec);
224
225         if (!buff)
226                 return 1;
227
228         conf->minio = atoi(buff);
229         FREE(buff);
230
231         return 0;
232 }
233
234 static int
235 def_minio_rq_handler(vector strvec)
236 {
237         char * buff;
238
239         buff = set_value(strvec);
240
241         if (!buff)
242                 return 1;
243
244         conf->minio_rq = atoi(buff);
245         FREE(buff);
246
247         return 0;
248 }
249
250 int
251 get_sys_max_fds(int *max_fds)
252 {
253         FILE *file;
254         int nr_open;
255         int ret = 1;
256
257         file = fopen("/proc/sys/fs/nr_open", "r");
258         if (!file) {
259                 fprintf(stderr, "Cannot open /proc/sys/fs/nr_open : %s\n",
260                         strerror(errno));
261                 return 1;
262         }
263         if (fscanf(file, "%d", &nr_open) != 1) {
264                 fprintf(stderr, "Cannot read max open fds from /proc/sys/fs/nr_open");
265                 if (ferror(file))
266                         fprintf(stderr, " : %s\n", strerror(errno));
267                 else
268                         fprintf(stderr, "\n");
269         } else {
270                 *max_fds = nr_open;
271                 ret = 0;
272         }
273         fclose(file);
274         return ret;
275 }
276
277
278 static int
279 max_fds_handler(vector strvec)
280 {
281         char * buff;
282         int r = 0;
283
284         buff = set_value(strvec);
285
286         if (!buff)
287                 return 1;
288
289         if (strlen(buff) == 3 &&
290             !strcmp(buff, "max"))
291                 r = get_sys_max_fds(&conf->max_fds);
292         else
293                 conf->max_fds = atoi(buff);
294         FREE(buff);
295
296         return r;
297 }
298
299 static int
300 def_mode_handler(vector strvec)
301 {
302         mode_t mode;
303         char *buff;
304
305         buff = set_value(strvec);
306
307         if (!buff)
308                 return 1;
309
310         if (sscanf(buff, "%o", &mode) == 1 && mode <= 0777) {
311                 conf->attribute_flags |= (1 << ATTR_MODE);
312                 conf->mode = mode;
313         }
314
315         FREE(buff);
316         return 0;
317 }
318
319 static int
320 def_uid_handler(vector strvec)
321 {
322         uid_t uid;
323         char *buff;
324         char passwd_buf[1024];
325         struct passwd info, *found;
326
327         buff = set_value(strvec);
328         if (!buff)
329                 return 1;
330         if (getpwnam_r(buff, &info, passwd_buf, 1024, &found) == 0 && found) {
331                 conf->attribute_flags |= (1 << ATTR_UID);
332                 conf->uid = info.pw_uid;
333         }
334         else if (sscanf(buff, "%u", &uid) == 1){
335                 conf->attribute_flags |= (1 << ATTR_UID);
336                 conf->uid = uid;
337         }
338
339         FREE(buff);
340         return 0;
341 }
342
343 static int
344 def_gid_handler(vector strvec)
345 {
346         gid_t gid;
347         char *buff;
348         char passwd_buf[1024];
349         struct passwd info, *found;
350
351         buff = set_value(strvec);
352         if (!buff)
353                 return 1;
354
355         if (getpwnam_r(buff, &info, passwd_buf, 1024, &found) == 0 && found) {
356                 conf->attribute_flags |= (1 << ATTR_GID);
357                 conf->gid = info.pw_gid;
358         }
359         else if (sscanf(buff, "%u", &gid) == 1){
360                 conf->attribute_flags |= (1 << ATTR_GID);
361                 conf->gid = gid;
362         }
363         FREE(buff);
364         return 0;
365 }
366
367 static int
368 def_weight_handler(vector strvec)
369 {
370         char * buff;
371
372         buff = set_value(strvec);
373
374         if (!buff)
375                 return 1;
376
377         if (strlen(buff) == 10 &&
378             !strcmp(buff, "priorities"))
379                 conf->rr_weight = RR_WEIGHT_PRIO;
380
381         if (strlen(buff) == strlen("uniform") &&
382             !strcmp(buff, "uniform"))
383                 conf->rr_weight = RR_WEIGHT_NONE;
384
385         FREE(buff);
386
387         return 0;
388 }
389
390 static int
391 default_failback_handler(vector strvec)
392 {
393         char * buff;
394
395         buff = set_value(strvec);
396
397         if (strlen(buff) == 6 && !strcmp(buff, "manual"))
398                 conf->pgfailback = -FAILBACK_MANUAL;
399         else if (strlen(buff) == 9 && !strcmp(buff, "immediate"))
400                 conf->pgfailback = -FAILBACK_IMMEDIATE;
401         else
402                 conf->pgfailback = atoi(buff);
403
404         FREE(buff);
405
406         return 0;
407 }
408
409 static int
410 def_no_path_retry_handler(vector strvec)
411 {
412         char * buff;
413
414         buff = set_value(strvec);
415         if (!buff)
416                 return 1;
417
418         if ((strlen(buff) == 4 && !strcmp(buff, "fail")) ||
419             (strlen(buff) == 1 && !strcmp(buff, "0")))
420                 conf->no_path_retry = NO_PATH_RETRY_FAIL;
421         else if (strlen(buff) == 5 && !strcmp(buff, "queue"))
422                 conf->no_path_retry = NO_PATH_RETRY_QUEUE;
423         else if ((conf->no_path_retry = atoi(buff)) < 1)
424                 conf->no_path_retry = NO_PATH_RETRY_UNDEF;
425
426         FREE(buff);
427         return 0;
428 }
429
430 static int
431 def_queue_without_daemon(vector strvec)
432 {
433         char * buff;
434
435         buff = set_value(strvec);
436         if (!buff)
437                 return 1;
438
439         if (!strncmp(buff, "off", 3) || !strncmp(buff, "no", 2) ||
440             !strncmp(buff, "0", 1))
441                 conf->queue_without_daemon = QUE_NO_DAEMON_OFF;
442         else if (!strncmp(buff, "on", 2) || !strncmp(buff, "yes", 3) ||
443                  !strncmp(buff, "1", 1))
444                 conf->queue_without_daemon = QUE_NO_DAEMON_ON;
445         else
446                 conf->queue_without_daemon = QUE_NO_DAEMON_UNDEF;
447
448         free(buff);
449         return 0;
450 }
451
452 static int
453 def_checker_timeout_handler(vector strvec)
454 {
455         unsigned int checker_timeout;
456         char *buff;
457
458         buff = set_value(strvec);
459         if (!buff)
460                 return 1;
461
462         if (sscanf(buff, "%u", &checker_timeout) == 1)
463                 conf->checker_timeout = checker_timeout;
464         else
465                 conf->checker_timeout = 0;
466
467         free(buff);
468         return 0;
469 }
470
471 static int
472 def_pg_timeout_handler(vector strvec)
473 {
474         int pg_timeout;
475         char * buff;
476
477         buff = set_value(strvec);
478
479         if (!buff)
480                 return 1;
481
482         if (strlen(buff) == 4 && !strcmp(buff, "none"))
483                 conf->pg_timeout = -PGTIMEOUT_NONE;
484         else if (sscanf(buff, "%d", &pg_timeout) == 1 && pg_timeout >= 0) {
485                 if (pg_timeout == 0)
486                         conf->pg_timeout = -PGTIMEOUT_NONE;
487                 else
488                         conf->pg_timeout = pg_timeout;
489         }
490         else
491                 conf->pg_timeout = PGTIMEOUT_UNDEF;
492
493         FREE(buff);
494         return 0;
495 }
496
497 static int
498 def_flush_on_last_del_handler(vector strvec)
499 {
500         char * buff;
501
502         buff = set_value(strvec);
503         if (!buff)
504                 return 1;
505
506         if ((strlen(buff) == 2 && strcmp(buff, "no") == 0) ||
507             (strlen(buff) == 1 && strcmp(buff, "0") == 0))
508                 conf->flush_on_last_del = FLUSH_DISABLED;
509         if ((strlen(buff) == 3 && strcmp(buff, "yes") == 0) ||
510             (strlen(buff) == 1 && strcmp(buff, "1") == 0))
511                 conf->flush_on_last_del = FLUSH_ENABLED;
512         else
513                 conf->flush_on_last_del = FLUSH_UNDEF;
514
515         FREE(buff);
516         return 0;
517 }
518
519 static int
520 def_log_checker_err_handler(vector strvec)
521 {
522         char * buff;
523
524         buff = set_value(strvec);
525
526         if (!buff)
527                 return 1;
528
529         if (strlen(buff) == 4 && !strcmp(buff, "once"))
530                 conf->log_checker_err = LOG_CHKR_ERR_ONCE;
531         else if (strlen(buff) == 6 && !strcmp(buff, "always"))
532                 conf->log_checker_err = LOG_CHKR_ERR_ALWAYS;
533
534         free(buff);
535         return 0;
536 }
537
538 static int
539 def_reservation_key_handler(vector strvec)
540 {
541         char *buff;
542         char *tbuff;
543         int j, k;
544         int len;
545         uint64_t prkey;
546
547         buff = set_value(strvec);
548         if (!buff)
549                 return 1;
550
551         tbuff = buff;
552
553         if (!memcmp("0x",buff, 2))
554                 buff = buff + 2;
555
556         len = strlen(buff);
557
558         k = strspn(buff, "0123456789aAbBcCdDeEfF");
559
560         if (len != k) {
561                 FREE(tbuff);
562                 return 1;
563         }
564
565         if (1 != sscanf (buff, "%" SCNx64 "", &prkey))
566         {
567                 FREE(tbuff);
568                 return 1;
569         }
570
571         if (!conf->reservation_key)
572                 conf->reservation_key = (unsigned char *) malloc(8);
573
574         memset(conf->reservation_key, 0, 8);
575
576         for (j = 7; j >= 0; --j) {
577                 conf->reservation_key[j] = (prkey & 0xff);
578                 prkey >>= 8;
579         }
580
581         FREE(tbuff);
582         return 0;
583 }
584
585 static int
586 names_handler(vector strvec)
587 {
588         char * buff;
589
590         buff = set_value(strvec);
591
592         if (!buff)
593                 return 1;
594
595         if ((strlen(buff) == 2 && !strcmp(buff, "no")) ||
596             (strlen(buff) == 1 && !strcmp(buff, "0")))
597                 conf->user_friendly_names = 0;
598         else if ((strlen(buff) == 3 && !strcmp(buff, "yes")) ||
599                  (strlen(buff) == 1 && !strcmp(buff, "1")))
600                 conf->user_friendly_names = 1;
601
602         FREE(buff);
603         return 0;
604 }
605
606 static int
607 bindings_file_handler(vector strvec)
608 {
609         conf->bindings_file = set_value(strvec);
610
611         if (!conf->bindings_file)
612                 return 1;
613
614         return 0;
615 }
616
617 /*
618  * blacklist block handlers
619  */
620 static int
621 blacklist_handler(vector strvec)
622 {
623         conf->blist_devnode = vector_alloc();
624         conf->blist_wwid = vector_alloc();
625         conf->blist_device = vector_alloc();
626
627         if (!conf->blist_devnode || !conf->blist_wwid || !conf->blist_device)
628                 return 1;
629
630         return 0;
631 }
632
633 static int
634 blacklist_exceptions_handler(vector strvec)
635 {
636         conf->elist_devnode = vector_alloc();
637         conf->elist_wwid = vector_alloc();
638         conf->elist_device = vector_alloc();
639
640         if (!conf->elist_devnode || !conf->elist_wwid || !conf->elist_device)
641                 return 1;
642
643         return 0;
644 }
645
646 static int
647 ble_devnode_handler(vector strvec)
648 {
649         char * buff;
650
651         buff = set_value(strvec);
652
653         if (!buff)
654                 return 1;
655
656         return store_ble(conf->blist_devnode, buff, ORIGIN_CONFIG);
657 }
658
659 static int
660 ble_except_devnode_handler(vector strvec)
661 {
662         char * buff;
663
664         buff = set_value(strvec);
665
666         if (!buff)
667                 return 1;
668
669         return store_ble(conf->elist_devnode, buff, ORIGIN_CONFIG);
670 }
671
672 static int
673 ble_wwid_handler(vector strvec)
674 {
675         char * buff;
676
677         buff = set_value(strvec);
678
679         if (!buff)
680                 return 1;
681
682         return store_ble(conf->blist_wwid, buff, ORIGIN_CONFIG);
683 }
684
685 static int
686 ble_except_wwid_handler(vector strvec)
687 {
688         char * buff;
689
690         buff = set_value(strvec);
691
692         if (!buff)
693                 return 1;
694
695         return store_ble(conf->elist_wwid, buff, ORIGIN_CONFIG);
696 }
697
698 static int
699 ble_device_handler(vector strvec)
700 {
701         return alloc_ble_device(conf->blist_device);
702 }
703
704 static int
705 ble_except_device_handler(vector strvec)
706 {
707         return alloc_ble_device(conf->elist_device);
708 }
709
710 static int
711 ble_vendor_handler(vector strvec)
712 {
713         char * buff;
714
715         buff = set_value(strvec);
716
717         if (!buff)
718                 return 1;
719
720         return set_ble_device(conf->blist_device, buff, NULL, ORIGIN_CONFIG);
721 }
722
723 static int
724 ble_except_vendor_handler(vector strvec)
725 {
726         char * buff;
727
728         buff = set_value(strvec);
729
730         if (!buff)
731                 return 1;
732
733         return set_ble_device(conf->elist_device, buff, NULL, ORIGIN_CONFIG);
734 }
735
736 static int
737 ble_product_handler(vector strvec)
738 {
739         char * buff;
740
741         buff = set_value(strvec);
742
743         if (!buff)
744                 return 1;
745
746         return set_ble_device(conf->blist_device, NULL, buff, ORIGIN_CONFIG);
747 }
748
749 static int
750 ble_except_product_handler(vector strvec)
751 {
752         char * buff;
753
754         buff = set_value(strvec);
755
756         if (!buff)
757                 return 1;
758
759         return set_ble_device(conf->elist_device, NULL, buff, ORIGIN_CONFIG);
760 }
761
762 /*
763  * devices block handlers
764  */
765 static int
766 devices_handler(vector strvec)
767 {
768         if (!conf->hwtable)
769                 conf->hwtable = vector_alloc();
770
771         if (!conf->hwtable)
772                 return 1;
773
774         return 0;
775 }
776
777 static int
778 device_handler(vector strvec)
779 {
780         struct hwentry * hwe;
781
782         hwe = alloc_hwe();
783
784         if (!hwe)
785                 return 1;
786
787         if (!vector_alloc_slot(conf->hwtable)) {
788                 free_hwe(hwe);
789                 return 1;
790         }
791         vector_set_slot(conf->hwtable, hwe);
792
793         return 0;
794 }
795
796 static int
797 vendor_handler(vector strvec)
798 {
799         struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
800
801         if (!hwe)
802                 return 1;
803
804         hwe->vendor = set_value(strvec);
805
806         if (!hwe->vendor)
807                 return 1;
808
809         return 0;
810 }
811
812 static int
813 product_handler(vector strvec)
814 {
815         struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
816
817         if (!hwe)
818                 return 1;
819
820         hwe->product = set_value(strvec);
821
822         if (!hwe->product)
823                 return 1;
824
825         return 0;
826 }
827
828 static int
829 revision_handler(vector strvec)
830 {
831         struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
832
833         if (!hwe)
834                 return 1;
835
836         hwe->revision = set_value(strvec);
837
838         if (!hwe->revision)
839                 return 1;
840
841         return 0;
842 }
843
844 static int
845 bl_product_handler(vector strvec)
846 {
847         struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
848
849         if (!hwe)
850                 return 1;
851
852         hwe->bl_product = set_value(strvec);
853         if (!hwe->bl_product)
854                 return 1;
855
856         return 0;
857 }
858
859 static int
860 hw_fast_io_fail_handler(vector strvec)
861 {
862         char * buff;
863         struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
864
865         buff = set_value(strvec);
866         if (strlen(buff) == 3 && !strcmp(buff, "off"))
867                 hwe->fast_io_fail = MP_FAST_IO_FAIL_OFF;
868         else if (sscanf(buff, "%d", &hwe->fast_io_fail) != 1 ||
869                  hwe->fast_io_fail < MP_FAST_IO_FAIL_ZERO)
870                 hwe->fast_io_fail = 0;
871         else if (hwe->fast_io_fail == 0)
872                 hwe->fast_io_fail = MP_FAST_IO_FAIL_ZERO;
873
874         FREE(buff);
875         return 0;
876 }
877
878 static int
879 hw_dev_loss_handler(vector strvec)
880 {
881         char * buff;
882         struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
883
884         buff = set_value(strvec);
885         if (!buff)
886                 return 1;
887
888         if (strlen(buff) == 8 && !strcmp(buff, "infinity"))
889                 hwe->dev_loss = MAX_DEV_LOSS_TMO;
890         else if (sscanf(buff, "%u", &hwe->dev_loss) != 1)
891                 hwe->dev_loss = 0;
892
893         FREE(buff);
894         return 0;
895 }
896
897 static int
898 hw_pgpolicy_handler(vector strvec)
899 {
900         char * buff;
901         struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
902
903         buff = set_value(strvec);
904
905         if (!buff)
906                 return 1;
907
908         hwe->pgpolicy = get_pgpolicy_id(buff);
909         FREE(buff);
910
911         return 0;
912 }
913
914 static int
915 hw_uid_attribute_handler(vector strvec)
916 {
917         struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
918
919         hwe->uid_attribute = set_value(strvec);
920
921         if (!hwe->uid_attribute)
922                 return 1;
923
924         return 0;
925 }
926
927 static int
928 hw_selector_handler(vector strvec)
929 {
930         struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
931
932         if (!hwe)
933                 return 1;
934
935         hwe->selector = set_value(strvec);
936
937         if (!hwe->selector)
938                 return 1;
939
940         return 0;
941 }
942
943 static int
944 hw_path_checker_handler(vector strvec)
945 {
946         struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
947
948         if (!hwe)
949                 return 1;
950
951         hwe->checker_name = set_value(strvec);
952
953         if (!hwe->checker_name)
954                 return 1;
955
956         return 0;
957 }
958
959 static int
960 hw_features_handler(vector strvec)
961 {
962         struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
963
964         if (!hwe)
965                 return 1;
966
967         hwe->features = set_value(strvec);
968
969         if (!hwe->features)
970                 return 1;
971
972         return 0;
973 }
974
975 static int
976 hw_handler_handler(vector strvec)
977 {
978         struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
979
980         if (!hwe)
981                 return 1;
982
983         hwe->hwhandler = set_value(strvec);
984
985         if (!hwe->hwhandler)
986                 return 1;
987
988         return 0;
989 }
990
991 static int
992 hw_prio_handler(vector strvec)
993 {
994         struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
995
996         if (!hwe)
997                 return 1;
998
999         hwe->prio_name = set_value(strvec);
1000
1001         if (!hwe->prio_name)
1002                 return 1;
1003
1004         return 0;
1005 }
1006
1007 static int
1008 hw_alias_prefix_handler(vector strvec)
1009 {
1010         struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
1011
1012         if (!hwe)
1013                 return 1;
1014
1015         hwe->alias_prefix = set_value(strvec);
1016
1017         if (!hwe->alias_prefix)
1018                 return 1;
1019
1020         return 0;
1021 }
1022
1023 static int
1024 hw_prio_args_handler(vector strvec)
1025 {
1026         struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
1027
1028         if (!hwe)
1029                 return 1;
1030
1031         hwe->prio_args = set_value(strvec);
1032
1033         if (!hwe->prio_args)
1034                 return 1;
1035
1036         return 0;
1037 }
1038
1039 static int
1040 hw_failback_handler(vector strvec)
1041 {
1042         struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
1043         char * buff;
1044
1045         if (!hwe)
1046                 return 1;
1047
1048         buff = set_value(strvec);
1049
1050         if (strlen(buff) == 6 && !strcmp(buff, "manual"))
1051                 hwe->pgfailback = -FAILBACK_MANUAL;
1052         else if (strlen(buff) == 9 && !strcmp(buff, "immediate"))
1053                 hwe->pgfailback = -FAILBACK_IMMEDIATE;
1054         else
1055                 hwe->pgfailback = atoi(buff);
1056
1057         FREE(buff);
1058
1059         return 0;
1060 }
1061
1062 static int
1063 hw_weight_handler(vector strvec)
1064 {
1065         struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
1066         char * buff;
1067
1068         if (!hwe)
1069                 return 1;
1070
1071         buff = set_value(strvec);
1072
1073         if (!buff)
1074                 return 1;
1075
1076         if (strlen(buff) == 10 &&
1077             !strcmp(buff, "priorities"))
1078                 hwe->rr_weight = RR_WEIGHT_PRIO;
1079
1080         if (strlen(buff) == strlen("uniform") &&
1081             !strcmp(buff, "uniform"))
1082                 hwe->rr_weight = RR_WEIGHT_NONE;
1083
1084         FREE(buff);
1085
1086         return 0;
1087 }
1088
1089 static int
1090 hw_no_path_retry_handler(vector strvec)
1091 {
1092         struct hwentry *hwe = VECTOR_LAST_SLOT(conf->hwtable);
1093         char *buff;
1094
1095         if (!hwe)
1096                 return 1;
1097
1098         buff = set_value(strvec);
1099         if (!buff)
1100                 return 1;
1101
1102         if ((strlen(buff) == 4 && !strcmp(buff, "fail")) ||
1103             (strlen(buff) == 1 && !strcmp(buff, "0")))
1104                 hwe->no_path_retry = NO_PATH_RETRY_FAIL;
1105         else if (strlen(buff) == 5 && !strcmp(buff, "queue"))
1106                 hwe->no_path_retry = NO_PATH_RETRY_QUEUE;
1107         else if ((hwe->no_path_retry = atoi(buff)) < 1)
1108                 hwe->no_path_retry = NO_PATH_RETRY_UNDEF;
1109
1110         FREE(buff);
1111         return 0;
1112 }
1113
1114 static int
1115 hw_minio_handler(vector strvec)
1116 {
1117         struct hwentry *hwe = VECTOR_LAST_SLOT(conf->hwtable);
1118         char * buff;
1119
1120         if (!hwe)
1121                 return 1;
1122
1123         buff = set_value(strvec);
1124
1125         if (!buff)
1126                 return 1;
1127
1128         hwe->minio = atoi(buff);
1129         FREE(buff);
1130
1131         return 0;
1132 }
1133
1134 static int
1135 hw_minio_rq_handler(vector strvec)
1136 {
1137         struct hwentry *hwe = VECTOR_LAST_SLOT(conf->hwtable);
1138         char * buff;
1139
1140         if (!hwe)
1141                 return 1;
1142
1143         buff = set_value(strvec);
1144
1145         if (!buff)
1146                 return 1;
1147
1148         hwe->minio_rq = atoi(buff);
1149         FREE(buff);
1150
1151         return 0;
1152 }
1153
1154 static int
1155 hw_pg_timeout_handler(vector strvec)
1156 {
1157         int pg_timeout;
1158         struct hwentry *hwe = VECTOR_LAST_SLOT(conf->hwtable);
1159         char *buff;
1160
1161         if (!hwe)
1162                 return 1;
1163
1164         buff = set_value(strvec);
1165
1166         if (!buff)
1167                 return 1;
1168
1169         if (strlen(buff) == 4 && !strcmp(buff, "none"))
1170                 hwe->pg_timeout = -PGTIMEOUT_NONE;
1171         else if (sscanf(buff, "%d", &pg_timeout) == 1 && pg_timeout >= 0) {
1172                 if (pg_timeout == 0)
1173                         hwe->pg_timeout = -PGTIMEOUT_NONE;
1174                 else
1175                         hwe->pg_timeout = pg_timeout;
1176         }
1177         else
1178                 hwe->pg_timeout = PGTIMEOUT_UNDEF;
1179
1180         FREE(buff);
1181         return 0;
1182 }
1183
1184 static int
1185 hw_flush_on_last_del_handler(vector strvec)
1186 {
1187         struct hwentry *hwe = VECTOR_LAST_SLOT(conf->hwtable);
1188         char * buff;
1189
1190         if (!hwe)
1191                 return 1;
1192
1193         buff = set_value(strvec);
1194         if (!buff)
1195                 return 1;
1196
1197         if ((strlen(buff) == 2 && strcmp(buff, "no") == 0) ||
1198             (strlen(buff) == 1 && strcmp(buff, "0") == 0))
1199                 hwe->flush_on_last_del = FLUSH_DISABLED;
1200         if ((strlen(buff) == 3 && strcmp(buff, "yes") == 0) ||
1201             (strlen(buff) == 1 && strcmp(buff, "1") == 0))
1202                 hwe->flush_on_last_del = FLUSH_ENABLED;
1203         else
1204                 hwe->flush_on_last_del = FLUSH_UNDEF;
1205
1206         FREE(buff);
1207         return 0;
1208 }
1209
1210 /*
1211  * multipaths block handlers
1212  */
1213 static int
1214 multipaths_handler(vector strvec)
1215 {
1216         conf->mptable = vector_alloc();
1217
1218         if (!conf->mptable)
1219                 return 1;
1220
1221         return 0;
1222 }
1223
1224 static int
1225 multipath_handler(vector strvec)
1226 {
1227         struct mpentry * mpe;
1228
1229         mpe = alloc_mpe();
1230
1231         if (!mpe)
1232                 return 1;
1233
1234         if (!vector_alloc_slot(conf->mptable)) {
1235                 free_mpe(mpe);
1236                 return 1;
1237         }
1238         vector_set_slot(conf->mptable, mpe);
1239
1240         return 0;
1241 }
1242
1243 static int
1244 wwid_handler(vector strvec)
1245 {
1246         struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable);
1247
1248         if (!mpe)
1249                 return 1;
1250
1251         mpe->wwid = set_value(strvec);
1252
1253         if (!mpe->wwid)
1254                 return 1;
1255
1256         return 0;
1257 }
1258
1259 static int
1260 alias_handler(vector strvec)
1261 {
1262         struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable);
1263
1264         if (!mpe)
1265                 return 1;
1266
1267         mpe->alias = set_value(strvec);
1268
1269         if (!mpe->alias)
1270                 return 1;
1271
1272         return 0;
1273 }
1274
1275 static int
1276 mp_pgpolicy_handler(vector strvec)
1277 {
1278         char * buff;
1279         struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable);
1280
1281         if (!mpe)
1282                 return 1;
1283
1284         buff = set_value(strvec);
1285
1286         if (!buff)
1287                 return 1;
1288
1289         mpe->pgpolicy = get_pgpolicy_id(buff);
1290         FREE(buff);
1291
1292         return 0;
1293 }
1294
1295 static int
1296 mp_selector_handler(vector strvec)
1297 {
1298         struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable);
1299
1300         if (!mpe)
1301                 return 1;
1302
1303         mpe->selector = set_value(strvec);
1304
1305         if (!mpe->selector)
1306                 return 1;
1307
1308         return 0;
1309 }
1310
1311 static int
1312 mp_failback_handler(vector strvec)
1313 {
1314         struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable);
1315         char * buff;
1316
1317         if (!mpe)
1318                 return 1;
1319
1320         buff = set_value(strvec);
1321
1322         if (strlen(buff) == 6 && !strcmp(buff, "manual"))
1323                 mpe->pgfailback = -FAILBACK_MANUAL;
1324         else if (strlen(buff) == 9 && !strcmp(buff, "immediate"))
1325                 mpe->pgfailback = -FAILBACK_IMMEDIATE;
1326         else
1327                 mpe->pgfailback = atoi(buff);
1328
1329         FREE(buff);
1330
1331         return 0;
1332 }
1333
1334 static int
1335 mp_mode_handler(vector strvec)
1336 {
1337         mode_t mode;
1338         struct mpentry *mpe = VECTOR_LAST_SLOT(conf->mptable);
1339         char *buff;
1340
1341         if (!mpe)
1342                 return 1;
1343
1344         buff = set_value(strvec);
1345         if (!buff)
1346                 return 1;
1347         if (sscanf(buff, "%o", &mode) == 1 && mode <= 0777) {
1348                 mpe->attribute_flags |= (1 << ATTR_MODE);
1349                 mpe->mode = mode;
1350         }
1351
1352         FREE(buff);
1353         return 0;
1354 }
1355
1356 static int
1357 mp_uid_handler(vector strvec)
1358 {
1359         uid_t uid;
1360         char *buff;
1361         char passwd_buf[1024];
1362         struct passwd info, *found;
1363
1364         struct mpentry *mpe = VECTOR_LAST_SLOT(conf->mptable);
1365
1366         if (!mpe)
1367                 return 1;
1368
1369         buff = set_value(strvec);
1370         if (!buff)
1371                 return 1;
1372
1373         if (getpwnam_r(buff, &info, passwd_buf, 1024, &found) == 0 && found) {
1374                 mpe->attribute_flags |= (1 << ATTR_UID);
1375                 mpe->uid = info.pw_uid;
1376         }
1377         else if (sscanf(buff, "%u", &uid) == 1){
1378                 mpe->attribute_flags |= (1 << ATTR_UID);
1379                 mpe->uid = uid;
1380         }
1381         FREE(buff);
1382         return 0;
1383 }
1384
1385 static int
1386 mp_gid_handler(vector strvec)
1387 {
1388         gid_t gid;
1389         char *buff;
1390         char passwd_buf[1024];
1391         struct passwd info, *found;
1392
1393         struct mpentry *mpe = VECTOR_LAST_SLOT(conf->mptable);
1394
1395         if (!mpe)
1396                 return 1;
1397
1398         buff = set_value(strvec);
1399         if (!buff)
1400                 return 1;
1401
1402         if (getpwnam_r(buff, &info, passwd_buf, 1024, &found) == 0 && found) {
1403                 mpe->attribute_flags |= (1 << ATTR_GID);
1404                 mpe->gid = info.pw_gid;
1405         }
1406         else if (sscanf(buff, "%u", &gid) == 1) {
1407                 mpe->attribute_flags |= (1 << ATTR_GID);
1408                 mpe->gid = gid;
1409         }
1410         FREE(buff);
1411         return 0;
1412 }
1413
1414 static int
1415 mp_weight_handler(vector strvec)
1416 {
1417         struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable);
1418         char * buff;
1419
1420         if (!mpe)
1421                 return 1;
1422
1423         buff = set_value(strvec);
1424
1425         if (!buff)
1426                 return 1;
1427
1428         if (strlen(buff) == 10 &&
1429             !strcmp(buff, "priorities"))
1430                 mpe->rr_weight = RR_WEIGHT_PRIO;
1431
1432         if (strlen(buff) == strlen("uniform") &&
1433             !strcmp(buff, "uniform"))
1434                 mpe->rr_weight = RR_WEIGHT_NONE;
1435
1436         FREE(buff);
1437
1438         return 0;
1439 }
1440
1441 static int
1442 mp_no_path_retry_handler(vector strvec)
1443 {
1444         struct mpentry *mpe = VECTOR_LAST_SLOT(conf->mptable);
1445         char *buff;
1446
1447         if (!mpe)
1448                 return 1;
1449
1450         buff = set_value(strvec);
1451         if (!buff)
1452                 return 1;
1453
1454         if ((strlen(buff) == 4 && !strcmp(buff, "fail")) ||
1455             (strlen(buff) == 1 && !strcmp(buff, "0")))
1456                 mpe->no_path_retry = NO_PATH_RETRY_FAIL;
1457         else if (strlen(buff) == 5 && !strcmp(buff, "queue"))
1458                 mpe->no_path_retry = NO_PATH_RETRY_QUEUE;
1459         else if ((mpe->no_path_retry = atoi(buff)) < 1)
1460                 mpe->no_path_retry = NO_PATH_RETRY_UNDEF;
1461
1462         FREE(buff);
1463         return 0;
1464 }
1465
1466 static int
1467 mp_minio_handler(vector strvec)
1468 {
1469         struct mpentry *mpe = VECTOR_LAST_SLOT(conf->mptable);
1470         char * buff;
1471
1472         if (!mpe)
1473                 return 1;
1474
1475         buff = set_value(strvec);
1476
1477         if (!buff)
1478                 return 1;
1479
1480         mpe->minio = atoi(buff);
1481         FREE(buff);
1482
1483         return 0;
1484 }
1485
1486 static int
1487 mp_minio_rq_handler(vector strvec)
1488 {
1489         struct mpentry *mpe = VECTOR_LAST_SLOT(conf->mptable);
1490         char * buff;
1491
1492         if (!mpe)
1493                 return 1;
1494
1495         buff = set_value(strvec);
1496
1497         if (!buff)
1498                 return 1;
1499
1500         mpe->minio_rq = atoi(buff);
1501         FREE(buff);
1502
1503         return 0;
1504 }
1505
1506 static int
1507 mp_pg_timeout_handler(vector strvec)
1508 {
1509         int pg_timeout;
1510         struct mpentry *mpe = VECTOR_LAST_SLOT(conf->mptable);
1511         char *buff;
1512
1513         if (!mpe)
1514                 return 1;
1515
1516         buff = set_value(strvec);
1517
1518         if (!buff)
1519                 return 1;
1520         if (strlen(buff) == 4 && !strcmp(buff, "none"))
1521                 mpe->pg_timeout = -PGTIMEOUT_NONE;
1522         else if (sscanf(buff, "%d", &pg_timeout) == 1 && pg_timeout >= 0) {
1523                 if (pg_timeout == 0)
1524                         mpe->pg_timeout = -PGTIMEOUT_NONE;
1525                 else
1526                         mpe->pg_timeout = pg_timeout;
1527         }
1528         else
1529                 mpe->pg_timeout = PGTIMEOUT_UNDEF;
1530
1531         FREE(buff);
1532         return 0;
1533 }
1534
1535 static int
1536 mp_features_handler(vector strvec)
1537 {
1538         struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable);
1539
1540         if (!mpe)
1541                 return 1;
1542
1543         mpe->features = set_value(strvec);
1544
1545         if (!mpe->features)
1546                 return 1;
1547
1548         return 0;
1549 }
1550
1551 static int
1552 mp_flush_on_last_del_handler(vector strvec)
1553 {
1554         struct mpentry *mpe = VECTOR_LAST_SLOT(conf->mptable);
1555         char * buff;
1556
1557         if (!mpe)
1558                 return 1;
1559
1560         buff = set_value(strvec);
1561         if (!buff)
1562                 return 1;
1563
1564         if ((strlen(buff) == 2 && strcmp(buff, "no") == 0) ||
1565             (strlen(buff) == 1 && strcmp(buff, "0") == 0))
1566                 mpe->flush_on_last_del = FLUSH_DISABLED;
1567         if ((strlen(buff) == 3 && strcmp(buff, "yes") == 0) ||
1568             (strlen(buff) == 1 && strcmp(buff, "1") == 0))
1569                 mpe->flush_on_last_del = FLUSH_ENABLED;
1570         else
1571                 mpe->flush_on_last_del = FLUSH_UNDEF;
1572
1573         FREE(buff);
1574         return 0;
1575 }
1576
1577 static int
1578 mp_prio_handler(vector strvec)
1579 {
1580         struct mpentry * mpe = VECTOR_LAST_SLOT(conf->hwtable);
1581
1582         if (!mpe)
1583                 return 1;
1584
1585         mpe->prio_name = set_value(strvec);
1586
1587         if (!mpe->prio_name)
1588                 return 1;
1589
1590         return 0;
1591 }
1592
1593 static int
1594 mp_prio_args_handler (vector strvec)
1595 {
1596         struct mpentry *mpe = VECTOR_LAST_SLOT(conf->mptable);
1597
1598         if (!mpe)
1599                 return 1;
1600
1601         mpe->prio_args = set_value(strvec);
1602         if (!mpe->prio_args)
1603                 return 1;
1604
1605         return 0;
1606 }
1607
1608 static int
1609 mp_reservation_key_handler (vector strvec)
1610 {
1611         char *buff;
1612         char *tbuff;
1613         struct mpentry *mpe = VECTOR_LAST_SLOT(conf->mptable);
1614
1615         int j, k, len;
1616         uint64_t prkey;
1617
1618         if (!mpe)
1619                 return 1;
1620
1621         buff = set_value(strvec);
1622         if (!buff)
1623                 return 1;
1624
1625         tbuff = buff;
1626         if (!memcmp(buff, "0x", 2))
1627                 buff = buff + 2;
1628
1629         len = strlen(buff);
1630
1631         k = strspn(buff, "0123456789aAbBcCdDeEfF");
1632         if (len != k) {
1633                 FREE(tbuff);
1634                 return 1;
1635         }
1636
1637         if (1 != sscanf (buff, "%" SCNx64 "", &prkey))
1638         {
1639                 FREE(tbuff);
1640                 return 1;
1641         }
1642
1643         if (!mpe->reservation_key)
1644                 mpe->reservation_key = (unsigned char *) malloc(8);
1645
1646         memset(mpe->reservation_key, 0, 8);
1647
1648         for (j = 7; j >= 0; --j) {
1649                 mpe->reservation_key[j] = (prkey & 0xff);
1650                 prkey >>= 8;
1651         }
1652
1653         FREE(tbuff);
1654         return 0;
1655 }
1656
1657
1658 /*
1659  * config file keywords printing
1660  */
1661 static int
1662 snprint_mp_wwid (char * buff, int len, void * data)
1663 {
1664         struct mpentry * mpe = (struct mpentry *)data;
1665
1666         return snprintf(buff, len, "%s", mpe->wwid);
1667 }
1668
1669 static int
1670 snprint_mp_alias (char * buff, int len, void * data)
1671 {
1672         struct mpentry * mpe = (struct mpentry *)data;
1673
1674         if (!mpe->alias)
1675                 return 0;
1676
1677         return snprintf(buff, len, "%s", mpe->alias);
1678 }
1679
1680 static int
1681 snprint_mp_path_grouping_policy (char * buff, int len, void * data)
1682 {
1683         struct mpentry * mpe = (struct mpentry *)data;
1684         char str[POLICY_NAME_SIZE];
1685
1686         if (!mpe->pgpolicy)
1687                 return 0;
1688         get_pgpolicy_name(str, POLICY_NAME_SIZE, mpe->pgpolicy);
1689
1690         return snprintf(buff, len, "%s", str);
1691 }
1692
1693 static int
1694 snprint_mp_selector (char * buff, int len, void * data)
1695 {
1696         struct mpentry * mpe = (struct mpentry *)data;
1697
1698         if (!mpe->selector)
1699                 return 0;
1700
1701         return snprintf(buff, len, "\"%s\"", mpe->selector);
1702 }
1703
1704 static int
1705 snprint_mp_failback (char * buff, int len, void * data)
1706 {
1707         struct mpentry * mpe = (struct mpentry *)data;
1708
1709         if (!mpe->pgfailback)
1710                 return 0;
1711
1712         switch(mpe->pgfailback) {
1713         case  FAILBACK_UNDEF:
1714                 break;
1715         case -FAILBACK_MANUAL:
1716                 return snprintf(buff, len, "manual");
1717         case -FAILBACK_IMMEDIATE:
1718                 return snprintf(buff, len, "immediate");
1719         default:
1720                 return snprintf(buff, len, "%i", mpe->pgfailback);
1721         }
1722         return 0;
1723 }
1724
1725 static int
1726 snprint_mp_mode(char * buff, int len, void * data)
1727 {
1728         struct mpentry * mpe = (struct mpentry *)data;
1729
1730         if ((mpe->attribute_flags & (1 << ATTR_MODE)) == 0)
1731                 return 0;
1732         return snprintf(buff, len, "0%o", mpe->mode);
1733 }
1734
1735 static int
1736 snprint_mp_uid(char * buff, int len, void * data)
1737 {
1738         struct mpentry * mpe = (struct mpentry *)data;
1739
1740         if ((mpe->attribute_flags & (1 << ATTR_UID)) == 0)
1741                 return 0;
1742         return snprintf(buff, len, "0%o", mpe->uid);
1743 }
1744
1745 static int
1746 snprint_mp_gid(char * buff, int len, void * data)
1747 {
1748         struct mpentry * mpe = (struct mpentry *)data;
1749
1750         if ((mpe->attribute_flags & (1 << ATTR_GID)) == 0)
1751                 return 0;
1752         return snprintf(buff, len, "0%o", mpe->gid);
1753 }
1754
1755 static int
1756 snprint_mp_rr_weight (char * buff, int len, void * data)
1757 {
1758         struct mpentry * mpe = (struct mpentry *)data;
1759
1760         if (!mpe->rr_weight)
1761                 return 0;
1762         if (mpe->rr_weight == RR_WEIGHT_PRIO)
1763                 return snprintf(buff, len, "priorities");
1764         if (mpe->rr_weight == RR_WEIGHT_NONE)
1765                 return snprintf(buff, len, "uniform");
1766
1767         return 0;
1768 }
1769
1770 static int
1771 snprint_mp_no_path_retry (char * buff, int len, void * data)
1772 {
1773         struct mpentry * mpe = (struct mpentry *)data;
1774
1775         if (!mpe->no_path_retry)
1776                 return 0;
1777
1778         switch(mpe->no_path_retry) {
1779         case NO_PATH_RETRY_UNDEF:
1780                 break;
1781         case NO_PATH_RETRY_FAIL:
1782                 return snprintf(buff, len, "fail");
1783         case NO_PATH_RETRY_QUEUE:
1784                 return snprintf(buff, len, "queue");
1785         default:
1786                 return snprintf(buff, len, "%i",
1787                                 mpe->no_path_retry);
1788         }
1789         return 0;
1790 }
1791
1792 static int
1793 snprint_mp_rr_min_io (char * buff, int len, void * data)
1794 {
1795         struct mpentry * mpe = (struct mpentry *)data;
1796
1797         if (!mpe->minio)
1798                 return 0;
1799
1800         return snprintf(buff, len, "%u", mpe->minio);
1801 }
1802
1803 static int
1804 snprint_mp_rr_min_io_rq (char * buff, int len, void * data)
1805 {
1806         struct mpentry * mpe = (struct mpentry *)data;
1807
1808         if (!mpe->minio_rq)
1809                 return 0;
1810
1811         return snprintf(buff, len, "%u", mpe->minio_rq);
1812 }
1813
1814 static int
1815 snprint_mp_pg_timeout (char * buff, int len, void * data)
1816 {
1817         struct mpentry * mpe = (struct mpentry *)data;
1818
1819         switch (mpe->pg_timeout) {
1820         case PGTIMEOUT_UNDEF:
1821                 break;
1822         case -PGTIMEOUT_NONE:
1823                 return snprintf(buff, len, "none");
1824         default:
1825                 return snprintf(buff, len, "%i", mpe->pg_timeout);
1826         }
1827         return 0;
1828 }
1829
1830 static int
1831 snprint_mp_features (char * buff, int len, void * data)
1832 {
1833         struct mpentry * mpe = (struct mpentry *)data;
1834
1835         if (!mpe->features)
1836                 return 0;
1837         if (strlen(mpe->features) == strlen(conf->features) &&
1838             !strcmp(mpe->features, conf->features))
1839                 return 0;
1840
1841         return snprintf(buff, len, "%s", mpe->features);
1842 }
1843
1844 static int
1845 snprint_mp_flush_on_last_del (char * buff, int len, void * data)
1846 {
1847         struct mpentry * mpe = (struct mpentry *)data;
1848
1849         switch (mpe->flush_on_last_del) {
1850         case FLUSH_DISABLED:
1851                 return snprintf(buff, len, "no");
1852         case FLUSH_ENABLED:
1853                 return snprintf(buff, len, "yes");
1854         }
1855         return 0;
1856 }
1857
1858 static int
1859 snprint_mp_prio(char * buff, int len, void * data)
1860 {
1861         struct mpentry * mpe = (struct mpentry *)data;
1862
1863         if (!mpe->prio_name)
1864                 return 0;
1865
1866         return snprintf(buff, len, "%s", mpe->prio_name);
1867 }
1868
1869 static int
1870 snprint_mp_prio_args(char * buff, int len, void * data)
1871 {
1872         struct mpentry * mpe = (struct mpentry *)data;
1873
1874         if (!mpe->prio_args)
1875                 return 0;
1876
1877         return snprintf(buff, len, "%s", mpe->prio_args);
1878 }
1879
1880 static int
1881 snprint_mp_reservation_key (char * buff, int len, void * data)
1882 {
1883         struct mpentry * mpe = (struct mpentry *)data;
1884         return snprintf(buff, len, "%s" , mpe->reservation_key);
1885 }
1886
1887
1888 static int
1889 snprint_hw_fast_io_fail(char * buff, int len, void * data)
1890 {
1891         struct hwentry * hwe = (struct hwentry *)data;
1892         if (!hwe->fast_io_fail)
1893                 return 0;
1894         if (hwe->fast_io_fail == conf->fast_io_fail)
1895                 return 0;
1896         if (hwe->fast_io_fail == MP_FAST_IO_FAIL_OFF)
1897                 return snprintf(buff, len, "off");
1898         if (hwe->fast_io_fail == MP_FAST_IO_FAIL_ZERO)
1899                 return snprintf(buff, len, "0");
1900         return snprintf(buff, len, "%d", hwe->fast_io_fail);
1901 }
1902
1903 static int
1904 snprint_hw_dev_loss(char * buff, int len, void * data)
1905 {
1906         struct hwentry * hwe = (struct hwentry *)data;
1907         if (!hwe->dev_loss)
1908                 return 0;
1909         if (hwe->dev_loss == conf->dev_loss)
1910                 return 0;
1911         if (hwe->dev_loss >= MAX_DEV_LOSS_TMO)
1912                 return snprintf(buff, len, "infinity");
1913
1914         return snprintf(buff, len, "%u", hwe->dev_loss);
1915 }
1916
1917 static int
1918 snprint_hw_vendor (char * buff, int len, void * data)
1919 {
1920         struct hwentry * hwe = (struct hwentry *)data;
1921
1922         if (!hwe->vendor)
1923                 return 0;
1924
1925         return snprintf(buff, len, "\"%s\"", hwe->vendor);
1926 }
1927
1928 static int
1929 snprint_hw_product (char * buff, int len, void * data)
1930 {
1931         struct hwentry * hwe = (struct hwentry *)data;
1932
1933         if (!hwe->product)
1934                 return 0;
1935
1936         return snprintf(buff, len, "\"%s\"", hwe->product);
1937 }
1938
1939 static int
1940 snprint_hw_revision (char * buff, int len, void * data)
1941 {
1942         struct hwentry * hwe = (struct hwentry *)data;
1943
1944         if (!hwe->revision)
1945                 return 0;
1946
1947         return snprintf(buff, len, "\"%s\"", hwe->revision);
1948 }
1949
1950 static int
1951 snprint_hw_bl_product (char * buff, int len, void * data)
1952 {
1953         struct hwentry * hwe = (struct hwentry *)data;
1954
1955         if (!hwe->bl_product)
1956                 return 0;
1957
1958         return snprintf(buff, len, "\"%s\"", hwe->bl_product);
1959 }
1960
1961 static int
1962 snprint_hw_uid_attribute (char * buff, int len, void * data)
1963 {
1964         struct hwentry * hwe = (struct hwentry *)data;
1965
1966         if (!hwe->uid_attribute)
1967                 return 0;
1968
1969         return snprintf(buff, len, "\"%s\"", hwe->uid_attribute);
1970 }
1971
1972 static int
1973 snprint_hw_prio (char * buff, int len, void * data)
1974 {
1975         struct hwentry * hwe = (struct hwentry *)data;
1976
1977         if (!hwe->prio_name)
1978                 return 0;
1979
1980         return snprintf(buff, len, "%s", hwe->prio_name);
1981 }
1982
1983 static int
1984 snprint_hw_alias_prefix (char * buff, int len, void * data)
1985 {
1986         struct hwentry * hwe = (struct hwentry *)data;
1987
1988         if (!hwe->alias_prefix)
1989                 return 0;
1990
1991         return snprintf(buff, len, "\"%s\"", hwe->alias_prefix);
1992 }
1993
1994 static int
1995 snprint_hw_prio_args (char * buff, int len, void * data)
1996 {
1997         struct hwentry * hwe = (struct hwentry *)data;
1998
1999         if (!hwe->prio_args)
2000                 return 0;
2001
2002         return snprintf(buff, len, "\"%s\"", hwe->prio_args);
2003 }
2004
2005 static int
2006 snprint_hw_features (char * buff, int len, void * data)
2007 {
2008         struct hwentry * hwe = (struct hwentry *)data;
2009
2010         if (!hwe->features)
2011                 return 0;
2012
2013         return snprintf(buff, len, "\"%s\"", hwe->features);
2014 }
2015
2016 static int
2017 snprint_hw_hardware_handler (char * buff, int len, void * data)
2018 {
2019         struct hwentry * hwe = (struct hwentry *)data;
2020
2021         if (!hwe->hwhandler)
2022                 return 0;
2023
2024         return snprintf(buff, len, "\"%s\"", hwe->hwhandler);
2025 }
2026
2027 static int
2028 snprint_hw_selector (char * buff, int len, void * data)
2029 {
2030         struct hwentry * hwe = (struct hwentry *)data;
2031
2032         if (!hwe->selector)
2033                 return 0;
2034
2035         return snprintf(buff, len, "\"%s\"", hwe->selector);
2036 }
2037
2038 static int
2039 snprint_hw_path_grouping_policy (char * buff, int len, void * data)
2040 {
2041         struct hwentry * hwe = (struct hwentry *)data;
2042
2043         char str[POLICY_NAME_SIZE];
2044
2045         if (!hwe->pgpolicy)
2046                 return 0;
2047
2048         get_pgpolicy_name(str, POLICY_NAME_SIZE, hwe->pgpolicy);
2049
2050         return snprintf(buff, len, "%s", str);
2051 }
2052
2053 static int
2054 snprint_hw_failback (char * buff, int len, void * data)
2055 {
2056         struct hwentry * hwe = (struct hwentry *)data;
2057
2058         if (!hwe->pgfailback)
2059                 return 0;
2060
2061         switch(hwe->pgfailback) {
2062         case  FAILBACK_UNDEF:
2063                 break;
2064         case -FAILBACK_MANUAL:
2065                 return snprintf(buff, len, "manual");
2066         case -FAILBACK_IMMEDIATE:
2067                 return snprintf(buff, len, "immediate");
2068         default:
2069                 return snprintf(buff, len, "%i", hwe->pgfailback);
2070         }
2071         return 0;
2072 }
2073
2074 static int
2075 snprint_hw_rr_weight (char * buff, int len, void * data)
2076 {
2077         struct hwentry * hwe = (struct hwentry *)data;
2078
2079         if (!hwe->rr_weight)
2080                 return 0;
2081         if (hwe->rr_weight == RR_WEIGHT_PRIO)
2082                 return snprintf(buff, len, "priorities");
2083         if (hwe->rr_weight == RR_WEIGHT_NONE)
2084                 return snprintf(buff, len, "uniform");
2085
2086         return 0;
2087 }
2088
2089 static int
2090 snprint_hw_no_path_retry (char * buff, int len, void * data)
2091 {
2092         struct hwentry * hwe = (struct hwentry *)data;
2093
2094         if (!hwe->no_path_retry)
2095                 return 0;
2096
2097         switch(hwe->no_path_retry) {
2098         case NO_PATH_RETRY_UNDEF:
2099                 break;
2100         case NO_PATH_RETRY_FAIL:
2101                 return snprintf(buff, len, "fail");
2102         case NO_PATH_RETRY_QUEUE:
2103                 return snprintf(buff, len, "queue");
2104         default:
2105                 return snprintf(buff, len, "%i",
2106                                 hwe->no_path_retry);
2107         }
2108         return 0;
2109 }
2110
2111 static int
2112 snprint_hw_rr_min_io (char * buff, int len, void * data)
2113 {
2114         struct hwentry * hwe = (struct hwentry *)data;
2115
2116         if (!hwe->minio)
2117                 return 0;
2118
2119         return snprintf(buff, len, "%u", hwe->minio);
2120 }
2121
2122 static int
2123 snprint_hw_rr_min_io_rq (char * buff, int len, void * data)
2124 {
2125         struct hwentry * hwe = (struct hwentry *)data;
2126
2127         if (!hwe->minio_rq)
2128                 return 0;
2129
2130         return snprintf(buff, len, "%u", hwe->minio_rq);
2131 }
2132
2133 static int
2134 snprint_hw_pg_timeout (char * buff, int len, void * data)
2135 {
2136         struct hwentry * hwe = (struct hwentry *)data;
2137
2138         if (!hwe->pg_timeout)
2139                 return 0;
2140
2141         switch (hwe->pg_timeout) {
2142         case PGTIMEOUT_UNDEF:
2143                 break;
2144         case -PGTIMEOUT_NONE:
2145                 return snprintf(buff, len, "none");
2146         default:
2147                 return snprintf(buff, len, "%i", hwe->pg_timeout);
2148         }
2149         return 0;
2150 }
2151
2152 static int
2153 snprint_hw_flush_on_last_del (char * buff, int len, void * data)
2154 {
2155         struct hwentry * hwe = (struct hwentry *)data;
2156
2157         switch (hwe->flush_on_last_del) {
2158         case FLUSH_DISABLED:
2159                 return snprintf(buff, len, "no");
2160         case FLUSH_ENABLED:
2161                 return snprintf(buff, len, "yes");
2162         }
2163         return 0;
2164 }
2165
2166 static int
2167 snprint_hw_path_checker (char * buff, int len, void * data)
2168 {
2169         struct hwentry * hwe = (struct hwentry *)data;
2170
2171         if (!hwe->checker_name)
2172                 return 0;
2173
2174         return snprintf(buff, len, "%s", hwe->checker_name);
2175 }
2176
2177 static int
2178 snprint_def_polling_interval (char * buff, int len, void * data)
2179 {
2180         return snprintf(buff, len, "%i", conf->checkint);
2181 }
2182
2183 static int
2184 snprint_def_fast_io_fail(char * buff, int len, void * data)
2185 {
2186         if (!conf->fast_io_fail)
2187                 return 0;
2188         if (conf->fast_io_fail == MP_FAST_IO_FAIL_OFF)
2189                 return snprintf(buff, len, "off");
2190         if (conf->fast_io_fail == MP_FAST_IO_FAIL_ZERO)
2191                 return snprintf(buff, len, "0");
2192         return snprintf(buff, len, "%d", conf->fast_io_fail);
2193 }
2194
2195 static int
2196 snprint_def_dev_loss(char * buff, int len, void * data)
2197 {
2198         if (!conf->dev_loss)
2199                 return 0;
2200         if (conf->dev_loss >= MAX_DEV_LOSS_TMO)
2201                 return snprintf(buff, len, "infinity");
2202         return snprintf(buff, len, "%u", conf->dev_loss);
2203 }
2204
2205 static int
2206 snprint_def_verbosity (char * buff, int len, void * data)
2207 {
2208         return snprintf(buff, len, "%i", conf->verbosity);
2209 }
2210
2211 static int
2212 snprint_def_max_polling_interval (char * buff, int len, void * data)
2213 {
2214         if (conf->max_checkint == MAX_CHECKINT(conf->checkint))
2215                 return 0;
2216         return snprintf(buff, len, "%i", conf->max_checkint);
2217 }
2218
2219 static int
2220 snprint_reassign_maps (char * buff, int len, void * data)
2221 {
2222         if (conf->reassign_maps == DEFAULT_REASSIGN_MAPS)
2223                 return 0;
2224         return snprintf(buff, len, "%s",
2225                         conf->reassign_maps?"yes":"no");
2226 }
2227
2228 static int
2229 snprint_def_multipath_dir (char * buff, int len, void * data)
2230 {
2231         if (!conf->multipath_dir)
2232                 return 0;
2233
2234         return snprintf(buff, len, "\"%s\"", conf->multipath_dir);
2235 }
2236
2237 static int
2238 snprint_def_selector (char * buff, int len, void * data)
2239 {
2240         if (!conf->selector)
2241                 return snprintf(buff, len, "\"%s\"", DEFAULT_SELECTOR);
2242
2243         return snprintf(buff, len, "\"%s\"", conf->selector);
2244 }
2245
2246 static int
2247 snprint_def_path_grouping_policy (char * buff, int len, void * data)
2248 {
2249         char str[POLICY_NAME_SIZE];
2250         int pgpolicy = conf->pgpolicy;
2251
2252         if (!pgpolicy)
2253                 pgpolicy = DEFAULT_PGPOLICY;
2254
2255         get_pgpolicy_name(str, POLICY_NAME_SIZE, pgpolicy);
2256
2257         return snprintf(buff, len, "%s", str);
2258 }
2259
2260 static int
2261 snprint_def_uid_attribute (char * buff, int len, void * data)
2262 {
2263         if (!conf->uid_attribute)
2264                 return snprintf(buff, len, "\"%s\"", DEFAULT_UID_ATTRIBUTE);
2265
2266         return snprintf(buff, len, "\"%s\"", conf->uid_attribute);
2267 }
2268
2269 static int
2270 snprint_def_prio (char * buff, int len, void * data)
2271 {
2272         if (!conf->prio_name)
2273                 return snprintf(buff, len, "%s", DEFAULT_PRIO);
2274
2275         return snprintf(buff, len, "%s", conf->prio_name);
2276 }
2277
2278 static int
2279 snprint_def_prio_args (char * buff, int len, void * data)
2280 {
2281         if (!conf->prio_args)
2282                 return snprintf(buff, len, "\"%s\"", DEFAULT_PRIO_ARGS);
2283
2284         return snprintf(buff, len, "\"%s\"", conf->prio_args);
2285 }
2286
2287 static int
2288 snprint_def_features (char * buff, int len, void * data)
2289 {
2290         if (!conf->features)
2291                 return snprintf(buff, len, "\"%s\"", DEFAULT_FEATURES);
2292
2293         return snprintf(buff, len, "\"%s\"", conf->features);
2294 }
2295
2296 static int
2297 snprint_def_path_checker (char * buff, int len, void * data)
2298 {
2299         if (!conf->checker_name)
2300                 return snprintf(buff, len, "%s", DEFAULT_CHECKER);
2301
2302         return snprintf(buff, len, "%s", conf->checker_name);
2303 }
2304
2305 static int
2306 snprint_def_failback (char * buff, int len, void * data)
2307 {
2308         int pgfailback = conf->pgfailback;
2309         if (!pgfailback)
2310                 pgfailback = DEFAULT_FAILBACK;
2311
2312         switch(conf->pgfailback) {
2313         case  FAILBACK_UNDEF:
2314                 break;
2315         case -FAILBACK_MANUAL:
2316                 return snprintf(buff, len, "manual");
2317         case -FAILBACK_IMMEDIATE:
2318                 return snprintf(buff, len, "immediate");
2319         default:
2320                 return snprintf(buff, len, "%i", conf->pgfailback);
2321         }
2322         return 0;
2323 }
2324
2325 static int
2326 snprint_def_rr_min_io (char * buff, int len, void * data)
2327 {
2328         if (!conf->minio)
2329                 return 0;
2330
2331         return snprintf(buff, len, "%u", conf->minio);
2332 }
2333
2334 static int
2335 snprint_def_rr_min_io_rq (char * buff, int len, void * data)
2336 {
2337         if (!conf->minio_rq)
2338                 return 0;
2339
2340         return snprintf(buff, len, "%u", conf->minio_rq);
2341 }
2342
2343 static int
2344 snprint_max_fds (char * buff, int len, void * data)
2345 {
2346         if (!conf->max_fds)
2347                 return 0;
2348
2349         return snprintf(buff, len, "%d", conf->max_fds);
2350 }
2351
2352 static int
2353 snprint_def_mode(char * buff, int len, void * data)
2354 {
2355         if ((conf->attribute_flags & (1 << ATTR_MODE)) == 0)
2356                 return 0;
2357         return snprintf(buff, len, "0%o", conf->mode);
2358 }
2359
2360 static int
2361 snprint_def_uid(char * buff, int len, void * data)
2362 {
2363         if ((conf->attribute_flags & (1 << ATTR_UID)) == 0)
2364                 return 0;
2365         return snprintf(buff, len, "0%o", conf->uid);
2366 }
2367
2368 static int
2369 snprint_def_gid(char * buff, int len, void * data)
2370 {
2371         if ((conf->attribute_flags & (1 << ATTR_GID)) == 0)
2372                 return 0;
2373         return snprintf(buff, len, "0%o", conf->gid);
2374 }
2375
2376 static int
2377 snprint_def_rr_weight (char * buff, int len, void * data)
2378 {
2379         if (!conf->rr_weight || conf->rr_weight == RR_WEIGHT_NONE)
2380                 return snprintf(buff, len, "uniform");
2381         if (conf->rr_weight == RR_WEIGHT_PRIO)
2382                 return snprintf(buff, len, "priorities");
2383
2384         return 0;
2385 }
2386
2387 static int
2388 snprint_def_no_path_retry (char * buff, int len, void * data)
2389 {
2390         switch(conf->no_path_retry) {
2391         case NO_PATH_RETRY_UNDEF:
2392                 break;
2393         case NO_PATH_RETRY_FAIL:
2394                 return snprintf(buff, len, "fail");
2395         case NO_PATH_RETRY_QUEUE:
2396                 return snprintf(buff, len, "queue");
2397         default:
2398                 return snprintf(buff, len, "%i",
2399                                 conf->no_path_retry);
2400         }
2401         return 0;
2402 }
2403
2404 static int
2405 snprint_def_queue_without_daemon (char * buff, int len, void * data)
2406 {
2407         switch (conf->queue_without_daemon) {
2408         case QUE_NO_DAEMON_OFF:
2409                 return snprintf(buff, len, "no");
2410         case QUE_NO_DAEMON_ON:
2411         case QUE_NO_DAEMON_UNDEF:
2412                 return snprintf(buff, len, "yes");
2413         }
2414         return 0;
2415 }
2416
2417 static int
2418 snprint_def_checker_timeout (char *buff, int len, void *data)
2419 {
2420         if (!conf->checker_timeout)
2421                 return 0;
2422
2423         return snprintf(buff, len, "%u", conf->checker_timeout);
2424 }
2425
2426 static int
2427 snprint_def_pg_timeout (char * buff, int len, void * data)
2428 {
2429         switch (conf->pg_timeout) {
2430         case PGTIMEOUT_UNDEF:
2431         case -PGTIMEOUT_NONE:
2432                 return snprintf(buff, len, "none");
2433         default:
2434                 return snprintf(buff, len, "%i", conf->pg_timeout);
2435         }
2436         return 0;
2437 }
2438
2439 static int
2440 snprint_def_flush_on_last_del (char * buff, int len, void * data)
2441 {
2442         switch (conf->flush_on_last_del) {
2443         case FLUSH_UNDEF:
2444         case FLUSH_DISABLED:
2445                 return snprintf(buff, len, "no");
2446         case FLUSH_ENABLED:
2447         case FLUSH_IN_PROGRESS:
2448                 return snprintf(buff, len, "yes");
2449         }
2450         return 0;
2451 }
2452
2453 static int
2454 snprint_def_log_checker_err (char * buff, int len, void * data)
2455 {
2456         if (conf->log_checker_err == LOG_CHKR_ERR_ONCE)
2457                 return snprintf(buff, len, "once");
2458         return snprintf(buff, len, "always");
2459 }
2460
2461 static int
2462 snprint_def_user_friendly_names (char * buff, int len, void * data)
2463 {
2464         if (!conf->user_friendly_names)
2465                 return snprintf(buff, len, "no");
2466
2467         return snprintf(buff, len, "yes");
2468 }
2469
2470 static int
2471 snprint_def_alias_prefix (char * buff, int len, void * data)
2472 {
2473         if (!conf->alias_prefix)
2474                 return snprintf(buff, len, "\"%s\"", DEFAULT_ALIAS_PREFIX);
2475         return snprintf(buff, len, "\"%s\"", conf->alias_prefix);
2476 }
2477
2478 static int
2479 snprint_def_bindings_file (char * buff, int len, void * data)
2480 {
2481         if (conf->bindings_file == NULL)
2482                 return 0;
2483         if (strlen(conf->bindings_file) == strlen(DEFAULT_BINDINGS_FILE) &&
2484             !strcmp(conf->bindings_file, DEFAULT_BINDINGS_FILE))
2485                 return 0;
2486
2487         return snprintf(buff, len, "%s", conf->bindings_file);
2488 }
2489
2490 static int
2491 snprint_def_reservation_key(char * buff, int len, void * data)
2492 {
2493         return snprintf(buff, len, "%s", conf->reservation_key);
2494 }
2495
2496 static int
2497 snprint_ble_simple (char * buff, int len, void * data)
2498 {
2499         struct blentry * ble = (struct blentry *)data;
2500
2501         return snprintf(buff, len, "\"%s\"", ble->str);
2502 }
2503
2504 static int
2505 snprint_bled_vendor (char * buff, int len, void * data)
2506 {
2507         struct blentry_device * bled = (struct blentry_device *)data;
2508
2509         return snprintf(buff, len, "\"%s\"", bled->vendor);
2510 }
2511
2512 static int
2513 snprint_bled_product (char * buff, int len, void * data)
2514 {
2515         struct blentry_device * bled = (struct blentry_device *)data;
2516
2517         return snprintf(buff, len, "\"%s\"", bled->product);
2518 }
2519
2520 #define __deprecated
2521
2522 void
2523 init_keywords(void)
2524 {
2525         install_keyword_root("defaults", NULL);
2526         install_keyword("verbosity", &verbosity_handler, &snprint_def_verbosity);
2527         install_keyword("polling_interval", &polling_interval_handler, &snprint_def_polling_interval);
2528         install_keyword("max_polling_interval", &max_polling_interval_handler, &snprint_def_max_polling_interval);
2529         install_keyword("reassign_maps", &reassign_maps_handler, &snprint_reassign_maps);
2530         install_keyword("multipath_dir", &multipath_dir_handler, &snprint_def_multipath_dir);
2531         install_keyword("path_selector", &def_selector_handler, &snprint_def_selector);
2532         install_keyword("path_grouping_policy", &def_pgpolicy_handler, &snprint_def_path_grouping_policy);
2533         install_keyword("uid_attribute", &def_uid_attribute_handler, &snprint_def_uid_attribute);
2534         install_keyword("prio", &def_prio_handler, &snprint_def_prio);
2535         install_keyword("prio_args", &def_prio_args_handler, &snprint_def_prio_args);
2536         install_keyword("features", &def_features_handler, &snprint_def_features);
2537         install_keyword("path_checker", &def_path_checker_handler, &snprint_def_path_checker);
2538         install_keyword("checker", &def_path_checker_handler, NULL);
2539         install_keyword("alias_prefix", &def_alias_prefix_handler, &snprint_def_alias_prefix);
2540         install_keyword("failback", &default_failback_handler, &snprint_def_failback);
2541         install_keyword("rr_min_io", &def_minio_handler, &snprint_def_rr_min_io);
2542         install_keyword("rr_min_io_rq", &def_minio_rq_handler, &snprint_def_rr_min_io_rq);
2543         install_keyword("max_fds", &max_fds_handler, &snprint_max_fds);
2544         install_keyword("rr_weight", &def_weight_handler, &snprint_def_rr_weight);
2545         install_keyword("no_path_retry", &def_no_path_retry_handler, &snprint_def_no_path_retry);
2546         install_keyword("queue_without_daemon", &def_queue_without_daemon, &snprint_def_queue_without_daemon);
2547         install_keyword("checker_timeout", &def_checker_timeout_handler, &snprint_def_checker_timeout);
2548         install_keyword("pg_timeout", &def_pg_timeout_handler, &snprint_def_pg_timeout);
2549         install_keyword("flush_on_last_del", &def_flush_on_last_del_handler, &snprint_def_flush_on_last_del);
2550         install_keyword("user_friendly_names", &names_handler, &snprint_def_user_friendly_names);
2551         install_keyword("mode", &def_mode_handler, &snprint_def_mode);
2552         install_keyword("uid", &def_uid_handler, &snprint_def_uid);
2553         install_keyword("gid", &def_gid_handler, &snprint_def_gid);
2554         install_keyword("fast_io_fail_tmo", &def_fast_io_fail_handler, &snprint_def_fast_io_fail);
2555         install_keyword("dev_loss_tmo", &def_dev_loss_handler, &snprint_def_dev_loss);
2556         install_keyword("bindings_file", &bindings_file_handler, &snprint_def_bindings_file);
2557         install_keyword("log_checker_err", &def_log_checker_err_handler, &snprint_def_log_checker_err);
2558         install_keyword("reservation_key", &def_reservation_key_handler, &snprint_def_reservation_key);
2559         __deprecated install_keyword("default_selector", &def_selector_handler, NULL);
2560         __deprecated install_keyword("default_path_grouping_policy", &def_pgpolicy_handler, NULL);
2561         __deprecated install_keyword("default_uid_attribute", &def_uid_attribute_handler, NULL);
2562         __deprecated install_keyword("default_features", &def_features_handler, NULL);
2563         __deprecated install_keyword("default_path_checker", &def_path_checker_handler, NULL);
2564
2565         install_keyword_root("blacklist", &blacklist_handler);
2566         install_keyword_multi("devnode", &ble_devnode_handler, &snprint_ble_simple);
2567         install_keyword_multi("wwid", &ble_wwid_handler, &snprint_ble_simple);
2568         install_keyword_multi("device", &ble_device_handler, NULL);
2569         install_sublevel();
2570         install_keyword("vendor", &ble_vendor_handler, &snprint_bled_vendor);
2571         install_keyword("product", &ble_product_handler, &snprint_bled_product);
2572         install_sublevel_end();
2573         install_keyword_root("blacklist_exceptions", &blacklist_exceptions_handler);
2574         install_keyword_multi("devnode", &ble_except_devnode_handler, &snprint_ble_simple);
2575         install_keyword_multi("wwid", &ble_except_wwid_handler, &snprint_ble_simple);
2576         install_keyword_multi("device", &ble_except_device_handler, NULL);
2577         install_sublevel();
2578         install_keyword("vendor", &ble_except_vendor_handler, &snprint_bled_vendor);
2579         install_keyword("product", &ble_except_product_handler, &snprint_bled_product);
2580         install_sublevel_end();
2581
2582 #if 0
2583         __deprecated install_keyword_root("devnode_blacklist", &blacklist_handler);
2584         __deprecated install_keyword("devnode", &ble_devnode_handler, &snprint_ble_simple);
2585         __deprecated install_keyword("wwid", &ble_wwid_handler, &snprint_ble_simple);
2586         __deprecated install_keyword("device", &ble_device_handler, NULL);
2587         __deprecated install_sublevel();
2588         __deprecated install_keyword("vendor", &ble_vendor_handler, &snprint_bled_vendor);
2589         __deprecated install_keyword("product", &ble_product_handler, &snprint_bled_product);
2590         __deprecated install_sublevel_end();
2591 #endif
2592
2593         install_keyword_root("devices", &devices_handler);
2594         install_keyword_multi("device", &device_handler, NULL);
2595         install_sublevel();
2596         install_keyword("vendor", &vendor_handler, &snprint_hw_vendor);
2597         install_keyword("product", &product_handler, &snprint_hw_product);
2598         install_keyword("revision", &revision_handler, &snprint_hw_revision);
2599         install_keyword("product_blacklist", &bl_product_handler, &snprint_hw_bl_product);
2600         install_keyword("path_grouping_policy", &hw_pgpolicy_handler, &snprint_hw_path_grouping_policy);
2601         install_keyword("uid_attribute", &hw_uid_attribute_handler, &snprint_hw_uid_attribute);
2602         install_keyword("path_selector", &hw_selector_handler, &snprint_hw_selector);
2603         install_keyword("path_checker", &hw_path_checker_handler, &snprint_hw_path_checker);
2604         install_keyword("checker", &hw_path_checker_handler, NULL);
2605         install_keyword("alias_prefix", &hw_alias_prefix_handler, &snprint_hw_alias_prefix);
2606         install_keyword("features", &hw_features_handler, &snprint_hw_features);
2607         install_keyword("hardware_handler", &hw_handler_handler, &snprint_hw_hardware_handler);
2608         install_keyword("prio", &hw_prio_handler, &snprint_hw_prio);
2609         install_keyword("prio_args", &hw_prio_args_handler, &snprint_hw_prio_args);
2610         install_keyword("failback", &hw_failback_handler, &snprint_hw_failback);
2611         install_keyword("rr_weight", &hw_weight_handler, &snprint_hw_rr_weight);
2612         install_keyword("no_path_retry", &hw_no_path_retry_handler, &snprint_hw_no_path_retry);
2613         install_keyword("rr_min_io", &hw_minio_handler, &snprint_hw_rr_min_io);
2614         install_keyword("rr_min_io_rq", &hw_minio_rq_handler, &snprint_hw_rr_min_io_rq);
2615         install_keyword("pg_timeout", &hw_pg_timeout_handler, &snprint_hw_pg_timeout);
2616         install_keyword("flush_on_last_del", &hw_flush_on_last_del_handler, &snprint_hw_flush_on_last_del);
2617         install_keyword("fast_io_fail_tmo", &hw_fast_io_fail_handler, &snprint_hw_fast_io_fail);
2618         install_keyword("dev_loss_tmo", &hw_dev_loss_handler, &snprint_hw_dev_loss);
2619         install_sublevel_end();
2620
2621         install_keyword_root("multipaths", &multipaths_handler);
2622         install_keyword_multi("multipath", &multipath_handler, NULL);
2623         install_sublevel();
2624         install_keyword("wwid", &wwid_handler, &snprint_mp_wwid);
2625         install_keyword("alias", &alias_handler, &snprint_mp_alias);
2626         install_keyword("path_grouping_policy", &mp_pgpolicy_handler, &snprint_mp_path_grouping_policy);
2627         install_keyword("path_selector", &mp_selector_handler, &snprint_mp_selector);
2628         install_keyword("prio", &mp_prio_handler, &snprint_mp_prio);
2629         install_keyword("prio_args", &mp_prio_args_handler, &snprint_mp_prio_args);
2630         install_keyword("failback", &mp_failback_handler, &snprint_mp_failback);
2631         install_keyword("rr_weight", &mp_weight_handler, &snprint_mp_rr_weight);
2632         install_keyword("no_path_retry", &mp_no_path_retry_handler, &snprint_mp_no_path_retry);
2633         install_keyword("rr_min_io", &mp_minio_handler, &snprint_mp_rr_min_io);
2634         install_keyword("rr_min_io_rq", &mp_minio_rq_handler, &snprint_mp_rr_min_io_rq);
2635         install_keyword("pg_timeout", &mp_pg_timeout_handler, &snprint_mp_pg_timeout);
2636         install_keyword("flush_on_last_del", &mp_flush_on_last_del_handler, &snprint_mp_flush_on_last_del);
2637         install_keyword("features", &mp_features_handler, &snprint_mp_features);
2638         install_keyword("mode", &mp_mode_handler, &snprint_mp_mode);
2639         install_keyword("uid", &mp_uid_handler, &snprint_mp_uid);
2640         install_keyword("gid", &mp_gid_handler, &snprint_mp_gid);
2641         install_keyword("reservation_key", &mp_reservation_key_handler, &snprint_mp_reservation_key);
2642         install_sublevel_end();
2643 }