Blame SOURCES/0054-UP-keep-udev-ref.patch

671555
---
671555
 libmpathpersist/mpath_persist.c  |    7 ++++---
671555
 libmpathpersist/mpath_persist.h  |    2 +-
671555
 libmpathpersist/mpath_pr_ioctl.c |    5 +++--
671555
 libmultipath/config.c            |    9 +++------
671555
 libmultipath/config.h            |    2 +-
671555
 mpathpersist/Makefile            |    2 +-
671555
 mpathpersist/main.c              |   11 +++++++----
671555
 multipath/Makefile               |    2 +-
671555
 multipath/main.c                 |   12 ++++++++----
671555
 multipathd/main.c                |   11 ++++++++---
671555
 10 files changed, 37 insertions(+), 26 deletions(-)
671555
671555
Index: multipath-tools-130222/libmpathpersist/mpath_persist.c
671555
===================================================================
671555
--- multipath-tools-130222.orig/libmpathpersist/mpath_persist.c
671555
+++ multipath-tools-130222/libmpathpersist/mpath_persist.c
671555
@@ -1,4 +1,3 @@
671555
-#include "mpath_persist.h"
671555
 #include <libdevmapper.h>
671555
 #include <defaults.h>
671555
 #include <sys/stat.h>
671555
@@ -8,6 +7,7 @@
671555
 #include <checkers.h>
671555
 #include <structs.h>
671555
 #include <structs_vec.h>
671555
+#include <libudev.h>
671555
 
671555
 #include <prio.h>
671555
 #include <unistd.h>
671555
@@ -20,6 +20,7 @@
671555
 #include <ctype.h>
671555
 #include <propsel.h>
671555
 
671555
+#include "mpath_persist.h"
671555
 #include "mpathpr.h"
671555
 #include "mpath_pr_ioctl.h"
671555
 
671555
@@ -32,9 +33,9 @@
671555
 
671555
 
671555
 int
