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
18 #include "pgpolicies.h"
19 #include "blacklist.h"
26 * default block handlers
29 polling_interval_handler(vector strvec)
33 buff = VECTOR_SLOT(strvec, 1);
34 conf->checkint = atoi(buff);
35 conf->max_checkint = MAX_CHECKINT(conf->checkint);
41 def_fast_io_fail_handler(vector strvec)
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 = MP_FAST_IO_FAIL_UNSET;
51 else if (conf->fast_io_fail == 0)
52 conf->fast_io_fail = MP_FAST_IO_FAIL_ZERO;
59 def_dev_loss_handler(vector strvec)
63 buff = set_value(strvec);
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)
77 verbosity_handler(vector strvec)
81 buff = VECTOR_SLOT(strvec, 1);
82 conf->verbosity = atoi(buff);
88 max_polling_interval_handler(vector strvec)
92 buff = VECTOR_SLOT(strvec, 1);
93 conf->max_checkint = atoi(buff);
99 reassign_maps_handler(vector strvec)
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;
115 multipath_dir_handler(vector strvec)
117 conf->multipath_dir = set_value(strvec);
119 if (!conf->multipath_dir)
126 def_selector_handler(vector strvec)
128 conf->selector = set_value(strvec);
137 def_pgpolicy_handler(vector strvec)
141 buff = set_value(strvec);
146 conf->pgpolicy = get_pgpolicy_id(buff);
153 def_uid_attribute_handler(vector strvec)
155 conf->uid_attribute = set_value(strvec);
157 if (!conf->uid_attribute)
164 def_getuid_callout_handler(vector strvec)
166 conf->getuid = set_value(strvec);
175 def_prio_handler(vector strvec)
177 conf->prio_name = set_value(strvec);
179 if (!conf->prio_name)
186 def_alias_prefix_handler(vector strvec)
188 conf->alias_prefix = set_value(strvec);
190 if (!conf->alias_prefix)
197 def_prio_args_handler(vector strvec)
199 conf->prio_args = set_value(strvec);
201 if (!conf->prio_args)
208 def_features_handler(vector strvec)
210 conf->features = set_value(strvec);
219 def_path_checker_handler(vector strvec)
221 conf->checker_name = set_value(strvec);
223 if (!conf->checker_name)
230 def_minio_handler(vector strvec)
234 buff = set_value(strvec);
239 conf->minio = atoi(buff);
246 def_minio_rq_handler(vector strvec)
250 buff = set_value(strvec);
255 conf->minio_rq = atoi(buff);
262 get_sys_max_fds(int *max_fds)
268 file = fopen("/proc/sys/fs/nr_open", "r");
270 fprintf(stderr, "Cannot open /proc/sys/fs/nr_open : %s\n",
274 if (fscanf(file, "%d", &nr_open) != 1) {
275 fprintf(stderr, "Cannot read max open fds from /proc/sys/fs/nr_open");
277 fprintf(stderr, " : %s\n", strerror(errno));
279 fprintf(stderr, "\n");
290 max_fds_handler(vector strvec)
295 buff = set_value(strvec);
300 if (strlen(buff) == 3 &&
301 !strcmp(buff, "max"))
302 r = get_sys_max_fds(&conf->max_fds);
304 conf->max_fds = atoi(buff);
311 def_mode_handler(vector strvec)
316 buff = set_value(strvec);
321 if (sscanf(buff, "%o", &mode) == 1 && mode <= 0777) {
322 conf->attribute_flags |= (1 << ATTR_MODE);
331 def_uid_handler(vector strvec)
335 char passwd_buf[1024];
336 struct passwd info, *found;
338 buff = set_value(strvec);
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;
345 else if (sscanf(buff, "%u", &uid) == 1){
346 conf->attribute_flags |= (1 << ATTR_UID);
355 def_gid_handler(vector strvec)
359 char passwd_buf[1024];
360 struct passwd info, *found;
362 buff = set_value(strvec);
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;
370 else if (sscanf(buff, "%u", &gid) == 1){
371 conf->attribute_flags |= (1 << ATTR_GID);
379 def_weight_handler(vector strvec)
383 buff = set_value(strvec);
388 if (strlen(buff) == 10 &&
389 !strcmp(buff, "priorities"))
390 conf->rr_weight = RR_WEIGHT_PRIO;
392 if (strlen(buff) == strlen("uniform") &&
393 !strcmp(buff, "uniform"))
394 conf->rr_weight = RR_WEIGHT_NONE;
402 default_failback_handler(vector strvec)
406 buff = set_value(strvec);
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 if (strlen(buff) == 10 && !strcmp(buff, "followover"))
413 conf->pgfailback = -FAILBACK_FOLLOWOVER;
415 conf->pgfailback = atoi(buff);
423 def_no_path_retry_handler(vector strvec)
427 buff = set_value(strvec);
431 if ((strlen(buff) == 4 && !strcmp(buff, "fail")) ||
432 (strlen(buff) == 1 && !strcmp(buff, "0")))
433 conf->no_path_retry = NO_PATH_RETRY_FAIL;
434 else if (strlen(buff) == 5 && !strcmp(buff, "queue"))
435 conf->no_path_retry = NO_PATH_RETRY_QUEUE;
436 else if ((conf->no_path_retry = atoi(buff)) < 1)
437 conf->no_path_retry = NO_PATH_RETRY_UNDEF;
444 def_queue_without_daemon(vector strvec)
448 buff = set_value(strvec);
452 if (!strncmp(buff, "on", 2) || !strncmp(buff, "yes", 3) ||
453 !strncmp(buff, "1", 1))
454 conf->queue_without_daemon = QUE_NO_DAEMON_ON;
456 conf->queue_without_daemon = QUE_NO_DAEMON_OFF;
463 def_checker_timeout_handler(vector strvec)
465 unsigned int checker_timeout;
468 buff = set_value(strvec);
472 if (sscanf(buff, "%u", &checker_timeout) == 1)
473 conf->checker_timeout = checker_timeout;
475 conf->checker_timeout = 0;
482 def_pg_timeout_handler(vector strvec)
486 buff = set_value(strvec);
491 /* Deprecated; device-mapper support has been removed */
498 def_flush_on_last_del_handler(vector strvec)
502 buff = set_value(strvec);
506 if ((strlen(buff) == 2 && strcmp(buff, "no") == 0) ||
507 (strlen(buff) == 1 && strcmp(buff, "0") == 0))
508 conf->flush_on_last_del = FLUSH_DISABLED;
509 else if ((strlen(buff) == 3 && strcmp(buff, "yes") == 0) ||
510 (strlen(buff) == 1 && strcmp(buff, "1") == 0))
511 conf->flush_on_last_del = FLUSH_ENABLED;
513 conf->flush_on_last_del = FLUSH_UNDEF;
520 def_log_checker_err_handler(vector strvec)
524 buff = set_value(strvec);
529 if (strlen(buff) == 4 && !strcmp(buff, "once"))
530 conf->log_checker_err = LOG_CHKR_ERR_ONCE;
531 else if (strlen(buff) == 6 && !strcmp(buff, "always"))
532 conf->log_checker_err = LOG_CHKR_ERR_ALWAYS;
539 def_reservation_key_handler(vector strvec)
547 buff = set_value(strvec);
553 if (!memcmp("0x",buff, 2))
558 k = strspn(buff, "0123456789aAbBcCdDeEfF");
565 if (1 != sscanf (buff, "%" SCNx64 "", &prkey))
571 if (!conf->reservation_key)
572 conf->reservation_key = (unsigned char *) malloc(8);
574 memset(conf->reservation_key, 0, 8);
576 for (j = 7; j >= 0; --j) {
577 conf->reservation_key[j] = (prkey & 0xff);
586 def_names_handler(vector strvec)
590 buff = set_value(strvec);
595 if ((strlen(buff) == 2 && !strcmp(buff, "no")) ||
596 (strlen(buff) == 1 && !strcmp(buff, "0")))
597 conf->user_friendly_names = USER_FRIENDLY_NAMES_OFF;
598 else if ((strlen(buff) == 3 && !strcmp(buff, "yes")) ||
599 (strlen(buff) == 1 && !strcmp(buff, "1")))
600 conf->user_friendly_names = USER_FRIENDLY_NAMES_ON;
602 conf->user_friendly_names = USER_FRIENDLY_NAMES_UNDEF;
609 bindings_file_handler(vector strvec)
611 conf->bindings_file = set_value(strvec);
613 if (!conf->bindings_file)
620 wwids_file_handler(vector strvec)
622 conf->wwids_file = set_value(strvec);
624 if (!conf->wwids_file)
631 def_retain_hwhandler_handler(vector strvec)
635 buff = set_value(strvec);
640 if ((strlen(buff) == 2 && !strcmp(buff, "no")) ||
641 (strlen(buff) == 1 && !strcmp(buff, "0")))
642 conf->retain_hwhandler = RETAIN_HWHANDLER_OFF;
643 else if ((strlen(buff) == 3 && !strcmp(buff, "yes")) ||
644 (strlen(buff) == 1 && !strcmp(buff, "1")))
645 conf->retain_hwhandler = RETAIN_HWHANDLER_ON;
647 conf->retain_hwhandler = RETAIN_HWHANDLER_UNDEF;
654 def_detect_prio_handler(vector strvec)
658 buff = set_value(strvec);
663 if ((strlen(buff) == 2 && !strcmp(buff, "no")) ||
664 (strlen(buff) == 1 && !strcmp(buff, "0")))
665 conf->detect_prio = DETECT_PRIO_OFF;
666 else if ((strlen(buff) == 3 && !strcmp(buff, "yes")) ||
667 (strlen(buff) == 1 && !strcmp(buff, "1")))
668 conf->detect_prio = DETECT_PRIO_ON;
670 conf->detect_prio = DETECT_PRIO_UNDEF;
677 * blacklist block handlers
680 blacklist_handler(vector strvec)
682 conf->blist_devnode = vector_alloc();
683 conf->blist_wwid = vector_alloc();
684 conf->blist_device = vector_alloc();
686 if (!conf->blist_devnode || !conf->blist_wwid || !conf->blist_device)
693 blacklist_exceptions_handler(vector strvec)
695 conf->elist_devnode = vector_alloc();
696 conf->elist_wwid = vector_alloc();
697 conf->elist_device = vector_alloc();
699 if (!conf->elist_devnode || !conf->elist_wwid || !conf->elist_device)
706 ble_devnode_handler(vector strvec)
710 buff = set_value(strvec);
715 return store_ble(conf->blist_devnode, buff, ORIGIN_CONFIG);
719 ble_except_devnode_handler(vector strvec)
723 buff = set_value(strvec);
728 return store_ble(conf->elist_devnode, buff, ORIGIN_CONFIG);
732 ble_wwid_handler(vector strvec)
736 buff = set_value(strvec);
741 return store_ble(conf->blist_wwid, buff, ORIGIN_CONFIG);
745 ble_except_wwid_handler(vector strvec)
749 buff = set_value(strvec);
754 return store_ble(conf->elist_wwid, buff, ORIGIN_CONFIG);
758 ble_device_handler(vector strvec)
760 return alloc_ble_device(conf->blist_device);
764 ble_except_device_handler(vector strvec)
766 return alloc_ble_device(conf->elist_device);
770 ble_vendor_handler(vector strvec)
774 buff = set_value(strvec);
779 return set_ble_device(conf->blist_device, buff, NULL, ORIGIN_CONFIG);
783 ble_except_vendor_handler(vector strvec)
787 buff = set_value(strvec);
792 return set_ble_device(conf->elist_device, buff, NULL, ORIGIN_CONFIG);
796 ble_product_handler(vector strvec)
800 buff = set_value(strvec);
805 return set_ble_device(conf->blist_device, NULL, buff, ORIGIN_CONFIG);
809 ble_except_product_handler(vector strvec)
813 buff = set_value(strvec);
818 return set_ble_device(conf->elist_device, NULL, buff, ORIGIN_CONFIG);
822 * devices block handlers
825 devices_handler(vector strvec)
828 conf->hwtable = vector_alloc();
837 device_handler(vector strvec)
839 struct hwentry * hwe;
846 if (!vector_alloc_slot(conf->hwtable)) {
850 vector_set_slot(conf->hwtable, hwe);
856 vendor_handler(vector strvec)
858 struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
863 hwe->vendor = set_value(strvec);
872 product_handler(vector strvec)
874 struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
879 hwe->product = set_value(strvec);
888 revision_handler(vector strvec)
890 struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
895 hwe->revision = set_value(strvec);
904 bl_product_handler(vector strvec)
906 struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
911 hwe->bl_product = set_value(strvec);
912 if (!hwe->bl_product)
919 hw_fast_io_fail_handler(vector strvec)
922 struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
924 buff = set_value(strvec);
925 if (strlen(buff) == 3 && !strcmp(buff, "off"))
926 hwe->fast_io_fail = MP_FAST_IO_FAIL_OFF;
927 else if (sscanf(buff, "%d", &hwe->fast_io_fail) != 1 ||
928 hwe->fast_io_fail < MP_FAST_IO_FAIL_ZERO)
929 hwe->fast_io_fail = MP_FAST_IO_FAIL_UNSET;
930 else if (hwe->fast_io_fail == 0)
931 hwe->fast_io_fail = MP_FAST_IO_FAIL_ZERO;
938 hw_dev_loss_handler(vector strvec)
941 struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
943 buff = set_value(strvec);
947 if (strlen(buff) == 8 && !strcmp(buff, "infinity"))
948 hwe->dev_loss = MAX_DEV_LOSS_TMO;
949 else if (sscanf(buff, "%u", &hwe->dev_loss) != 1)
957 hw_pgpolicy_handler(vector strvec)
960 struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
962 buff = set_value(strvec);
967 hwe->pgpolicy = get_pgpolicy_id(buff);
974 hw_uid_attribute_handler(vector strvec)
976 struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
978 hwe->uid_attribute = set_value(strvec);
980 if (!hwe->uid_attribute)
987 hw_getuid_callout_handler(vector strvec)
989 struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
991 hwe->getuid = set_value(strvec);
1000 hw_selector_handler(vector strvec)
1002 struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
1007 hwe->selector = set_value(strvec);
1016 hw_path_checker_handler(vector strvec)
1018 struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
1023 hwe->checker_name = set_value(strvec);
1025 if (!hwe->checker_name)
1032 hw_features_handler(vector strvec)
1034 struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
1039 hwe->features = set_value(strvec);
1048 hw_handler_handler(vector strvec)
1050 struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
1055 hwe->hwhandler = set_value(strvec);
1057 if (!hwe->hwhandler)
1064 hw_prio_handler(vector strvec)
1066 struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
1071 hwe->prio_name = set_value(strvec);
1073 if (!hwe->prio_name)
1080 hw_alias_prefix_handler(vector strvec)
1082 struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
1087 hwe->alias_prefix = set_value(strvec);
1089 if (!hwe->alias_prefix)
1096 hw_prio_args_handler(vector strvec)
1098 struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
1103 hwe->prio_args = set_value(strvec);
1105 if (!hwe->prio_args)
1112 hw_failback_handler(vector strvec)
1114 struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
1120 buff = set_value(strvec);
1122 if (strlen(buff) == 6 && !strcmp(buff, "manual"))
1123 hwe->pgfailback = -FAILBACK_MANUAL;
1124 else if (strlen(buff) == 9 && !strcmp(buff, "immediate"))
1125 hwe->pgfailback = -FAILBACK_IMMEDIATE;
1126 else if (strlen(buff) == 10 && !strcmp(buff, "followover"))
1127 hwe->pgfailback = -FAILBACK_FOLLOWOVER;
1129 hwe->pgfailback = atoi(buff);
1137 hw_weight_handler(vector strvec)
1139 struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
1145 buff = set_value(strvec);
1150 if (strlen(buff) == 10 &&
1151 !strcmp(buff, "priorities"))
1152 hwe->rr_weight = RR_WEIGHT_PRIO;
1154 if (strlen(buff) == strlen("uniform") &&
1155 !strcmp(buff, "uniform"))
1156 hwe->rr_weight = RR_WEIGHT_NONE;
1164 hw_no_path_retry_handler(vector strvec)
1166 struct hwentry *hwe = VECTOR_LAST_SLOT(conf->hwtable);
1172 buff = set_value(strvec);
1176 if ((strlen(buff) == 4 && !strcmp(buff, "fail")) ||
1177 (strlen(buff) == 1 && !strcmp(buff, "0")))
1178 hwe->no_path_retry = NO_PATH_RETRY_FAIL;
1179 else if (strlen(buff) == 5 && !strcmp(buff, "queue"))
1180 hwe->no_path_retry = NO_PATH_RETRY_QUEUE;
1181 else if ((hwe->no_path_retry = atoi(buff)) < 1)
1182 hwe->no_path_retry = NO_PATH_RETRY_UNDEF;
1189 hw_minio_handler(vector strvec)
1191 struct hwentry *hwe = VECTOR_LAST_SLOT(conf->hwtable);
1197 buff = set_value(strvec);
1202 hwe->minio = atoi(buff);
1209 hw_minio_rq_handler(vector strvec)
1211 struct hwentry *hwe = VECTOR_LAST_SLOT(conf->hwtable);
1217 buff = set_value(strvec);
1222 hwe->minio_rq = atoi(buff);
1229 hw_pg_timeout_handler(vector strvec)
1233 buff = set_value(strvec);
1238 /* Deprecated; device-mapper support has been removed */
1245 hw_flush_on_last_del_handler(vector strvec)
1247 struct hwentry *hwe = VECTOR_LAST_SLOT(conf->hwtable);
1253 buff = set_value(strvec);
1257 if ((strlen(buff) == 2 && strcmp(buff, "no") == 0) ||
1258 (strlen(buff) == 1 && strcmp(buff, "0") == 0))
1259 hwe->flush_on_last_del = FLUSH_DISABLED;
1260 else if ((strlen(buff) == 3 && strcmp(buff, "yes") == 0) ||
1261 (strlen(buff) == 1 && strcmp(buff, "1") == 0))
1262 hwe->flush_on_last_del = FLUSH_ENABLED;
1264 hwe->flush_on_last_del = FLUSH_UNDEF;
1271 hw_names_handler(vector strvec)
1273 struct hwentry *hwe = VECTOR_LAST_SLOT(conf->hwtable);
1279 buff = set_value(strvec);
1283 if ((strlen(buff) == 2 && strcmp(buff, "no") == 0) ||
1284 (strlen(buff) == 1 && strcmp(buff, "0") == 0))
1285 hwe->user_friendly_names = USER_FRIENDLY_NAMES_OFF;
1286 else if ((strlen(buff) == 3 && strcmp(buff, "yes") == 0) ||
1287 (strlen(buff) == 1 && strcmp(buff, "1") == 0))
1288 hwe->user_friendly_names = USER_FRIENDLY_NAMES_ON;
1290 hwe->user_friendly_names = USER_FRIENDLY_NAMES_UNDEF;
1297 hw_retain_hwhandler_handler(vector strvec)
1299 struct hwentry *hwe = VECTOR_LAST_SLOT(conf->hwtable);
1305 buff = set_value(strvec);
1310 if ((strlen(buff) == 2 && !strcmp(buff, "no")) ||
1311 (strlen(buff) == 1 && !strcmp(buff, "0")))
1312 hwe->retain_hwhandler = RETAIN_HWHANDLER_OFF;
1313 else if ((strlen(buff) == 3 && !strcmp(buff, "yes")) ||
1314 (strlen(buff) == 1 && !strcmp(buff, "1")))
1315 hwe->retain_hwhandler = RETAIN_HWHANDLER_ON;
1317 hwe->user_friendly_names = RETAIN_HWHANDLER_UNDEF;
1324 hw_detect_prio_handler(vector strvec)
1326 struct hwentry *hwe = VECTOR_LAST_SLOT(conf->hwtable);
1332 buff = set_value(strvec);
1337 if ((strlen(buff) == 2 && !strcmp(buff, "no")) ||
1338 (strlen(buff) == 1 && !strcmp(buff, "0")))
1339 hwe->detect_prio = DETECT_PRIO_OFF;
1340 else if ((strlen(buff) == 3 && !strcmp(buff, "yes")) ||
1341 (strlen(buff) == 1 && !strcmp(buff, "1")))
1342 hwe->detect_prio = DETECT_PRIO_ON;
1344 hwe->detect_prio = DETECT_PRIO_UNDEF;
1351 * multipaths block handlers
1354 multipaths_handler(vector strvec)
1356 conf->mptable = vector_alloc();
1365 multipath_handler(vector strvec)
1367 struct mpentry * mpe;
1374 if (!vector_alloc_slot(conf->mptable)) {
1378 vector_set_slot(conf->mptable, mpe);
1384 wwid_handler(vector strvec)
1386 struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable);
1391 mpe->wwid = set_value(strvec);
1400 alias_handler(vector strvec)
1402 struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable);
1407 mpe->alias = set_value(strvec);
1416 mp_pgpolicy_handler(vector strvec)
1419 struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable);
1424 buff = set_value(strvec);
1429 mpe->pgpolicy = get_pgpolicy_id(buff);
1436 mp_selector_handler(vector strvec)
1438 struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable);
1443 mpe->selector = set_value(strvec);
1452 mp_failback_handler(vector strvec)
1454 struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable);
1460 buff = set_value(strvec);
1462 if (strlen(buff) == 6 && !strcmp(buff, "manual"))
1463 mpe->pgfailback = -FAILBACK_MANUAL;
1464 else if (strlen(buff) == 9 && !strcmp(buff, "immediate"))
1465 mpe->pgfailback = -FAILBACK_IMMEDIATE;
1466 else if (strlen(buff) == 10 && !strcmp(buff, "followover"))
1467 mpe->pgfailback = -FAILBACK_FOLLOWOVER;
1469 mpe->pgfailback = atoi(buff);
1477 mp_mode_handler(vector strvec)
1480 struct mpentry *mpe = VECTOR_LAST_SLOT(conf->mptable);
1486 buff = set_value(strvec);
1489 if (sscanf(buff, "%o", &mode) == 1 && mode <= 0777) {
1490 mpe->attribute_flags |= (1 << ATTR_MODE);
1499 mp_uid_handler(vector strvec)
1503 char passwd_buf[1024];
1504 struct passwd info, *found;
1506 struct mpentry *mpe = VECTOR_LAST_SLOT(conf->mptable);
1511 buff = set_value(strvec);
1515 if (getpwnam_r(buff, &info, passwd_buf, 1024, &found) == 0 && found) {
1516 mpe->attribute_flags |= (1 << ATTR_UID);
1517 mpe->uid = info.pw_uid;
1519 else if (sscanf(buff, "%u", &uid) == 1){
1520 mpe->attribute_flags |= (1 << ATTR_UID);
1528 mp_gid_handler(vector strvec)
1532 char passwd_buf[1024];
1533 struct passwd info, *found;
1535 struct mpentry *mpe = VECTOR_LAST_SLOT(conf->mptable);
1540 buff = set_value(strvec);
1544 if (getpwnam_r(buff, &info, passwd_buf, 1024, &found) == 0 && found) {
1545 mpe->attribute_flags |= (1 << ATTR_GID);
1546 mpe->gid = info.pw_gid;
1548 else if (sscanf(buff, "%u", &gid) == 1) {
1549 mpe->attribute_flags |= (1 << ATTR_GID);
1557 mp_weight_handler(vector strvec)
1559 struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable);
1565 buff = set_value(strvec);
1570 if (strlen(buff) == 10 &&
1571 !strcmp(buff, "priorities"))
1572 mpe->rr_weight = RR_WEIGHT_PRIO;
1574 if (strlen(buff) == strlen("uniform") &&
1575 !strcmp(buff, "uniform"))
1576 mpe->rr_weight = RR_WEIGHT_NONE;
1584 mp_no_path_retry_handler(vector strvec)
1586 struct mpentry *mpe = VECTOR_LAST_SLOT(conf->mptable);
1592 buff = set_value(strvec);
1596 if ((strlen(buff) == 4 && !strcmp(buff, "fail")) ||
1597 (strlen(buff) == 1 && !strcmp(buff, "0")))
1598 mpe->no_path_retry = NO_PATH_RETRY_FAIL;
1599 else if (strlen(buff) == 5 && !strcmp(buff, "queue"))
1600 mpe->no_path_retry = NO_PATH_RETRY_QUEUE;
1601 else if ((mpe->no_path_retry = atoi(buff)) < 1)
1602 mpe->no_path_retry = NO_PATH_RETRY_UNDEF;
1609 mp_minio_handler(vector strvec)
1611 struct mpentry *mpe = VECTOR_LAST_SLOT(conf->mptable);
1617 buff = set_value(strvec);
1622 mpe->minio = atoi(buff);
1629 mp_minio_rq_handler(vector strvec)
1631 struct mpentry *mpe = VECTOR_LAST_SLOT(conf->mptable);
1637 buff = set_value(strvec);
1642 mpe->minio_rq = atoi(buff);
1649 mp_pg_timeout_handler(vector strvec)
1653 buff = set_value(strvec);
1658 /* Deprecated; device-mapper support has been removed */
1665 mp_features_handler(vector strvec)
1667 struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable);
1672 mpe->features = set_value(strvec);
1681 mp_flush_on_last_del_handler(vector strvec)
1683 struct mpentry *mpe = VECTOR_LAST_SLOT(conf->mptable);
1689 buff = set_value(strvec);
1693 if ((strlen(buff) == 2 && strcmp(buff, "no") == 0) ||
1694 (strlen(buff) == 1 && strcmp(buff, "0") == 0))
1695 mpe->flush_on_last_del = FLUSH_DISABLED;
1696 else if ((strlen(buff) == 3 && strcmp(buff, "yes") == 0) ||
1697 (strlen(buff) == 1 && strcmp(buff, "1") == 0))
1698 mpe->flush_on_last_del = FLUSH_ENABLED;
1700 mpe->flush_on_last_del = FLUSH_UNDEF;
1707 mp_prio_handler(vector strvec)
1709 struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable);
1714 mpe->prio_name = set_value(strvec);
1716 if (!mpe->prio_name)
1723 mp_prio_args_handler (vector strvec)
1725 struct mpentry *mpe = VECTOR_LAST_SLOT(conf->mptable);
1730 mpe->prio_args = set_value(strvec);
1731 if (!mpe->prio_args)
1738 mp_reservation_key_handler (vector strvec)
1742 struct mpentry *mpe = VECTOR_LAST_SLOT(conf->mptable);
1750 buff = set_value(strvec);
1755 if (!memcmp(buff, "0x", 2))
1760 k = strspn(buff, "0123456789aAbBcCdDeEfF");
1766 if (1 != sscanf (buff, "%" SCNx64 "", &prkey))
1772 if (!mpe->reservation_key)
1773 mpe->reservation_key = (unsigned char *) malloc(8);
1775 memset(mpe->reservation_key, 0, 8);
1777 for (j = 7; j >= 0; --j) {
1778 mpe->reservation_key[j] = (prkey & 0xff);
1787 mp_names_handler(vector strvec)
1789 struct mpentry *mpe = VECTOR_LAST_SLOT(conf->mptable);
1795 buff = set_value(strvec);
1799 if ((strlen(buff) == 2 && strcmp(buff, "no") == 0) ||
1800 (strlen(buff) == 1 && strcmp(buff, "0") == 0))
1801 mpe->user_friendly_names = USER_FRIENDLY_NAMES_OFF;
1802 else if ((strlen(buff) == 3 && strcmp(buff, "yes") == 0) ||
1803 (strlen(buff) == 1 && strcmp(buff, "1") == 0))
1804 mpe->user_friendly_names = USER_FRIENDLY_NAMES_ON;
1806 mpe->user_friendly_names = USER_FRIENDLY_NAMES_UNDEF;
1813 * config file keywords printing
1816 snprint_mp_wwid (char * buff, int len, void * data)
1818 struct mpentry * mpe = (struct mpentry *)data;
1820 return snprintf(buff, len, "%s", mpe->wwid);
1824 snprint_mp_alias (char * buff, int len, void * data)
1826 struct mpentry * mpe = (struct mpentry *)data;
1831 return snprintf(buff, len, "%s", mpe->alias);
1835 snprint_mp_path_grouping_policy (char * buff, int len, void * data)
1837 struct mpentry * mpe = (struct mpentry *)data;
1838 char str[POLICY_NAME_SIZE];
1842 get_pgpolicy_name(str, POLICY_NAME_SIZE, mpe->pgpolicy);
1844 return snprintf(buff, len, "\"%s\"", str);
1848 snprint_mp_selector (char * buff, int len, void * data)
1850 struct mpentry * mpe = (struct mpentry *)data;
1855 return snprintf(buff, len, "\"%s\"", mpe->selector);
1859 snprint_mp_failback (char * buff, int len, void * data)
1861 struct mpentry * mpe = (struct mpentry *)data;
1863 if (!mpe->pgfailback)
1866 switch(mpe->pgfailback) {
1867 case FAILBACK_UNDEF:
1869 case -FAILBACK_MANUAL:
1870 return snprintf(buff, len, "\"manual\"");
1871 case -FAILBACK_IMMEDIATE:
1872 return snprintf(buff, len, "\"immediate\"");
1873 case -FAILBACK_FOLLOWOVER:
1874 return snprintf(buff, len, "\"followover\"");
1876 return snprintf(buff, len, "%i", mpe->pgfailback);
1882 snprint_mp_mode(char * buff, int len, void * data)
1884 struct mpentry * mpe = (struct mpentry *)data;
1886 if ((mpe->attribute_flags & (1 << ATTR_MODE)) == 0)
1888 return snprintf(buff, len, "0%o", mpe->mode);
1892 snprint_mp_uid(char * buff, int len, void * data)
1894 struct mpentry * mpe = (struct mpentry *)data;
1896 if ((mpe->attribute_flags & (1 << ATTR_UID)) == 0)
1898 return snprintf(buff, len, "0%o", mpe->uid);
1902 snprint_mp_gid(char * buff, int len, void * data)
1904 struct mpentry * mpe = (struct mpentry *)data;
1906 if ((mpe->attribute_flags & (1 << ATTR_GID)) == 0)
1908 return snprintf(buff, len, "0%o", mpe->gid);
1912 snprint_mp_rr_weight (char * buff, int len, void * data)
1914 struct mpentry * mpe = (struct mpentry *)data;
1916 if (!mpe->rr_weight)
1918 if (mpe->rr_weight == RR_WEIGHT_PRIO)
1919 return snprintf(buff, len, "\"priorities\"");
1920 if (mpe->rr_weight == RR_WEIGHT_NONE)
1921 return snprintf(buff, len, "\"uniform\"");
1927 snprint_mp_no_path_retry (char * buff, int len, void * data)
1929 struct mpentry * mpe = (struct mpentry *)data;
1931 if (!mpe->no_path_retry)
1934 switch(mpe->no_path_retry) {
1935 case NO_PATH_RETRY_UNDEF:
1937 case NO_PATH_RETRY_FAIL:
1938 return snprintf(buff, len, "\"fail\"");
1939 case NO_PATH_RETRY_QUEUE:
1940 return snprintf(buff, len, "\"queue\"");
1942 return snprintf(buff, len, "%i",
1943 mpe->no_path_retry);
1949 snprint_mp_rr_min_io (char * buff, int len, void * data)
1951 struct mpentry * mpe = (struct mpentry *)data;
1956 return snprintf(buff, len, "%u", mpe->minio);
1960 snprint_mp_rr_min_io_rq (char * buff, int len, void * data)
1962 struct mpentry * mpe = (struct mpentry *)data;
1967 return snprintf(buff, len, "%u", mpe->minio_rq);
1971 snprint_mp_pg_timeout (char * buff, int len, void * data)
1977 snprint_mp_features (char * buff, int len, void * data)
1979 struct mpentry * mpe = (struct mpentry *)data;
1983 if (strlen(mpe->features) == strlen(conf->features) &&
1984 !strcmp(mpe->features, conf->features))
1987 return snprintf(buff, len, "\"%s\"", mpe->features);
1991 snprint_mp_flush_on_last_del (char * buff, int len, void * data)
1993 struct mpentry * mpe = (struct mpentry *)data;
1995 switch (mpe->flush_on_last_del) {
1996 case FLUSH_DISABLED:
1997 return snprintf(buff, len, "\"no\"");
1999 return snprintf(buff, len, "\"yes\"");
2005 snprint_mp_prio(char * buff, int len, void * data)
2007 struct mpentry * mpe = (struct mpentry *)data;
2009 if (!mpe->prio_name)
2012 return snprintf(buff, len, "\"%s\"", mpe->prio_name);
2016 snprint_mp_prio_args(char * buff, int len, void * data)
2018 struct mpentry * mpe = (struct mpentry *)data;
2020 if (!mpe->prio_args)
2023 return snprintf(buff, len, "\"%s\"", mpe->prio_args);
2027 snprint_mp_reservation_key (char * buff, int len, void * data)
2030 unsigned char *keyp;
2032 struct mpentry * mpe = (struct mpentry *)data;
2034 if (!mpe->reservation_key)
2036 keyp = (unsigned char *)mpe->reservation_key;
2037 for (i = 0; i < 8; i++) {
2044 return snprintf(buff, len, "0x%" PRIx64, prkey);
2048 snprint_mp_user_friendly_names (char * buff, int len, void * data)
2050 struct mpentry * mpe = (struct mpentry *)data;
2052 if (mpe->user_friendly_names == USER_FRIENDLY_NAMES_UNDEF)
2054 else if (mpe->user_friendly_names == USER_FRIENDLY_NAMES_OFF)
2055 return snprintf(buff, len, "\"no\"");
2057 return snprintf(buff, len, "\"yes\"");
2061 snprint_hw_fast_io_fail(char * buff, int len, void * data)
2063 struct hwentry * hwe = (struct hwentry *)data;
2064 if (hwe->fast_io_fail == MP_FAST_IO_FAIL_UNSET)
2066 if (hwe->fast_io_fail == conf->fast_io_fail)
2068 if (hwe->fast_io_fail == MP_FAST_IO_FAIL_OFF)
2069 return snprintf(buff, len, "\"off\"");
2070 if (hwe->fast_io_fail == MP_FAST_IO_FAIL_ZERO)
2071 return snprintf(buff, len, "0");
2072 return snprintf(buff, len, "%d", hwe->fast_io_fail);
2076 snprint_hw_dev_loss(char * buff, int len, void * data)
2078 struct hwentry * hwe = (struct hwentry *)data;
2081 if (hwe->dev_loss == conf->dev_loss)
2083 if (hwe->dev_loss >= MAX_DEV_LOSS_TMO)
2084 return snprintf(buff, len, "\"infinity\"");
2086 return snprintf(buff, len, "%u", hwe->dev_loss);
2090 snprint_hw_vendor (char * buff, int len, void * data)
2092 struct hwentry * hwe = (struct hwentry *)data;
2097 return snprintf(buff, len, "\"%s\"", hwe->vendor);
2101 snprint_hw_product (char * buff, int len, void * data)
2103 struct hwentry * hwe = (struct hwentry *)data;
2108 return snprintf(buff, len, "\"%s\"", hwe->product);
2112 snprint_hw_revision (char * buff, int len, void * data)
2114 struct hwentry * hwe = (struct hwentry *)data;
2119 return snprintf(buff, len, "\"%s\"", hwe->revision);
2123 snprint_hw_bl_product (char * buff, int len, void * data)
2125 struct hwentry * hwe = (struct hwentry *)data;
2127 if (!hwe->bl_product)
2130 return snprintf(buff, len, "\"%s\"", hwe->bl_product);
2134 snprint_hw_uid_attribute (char * buff, int len, void * data)
2136 struct hwentry * hwe = (struct hwentry *)data;
2138 if (!hwe->uid_attribute)
2141 return snprintf(buff, len, "\"%s\"", hwe->uid_attribute);
2145 snprint_hw_getuid_callout (char * buff, int len, void * data)
2147 struct hwentry * hwe = (struct hwentry *)data;
2152 return snprintf(buff, len, "\"%s\"", hwe->getuid);
2156 snprint_hw_prio (char * buff, int len, void * data)
2158 struct hwentry * hwe = (struct hwentry *)data;
2160 if (!hwe->prio_name)
2163 return snprintf(buff, len, "\"%s\"", hwe->prio_name);
2167 snprint_hw_alias_prefix (char * buff, int len, void * data)
2169 struct hwentry * hwe = (struct hwentry *)data;
2171 if (!hwe->alias_prefix)
2174 return snprintf(buff, len, "\"%s\"", hwe->alias_prefix);
2178 snprint_hw_prio_args (char * buff, int len, void * data)
2180 struct hwentry * hwe = (struct hwentry *)data;
2182 if (!hwe->prio_args)
2185 return snprintf(buff, len, "\"%s\"", hwe->prio_args);
2189 snprint_hw_features (char * buff, int len, void * data)
2191 struct hwentry * hwe = (struct hwentry *)data;
2196 return snprintf(buff, len, "\"%s\"", hwe->features);
2200 snprint_hw_hardware_handler (char * buff, int len, void * data)
2202 struct hwentry * hwe = (struct hwentry *)data;
2204 if (!hwe->hwhandler)
2207 return snprintf(buff, len, "\"%s\"", hwe->hwhandler);
2211 snprint_hw_selector (char * buff, int len, void * data)
2213 struct hwentry * hwe = (struct hwentry *)data;
2218 return snprintf(buff, len, "\"%s\"", hwe->selector);
2222 snprint_hw_path_grouping_policy (char * buff, int len, void * data)
2224 struct hwentry * hwe = (struct hwentry *)data;
2226 char str[POLICY_NAME_SIZE];
2231 get_pgpolicy_name(str, POLICY_NAME_SIZE, hwe->pgpolicy);
2233 return snprintf(buff, len, "\"%s\"", str);
2237 snprint_hw_failback (char * buff, int len, void * data)
2239 struct hwentry * hwe = (struct hwentry *)data;
2241 if (!hwe->pgfailback)
2244 switch(hwe->pgfailback) {
2245 case FAILBACK_UNDEF:
2247 case -FAILBACK_MANUAL:
2248 return snprintf(buff, len, "\"manual\"");
2249 case -FAILBACK_IMMEDIATE:
2250 return snprintf(buff, len, "\"immediate\"");
2251 case -FAILBACK_FOLLOWOVER:
2252 return snprintf(buff, len, "\"followover\"");
2254 return snprintf(buff, len, "%i", hwe->pgfailback);
2260 snprint_hw_rr_weight (char * buff, int len, void * data)
2262 struct hwentry * hwe = (struct hwentry *)data;
2264 if (!hwe->rr_weight)
2266 if (hwe->rr_weight == RR_WEIGHT_PRIO)
2267 return snprintf(buff, len, "\"priorities\"");
2268 if (hwe->rr_weight == RR_WEIGHT_NONE)
2269 return snprintf(buff, len, "\"uniform\"");
2275 snprint_hw_no_path_retry (char * buff, int len, void * data)
2277 struct hwentry * hwe = (struct hwentry *)data;
2279 if (!hwe->no_path_retry)
2282 switch(hwe->no_path_retry) {
2283 case NO_PATH_RETRY_UNDEF:
2285 case NO_PATH_RETRY_FAIL:
2286 return snprintf(buff, len, "\"fail\"");
2287 case NO_PATH_RETRY_QUEUE:
2288 return snprintf(buff, len, "\"queue\"");
2290 return snprintf(buff, len, "%i",
2291 hwe->no_path_retry);
2297 snprint_hw_rr_min_io (char * buff, int len, void * data)
2299 struct hwentry * hwe = (struct hwentry *)data;
2304 return snprintf(buff, len, "%u", hwe->minio);
2308 snprint_hw_rr_min_io_rq (char * buff, int len, void * data)
2310 struct hwentry * hwe = (struct hwentry *)data;
2315 return snprintf(buff, len, "%u", hwe->minio_rq);
2319 snprint_hw_pg_timeout (char * buff, int len, void * data)
2325 snprint_hw_flush_on_last_del (char * buff, int len, void * data)
2327 struct hwentry * hwe = (struct hwentry *)data;
2329 switch (hwe->flush_on_last_del) {
2330 case FLUSH_DISABLED:
2331 return snprintf(buff, len, "\"no\"");
2333 return snprintf(buff, len, "\"yes\"");
2339 snprint_hw_path_checker (char * buff, int len, void * data)
2341 struct hwentry * hwe = (struct hwentry *)data;
2343 if (!hwe->checker_name)
2346 return snprintf(buff, len, "\"%s\"", hwe->checker_name);
2350 snprint_hw_user_friendly_names (char * buff, int len, void * data)
2352 struct hwentry * hwe = (struct hwentry *)data;
2354 if (hwe->user_friendly_names == USER_FRIENDLY_NAMES_UNDEF)
2356 else if (hwe->user_friendly_names == USER_FRIENDLY_NAMES_OFF)
2357 return snprintf(buff, len, "\"no\"");
2359 return snprintf(buff, len, "\"yes\"");
2363 snprint_hw_retain_hwhandler_handler(char * buff, int len, void * data)
2365 struct hwentry * hwe = (struct hwentry *)data;
2367 if (hwe->retain_hwhandler == RETAIN_HWHANDLER_ON)
2368 return snprintf(buff, len, "\"yes\"");
2369 else if (hwe->retain_hwhandler == RETAIN_HWHANDLER_OFF)
2370 return snprintf(buff, len, "\"no\"");
2376 snprint_detect_prio(char * buff, int len, void * data)
2378 struct hwentry * hwe = (struct hwentry *)data;
2380 if (hwe->detect_prio == DETECT_PRIO_ON)
2381 return snprintf(buff, len, "\"yes\"");
2382 else if (hwe->detect_prio == DETECT_PRIO_OFF)
2383 return snprintf(buff, len, "\"no\"");
2389 snprint_def_polling_interval (char * buff, int len, void * data)
2391 return snprintf(buff, len, "%i", conf->checkint);
2395 snprint_def_fast_io_fail(char * buff, int len, void * data)
2397 if (conf->fast_io_fail == MP_FAST_IO_FAIL_UNSET)
2399 if (conf->fast_io_fail == MP_FAST_IO_FAIL_OFF)
2400 return snprintf(buff, len, "\"off\"");
2401 if (conf->fast_io_fail == MP_FAST_IO_FAIL_ZERO)
2402 return snprintf(buff, len, "0");
2403 return snprintf(buff, len, "%d", conf->fast_io_fail);
2407 snprint_def_dev_loss(char * buff, int len, void * data)
2409 if (!conf->dev_loss)
2411 if (conf->dev_loss >= MAX_DEV_LOSS_TMO)
2412 return snprintf(buff, len, "\"infinity\"");
2413 return snprintf(buff, len, "%u", conf->dev_loss);
2417 snprint_def_verbosity (char * buff, int len, void * data)
2419 return snprintf(buff, len, "%i", conf->verbosity);
2423 snprint_def_max_polling_interval (char * buff, int len, void * data)
2425 if (conf->max_checkint == MAX_CHECKINT(conf->checkint))
2427 return snprintf(buff, len, "%i", conf->max_checkint);
2431 snprint_reassign_maps (char * buff, int len, void * data)
2433 if (conf->reassign_maps == DEFAULT_REASSIGN_MAPS)
2435 return snprintf(buff, len, "\"%s\"",
2436 conf->reassign_maps?"yes":"no");
2440 snprint_def_multipath_dir (char * buff, int len, void * data)
2442 if (!conf->multipath_dir)
2445 return snprintf(buff, len, "\"%s\"", conf->multipath_dir);
2449 snprint_def_selector (char * buff, int len, void * data)
2451 if (!conf->selector)
2452 return snprintf(buff, len, "\"%s\"", DEFAULT_SELECTOR);
2454 return snprintf(buff, len, "\"%s\"", conf->selector);
2458 snprint_def_path_grouping_policy (char * buff, int len, void * data)
2460 char str[POLICY_NAME_SIZE];
2461 int pgpolicy = conf->pgpolicy;
2464 pgpolicy = DEFAULT_PGPOLICY;
2466 get_pgpolicy_name(str, POLICY_NAME_SIZE, pgpolicy);
2468 return snprintf(buff, len, "\"%s\"", str);
2472 snprint_def_uid_attribute (char * buff, int len, void * data)
2474 if (!conf->uid_attribute)
2475 return snprintf(buff, len, "\"%s\"", DEFAULT_UID_ATTRIBUTE);
2477 return snprintf(buff, len, "\"%s\"", conf->uid_attribute);
2481 snprint_def_getuid_callout (char * buff, int len, void * data)
2486 return snprintf(buff, len, "\"%s\"", conf->getuid);
2490 snprint_def_prio (char * buff, int len, void * data)
2492 if (!conf->prio_name)
2493 return snprintf(buff, len, "\"%s\"", DEFAULT_PRIO);
2495 return snprintf(buff, len, "\"%s\"", conf->prio_name);
2499 snprint_def_prio_args (char * buff, int len, void * data)
2501 if (!conf->prio_args)
2502 return snprintf(buff, len, "\"%s\"", DEFAULT_PRIO_ARGS);
2504 return snprintf(buff, len, "\"%s\"", conf->prio_args);
2508 snprint_def_features (char * buff, int len, void * data)
2510 if (!conf->features)
2511 return snprintf(buff, len, "\"%s\"", DEFAULT_FEATURES);
2513 return snprintf(buff, len, "\"%s\"", conf->features);
2517 snprint_def_path_checker (char * buff, int len, void * data)
2519 if (!conf->checker_name)
2520 return snprintf(buff, len, "\"%s\"", DEFAULT_CHECKER);
2522 return snprintf(buff, len, "\"%s\"", conf->checker_name);
2526 snprint_def_failback (char * buff, int len, void * data)
2528 int pgfailback = conf->pgfailback;
2530 pgfailback = DEFAULT_FAILBACK;
2532 switch(conf->pgfailback) {
2533 case FAILBACK_UNDEF:
2535 case -FAILBACK_MANUAL:
2536 return snprintf(buff, len, "\"manual\"");
2537 case -FAILBACK_IMMEDIATE:
2538 return snprintf(buff, len, "\"immediate\"");
2539 case -FAILBACK_FOLLOWOVER:
2540 return snprintf(buff, len, "\"followover\"");
2542 return snprintf(buff, len, "%i", conf->pgfailback);
2548 snprint_def_rr_min_io (char * buff, int len, void * data)
2553 return snprintf(buff, len, "%u", conf->minio);
2557 snprint_def_rr_min_io_rq (char * buff, int len, void * data)
2559 if (!conf->minio_rq)
2562 return snprintf(buff, len, "%u", conf->minio_rq);
2566 snprint_max_fds (char * buff, int len, void * data)
2573 r = get_sys_max_fds(&max_fds);
2574 if (!r && max_fds == conf->max_fds)
2575 return snprintf(buff, len, "\"max\"");
2577 return snprintf(buff, len, "%d", conf->max_fds);
2581 snprint_def_mode(char * buff, int len, void * data)
2583 if ((conf->attribute_flags & (1 << ATTR_MODE)) == 0)
2585 return snprintf(buff, len, "0%o", conf->mode);
2589 snprint_def_uid(char * buff, int len, void * data)
2591 if ((conf->attribute_flags & (1 << ATTR_UID)) == 0)
2593 return snprintf(buff, len, "0%o", conf->uid);
2597 snprint_def_gid(char * buff, int len, void * data)
2599 if ((conf->attribute_flags & (1 << ATTR_GID)) == 0)
2601 return snprintf(buff, len, "0%o", conf->gid);
2605 snprint_def_rr_weight (char * buff, int len, void * data)
2607 if (!conf->rr_weight || conf->rr_weight == RR_WEIGHT_NONE)
2608 return snprintf(buff, len, "\"uniform\"");
2609 if (conf->rr_weight == RR_WEIGHT_PRIO)
2610 return snprintf(buff, len, "\"priorities\"");
2616 snprint_def_no_path_retry (char * buff, int len, void * data)
2618 switch(conf->no_path_retry) {
2619 case NO_PATH_RETRY_UNDEF:
2621 case NO_PATH_RETRY_FAIL:
2622 return snprintf(buff, len, "\"fail\"");
2623 case NO_PATH_RETRY_QUEUE:
2624 return snprintf(buff, len, "\"queue\"");
2626 return snprintf(buff, len, "%i",
2627 conf->no_path_retry);
2633 snprint_def_queue_without_daemon (char * buff, int len, void * data)
2635 switch (conf->queue_without_daemon) {
2636 case QUE_NO_DAEMON_OFF:
2637 return snprintf(buff, len, "\"no\"");
2638 case QUE_NO_DAEMON_ON:
2639 return snprintf(buff, len, "\"yes\"");
2640 case QUE_NO_DAEMON_FORCE:
2641 return snprintf(buff, len, "\"forced\"");
2647 snprint_def_checker_timeout (char *buff, int len, void *data)
2649 if (!conf->checker_timeout)
2652 return snprintf(buff, len, "%u", conf->checker_timeout);
2656 snprint_def_pg_timeout (char * buff, int len, void * data)
2662 snprint_def_flush_on_last_del (char * buff, int len, void * data)
2664 switch (conf->flush_on_last_del) {
2666 case FLUSH_DISABLED:
2667 return snprintf(buff, len, "\"no\"");
2669 case FLUSH_IN_PROGRESS:
2670 return snprintf(buff, len, "\"yes\"");
2676 snprint_def_log_checker_err (char * buff, int len, void * data)
2678 if (conf->log_checker_err == LOG_CHKR_ERR_ONCE)
2679 return snprintf(buff, len, "once");
2680 return snprintf(buff, len, "always");
2684 snprint_def_user_friendly_names (char * buff, int len, void * data)
2686 if (conf->user_friendly_names == USER_FRIENDLY_NAMES_ON)
2687 return snprintf(buff, len, "\"yes\"");
2689 return snprintf(buff, len, "\"no\"");
2693 snprint_def_alias_prefix (char * buff, int len, void * data)
2695 if (!conf->alias_prefix)
2696 return snprintf(buff, len, "\"%s\"", DEFAULT_ALIAS_PREFIX);
2697 return snprintf(buff, len, "\"%s\"", conf->alias_prefix);
2701 snprint_def_bindings_file (char * buff, int len, void * data)
2703 if (conf->bindings_file == NULL)
2705 return snprintf(buff, len, "\"%s\"", conf->bindings_file);
2709 snprint_def_wwids_file (char * buff, int len, void * data)
2711 if (conf->wwids_file == NULL)
2713 return snprintf(buff, len, "%s", conf->wwids_file);
2717 snprint_def_reservation_key(char * buff, int len, void * data)
2720 unsigned char *keyp;
2723 if (!conf->reservation_key)
2725 keyp = (unsigned char *)conf->reservation_key;
2726 for (i = 0; i < 8; i++) {
2732 return snprintf(buff, len, "0x%" PRIx64, prkey);
2736 snprint_def_retain_hwhandler_handler(char * buff, int len, void * data)
2738 if (conf->retain_hwhandler == RETAIN_HWHANDLER_ON)
2739 return snprintf(buff, len, "yes");
2741 return snprintf(buff, len, "no");
2745 snprint_def_detect_prio(char * buff, int len, void * data)
2747 if (conf->detect_prio == DETECT_PRIO_ON)
2748 return snprintf(buff, len, "yes");
2750 return snprintf(buff, len, "no");
2754 snprint_ble_simple (char * buff, int len, void * data)
2756 struct blentry * ble = (struct blentry *)data;
2758 return snprintf(buff, len, "\"%s\"", ble->str);
2762 snprint_bled_vendor (char * buff, int len, void * data)
2764 struct blentry_device * bled = (struct blentry_device *)data;
2766 return snprintf(buff, len, "\"%s\"", bled->vendor);
2770 snprint_bled_product (char * buff, int len, void * data)
2772 struct blentry_device * bled = (struct blentry_device *)data;
2774 return snprintf(buff, len, "\"%s\"", bled->product);
2777 #define __deprecated
2782 install_keyword_root("defaults", NULL);
2783 install_keyword("verbosity", &verbosity_handler, &snprint_def_verbosity);
2784 install_keyword("polling_interval", &polling_interval_handler, &snprint_def_polling_interval);
2785 install_keyword("max_polling_interval", &max_polling_interval_handler, &snprint_def_max_polling_interval);
2786 install_keyword("reassign_maps", &reassign_maps_handler, &snprint_reassign_maps);
2787 install_keyword("multipath_dir", &multipath_dir_handler, &snprint_def_multipath_dir);
2788 install_keyword("path_selector", &def_selector_handler, &snprint_def_selector);
2789 install_keyword("path_grouping_policy", &def_pgpolicy_handler, &snprint_def_path_grouping_policy);
2790 install_keyword("uid_attribute", &def_uid_attribute_handler, &snprint_def_uid_attribute);
2791 install_keyword("getuid_callout", &def_getuid_callout_handler, &snprint_def_getuid_callout);
2792 install_keyword("prio", &def_prio_handler, &snprint_def_prio);
2793 install_keyword("prio_args", &def_prio_args_handler, &snprint_def_prio_args);
2794 install_keyword("features", &def_features_handler, &snprint_def_features);
2795 install_keyword("path_checker", &def_path_checker_handler, &snprint_def_path_checker);
2796 install_keyword("checker", &def_path_checker_handler, NULL);
2797 install_keyword("alias_prefix", &def_alias_prefix_handler, &snprint_def_alias_prefix);
2798 install_keyword("failback", &default_failback_handler, &snprint_def_failback);
2799 install_keyword("rr_min_io", &def_minio_handler, &snprint_def_rr_min_io);
2800 install_keyword("rr_min_io_rq", &def_minio_rq_handler, &snprint_def_rr_min_io_rq);
2801 install_keyword("max_fds", &max_fds_handler, &snprint_max_fds);
2802 install_keyword("rr_weight", &def_weight_handler, &snprint_def_rr_weight);
2803 install_keyword("no_path_retry", &def_no_path_retry_handler, &snprint_def_no_path_retry);
2804 install_keyword("queue_without_daemon", &def_queue_without_daemon, &snprint_def_queue_without_daemon);
2805 install_keyword("checker_timeout", &def_checker_timeout_handler, &snprint_def_checker_timeout);
2806 install_keyword("pg_timeout", &def_pg_timeout_handler, &snprint_def_pg_timeout);
2807 install_keyword("flush_on_last_del", &def_flush_on_last_del_handler, &snprint_def_flush_on_last_del);
2808 install_keyword("user_friendly_names", &def_names_handler, &snprint_def_user_friendly_names);
2809 install_keyword("mode", &def_mode_handler, &snprint_def_mode);
2810 install_keyword("uid", &def_uid_handler, &snprint_def_uid);
2811 install_keyword("gid", &def_gid_handler, &snprint_def_gid);
2812 install_keyword("fast_io_fail_tmo", &def_fast_io_fail_handler, &snprint_def_fast_io_fail);
2813 install_keyword("dev_loss_tmo", &def_dev_loss_handler, &snprint_def_dev_loss);
2814 install_keyword("bindings_file", &bindings_file_handler, &snprint_def_bindings_file);
2815 install_keyword("wwids_file", &wwids_file_handler, &snprint_def_wwids_file);
2816 install_keyword("log_checker_err", &def_log_checker_err_handler, &snprint_def_log_checker_err);
2817 install_keyword("reservation_key", &def_reservation_key_handler, &snprint_def_reservation_key);
2818 install_keyword("retain_attached_hw_handler", &def_retain_hwhandler_handler, &snprint_def_retain_hwhandler_handler);
2819 install_keyword("detect_prio", &def_detect_prio_handler, &snprint_def_detect_prio);
2820 __deprecated install_keyword("default_selector", &def_selector_handler, NULL);
2821 __deprecated install_keyword("default_path_grouping_policy", &def_pgpolicy_handler, NULL);
2822 __deprecated install_keyword("default_uid_attribute", &def_uid_attribute_handler, NULL);
2823 __deprecated install_keyword("default_getuid_callout", &def_getuid_callout_handler, NULL);
2824 __deprecated install_keyword("default_features", &def_features_handler, NULL);
2825 __deprecated install_keyword("default_path_checker", &def_path_checker_handler, NULL);
2827 install_keyword_root("blacklist", &blacklist_handler);
2828 install_keyword_multi("devnode", &ble_devnode_handler, &snprint_ble_simple);
2829 install_keyword_multi("wwid", &ble_wwid_handler, &snprint_ble_simple);
2830 install_keyword_multi("device", &ble_device_handler, NULL);
2832 install_keyword("vendor", &ble_vendor_handler, &snprint_bled_vendor);
2833 install_keyword("product", &ble_product_handler, &snprint_bled_product);
2834 install_sublevel_end();
2835 install_keyword_root("blacklist_exceptions", &blacklist_exceptions_handler);
2836 install_keyword_multi("devnode", &ble_except_devnode_handler, &snprint_ble_simple);
2837 install_keyword_multi("wwid", &ble_except_wwid_handler, &snprint_ble_simple);
2838 install_keyword_multi("device", &ble_except_device_handler, NULL);
2840 install_keyword("vendor", &ble_except_vendor_handler, &snprint_bled_vendor);
2841 install_keyword("product", &ble_except_product_handler, &snprint_bled_product);
2842 install_sublevel_end();
2845 __deprecated install_keyword_root("devnode_blacklist", &blacklist_handler);
2846 __deprecated install_keyword("devnode", &ble_devnode_handler, &snprint_ble_simple);
2847 __deprecated install_keyword("wwid", &ble_wwid_handler, &snprint_ble_simple);
2848 __deprecated install_keyword("device", &ble_device_handler, NULL);
2849 __deprecated install_sublevel();
2850 __deprecated install_keyword("vendor", &ble_vendor_handler, &snprint_bled_vendor);
2851 __deprecated install_keyword("product", &ble_product_handler, &snprint_bled_product);
2852 __deprecated install_sublevel_end();
2855 install_keyword_root("devices", &devices_handler);
2856 install_keyword_multi("device", &device_handler, NULL);
2858 install_keyword("vendor", &vendor_handler, &snprint_hw_vendor);
2859 install_keyword("product", &product_handler, &snprint_hw_product);
2860 install_keyword("revision", &revision_handler, &snprint_hw_revision);
2861 install_keyword("product_blacklist", &bl_product_handler, &snprint_hw_bl_product);
2862 install_keyword("path_grouping_policy", &hw_pgpolicy_handler, &snprint_hw_path_grouping_policy);
2863 install_keyword("uid_attribute", &hw_uid_attribute_handler, &snprint_hw_uid_attribute);
2864 install_keyword("getuid_callout", &hw_getuid_callout_handler, &snprint_hw_getuid_callout);
2865 install_keyword("path_selector", &hw_selector_handler, &snprint_hw_selector);
2866 install_keyword("path_checker", &hw_path_checker_handler, &snprint_hw_path_checker);
2867 install_keyword("checker", &hw_path_checker_handler, NULL);
2868 install_keyword("alias_prefix", &hw_alias_prefix_handler, &snprint_hw_alias_prefix);
2869 install_keyword("features", &hw_features_handler, &snprint_hw_features);
2870 install_keyword("hardware_handler", &hw_handler_handler, &snprint_hw_hardware_handler);
2871 install_keyword("prio", &hw_prio_handler, &snprint_hw_prio);
2872 install_keyword("prio_args", &hw_prio_args_handler, &snprint_hw_prio_args);
2873 install_keyword("failback", &hw_failback_handler, &snprint_hw_failback);
2874 install_keyword("rr_weight", &hw_weight_handler, &snprint_hw_rr_weight);
2875 install_keyword("no_path_retry", &hw_no_path_retry_handler, &snprint_hw_no_path_retry);
2876 install_keyword("rr_min_io", &hw_minio_handler, &snprint_hw_rr_min_io);
2877 install_keyword("rr_min_io_rq", &hw_minio_rq_handler, &snprint_hw_rr_min_io_rq);
2878 install_keyword("pg_timeout", &hw_pg_timeout_handler, &snprint_hw_pg_timeout);
2879 install_keyword("flush_on_last_del", &hw_flush_on_last_del_handler, &snprint_hw_flush_on_last_del);
2880 install_keyword("fast_io_fail_tmo", &hw_fast_io_fail_handler, &snprint_hw_fast_io_fail);
2881 install_keyword("dev_loss_tmo", &hw_dev_loss_handler, &snprint_hw_dev_loss);
2882 install_keyword("user_friendly_names", &hw_names_handler, &snprint_hw_user_friendly_names);
2883 install_keyword("retain_attached_hw_handler", &hw_retain_hwhandler_handler, &snprint_hw_retain_hwhandler_handler);
2884 install_keyword("detect_prio", &hw_detect_prio_handler, &snprint_detect_prio);
2885 install_sublevel_end();
2887 install_keyword_root("multipaths", &multipaths_handler);
2888 install_keyword_multi("multipath", &multipath_handler, NULL);
2890 install_keyword("wwid", &wwid_handler, &snprint_mp_wwid);
2891 install_keyword("alias", &alias_handler, &snprint_mp_alias);
2892 install_keyword("path_grouping_policy", &mp_pgpolicy_handler, &snprint_mp_path_grouping_policy);
2893 install_keyword("path_selector", &mp_selector_handler, &snprint_mp_selector);
2894 install_keyword("prio", &mp_prio_handler, &snprint_mp_prio);
2895 install_keyword("prio_args", &mp_prio_args_handler, &snprint_mp_prio_args);
2896 install_keyword("failback", &mp_failback_handler, &snprint_mp_failback);
2897 install_keyword("rr_weight", &mp_weight_handler, &snprint_mp_rr_weight);
2898 install_keyword("no_path_retry", &mp_no_path_retry_handler, &snprint_mp_no_path_retry);
2899 install_keyword("rr_min_io", &mp_minio_handler, &snprint_mp_rr_min_io);
2900 install_keyword("rr_min_io_rq", &mp_minio_rq_handler, &snprint_mp_rr_min_io_rq);
2901 install_keyword("pg_timeout", &mp_pg_timeout_handler, &snprint_mp_pg_timeout);
2902 install_keyword("flush_on_last_del", &mp_flush_on_last_del_handler, &snprint_mp_flush_on_last_del);
2903 install_keyword("features", &mp_features_handler, &snprint_mp_features);
2904 install_keyword("mode", &mp_mode_handler, &snprint_mp_mode);
2905 install_keyword("uid", &mp_uid_handler, &snprint_mp_uid);
2906 install_keyword("gid", &mp_gid_handler, &snprint_mp_gid);
2907 install_keyword("reservation_key", &mp_reservation_key_handler, &snprint_mp_reservation_key);
2908 install_keyword("user_friendly_names", &mp_names_handler, &snprint_mp_user_friendly_names);
2909 install_sublevel_end();