svn commit: r253835 - stable/9/usr.sbin/ctladm

Edward Tomasz Napierala trasz at FreeBSD.org
Wed Jul 31 10:54:24 UTC 2013


Author: trasz
Date: Wed Jul 31 10:54:24 2013
New Revision: 253835
URL: http://svnweb.freebsd.org/changeset/base/253835

Log:
  MFC r249328:
  
  Make ctladm(8) try to load ctl.ko kernel module if needed.
  
  Approved by:	re (delphij)

Modified:
  stable/9/usr.sbin/ctladm/ctladm.c
Directory Properties:
  stable/9/usr.sbin/ctladm/   (props changed)

Modified: stable/9/usr.sbin/ctladm/ctladm.c
==============================================================================
--- stable/9/usr.sbin/ctladm/ctladm.c	Wed Jul 31 07:09:35 2013	(r253834)
+++ stable/9/usr.sbin/ctladm/ctladm.c	Wed Jul 31 10:54:24 2013	(r253835)
@@ -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));


More information about the svn-src-stable-9 mailing list