671555
-mpath_lib_init (void)
671555
+mpath_lib_init (struct udev *udev)
671555
 {
671555
-	if (load_config(DEFAULT_CONFIGFILE)){
671555
+	if (load_config(DEFAULT_CONFIGFILE, udev)){
671555
 		condlog(0, "Failed to initialize multipath config.");
671555
 		return 1;
671555
 	}
671555
Index: multipath-tools-130222/libmpathpersist/mpath_persist.h
671555
===================================================================
671555
--- multipath-tools-130222.orig/libmpathpersist/mpath_persist.h
671555
+++ multipath-tools-130222/libmpathpersist/mpath_persist.h
671555
@@ -174,7 +174,7 @@ struct prout_param_descriptor { 	/* PROU
671555
  *
671555
  * RETURNS: 0->Success, 1->Failed.
671555
  */
671555
-extern int mpath_lib_init (void );
671555
+extern int mpath_lib_init (struct udev *udev);
671555
 
671555
 
671555
 /*
671555
Index: multipath-tools-130222/libmpathpersist/mpath_pr_ioctl.c
671555
===================================================================
671555
--- multipath-tools-130222.orig/libmpathpersist/mpath_pr_ioctl.c
671555
+++ multipath-tools-130222/libmpathpersist/mpath_pr_ioctl.c
671555
@@ -10,8 +10,9 @@
671555
 #include <string.h>
671555
 #include <sys/ioctl.h>
671555
 #include <unistd.h>
671555
-#include "mpath_pr_ioctl.h" 
671555
-#include <mpath_persist.h> 
671555
+#include <libudev.h>
671555
+#include "mpath_pr_ioctl.h"
671555
+#include <mpath_persist.h>
671555
 
671555
 #include <debug.h>
671555
 
671555
Index: multipath-tools-130222/libmultipath/config.c
671555
===================================================================
671555
--- multipath-tools-130222.orig/libmultipath/config.c
671555
+++ multipath-tools-130222/libmultipath/config.c
671555
@@ -467,9 +467,6 @@ free_config (struct config * conf)
671555
 	if (conf->dev)
671555
 		FREE(conf->dev);
671555
 
671555
-	if (conf->udev)
671555
-		udev_unref(conf->udev);
671555
-
671555
 	if (conf->multipath_dir)
671555
 		FREE(conf->multipath_dir);
671555
 
671555
@@ -519,12 +516,12 @@ free_config (struct config * conf)
671555
 }
671555
 
671555
 int
671555
-load_config (char * file)
671555
+load_config (char * file, struct udev *udev)
671555
 {
671555
 	if (!conf)
671555
 		conf = alloc_config();
671555
 
671555
-	if (!conf)
671555
+	if (!conf || !udev)
671555
 		return 1;
671555
 
671555
 	/*
671555
@@ -533,7 +530,7 @@ load_config (char * file)
671555
 	if (!conf->verbosity)
671555
 		conf->verbosity = DEFAULT_VERBOSITY;
671555
 
671555
-	conf->udev = udev_new();
671555
+	conf->udev = udev;
671555
 	dm_drv_version(conf->version, TGT_MPATH);
671555
 	conf->dev_type = DEV_NONE;
671555
 	conf->minio = DEFAULT_MINIO;
671555
Index: multipath-tools-130222/libmultipath/config.h
671555
===================================================================
671555
--- multipath-tools-130222.orig/libmultipath/config.h
671555
+++ multipath-tools-130222/libmultipath/config.h
671555
@@ -159,7 +159,7 @@ void free_mptable (vector mptable);
671555
 
671555
 int store_hwe (vector hwtable, struct hwentry *);
671555
 
671555
-int load_config (char * file);
671555
+int load_config (char * file, struct udev * udev);
671555
 struct config * alloc_config (void);
671555
 void free_config (struct config * conf);
671555
 
671555
Index: multipath-tools-130222/mpathpersist/main.c
671555
===================================================================
671555
--- multipath-tools-130222.orig/mpathpersist/main.c
671555
+++ multipath-tools-130222/mpathpersist/main.c
671555
@@ -7,6 +7,7 @@
671555
 #include <vector.h>
671555
 #include <structs.h>
671555
 #include <getopt.h>
671555
+#include <libudev.h>
671555
 #include <mpath_persist.h>
671555
 #include "main.h"
671555
 #include <pthread.h>
671555
@@ -68,7 +69,8 @@ int main (int argc, char * argv[])
671555
 	int noisy = 0;
671555
 	int num_transport =0;
671555
 	void *resp = NULL;
671555
-	struct transportid * tmp; 
671555
+	struct transportid * tmp;
671555
+	struct udev *udev = NULL;
671555
 
671555
 	if (optind == argc)
671555
 	{
671555
@@ -84,8 +86,8 @@ int main (int argc, char * argv[])
671555
 		exit (1);
671555
 	}
671555
 
671555
-
671555
-	mpath_lib_init();
671555
+	udev = udev_new();
671555
+	mpath_lib_init(udev);
671555
 	memset(transportids,0,MPATH_MX_TIDS);
671555
 
671555
 	while (1)
671555
@@ -461,12 +463,13 @@ int main (int argc, char * argv[])
671555
 	if (res < 0)
671555
 	{
671555
 		mpath_lib_exit();
671555
+		udev_unref(udev);
671555
 		return MPATH_PR_FILE_ERROR;
671555
 	}
671555
 
671555
 out :
671555
 	mpath_lib_exit();
671555
-
671555
+	udev_unref(udev);
671555
 	return (ret >= 0) ? ret : MPATH_PR_OTHER;
671555
 }
671555
 
671555
Index: multipath-tools-130222/multipath/main.c
671555
===================================================================
671555
--- multipath-tools-130222.orig/multipath/main.c
671555
+++ multipath-tools-130222/multipath/main.c
671555
@@ -27,6 +27,7 @@
671555
 #include <stdio.h>
671555
 #include <unistd.h>
671555
 #include <ctype.h>
671555
+#include <libudev.h>
671555
 
671555
 #include <checkers.h>
671555
 #include <prio.h>
671555
@@ -435,6 +436,7 @@ convert_dev(char *dev)
671555
 int
671555
 main (int argc, char *argv[])
671555
 {
671555
+	struct udev *udev;
671555
 	int arg;
671555
 	extern char *optarg;
671555
 	extern int optind;
671555
@@ -445,7 +447,9 @@ main (int argc, char *argv[])
671555
 		exit(1);
671555
 	}
671555
 
671555
-	if (load_config(DEFAULT_CONFIGFILE))
671555
+	udev = udev_new();
671555
+
671555
+	if (load_config(DEFAULT_CONFIGFILE, udev))
671555
 		exit(1);
671555
 
671555
 	if (dm_prereq())
671555
@@ -560,11 +564,11 @@ main (int argc, char *argv[])
671555
 
671555
 	if (init_checkers()) {
671555
 		condlog(0, "failed to initialize checkers");
671555
-		exit(1);
671555
+		goto out;
671555
 	}
671555
 	if (init_prio()) {
671555
 		condlog(0, "failed to initialize prioritizers");
671555
-		exit(1);
671555
+		goto out;
671555
 	}
671555
 	dm_init();
671555
 
671555
@@ -628,7 +632,7 @@ out:
671555
 	 */
671555
 	free_config(conf);
671555
 	conf = NULL;
671555
-
671555
+	udev_unref(udev);
671555
 #ifdef _DEBUG_
671555
 	dbg_free_final(NULL);
671555
 #endif
671555
Index: multipath-tools-130222/multipathd/main.c
671555
===================================================================
671555
--- multipath-tools-130222.orig/multipathd/main.c
671555
+++ multipath-tools-130222/multipathd/main.c
671555
@@ -93,6 +93,8 @@ static sem_t exit_sem;
671555
  */
671555
 struct vectors * gvecs;
671555
 
671555
+struct udev * udev;
671555
+
671555
 static int
671555
 need_switch_pathgroup (struct multipath * mpp, int refresh)
671555
 {
671555
@@ -1408,7 +1410,7 @@ reconfigure (struct vectors * vecs)
671555
 	vecs->pathvec = NULL;
671555
 	conf = NULL;
671555
 
671555
-	if (!load_config(DEFAULT_CONFIGFILE)) {
671555
+	if (!load_config(DEFAULT_CONFIGFILE, udev)) {
671555
 		conf->verbosity = old->verbosity;
671555
 		conf->daemon = 1;
671555
 		configure(vecs, 1);
671555
@@ -1601,6 +1603,8 @@ child (void * param)
671555
 	sem_init(&exit_sem, 0, 0);
671555
 	signal_init();
671555
 
671555
+	udev = udev_new();
671555
+
671555
 	setup_thread_attr(&misc_attr, 64 * 1024, 1);
671555
 	setup_thread_attr(&waiter_attr, 32 * 1024, 1);
671555
 
671555
@@ -1615,7 +1619,7 @@ child (void * param)
671555
 	condlog(2, "--------start up--------");
671555
 	condlog(2, "read " DEFAULT_CONFIGFILE);
671555
 
671555
-	if (load_config(DEFAULT_CONFIGFILE))
671555
+	if (load_config(DEFAULT_CONFIGFILE, udev))
671555
 		exit(1);
671555
 
671555
 	if (init_checkers()) {
671555
@@ -1765,7 +1769,8 @@ child (void * param)
671555
 	 */
671555
 	free_config(conf);
671555
 	conf = NULL;
671555
-
671555
+	udev_unref(udev);
671555
+	udev = NULL;
671555
 #ifdef _DEBUG_
671555
 	dbg_free_final(NULL);
671555
 #endif
671555
Index: multipath-tools-130222/mpathpersist/Makefile
671555
===================================================================
671555
--- multipath-tools-130222.orig/mpathpersist/Makefile
671555
+++ multipath-tools-130222/mpathpersist/Makefile
671555
@@ -5,7 +5,7 @@ include ../Makefile.inc
671555
 OBJS = main.o 
671555
 
671555
 CFLAGS += -I$(multipathdir) -I$(mpathpersistdir) 
671555
-LDFLAGS += -lpthread -ldevmapper -L$(mpathpersistdir) -lmpathpersist -L$(multipathdir) -lmultipath 
671555
+LDFLAGS += -lpthread -ldevmapper -L$(mpathpersistdir) -lmpathpersist -L$(multipathdir) -lmultipath -ludev
671555
 
671555
 EXEC = mpathpersist
671555
 
671555
Index: multipath-tools-130222/multipath/Makefile
671555
===================================================================
671555
--- multipath-tools-130222.orig/multipath/Makefile
671555
+++ multipath-tools-130222/multipath/Makefile
671555
@@ -7,7 +7,7 @@ include ../Makefile.inc
671555
 OBJS = main.o
671555
 
671555
 CFLAGS += -fPIC -I$(multipathdir)
671555
-LDFLAGS += -lpthread -ldevmapper -ldl -L$(multipathdir) -lmultipath
671555
+LDFLAGS += -lpthread -ldevmapper -ldl -L$(multipathdir) -lmultipath -ludev
671555
 
671555
 EXEC = multipath
671555