aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorEnji Cooper <ngie@FreeBSD.org>2017-03-30 04:56:27 +0000
committerEnji Cooper <ngie@FreeBSD.org>2017-03-30 04:56:27 +0000
commit653e7d639682be855c34415b1b7542d9388aafd6 (patch)
treeb8a0d37377f1f1c0cafa1aaf20ee95d266860cf1 /usr.sbin
parent3aeacc55a5f01aaf03762fff5de1ff9c98c28a90 (diff)
downloadsrc-653e7d639682be855c34415b1b7542d9388aafd6.tar.gz
src-653e7d639682be855c34415b1b7542d9388aafd6.zip
Split iscsi(4) ctl frontend off of ctl(4) as cfiscsi(4)
The goal of this work is to remove the explicit dependency for ctl(4) on iscsi(4), so end-users without iscsi(4) support in the kernel can use ctl(4) for its other functions. This allows those without iscsi(4) support built into the kernel to use ctl(4) as a test mechanism. As a sidenote, this was possible around the 10.0-RELEASE period, but made impossible for end-users without iscsi(4) between 10.0-RELEASE and 11.0-RELEASE. Automatically load cfiscsi(4) from ctladm(8) and ctld(8) for backwards compatibility with previously releases. The automatic loading feature is compiled into the beforementioned tools if MK_ISCSI == yes when building world. Add a manpage for cfiscsi(4) and refer to it in ctl(4). Differential Revision: D10099 MFC after: 2 months Relnotes: yes Reviewed by: mav, trasz Sponsored by: Dell EMC Isilon
Notes
Notes: svn path=/head/; revision=316212
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ctladm/Makefile6
-rw-r--r--usr.sbin/ctladm/ctladm.c8
-rw-r--r--usr.sbin/ctld/Makefile6
-rw-r--r--usr.sbin/ctld/kernel.c9
4 files changed, 29 insertions, 0 deletions
diff --git a/usr.sbin/ctladm/Makefile b/usr.sbin/ctladm/Makefile
index c5e7e87f7a72..5b74668bf571 100644
--- a/usr.sbin/ctladm/Makefile
+++ b/usr.sbin/ctladm/Makefile
@@ -1,5 +1,7 @@
# $FreeBSD$
+.include <src.opts.mk>
+
PROG= ctladm
SRCS= ctladm.c util.c ctl_util.c ctl_scsi_all.c
.PATH: ${SRCTOP}/sys/cam/ctl
@@ -17,4 +19,8 @@ WARNS?= 3
LIBADD= cam sbuf bsdxml util
MAN= ctladm.8
+.if ${MK_ISCSI} != "no"
+CFLAGS+= -DWANT_ISCSI
+.endif
+
.include <bsd.prog.mk>
diff --git a/usr.sbin/ctladm/ctladm.c b/usr.sbin/ctladm/ctladm.c
index cedfb12115ad..dffa3734ec4b 100644
--- a/usr.sbin/ctladm/ctladm.c
+++ b/usr.sbin/ctladm/ctladm.c
@@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
#include <sys/callout.h>
#include <sys/ioctl.h>
#include <sys/linker.h>
+#include <sys/module.h>
#include <sys/queue.h>
#include <sys/sbuf.h>
#include <sys/stat.h>
@@ -4152,6 +4153,13 @@ main(int argc, char **argv)
retval = 1;
goto bailout;
}
+#ifdef WANT_ISCSI
+ else {
+ if (modfind("cfiscsi") == -1 &&
+ kldload("cfiscsi") == -1)
+ warn("couldn't load cfiscsi");
+ }
+#endif
} else if ((command != CTLADM_CMD_HELP)
&& ((cmdargs & CTLADM_ARG_DEVICE) == 0)) {
fprintf(stderr, "%s: you must specify a device with the "
diff --git a/usr.sbin/ctld/Makefile b/usr.sbin/ctld/Makefile
index 7c342568fe35..944b94d663c8 100644
--- a/usr.sbin/ctld/Makefile
+++ b/usr.sbin/ctld/Makefile
@@ -1,5 +1,7 @@
# $FreeBSD$
+.include <src.opts.mk>
+
CFLAGS+=-I${SRCTOP}/contrib/libucl/include
.PATH: ${SRCTOP}/contrib/libucl/include
@@ -21,4 +23,8 @@ CLEANFILES= y.tab.c y.tab.h y.output
WARNS?= 6
NO_WMISSING_VARIABLE_DECLARATIONS=
+.if ${MK_ISCSI} != "no"
+CFLAGS+= -DWANT_ISCSI
+.endif
+
.include <bsd.prog.mk>
diff --git a/usr.sbin/ctld/kernel.c b/usr.sbin/ctld/kernel.c
index b646bc7795ab..b56364a1463e 100644
--- a/usr.sbin/ctld/kernel.c
+++ b/usr.sbin/ctld/kernel.c
@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
#include <sys/callout.h>
#include <sys/ioctl.h>
#include <sys/linker.h>
+#include <sys/module.h>
#include <sys/queue.h>
#include <sys/sbuf.h>
#include <sys/stat.h>
@@ -90,6 +91,14 @@ kernel_init(void)
}
if (ctl_fd < 0)
log_err(1, "failed to open %s", CTL_DEFAULT_DEV);
+#ifdef WANT_ISCSI
+ else {
+ saved_errno = errno;
+ if (modfind("cfiscsi") == -1 && kldload("cfiscsi") == -1)
+ log_warn("couldn't load cfiscsi");
+ errno = saved_errno;
+ }
+#endif
}
/*