--- /dev/null	Mon Jul  1 21:15:24 2013
+++ new/usr/src/uts/common/io/fsd/fsd.c	Mon Jul  1 21:15:24 2013
@@ -0,0 +1,212 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2013 Damian Bogel. All rights reserved.
+ */
+
+/*
+ * Kernel module part of the Hello World pseudo-device driver for illumos.
+ */
+
+/*
+ * TODO:
+ * - fsd_open(): check privilages
+ */
+
+#include <sys/conf.h>
+#include <sys/cred.h>
+#include <sys/ddi.h>
+#include <sys/devops.h>
+#include <sys/errno.h>
+#include <sys/file.h>
+#include <sys/fsd.h>
+#include <sys/modctl.h>
+#include <sys/open.h>
+#include <sys/stat.h>
+#include <sys/sunddi.h>
+#include <sys/types.h>
+
+#include "fsd_impl.h"
+
+/* Internal fsd world variables */
+static dev_info_t	*fsd_devinfo;
+
+static int
+fsd_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
+{
+	if (cmd != DDI_ATTACH)
+		return (DDI_FAILURE);
+
+	if (fsd_devinfo != NULL)
+		return (DDI_FAILURE);
+
+	int instance;
+	instance = ddi_get_instance(dip);
+	if (ddi_create_minor_node(dip, "fsd", S_IFCHR, instance,
+	    DDI_PSEUDO, 0) == DDI_FAILURE) {
+		fsd_print("Failed to create minor node\n");
+		return (DDI_FAILURE);
+	}
+	fsd_devinfo = dip;
+	return (DDI_SUCCESS);
+}
+
+static int
+fsd_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
+{
+	if (cmd != DDI_DETACH)
+		return (DDI_FAILURE);
+	ddi_remove_minor_node(dip, NULL);
+	fsd_devinfo = NULL;
+	return (DDI_SUCCESS);
+}
+
+static int
+fsd_getinfo(
+	dev_info_t *dip,
+	ddi_info_cmd_t infocmd,
+	void *arg,
+	void **resultp
+)
+{
+	_NOTE(ARGUNUSED(dip));
+	switch (infocmd) {
+	case DDI_INFO_DEVT2DEVINFO:
+		*resultp = (void*)(uintptr_t)getminor((dev_t)arg);
+		return (DDI_SUCCESS);
+	case DDI_INFO_DEVT2INSTANCE:
+		*resultp = fsd_devinfo;
+		return (DDI_SUCCESS);
+	default:
+		return (DDI_FAILURE);
+	}
+}
+
+static int
+fsd_open(dev_t *devp, int oflag, int sflag, cred_t *cred_p)
+{
+	_NOTE(ARGUNUSED(devp));
+	_NOTE(ARGUNUSED(oflag));
+	_NOTE(ARGUNUSED(sflag));
+	_NOTE(ARGUNUSED(cred_p));
+	return (0);
+}
+
+static int
+fsd_close(dev_t dev, int flag, int otyp, cred_t *cred_p)
+{
+	_NOTE(ARGUNUSED(dev));
+	_NOTE(ARGUNUSED(flag));
+	_NOTE(ARGUNUSED(otyp));
+	_NOTE(ARGUNUSED(cred_p));
+	return (0);
+}
+
+static int
+fsd_ioctl(
+	dev_t dev,
+	int cmd,
+	intptr_t arg,
+	int mode,
+	cred_t *cred_p,
+	int *rval_p
+)
+{
+	_NOTE(ARGUNUSED(dev));
+	_NOTE(ARGUNUSED(cred_p));
+	_NOTE(ARGUNUSED(rval_p));
+
+	switch (cmd) {
+	case FSD_PRINT_MSG:
+	{
+		struct fsd_msg m;
+		if (ddi_copyin(
+		    (void*)arg, &m.len, sizeof (m.len), mode) != 0)
+			return (EFAULT);
+		if (m.len > FSD_MAX_MSG_LEN)
+			return (EINVAL);
+		if (ddi_copyin(
+		    (void*)((uintptr_t)arg + sizeof (m.len)),
+		    m.s, m.len, mode) != 0)
+			return (EFAULT);
+		m.s[m.len] = '\0';
+		fsd_print(m.s);
+		break;
+	}
+	default:
+		return (EINVAL);
+	}
+	return (0);
+}
+
+
+static struct cb_ops cb_ops = {
+	fsd_open,	/* open(9E) */
+	fsd_close,	/* close(9E) */
+	nodev,		/* strategy(9E) */
+	nodev,		/* print(9E) */
+	nodev,		/* dump(9E) */
+	nodev,		/* read(9E) */
+	nodev,		/* write(9E) */
+	fsd_ioctl,	/* ioctl(9E) */
+	nodev,		/* devmap(9E) */
+	nodev,		/* mmap(9E) */
+	nodev,		/* segmap(9E) */
+	nochpoll,	/* chpoll(9E) */
+	ddi_prop_op,	/* prop_op(9E) */
+	NULL,		/* streamtab(9E) */
+	D_MP | D_64BIT,	/* cb_flag(9E) */
+	CB_REV,		/* cb_rev(9E) */
+	nodev,		/* aread(9E) */
+	nodev,		/* awrite(9E) */
+};
+
+static struct dev_ops dev_ops = {
+	DEVO_REV,		/* driver build version */
+	0,			/* reference count */
+	fsd_getinfo,		/* getinfo */
+	nulldev,
+	nulldev,		/* probe */
+	fsd_attach,		/* attach */
+	fsd_detach,		/* detach */
+	nodev,
+	&cb_ops,		/* cb_ops */
+	NULL,			/* bus_ops */
+	NULL,			/* power */
+	ddi_quiesce_not_needed,	/* quiesce */
+};
+
+static struct modldrv modldrv = {
+	&mod_driverops,	"Filesystem Disturber Driver", &dev_ops
+};
+
+static struct modlinkage modlinkage = {
+	MODREV_1, &modldrv, NULL
+};
+
+int
+_init(void)
+{
+	return (mod_install(&modlinkage));
+}
+
+int
+_info(struct modinfo *modinfop)
+{
+	return (mod_info(&modlinkage, modinfop));
+}
+
+int
+_fini(void)
+{
+	return (mod_remove(&modlinkage));
+}
