[Pkg-iscsi-maintainers] [SCM] Debian Open-iSCSI Packaging branch, upstream-mnc, updated. 2.0-872-193-gde2c0e7

Mike Christie michaelc at cs.wisc.edu
Sat Apr 7 15:44:10 UTC 2012


The following commit has been merged in the upstream-mnc branch:
commit 2ca905d65613496a78e676f3f6dc79e345e32954
Author: Mike Christie <michaelc at cs.wisc.edu>
Date:   Wed Mar 14 22:36:18 2012 -0500

    iscsi tools: iscsiadm modprobe support
    
    Lots of distros do not have libkmod yet, so here is
    /sbin/modprobe support.

diff --git a/usr/Makefile b/usr/Makefile
index ba96613..498b282 100644
--- a/usr/Makefile
+++ b/usr/Makefile
@@ -33,7 +33,7 @@ endif
 OPTFLAGS ?= -O2 -g
 WARNFLAGS ?= -Wall -Wstrict-prototypes
 CFLAGS += $(OPTFLAGS) $(WARNFLAGS) -I../include -I. -I../utils/open-isns \
-				-l kmod -D$(OSNAME) $(IPC_CFLAGS)
+				-D$(OSNAME) $(IPC_CFLAGS)
 PROGRAMS = iscsid iscsiadm iscsistart
 
 # libc compat files
diff --git a/usr/transport.c b/usr/transport.c
index 04c7493..80216a2 100644
--- a/usr/transport.c
+++ b/usr/transport.c
@@ -19,10 +19,14 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <errno.h>
+#ifdef USE_KMOD
 #include <libkmod.h>
+#endif
 #include <net/if.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
+#include <sys/types.h>
+#include <sys/wait.h>
 
 #include "sysdeps.h"
 #include "iscsi_err.h"
@@ -150,6 +154,11 @@ free_ifni:
 	return 0;
 }
 
+/*
+ * Most distros still do not have wide libkmod use, so
+ * use modprobe for now
+ */
+#ifdef USE_KMOD
 int transport_load_kmod(char *transport_name)
 {
 	struct kmod_ctx *ctx;
@@ -195,6 +204,52 @@ unref_mod:
 	return rc;
 }
 
+#else
+
+int transport_load_kmod(char *transport_name)
+{
+	char *cmdline[4];
+	pid_t pid;
+
+	cmdline[0] = "/sbin/modprobe";
+	cmdline[1] = "-qb";
+	cmdline[3] = NULL;
+
+	/*
+	 * dumb dumb mistake - named iscsi_tcp and ib_iser differently from
+	 * transport name
+	 */
+	if (!strcmp(transport_name, "tcp"))
+		cmdline[2] = "iscsi_tcp";
+	else if (!strcmp(transport_name, "iser"))
+		cmdline[2] = "ib_iser";
+	else
+		cmdline[2] = transport_name;
+
+	pid = fork();
+	if (pid == 0) {
+		if (execv("/sbin/modprobe", cmdline) < 0) {
+			log_error("Failed to load module %s: %s",
+				   transport_name, strerror(errno));
+			exit(-errno);
+		}
+		exit(0);
+	} else if (pid < 0) {
+		log_error("Failed to fork process to load module %s: %s",
+			  transport_name, strerror(errno));
+		return ISCSI_ERR_TRANS_NOT_FOUND;
+	}
+
+	if (waitpid(pid, NULL, 0) < 0) {
+		log_error("Failed to load module %s", transport_name);
+		return ISCSI_ERR_TRANS_NOT_FOUND;
+	}
+
+	return 0;
+}
+
+#endif
+
 int set_transport_template(struct iscsi_transport *t)
 {
 	struct iscsi_transport_template *tmpl;

-- 
Debian Open-iSCSI Packaging



More information about the Pkg-iscsi-maintainers mailing list