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