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

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