summaryrefslogtreecommitdiffstats
path: root/usr.bin/iscsictl/iscsictl.c
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2013-09-18 08:37:14 +0000
committertrasz <trasz@FreeBSD.org>2013-09-18 08:37:14 +0000
commit2320759748604480072b729069f5e3012914398b (patch)
tree5e1b95f26baf4ffed69f3b0909ea4f49779ac355 /usr.bin/iscsictl/iscsictl.c
parentaa6935c0786ab4f36492f049786d15ed8ba0a183 (diff)
downloadFreeBSD-src-2320759748604480072b729069f5e3012914398b.zip
FreeBSD-src-2320759748604480072b729069f5e3012914398b.tar.gz
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)
Diffstat (limited to 'usr.bin/iscsictl/iscsictl.c')
-rw-r--r--usr.bin/iscsictl/iscsictl.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/usr.bin/iscsictl/iscsictl.c b/usr.bin/iscsictl/iscsictl.c
index ff37c12..1088d69 100644
--- a/usr.bin/iscsictl/iscsictl.c
+++ b/usr.bin/iscsictl/iscsictl.c
@@ -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);
OpenPOWER on IntegriCloud