Date: Wed, 10 Apr 2013 08:48:11 +0000 (UTC) From: Edward Tomasz Napierala <trasz@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r249328 - head/usr.sbin/ctladm Message-ID: <201304100848.r3A8mBMp053967@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: trasz Date: Wed Apr 10 08:48:10 2013 New Revision: 249328 URL: http://svnweb.freebsd.org/changeset/base/249328 Log: Make ctladm(8) try to load ctl.ko kernel module if needed. Reviewed by: ken Modified: head/usr.sbin/ctladm/ctladm.c Modified: head/usr.sbin/ctladm/ctladm.c ============================================================================== --- head/usr.sbin/ctladm/ctladm.c Wed Apr 10 08:09:25 2013 (r249327) +++ head/usr.sbin/ctladm/ctladm.c Wed Apr 10 08:48:10 2013 (r249328) @@ -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));
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201304100848.r3A8mBMp053967>