diff options
author | trasz <trasz@FreeBSD.org> | 2013-04-10 08:48:10 +0000 |
---|---|---|
committer | trasz <trasz@FreeBSD.org> | 2013-04-10 08:48:10 +0000 |
commit | 7843a647ca0491f43eb99f60e80fd78a7bbdf8ef (patch) | |
tree | 2931393ed3b52fed4a3b444697f6a5a72f66b7b2 /usr.sbin | |
parent | e79bb9704b0801e384d3cf9953bd20277e72961d (diff) | |
download | FreeBSD-src-7843a647ca0491f43eb99f60e80fd78a7bbdf8ef.zip FreeBSD-src-7843a647ca0491f43eb99f60e80fd78a7bbdf8ef.tar.gz |
Make ctladm(8) try to load ctl.ko kernel module if needed.
Reviewed by: ken
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ctladm/ctladm.c | 10 |
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)); |