Module Name:    src
Committed By:   pgoyette
Date:           Tue Jan  5 09:37:11 UTC 2016

Modified Files:
        src/sys/dev/filemon: filemon.c

Log Message:
Although not recommended, it is possible to include filemon(4) as a
built-in module.  If we do this, don't try to call devsw_attach() as
our device structures will already have been included via ioconf.[ch].

This avoids calling the init routine twice (once for CLASS_DRIVER and
then later for CLASS_ANY), which in turn avoids trying to initialize
an already initialized lock.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/filemon/filemon.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/dev/filemon/filemon.c
diff -u src/sys/dev/filemon/filemon.c:1.22 src/sys/dev/filemon/filemon.c:1.23
--- src/sys/dev/filemon/filemon.c:1.22	Wed Nov 25 07:34:49 2015
+++ src/sys/dev/filemon/filemon.c	Tue Jan  5 09:37:11 2016
@@ -1,4 +1,4 @@
-/*      $NetBSD: filemon.c,v 1.22 2015/11/25 07:34:49 pgoyette Exp $ */
+/*      $NetBSD: filemon.c,v 1.23 2016/01/05 09:37:11 pgoyette Exp $ */
 /*
  * Copyright (c) 2010, Juniper Networks, Inc.
  *
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: filemon.c,v 1.22 2015/11/25 07:34:49 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: filemon.c,v 1.23 2016/01/05 09:37:11 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -391,8 +391,10 @@ static int
 filemon_modcmd(modcmd_t cmd, void *data)
 {
 	int error = 0;
+#ifdef _MODULE
 	int bmajor = -1;
 	int cmajor = -1;
+#endif
 
 	switch (cmd) {
 	case MODULE_CMD_INIT:
@@ -401,15 +403,19 @@ filemon_modcmd(modcmd_t cmd, void *data)
 #endif
 
 		error = filemon_load(data);
+#ifdef _MODULE
 		if (!error)
 			error = devsw_attach("filemon", NULL, &bmajor,
 			    &filemon_cdevsw, &cmajor);
+#endif
 		break;
 
 	case MODULE_CMD_FINI:
 		error = filemon_unload();
+#ifdef _MODULE
 		if (!error)
 			error = devsw_detach(NULL, &filemon_cdevsw);
+#endif
 		break;
 
 	case MODULE_CMD_STAT:

Reply via email to