summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ctladm/ctladm.c
diff options
context:
space:
mode:
authorsjg <sjg@FreeBSD.org>2013-04-12 20:48:55 +0000
committersjg <sjg@FreeBSD.org>2013-04-12 20:48:55 +0000
commit97d8b9495668afa398ab17c8c5f7e223b5fd2e89 (patch)
tree54038c9ac32a45f8741dcc23fb9a8ffc0e15ff89 /usr.sbin/ctladm/ctladm.c
parent5ee3bfdb338e7c80af29a67f4425c4be24c7b866 (diff)
parent086d73aef6d0ab7d21daa2076fdc8d25961f9b05 (diff)
downloadFreeBSD-src-97d8b9495668afa398ab17c8c5f7e223b5fd2e89.zip
FreeBSD-src-97d8b9495668afa398ab17c8c5f7e223b5fd2e89.tar.gz
sync from head
Diffstat (limited to 'usr.sbin/ctladm/ctladm.c')
-rw-r--r--usr.sbin/ctladm/ctladm.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/usr.sbin/ctladm/ctladm.c b/usr.sbin/ctladm/ctladm.c
index 2a743da..bfbedc7 100644
--- a/usr.sbin/ctladm/ctladm.c
+++ b/usr.sbin/ctladm/ctladm.c
@@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
+#include <sys/linker.h>
#include <sys/queue.h>
#include <sys/callout.h>
#include <sys/sbuf.h>
@@ -3814,6 +3815,7 @@ main(int argc, char **argv)
int retval, fd;
int retries;
int initid;
+ int saved_errno;
retval = 0;
cmdargs = CTLADM_ARG_NONE;
@@ -3963,6 +3965,14 @@ main(int argc, char **argv)
if ((cmdargs & CTLADM_ARG_DEVICE)
&& (command != CTLADM_CMD_HELP)) {
fd = open(device, O_RDWR);
+ if (fd == -1 && errno == ENOENT) {
+ saved_errno = errno;
+ retval = kldload("ctl");
+ if (retval != -1)
+ fd = open(device, O_RDWR);
+ else
+ errno = saved_errno;
+ }
if (fd == -1) {
fprintf(stderr, "%s: error opening %s: %s\n",
argv[0], device, strerror(errno));
OpenPOWER on IntegriCloud