summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorhaad <haad@NetBSD.org>2009-02-05 17:32:10 +0000
committerhaad <haad@NetBSD.org>2009-02-05 17:32:10 +0000
commit7aa7bdd03cb2ee1329a4fa08e5fcbe52dae30b1e (patch)
tree6657a11e6fb0ae9c0deb1ff3c479e74cf5b248de /sys
parent685cae19f28c016026775e99676028a20af68b99 (diff)
Add support for the MODULAR framework to the vnd driver. Enable building of
vnd.kmod by default.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/vnd.c60
-rw-r--r--sys/modules/Makefile5
-rw-r--r--sys/modules/vnd/Makefile13
3 files changed, 75 insertions, 3 deletions
diff --git a/sys/dev/vnd.c b/sys/dev/vnd.c
index 9ef546febfd..8b0e95d9d7c 100644
--- a/sys/dev/vnd.c
+++ b/sys/dev/vnd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vnd.c,v 1.192 2009/01/13 13:35:52 yamt Exp $ */
+/* $NetBSD: vnd.c,v 1.193 2009/02/05 17:32:10 haad Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
@@ -130,7 +130,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.192 2009/01/13 13:35:52 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.193 2009/02/05 17:32:10 haad Exp $");
#if defined(_KERNEL_OPT)
#include "fs_nfs.h"
@@ -1912,3 +1912,59 @@ vnd_set_properties(struct vnd_softc *vnd)
if (odisk_info)
prop_object_release(odisk_info);
}
+
+#ifdef _MODULE
+
+#include <sys/module.h>
+
+MODULE(MODULE_CLASS_DRIVER, vnd, NULL);
+CFDRIVER_DECL(vnd, DV_DISK, NULL);
+
+static int
+vnd_modcmd(modcmd_t cmd, void *arg)
+{
+ int bmajor = -1, cmajor = -1, error = 0;
+
+ switch (cmd) {
+ case MODULE_CMD_INIT:
+ error = config_cfdriver_attach(&vnd_cd);
+ if (error)
+ break;
+
+ error = config_cfattach_attach(vnd_cd.cd_name, &vnd_ca);
+ if (error) {
+ config_cfdriver_detach(&vnd_cd);
+ aprint_error("%s: unable to register cfattach\n",
+ vnd_cd.cd_name);
+ break;
+ }
+
+ error = devsw_attach("vnd", &vnd_bdevsw, &bmajor,
+ &vnd_cdevsw, &cmajor);
+ if (error) {
+ config_cfattach_detach(vnd_cd.cd_name, &vnd_ca);
+ config_cfdriver_detach(&vnd_cd);
+ break;
+ }
+
+ break;
+
+ case MODULE_CMD_FINI:
+ error = config_cfattach_detach(vnd_cd.cd_name, &vnd_ca);
+ if (error)
+ break;
+ config_cfdriver_detach(&vnd_cd);
+ devsw_detach(&vnd_bdevsw, &vnd_cdevsw);
+ break;
+
+ case MODULE_CMD_STAT:
+ return ENOTTY;
+
+ default:
+ return ENOTTY;
+ }
+
+ return error;
+}
+
+#endif
diff --git a/sys/modules/Makefile b/sys/modules/Makefile
index c1b839f8fa8..7916cab9ac6 100644
--- a/sys/modules/Makefile
+++ b/sys/modules/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.24 2009/01/05 15:36:51 pooka Exp $
+# $NetBSD: Makefile,v 1.25 2009/02/05 17:32:10 haad Exp $
# For all platforms
@@ -6,7 +6,9 @@ SUBDIR= accf_dataready
SUBDIR+= accf_httpready
SUBDIR+= adosfs
SUBDIR+= aio
+SUBDIR+= ccd
SUBDIR+= cd9660
+SUBDIR+= cgd
SUBDIR+= coda
SUBDIR+= coda5
SUBDIR+= compat
@@ -45,6 +47,7 @@ SUBDIR+= tmpfs
SUBDIR+= udf
SUBDIR+= umap
SUBDIR+= union
+SUBDIR+= vnd
.if (defined(NOTYET))
SUBDIR+= unionfs
.endif
diff --git a/sys/modules/vnd/Makefile b/sys/modules/vnd/Makefile
new file mode 100644
index 00000000000..c801459699e
--- /dev/null
+++ b/sys/modules/vnd/Makefile
@@ -0,0 +1,13 @@
+# $NetBSD: Makefile,v 1.1 2009/02/05 17:32:10 haad Exp $
+
+.include "../Makefile.inc"
+
+CPPFLAGS+= -D VND_COMPRESSION
+
+.PATH: ${S}/dev
+
+
+KMOD= vnd
+SRCS= vnd.c
+
+.include <bsd.kmodule.mk>