Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MFC r249328:

Make ctladm(8) try to load ctl.ko kernel module if needed.

Approved by:	re (delphij)
  • Loading branch information...
commit 2218d2bbe8a7c0c6c1ed0130944b85e621215b51 1 parent d09cd93
@trasz trasz authored
Showing with 10 additions and 0 deletions.
  1. +10 −0 usr.sbin/ctladm/ctladm.c
View
10 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>
@@ -3816,6 +3817,7 @@ main(int argc, char **argv)
int retval, fd;
int retries;
int initid;
+ int saved_errno;
retval = 0;
cmdargs = CTLADM_ARG_NONE;
@@ -3965,6 +3967,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));
Please sign in to comment.
Something went wrong with that request. Please try again.