Module Name:    src
Committed By:   pgoyette
Date:           Sat Jan 14 21:36:59 UTC 2017

Modified Files:
        src/sys/rump/dev/lib/libdrvctl: drvctl_component.c
        src/sys/rump/librump/rumpkern: devsw.c

Log Message:
Don't call the drvctl module's initialization code during rump component
initialization.  Instead, temporarily attach the drvctl's cdevsw to
determine its device c-major, create the /dev/drvctl node using that
c-major, and then detach.  This leaves things in a state where normal
module initialization can run.

Since we're now creating the /dev/drvctl device node correctly, we don't
need to create it again.  So mark the device as DEVNODE_DONTBOTHER in
the devsw_conv0 conversion table.

This bug was introduced more than a year ago (src/sys/kern/kern_drvctl.c
rev 1.40), but was silently ignored except when running a rump_server
built with LOCKDEBUG.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/rump/dev/lib/libdrvctl/drvctl_component.c
cvs rdiff -u -r1.7 -r1.8 src/sys/rump/librump/rumpkern/devsw.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/rump/dev/lib/libdrvctl/drvctl_component.c
diff -u src/sys/rump/dev/lib/libdrvctl/drvctl_component.c:1.2 src/sys/rump/dev/lib/libdrvctl/drvctl_component.c:1.3
--- src/sys/rump/dev/lib/libdrvctl/drvctl_component.c:1.2	Tue Jan 26 23:12:15 2016
+++ src/sys/rump/dev/lib/libdrvctl/drvctl_component.c	Sat Jan 14 21:36:58 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: drvctl_component.c,v 1.2 2016/01/26 23:12:15 pooka Exp $	*/
+/*	$NetBSD: drvctl_component.c,v 1.3 2017/01/14 21:36:58 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 2010 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drvctl_component.c,v 1.2 2016/01/26 23:12:15 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drvctl_component.c,v 1.3 2017/01/14 21:36:58 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
@@ -36,6 +36,7 @@ __KERNEL_RCSID(0, "$NetBSD: drvctl_compo
 #include "ioconf.c"
 
 #include <rump-sys/kern.h>
+#include <rump-sys/vfs.h>
 
 RUMP_COMPONENT(RUMP_COMPONENT_DEV)
 {
@@ -43,13 +44,16 @@ RUMP_COMPONENT(RUMP_COMPONENT_DEV)
 	devmajor_t bmaj, cmaj;
 	int error;
 
-	drvctl_init();
-
-	config_init_component(cfdriver_ioconf_drvctl,
-	    cfattach_ioconf_drvctl, cfdata_ioconf_drvctl);
-
 	bmaj = cmaj = NODEVMAJOR;
-	if ((error = devsw_attach("drvctl", NULL, &bmaj,
-	    &drvctl_cdevsw, &cmaj)) != 0)
+	error = devsw_attach("drvctl", NULL, &bmaj, &drvctl_cdevsw, &cmaj);
+	if (error != 0)
 		panic("drvctl devsw attach failed: %d", error);
+
+	error = rump_vfs_makeonedevnode(S_IFCHR, "/dev/drvctl", cmaj, 0);
+	if ( error !=0)
+		panic("cannot create drvctl device node: %d", error);
+
+	error = devsw_detach(NULL, &drvctl_cdevsw);
+	if (error != 0)
+		panic("cannot detach drvctl devsw: %d", error);
 }

Index: src/sys/rump/librump/rumpkern/devsw.c
diff -u src/sys/rump/librump/rumpkern/devsw.c:1.7 src/sys/rump/librump/rumpkern/devsw.c:1.8
--- src/sys/rump/librump/rumpkern/devsw.c:1.7	Fri Feb 25 18:56:20 2011
+++ src/sys/rump/librump/rumpkern/devsw.c	Sat Jan 14 21:36:58 2017
@@ -14,7 +14,7 @@ struct devsw_conv devsw_conv0[] = {
 	{ "pps", -1, 164, DEVNODE_DONTBOTHER, 0, { 0, 0 }},
 	{ "ptm", -1, 165, DEVNODE_DONTBOTHER, 0, { 0, 0 }},
 	{ "atabus", -1, 166, DEVNODE_VECTOR, 0, { 4, 0 }},
-	{ "drvctl", -1, 167, DEVNODE_SINGLE, 0, { 0, 0 }},
+	{ "drvctl", -1, 167, DEVNODE_DONTBOTHER, 0, { 0, 0 }},
 	{ "dk", 168, 168, DEVNODE_DONTBOTHER, 0, { 0, 0 }},
 	{ "tap", -1, 169, DEVNODE_VECTOR, 0, { 4, 0 }},
 	{ "veriexec", -1, 170, DEVNODE_DONTBOTHER, 0, { 0, 0 }},

Reply via email to