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