2 libmultipath/Makefile | 2
3 libmultipath/alias.c | 152 ------------------------------
4 libmultipath/alias.h | 1
5 libmultipath/config.c | 5 -
6 libmultipath/config.h | 1
7 libmultipath/configure.c | 23 ++++
8 libmultipath/defaults.h | 2
9 libmultipath/dict.c | 34 ++++++
10 libmultipath/file.c | 178 +++++++++++++++++++++++++++++++++++
11 libmultipath/file.h | 11 ++
12 libmultipath/finder.c | 150 ++++++++++++++++++++++++++++++
13 libmultipath/finder.h | 18 +++
14 multipath/Makefile | 2
16 multipath/mpathconf | 234 +++++++++++++++++++++++++++++++++++++++++++++++
17 multipathd/main.c | 27 +++--
18 16 files changed, 679 insertions(+), 163 deletions(-)
20 Index: multipath-tools/libmultipath/alias.c
21 ===================================================================
22 --- multipath-tools.orig/libmultipath/alias.c
23 +++ multipath-tools/libmultipath/alias.c
25 * Copyright (c) 2005 Benjamin Marzinski, Redhat
28 -#include <sys/types.h>
29 -#include <sys/stat.h>
49 -ensure_directories_exist(char *str, mode_t dir_mode)
55 - pathname = strdup(str);
57 - condlog(0, "Cannot copy bindings file pathname : %s",
62 - /* skip leading slashes */
63 - while (end && *end && (*end == '/'))
66 - while ((end = strchr(end, '/'))) {
67 - /* if there is another slash, make the dir. */
69 - err = mkdir(pathname, dir_mode);
70 - if (err && errno != EEXIST) {
71 - condlog(0, "Cannot make directory [%s] : %s",
72 - pathname, strerror(errno));
77 - condlog(3, "Created dir [%s]", pathname);
92 -lock_bindings_file(int fd)
94 - struct sigaction act, oldact;
95 - sigset_t set, oldset;
99 - memset(&lock, 0, sizeof(lock));
100 - lock.l_type = F_WRLCK;
101 - lock.l_whence = SEEK_SET;
103 - act.sa_handler = sigalrm;
104 - sigemptyset(&act.sa_mask);
107 - sigaddset(&set, SIGALRM);
109 - sigaction(SIGALRM, &act, &oldact);
110 - sigprocmask(SIG_UNBLOCK, &set, &oldset);
112 - alarm(BINDINGS_FILE_TIMEOUT);
113 - err = fcntl(fd, F_SETLKW, &lock);
117 - if (errno != EINTR)
118 - condlog(0, "Cannot lock bindings file : %s",
121 - condlog(0, "Bindings file is locked. Giving up.");
124 - sigprocmask(SIG_SETMASK, &oldset, NULL);
125 - sigaction(SIGALRM, &oldact, NULL);
132 -open_bindings_file(char *file, int *can_write)
137 - if (ensure_directories_exist(file, 0700))
140 - fd = open(file, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
142 - if (errno == EROFS) {
144 - condlog(3, "Cannot open bindings file [%s] read/write. "
145 - " trying readonly", file);
146 - fd = open(file, O_RDONLY);
148 - condlog(0, "Cannot open bindings file [%s] "
149 - "readonly : %s", file, strerror(errno));
154 - condlog(0, "Cannot open bindings file [%s] : %s", file,
159 - if (*can_write && lock_bindings_file(fd) < 0)
162 - memset(&s, 0, sizeof(s));
163 - if (fstat(fd, &s) < 0){
164 - condlog(0, "Cannot stat bindings file : %s", strerror(errno));
167 - if (s.st_size == 0) {
168 - if (*can_write == 0)
170 - /* If bindings file is empty, write the header */
171 - size_t len = strlen(BINDINGS_FILE_HEADER);
172 - if (write_all(fd, BINDINGS_FILE_HEADER, len) != len) {
174 - "Cannot write header to bindings file : %s",
176 - /* cleanup partially written header */
181 - condlog(3, "Initialized new bindings file [%s]", file);
192 format_devname(char *name, int id, int len)
195 @@ -364,7 +218,7 @@ get_user_friendly_alias(char *wwid, char
199 - fd = open_bindings_file(file, &can_write);
200 + fd = open_file(file, &can_write, BINDINGS_FILE_HEADER);
204 @@ -414,7 +268,7 @@ get_user_friendly_wwid(char *alias, char
208 - fd = open_bindings_file(file, &unused);
209 + fd = open_file(file, &unused, BINDINGS_FILE_HEADER);
213 Index: multipath-tools/libmultipath/alias.h
214 ===================================================================
215 --- multipath-tools.orig/libmultipath/alias.h
216 +++ multipath-tools/libmultipath/alias.h
218 -#define BINDINGS_FILE_TIMEOUT 30
219 #define BINDINGS_FILE_HEADER \
220 "# Multipath bindings, Version : 1.0\n" \
221 "# NOTE: this file is automatically maintained by the multipath program.\n" \
222 Index: multipath-tools/libmultipath/config.c
223 ===================================================================
224 --- multipath-tools.orig/libmultipath/config.c
225 +++ multipath-tools/libmultipath/config.c
226 @@ -452,6 +452,7 @@ load_config (char * file)
227 conf->multipath_dir = set_default(DEFAULT_MULTIPATHDIR);
228 conf->flush_on_last_del = 0;
229 conf->attribute_flags = 0;
230 + conf->find_multipaths = DEFAULT_FIND_MULTIPATHS;
233 * preload default hwtable
234 @@ -476,10 +477,12 @@ load_config (char * file)
237 condlog(0, "/etc/multipath.conf does not exist, blacklisting all devices.");
238 - condlog(0, "A default multipath.conf file is located at");
239 + condlog(0, "A sample multipath.conf file is located at");
241 "/usr/share/doc/device-mapper-multipath-%d.%d.%d/multipath.conf",
242 MULTIPATH_VERSION(VERSION_CODE));
244 +"You can run /sbin/mpathconf to create or modify /etc/multipath.conf");
245 conf->blist_devnode = vector_alloc();
246 if (!conf->blist_devnode) {
247 condlog(0, "cannot allocate blacklist\n");
248 Index: multipath-tools/libmultipath/config.h
249 ===================================================================
250 --- multipath-tools.orig/libmultipath/config.h
251 +++ multipath-tools/libmultipath/config.h
252 @@ -85,6 +85,7 @@ struct config {
255 unsigned int dev_loss;
256 + int find_multipaths;
260 Index: multipath-tools/libmultipath/configure.c
261 ===================================================================
262 --- multipath-tools.orig/libmultipath/configure.c
263 +++ multipath-tools/libmultipath/configure.c
271 setup_map (struct multipath * mpp)
272 @@ -462,6 +463,10 @@ coalesce_paths (struct vectors * vecs, v
274 memset(empty_buff, 0, WWID_SIZE);
276 + /* ignore refwwid if it's empty */
277 + if (refwwid && !strlen(refwwid))
281 vector_foreach_slot (pathvec, pp1, k) {
283 @@ -472,21 +477,35 @@ coalesce_paths (struct vectors * vecs, v
285 /* 1. if path has no unique id or wwid blacklisted */
286 if (memcmp(empty_buff, pp1->wwid, WWID_SIZE) == 0 ||
287 - filter_path(conf, pp1) > 0)
288 + filter_path(conf, pp1) > 0) {
293 /* 2. if path already coalesced */
297 /* 3. if path has disappeared */
304 /* 4. path is out of scope */
305 if (refwwid && strncmp(pp1->wwid, refwwid, WWID_SIZE))
308 + /* If find_multipaths was selected check if the path is valid */
309 + if (conf->find_multipaths){
310 + if (refwwid || should_multipath(pp1, pathvec))
311 + remember_wwid(pp1->wwid);
319 * at this point, we know we really got a new mp
321 Index: multipath-tools/libmultipath/defaults.h
322 ===================================================================
323 --- multipath-tools.orig/libmultipath/defaults.h
324 +++ multipath-tools/libmultipath/defaults.h
326 #define DEFAULT_PGTIMEOUT -PGTIMEOUT_NONE
327 #define DEFAULT_USER_FRIENDLY_NAMES 0
328 #define DEFAULT_VERBOSITY 2
329 +#define DEFAULT_FIND_MULTIPATHS 0
331 #define DEFAULT_CHECKINT 5
332 #define MAX_CHECKINT(a) (a << 2)
334 #define DEFAULT_SOCKET "/var/run/multipathd.sock"
335 #define DEFAULT_CONFIGFILE "/etc/multipath.conf"
336 #define DEFAULT_BINDINGS_FILE "/etc/multipath/bindings"
337 +#define DEFAULT_WWIDS_FILE "/etc/multipath/wwids"
339 char * set_default (char * str);
340 Index: multipath-tools/libmultipath/dict.c
341 ===================================================================
342 --- multipath-tools.orig/libmultipath/dict.c
343 +++ multipath-tools/libmultipath/dict.c
344 @@ -444,6 +444,27 @@ def_flush_on_last_del_handler(vector str
348 +def_find_multipaths_handler(vector strvec)
352 + buff = set_value(strvec);
357 + if ((strlen(buff) == 2 && !strcmp(buff, "no")) ||
358 + (strlen(buff) == 1 && !strcmp(buff, "0")))
359 + conf->find_multipaths = 0;
360 + else if ((strlen(buff) == 3 && !strcmp(buff, "yes")) ||
361 + (strlen(buff) == 1 && !strcmp(buff, "1")))
362 + conf->find_multipaths = 1;
369 names_handler(vector strvec)
372 @@ -2076,6 +2097,18 @@ snprint_def_flush_on_last_del (char * bu
376 +snprint_def_find_multipaths (char * buff, int len, void * data)
378 + if (conf->find_multipaths == DEFAULT_FIND_MULTIPATHS)
380 + if (!conf->find_multipaths)
381 + return snprintf(buff, len, "no");
383 + return snprintf(buff, len, "yes");
388 snprint_def_user_friendly_names (char * buff, int len, void * data)
390 if (conf->user_friendly_names == DEFAULT_USER_FRIENDLY_NAMES)
391 @@ -2141,6 +2174,7 @@ init_keywords(void)
392 install_keyword("gid", &def_gid_handler, &snprint_def_gid);
393 install_keyword("fast_io_fail_tmo", &def_fast_io_fail_handler, &snprint_def_fast_io_fail);
394 install_keyword("dev_loss_tmo", &def_dev_loss_handler, &snprint_def_dev_loss);
395 + install_keyword("find_multipaths", &def_find_multipaths_handler, &snprint_def_find_multipaths);
396 __deprecated install_keyword("default_selector", &def_selector_handler, NULL);
397 __deprecated install_keyword("default_path_grouping_policy", &def_pgpolicy_handler, NULL);
398 __deprecated install_keyword("default_getuid_callout", &def_getuid_callout_handler, NULL);
399 Index: multipath-tools/libmultipath/file.c
400 ===================================================================
402 +++ multipath-tools/libmultipath/file.c
405 + * Copyright (c) 2005 Christophe Varoqui
406 + * Copyright (c) 2005 Benjamin Marzinski, Redhat
409 +#include <sys/types.h>
410 +#include <sys/stat.h>
425 + * significant parts of this file were taken from iscsi-bindings.c of the
426 + * linux-iscsi project.
427 + * Copyright (C) 2002 Cisco Systems, Inc.
429 + * This program is free software; you can redistribute it and/or modify
430 + * it under the terms of the GNU General Public License as published
431 + * by the Free Software Foundation; either version 2 of the License, or
432 + * (at your option) any later version.
434 + * This program is distributed in the hope that it will be useful, but
435 + * WITHOUT ANY WARRANTY; without even the implied warranty of
436 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
437 + * General Public License for more details.
439 + * See the file COPYING included with this distribution for more details.
443 +ensure_directories_exist(char *str, mode_t dir_mode)
449 + pathname = strdup(str);
451 + condlog(0, "Cannot copy file pathname %s : %s",
452 + str, strerror(errno));
456 + /* skip leading slashes */
457 + while (end && *end && (*end == '/'))
460 + while ((end = strchr(end, '/'))) {
461 + /* if there is another slash, make the dir. */
463 + err = mkdir(pathname, dir_mode);
464 + if (err && errno != EEXIST) {
465 + condlog(0, "Cannot make directory [%s] : %s",
466 + pathname, strerror(errno));
471 + condlog(3, "Created dir [%s]", pathname);
486 +lock_file(int fd, char *file_name)
488 + struct sigaction act, oldact;
489 + sigset_t set, oldset;
493 + memset(&lock, 0, sizeof(lock));
494 + lock.l_type = F_WRLCK;
495 + lock.l_whence = SEEK_SET;
497 + act.sa_handler = sigalrm;
498 + sigemptyset(&act.sa_mask);
501 + sigaddset(&set, SIGALRM);
503 + sigaction(SIGALRM, &act, &oldact);
504 + sigprocmask(SIG_UNBLOCK, &set, &oldset);
506 + alarm(FILE_TIMEOUT);
507 + err = fcntl(fd, F_SETLKW, &lock);
511 + if (errno != EINTR)
512 + condlog(0, "Cannot lock %s : %s", file_name,
515 + condlog(0, "%s is locked. Giving up.", file_name);
518 + sigprocmask(SIG_SETMASK, &oldset, NULL);
519 + sigaction(SIGALRM, &oldact, NULL);
524 +open_file(char *file, int *can_write, char *header)
529 + if (ensure_directories_exist(file, 0700))
532 + fd = open(file, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
534 + if (errno == EROFS) {
536 + condlog(3, "Cannot open file [%s] read/write. "
537 + " trying readonly", file);
538 + fd = open(file, O_RDONLY);
540 + condlog(0, "Cannot open file [%s] "
541 + "readonly : %s", file, strerror(errno));
546 + condlog(0, "Cannot open file [%s] : %s", file,
551 + if (*can_write && lock_file(fd, file) < 0)
554 + memset(&s, 0, sizeof(s));
555 + if (fstat(fd, &s) < 0){
556 + condlog(0, "Cannot stat file %s : %s", file, strerror(errno));
559 + if (s.st_size == 0) {
560 + if (*can_write == 0)
562 + /* If file is empty, write the header */
563 + size_t len = strlen(header);
564 + if (write_all(fd, header, len) != len) {
566 + "Cannot write header to file %s : %s", file,
568 + /* cleanup partially written header */
573 + condlog(3, "Initialized new file [%s]", file);
582 Index: multipath-tools/libmultipath/file.h
583 ===================================================================
585 +++ multipath-tools/libmultipath/file.h
588 + * Copyright (c) 2010 Benjamin Marzinski, Redhat
594 +#define FILE_TIMEOUT 30
595 +int open_file(char *file, int *can_write, char *header);
597 +#endif /* _FILE_H */
598 Index: multipath-tools/libmultipath/finder.c
599 ===================================================================
601 +++ multipath-tools/libmultipath/finder.c
610 +#include "checkers.h"
612 +#include "structs.h"
617 +#include "defaults.h"
620 + * Copyright (c) 2010 Benjamin Marzinski, Redhat
624 +lookup_wwid(FILE *f, char *wwid) {
625 + char buf[LINE_MAX];
627 + while (fgets(buf, LINE_MAX, f)) {
630 + c = strpbrk(buf, "#\n\r");
635 + if (strncmp(wwid, buf, WWID_SIZE) == 0)
642 +write_out_wwid(int fd, char *wwid) {
645 + char buf[WWID_SIZE + 1];
647 + ret = snprintf(buf, WWID_SIZE + 1, "%s\n", wwid);
648 + if (ret > WWID_SIZE || ret < 0){
649 + condlog(0, "can't format wwid for writing (%d) : %s",
650 + ret, strerror(errno));
653 + offset = lseek(fd, 0, SEEK_END);
655 + condlog(0, "can't seek to the end of wwids file : %s",
659 + if (write_all(fd, buf, strlen(buf)) != strlen(buf)) {
660 + condlog(0, "cannot write wwid to wwids file : %s",
662 + ftruncate(fd, offset);
669 +check_wwids_file(char *wwid, int write_wwid)
671 + int scan_fd, fd, can_write, found, ret;
673 + fd = open_file(DEFAULT_WWIDS_FILE, &can_write, WWIDS_FILE_HEADER);
679 + condlog(0, "can't dup wwids file descriptor : %s",
684 + f = fdopen(scan_fd, "r");
686 + condlog(0,"can't fdopen wwids file : %s", strerror(errno));
691 + found = lookup_wwid(f, wwid);
701 + condlog(0, "wwids file is read-only. Can't write wwid");
705 + ret = write_out_wwid(fd, wwid);
714 +should_multipath(struct path *pp1, vector pathvec)
719 + condlog(4, "checking if %s should be multipathed", pp1->dev);
720 + vector_foreach_slot(pathvec, pp2, i) {
721 + if (pp1->dev == pp2->dev)
723 + if (strncmp(pp1->wwid, pp2->wwid, WWID_SIZE) == 0) {
724 + condlog(3, "found multiple paths with wwid %s, "
725 + "multipathing %s", pp1->wwid, pp1->dev);
729 + if (check_wwids_file(pp1->wwid, 0) < 0) {
730 + condlog(3, "wwid %s not in wwids file, skipping %s",
731 + pp1->wwid, pp1->dev);
734 + condlog(3, "found wwid %s in wwids file, multipathing %s", pp1->wwid,
740 +remember_wwid(char *wwid)
742 + int ret = check_wwids_file(wwid, 1);
744 + condlog(3, "failed writing wwid %s to wwids file", wwid);
748 + condlog(3, "wrote wwid %s to wwids file", wwid);
750 + condlog(4, "wwid %s already in wwids file", wwid);
753 Index: multipath-tools/libmultipath/finder.h
754 ===================================================================
756 +++ multipath-tools/libmultipath/finder.h
759 + * Copyright (c) 2010 Benjamin Marzinski, Redhat
765 +#define WWIDS_FILE_HEADER \
766 +"# Multipath wwids, Version : 1.0\n" \
767 +"# NOTE: This file is automatically maintained by multipath and multipathd.\n" \
768 +"# You should not need to edit this file in normal circumstances.\n" \
772 +int should_multipath(struct path *pp, vector pathvec);
773 +int remember_wwid(char *wwid);
775 +#endif /* _FINDER_H */
776 Index: multipath-tools/multipath/main.c
777 ===================================================================
778 --- multipath-tools.orig/multipath/main.c
779 +++ multipath-tools/multipath/main.c
780 @@ -307,7 +307,7 @@ configure (void)
782 * core logic entry point
784 - r = coalesce_paths(&vecs, NULL, NULL, conf->force_reload);
785 + r = coalesce_paths(&vecs, NULL, refwwid, conf->force_reload);
789 Index: multipath-tools/multipathd/main.c
790 ===================================================================
791 --- multipath-tools.orig/multipathd/main.c
792 +++ multipath-tools/multipathd/main.c
795 #include <configure.h>
801 @@ -397,7 +398,7 @@ ev_add_path (char * devname, struct vect
803 if (memcmp(empty_buff, pp->wwid, WWID_SIZE) == 0) {
804 condlog(0, "%s: failed to get path uid", devname);
805 - return 1; /* leave path added to pathvec */
806 + goto fail; /* leave path added to pathvec */
808 if (filter_path(conf, pp) > 0){
809 int i = find_slot(vecs->pathvec, (void *)pp);
810 @@ -412,18 +413,26 @@ rescan:
811 condlog(4,"%s: adopting all paths for path %s",
812 mpp->alias, pp->dev);
813 if (adopt_paths(vecs->pathvec, mpp))
814 - return 1; /* leave path added to pathvec */
815 + goto fail; /* leave path added to pathvec */
817 verify_paths(mpp, vecs, NULL);
818 mpp->flush_on_last_del = FLUSH_UNDEF;
819 mpp->action = ACT_RELOAD;
822 + if (conf->find_multipaths) {
823 + if (should_multipath(pp, vecs->pathvec))
824 + remember_wwid(pp->wwid);
830 condlog(4,"%s: creating new map", pp->dev);
831 if ((mpp = add_map_with_path(vecs, pp, 1)))
832 mpp->action = ACT_CREATE;
834 - return 1; /* leave path added to pathvec */
835 + goto fail; /* leave path added to pathvec */
839 @@ -432,7 +441,7 @@ rescan:
840 if (setup_map(mpp)) {
841 condlog(0, "%s: failed to setup map for addition of new "
842 "path %s", mpp->alias, devname);
847 * reload the map for the multipath mapped device
848 @@ -450,7 +459,7 @@ rescan:
857 @@ -458,19 +467,21 @@ rescan:
858 * update our state from kernel regardless of create or reload
860 if (setup_multipath(vecs, mpp))
866 if (mpp->action == ACT_CREATE &&
867 start_waiter_thread(mpp, vecs))
871 condlog(2, "%s path added to devmap %s", devname, mpp->alias);
876 remove_map(mpp, vecs, 1);
882 Index: multipath-tools/libmultipath/Makefile
883 ===================================================================
884 --- multipath-tools.orig/libmultipath/Makefile
885 +++ multipath-tools/libmultipath/Makefile
886 @@ -12,7 +12,7 @@ OBJS = memory.o parser.o vector.o devmap
887 pgpolicies.o debug.o regex.o defaults.o uevent.o \
888 switchgroup.o uxsock.o print.o alias.o log_pthread.o \
889 log.o configure.o structs_vec.o sysfs.o prio.o checkers.o \
891 + lock.o waiter.o file.o finder.o
893 LIBDM_API_FLUSH = $(shell if test -d /lib64 ; then objdump -T /lib64/libdevmapper.so* ; else objdump -T /lib/libdevmapper.so.* ; fi | grep -c dm_task_no_flush)
895 Index: multipath-tools/multipath/mpathconf
896 ===================================================================
898 +++ multipath-tools/multipath/mpathconf
902 +# Copyright (C) 2010 Red Hat, Inc. All rights reserved.
904 +# This file is part of the device-mapper-multipath package.
906 +# This copyrighted material is made available to anyone wishing to use,
907 +# modify, copy, or redistribute it subject to the terms and conditions
908 +# of the GNU General Public License v.2.
910 +# You should have received a copy of the GNU General Public License
911 +# along with this program; if not, write to the Free Software Foundation,
912 +# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
915 +# Simple editting of /etc/multipath.conf
916 +# This program was largely ripped off from lvmconf
919 +DEFAULT_CONFIGFILE="/usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf"
920 +CONFIGFILE="/etc/multipath.conf"
921 +MULTIPATHDIR="/etc/multipath"
922 +TMPFILE=/etc/multipath/.multipath.conf.tmp
926 + echo "usage: $0 <command>"
929 + echo "Enable: --enable [--user_friendly_names <y|n>] [--find_multipaths <y|n>"
930 + echo "Disable: --disable"
931 + echo "Set user_friendly_names: --user_friendly_names <y|n>"
932 + echo "Set find_multipaths: --find_multipaths <y|n>"
938 + while [ -n "$1" ]; do
948 + --user_friendly_names)
949 + if [ -n "$2" ]; then
958 + if [ -n "$2" ]; then
973 +function validate_args
975 + if [ "$ENABLE" = "0" ] && [ -n "$FRIENDLY" -o -n "$FIND" ]; then
976 + echo "ignoring extra parameters on disable"
980 + if [ -n "$FRIENDLY" ] && [ "$FRIENDLY" != "y" -a "$FRIENDLY" != "n" ]; then
981 + echo "--user_friendly_names must be either 'y' or 'n'"
984 + if [ -n "$FIND" ] && [ "$FIND" != "y" -a "$FIND" != "n" ]; then
985 + echo "--find_multipaths must be either 'y' or 'n'"
988 + if [ -z "$ENABLE" -a -z "$FIND" -a -z "$FRIENDLY" ]; then
999 +if [ ! -d "$MULTIPATHDIR" ]; then
1000 + echo "/etc/multipath/ does not exist. failing"
1004 +rm $TMPFILE 2> /dev/null
1005 +if [ -f "$CONFIGFILE" ]; then
1006 + cp $CONFIGFILE $TMPFILE
1007 +elif [ -f "$DEFAULT_CONFIGFILE" ]; then
1008 + cp $DEFAULT_CONFIGFILE $TMPFILE
1013 +if grep -q "^blacklist[[:space:]]*{" $TMPFILE ; then
1017 +if grep -q "^defaults[[:space:]]*{" $TMPFILE ; then
1021 +if [ "$HAVE_BLACKLIST" = "1" ]; then
1022 + if sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*devnode \"\.\?\*\"" ; then
1024 + elif sed -n '/^blacklist[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*#[#[:space:]]*devnode \"\.\?\*\"" ; then
1029 +if [ "$HAVE_DEFAULTS" = "1" ]; then
1030 + if sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*find_multipaths[[:space:]]*\(yes\|1\)" ; then
1032 + elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*find_multipaths[[:space:]]*\(no\|0\)" ; then
1035 + if sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*user_friendly_names[[:space:]]*\(yes\|1\)" ; then
1037 + elif sed -n '/^defaults[[:space:]]*{/,/^}/ p' $TMPFILE | grep -q "^[[:space:]]*user_friendly_names[[:space:]]*\(no\|0\)" ; then
1042 +if [ -n "$DISPLAY" ]; then
1043 + if [ -z "$HAVE_DISABLE" -o "$HAVE_DISABLE" = 0 ]; then
1044 + echo "multipath is enabled"
1046 + echo "multipath is disabled"
1048 + if [ -z "$HAVE_FIND" -o "$HAVE_FIND" = 0 ]; then
1049 + echo "find_multipaths is disabled"
1051 + echo "find_multipaths is enabled"
1053 + if [ -z "$HAVE_FRIENDLY" -o "$HAVE_FRIENDLY" = 0 ]; then
1054 + echo "user_friendly_names is disabled"
1056 + echo "user_friendly_names is enabled"
1061 +if [ -z "$HAVE_BLACKLIST" ]; then
1062 + cat >> $TMPFILE <<- _EOF_
1069 +if [ -z "$HAVE_DEFAULTS" ]; then
1070 + cat >> $TMPFILE <<- _EOF_
1077 +if [ "$ENABLE" = 1 ]; then
1078 + if [ "$HAVE_DISABLE" = 1 ]; then
1079 + sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*devnode \"\.\?\*\"/# devnode ".*"/' $TMPFILE
1081 +elif [ "$ENABLE" = 0 ]; then
1082 + if [ -z "$HAVE_DISABLE" ]; then
1083 + sed -i '/^blacklist[[:space:]]*{/ a\
1086 + elif [ "$HAVE_DISABLE" = 0 ]; then
1087 + sed -i '/^blacklist[[:space:]]*{/,/^}/ s/^[[:space:]]*#[#[:space:]]*devnode \"\.\?\*\"/ devnode ".*"/' $TMPFILE
1091 +if [ "$FIND" = "n" ]; then
1092 + if [ "$HAVE_FIND" = 1 ]; then
1093 + sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*find_multipaths[[:space:]]*\(yes\|1\)/ find_multipaths no/' $TMPFILE
1095 +elif [ "$FIND" = "y" ]; then
1096 + if [ -z "$HAVE_FIND" ]; then
1097 + sed -i '/^defaults[[:space:]]*{/ a\
1098 + find_multipaths yes
1100 + elif [ "$HAVE_FIND" = 0 ]; then
1101 + sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*find_multipaths[[:space:]]*\(no\|0\)/ find_multipaths yes/' $TMPFILE
1105 +if [ "$FRIENDLY" = "n" ]; then
1106 + if [ "$HAVE_FRIENDLY" = 1 ]; then
1107 + sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*user_friendly_names[[:space:]]*\(yes\|1\)/ user_friendly_names no/' $TMPFILE
1109 +elif [ "$FRIENDLY" = "y" ]; then
1110 + if [ -z "$HAVE_FRIENDLY" ]; then
1111 + sed -i '/^defaults[[:space:]]*{/ a\
1112 + user_friendly_names yes
1114 + elif [ "$HAVE_FRIENDLY" = 0 ]; then
1115 + sed -i '/^defaults[[:space:]]*{/,/^}/ s/^[[:space:]]*user_friendly_names[[:space:]]*\(no\|0\)/ user_friendly_names yes/' $TMPFILE
1119 +if [ -f "$CONFIGFILE" ]; then
1120 + cp $CONFIGFILE $CONFIGFILE.old
1121 + if [ $? != 0 ]; then
1122 + echo "failed to backup old config file, $CONFIGFILE not updated"
1127 +cp $TMPFILE $CONFIGFILE
1128 +if [ $? != 0 ]; then
1129 + echo "failed to copy new config file into place, check $CONFIGFILE is still OK"
1134 Index: multipath-tools/multipath/Makefile
1135 ===================================================================
1136 --- multipath-tools.orig/multipath/Makefile
1137 +++ multipath-tools/multipath/Makefile
1138 @@ -21,6 +21,7 @@ $(EXEC): $(OBJS)
1140 $(INSTALL_PROGRAM) -d $(DESTDIR)$(bindir)
1141 $(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir)/
1142 + $(INSTALL_PROGRAM) -m 755 mpathconf $(DESTDIR)$(bindir)/
1143 $(INSTALL_PROGRAM) -d $(DESTDIR)/lib/udev/rules.d
1144 $(INSTALL_PROGRAM) -m 644 multipath.rules $(DESTDIR)/lib/udev/rules.d/40-multipath.rules
1145 $(INSTALL_PROGRAM) -d $(DESTDIR)$(mandir)
1146 @@ -31,6 +32,7 @@ install:
1148 rm $(DESTDIR)/lib/udev/rules.d/multipath.rules
1149 rm $(DESTDIR)$(bindir)/$(EXEC)
1150 + rm $(DESTDIR)$(bindir)/mpathconf
1151 rm $(DESTDIR)$(mandir)/$(EXEC).8.gz
1152 rm $(DESTDIR)$(man5dir)/$(EXEC).conf.5.gz