From: Hannes Reinecke Date: Wed, 23 Jul 2008 08:42:16 +0000 (+0200) Subject: Implement 'bindings_file' option X-Git-Tag: upstream/0.5.0~106^2~48 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ee20f6da62a84f2637aca267098b2c296eaf1642;p=platform%2Fupstream%2Fmultipath-tools.git Implement 'bindings_file' option Early in boot /var might not be accessible, so this patch implements a 'bindings_file' option which allows to place the persisting bindings file at a different location. Signed-off-by: Hannes Reinecke --- diff --git a/libmultipath/config.c b/libmultipath/config.c index b217449..0fcd58d 100644 --- a/libmultipath/config.c +++ b/libmultipath/config.c @@ -441,6 +441,9 @@ free_config (struct config * conf) if (conf->hwhandler) FREE(conf->hwhandler); + if (conf->bindings_file) + FREE(conf->bindings_file); + if (conf->prio_name) FREE(conf->prio_name); @@ -487,7 +490,7 @@ load_config (char * file) conf->minio = DEFAULT_MINIO; conf->minio_rq = DEFAULT_MINIO_RQ; conf->max_fds = 0; - conf->bindings_file = DEFAULT_BINDINGS_FILE; + conf->bindings_file = set_default(DEFAULT_BINDINGS_FILE); conf->bindings_read_only = 0; conf->multipath_dir = set_default(DEFAULT_MULTIPATHDIR); conf->flush_on_last_del = 0; @@ -581,7 +584,11 @@ load_config (char * file) if (conf->udev_dir == NULL) conf->udev_dir = set_default(DEFAULT_UDEVDIR); - if (!conf->udev_dir || !conf->multipath_dir) + if (conf->bindings_file == NULL) + conf->bindings_file = set_default(DEFAULT_BINDINGS_FILE); + + if (!conf->udev_dir || !conf->multipath_dir || + !conf->bindings_file) goto out; return 0; diff --git a/libmultipath/dict.c b/libmultipath/dict.c index fb3032a..8a5813c 100644 --- a/libmultipath/dict.c +++ b/libmultipath/dict.c @@ -524,6 +524,17 @@ names_handler(vector strvec) return 0; } +static int +bindings_file_handler(vector strvec) +{ + conf->bindings_file = set_value(strvec); + + if (!conf->bindings_file) + return 1; + + return 0; +} + /* * blacklist block handlers */ @@ -2299,6 +2310,18 @@ snprint_def_alias_prefix (char * buff, int len, void * data) return snprintf(buff, len, "\"%s\"", conf->alias_prefix); } +static int +snprint_def_bindings_file (char * buff, int len, void * data) +{ + if (conf->bindings_file == NULL) + return 0; + if (strlen(conf->bindings_file) == strlen(DEFAULT_BINDINGS_FILE) && + !strcmp(conf->bindings_file, DEFAULT_BINDINGS_FILE)) + return 0; + + return snprintf(buff, len, "%s", conf->bindings_file); +} + static int snprint_ble_simple (char * buff, int len, void * data) { @@ -2359,6 +2382,7 @@ init_keywords(void) install_keyword("gid", &def_gid_handler, &snprint_def_gid); install_keyword("fast_io_fail_tmo", &def_fast_io_fail_handler, &snprint_def_fast_io_fail); install_keyword("dev_loss_tmo", &def_dev_loss_handler, &snprint_def_dev_loss); + install_keyword("bindings_file", &bindings_file_handler, &snprint_def_bindings_file); __deprecated install_keyword("default_selector", &def_selector_handler, NULL); __deprecated install_keyword("default_path_grouping_policy", &def_pgpolicy_handler, NULL); __deprecated install_keyword("default_getuid_callout", &def_getuid_callout_handler, NULL); diff --git a/multipath.conf.annotated b/multipath.conf.annotated index 19bdd48..d97b95e 100644 --- a/multipath.conf.annotated +++ b/multipath.conf.annotated @@ -238,6 +238,14 @@ # # values : n > 0 # # default : determined by the OS # dev_loss_tmo 600 +# # name : bindings_file +# # scope : multipath +# # desc : The location of the bindings file that is used with +# # the user_friendly_names option. +# # values : +# # default : "/var/lib/multipath/bindings" +# bindings_file "/etc/multipath_bindings" +# #} # ## diff --git a/multipath/multipath.conf.5 b/multipath/multipath.conf.5 index cfc67fd..0fa0d31 100644 --- a/multipath/multipath.conf.5 +++ b/multipath/multipath.conf.5 @@ -298,6 +298,10 @@ cannot be told to stop queueing IO. Setting queue_without_daemon to .I no , avoids this problem. Default is .I yes +.TP +.B bindings_file +The full pathname of the binding file to be used when the user_friendly_names option is set. Defaults to +.I /var/lib/multipath/bindings . .SH "blacklist section" The