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

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