Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Sep 2013 08:37:14 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r255665 - in head: usr.bin/iscsictl usr.sbin/ctld usr.sbin/iscsid
Message-ID:  <201309180837.r8I8bE1W057529@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Wed Sep 18 08:37:14 2013
New Revision: 255665
URL: http://svnweb.freebsd.org/changeset/base/255665

Log:
  Make iscsictl(8) automatically try to load the iscsi module.  While here,
  improve module loading in iscsid(8) and ctld(8).
  
  Approved by:	re (delphij)

Modified:
  head/usr.bin/iscsictl/iscsictl.c
  head/usr.sbin/ctld/kernel.c
  head/usr.sbin/iscsid/iscsid.c

Modified: head/usr.bin/iscsictl/iscsictl.c
==============================================================================
--- head/usr.bin/iscsictl/iscsictl.c	Wed Sep 18 06:40:47 2013	(r255664)
+++ head/usr.bin/iscsictl/iscsictl.c	Wed Sep 18 08:37:14 2013	(r255665)
@@ -30,6 +30,8 @@
  */
 
 #include <sys/ioctl.h>
+#include <sys/param.h>
+#include <sys/linker.h>
 #include <assert.h>
 #include <ctype.h>
 #include <err.h>
@@ -512,7 +514,7 @@ main(int argc, char **argv)
 	const char *conf_path = DEFAULT_CONFIG_PATH;
 	char *nickname = NULL, *discovery_host = NULL, *host = NULL,
 	     *target = NULL, *user = NULL, *secret = NULL;
-	int ch, error, iscsi_fd;
+	int ch, error, iscsi_fd, retval, saved_errno;
 	int failed = 0;
 	struct conf *conf;
 	struct target *targ;
@@ -672,6 +674,14 @@ main(int argc, char **argv)
 	}
 
 	iscsi_fd = open(ISCSI_PATH, O_RDWR);
+	if (iscsi_fd < 0 && errno == ENOENT) {
+		saved_errno = errno;
+		retval = kldload("iscsi");
+		if (retval != -1)
+			iscsi_fd = open(ISCSI_PATH, O_RDWR);
+		else
+			errno = saved_errno;
+	}
 	if (iscsi_fd < 0)
 		err(1, "failed to open %s", ISCSI_PATH);
 

Modified: head/usr.sbin/ctld/kernel.c
==============================================================================
--- head/usr.sbin/ctld/kernel.c	Wed Sep 18 06:40:47 2013	(r255664)
+++ head/usr.sbin/ctld/kernel.c	Wed Sep 18 08:37:14 2013	(r255665)
@@ -79,7 +79,7 @@ kernel_init(void)
 	int retval, saved_errno;
 
 	ctl_fd = open(CTL_DEFAULT_DEV, O_RDWR);
-	if (ctl_fd < 0) {
+	if (ctl_fd < 0 && errno == ENOENT) {
 		saved_errno = errno;
 		retval = kldload("ctl");
 		if (retval != -1)

Modified: head/usr.sbin/iscsid/iscsid.c
==============================================================================
--- head/usr.sbin/iscsid/iscsid.c	Wed Sep 18 06:40:47 2013	(r255664)
+++ head/usr.sbin/iscsid/iscsid.c	Wed Sep 18 08:37:14 2013	(r255665)
@@ -509,7 +509,7 @@ main(int argc, char **argv)
 	}
 
 	iscsi_fd = open(ISCSI_PATH, O_RDWR);
-	if (iscsi_fd < 0) {
+	if (iscsi_fd < 0 && errno == ENOENT) {
 		saved_errno = errno;
 		retval = kldload("iscsi");
 		if (retval != -1)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201309180837.r8I8bE1W057529>