Implement 'bindings_file' option
authorHannes Reinecke <hare@suse.de>
Wed, 23 Jul 2008 08:42:16 +0000 (10:42 +0200)
committerHannes Reinecke <hare@suse.de>
Fri, 13 May 2011 08:11:53 +0000 (10:11 +0200)
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 <hare@suse.de>
libmultipath/config.c
libmultipath/dict.c
multipath.conf.annotated
multipath/multipath.conf.5

index b217449..0fcd58d 100644 (file)
@@ -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;
index fb3032a..8a5813c 100644 (file)
@@ -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
  */
@@ -2300,6 +2311,18 @@ snprint_def_alias_prefix (char * buff, int len, void * data)
 }
 
 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)
 {
        struct blentry * ble = (struct blentry *)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);
index 19bdd48..d97b95e 100644 (file)
 #      # 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  : <full_pathname>
+#      # default : "/var/lib/multipath/bindings"
+#      bindings_file "/etc/multipath_bindings"
+#
 #}
 #      
 ##
index cfc67fd..0fa0d31 100644 (file)
@@ -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