1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-20 11:11:24 +00:00

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

Reviewed by:	ken
This commit is contained in:
Edward Tomasz Napierala 2013-04-10 08:48:10 +00:00
parent 18ba072a22
commit 57cdcaa6df
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=249328

View File

@ -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));