public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Banks <gnb@sgi.com>
To: Linux NFS ML <linux-nfs@vger.kernel.org>
Cc: "Frank Ch. Eigler" <fche@redhat.com>
Subject: [patch 5/5] Add a (not built) module to test the dprintk module.
Date: Mon, 19 Jan 2009 17:40:23 +1100	[thread overview]
Message-ID: <20090119064912.595383000@sgi.com> (raw)
In-Reply-To: 20090119064018.442220000@sgi.com

Not to be applied, test code only.

Signed-off-by: Greg Banks <gnb@sgi.com>
---

 kernel/Makefile       |    3 +
 kernel/test-dprintk.c |   69 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+)

Index: bfields/kernel/test-dprintk.c
===================================================================
--- /dev/null
+++ bfields/kernel/test-dprintk.c
@@ -0,0 +1,69 @@
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/proc_fs.h>
+#include <asm/uaccess.h>
+#include <linux/dprintk.h>
+
+int foo(int x)
+{
+	dprintk("foo: x=%d\n", x);
+	return x+42;
+}
+
+int bar(int x)
+{
+	dprintk("bar: x=%d\n", x);
+	return x-3;
+}
+
+static ssize_t exp_write(struct file *file, const char __user *ubuf,
+		         size_t len, loff_t *offp)
+{
+	char tmp[8];
+
+	if (*offp != 0 || len == 0)
+		return 0;
+	if (len > sizeof(tmp))
+		len = sizeof(tmp);
+
+	if (copy_from_user(tmp, ubuf, len))
+		return -EFAULT;
+
+	switch (tmp[0]) {
+	case 'f': foo(100); break;
+	case 'b': bar(100); break;
+	}
+
+	*offp += len;
+	return len;
+}
+
+static struct file_operations exp_fops = {
+	.write = exp_write,
+};
+
+static int __init exp_init(void)
+{
+	struct proc_dir_entry *pde;
+
+	printk("exp_init:\n");
+
+	pde = create_proc_entry("foobar", 0200, &proc_root);
+	if (pde != NULL)
+		pde->proc_fops = &exp_fops;
+
+	return 0;
+}
+
+static void __exit exp_cleanup(void)
+{
+	printk("exp_cleanup:\n");
+	remove_proc_entry("foobar", &proc_root);
+}
+
+MODULE_LICENSE("GPL");
+module_init(exp_init);
+module_exit(exp_cleanup);
+
+/* vim:set ai sw=8 sts=8: */
Index: bfields/kernel/Makefile
===================================================================
--- bfields.orig/kernel/Makefile
+++ bfields/kernel/Makefile
@@ -91,6 +91,9 @@ obj-$(CONFIG_SMP) += sched_cpupri.o
 obj-$(CONFIG_SLOW_WORK) += slow-work.o
 obj-$(CONFIG_DPRINTK) += dprintk.o
 
+# Uncomment this to build a module for testing dprintk.ko
+# obj-m += test-dprintk.o
+
 ifneq ($(CONFIG_SCHED_OMIT_FRAME_POINTER),y)
 # According to Alan Modra <alan-HpYC8cTCicIJY7gZg3T8ig@public.gmane.org>, the -fno-omit-frame-pointer is
 # needed for x86 only.  Why this used to be enabled for all architectures is beyond

--
-- 
Greg Banks, P.Engineer, SGI Australian Software Group.
the brightly coloured sporks of revolution.
I don't speak for SGI.

      parent reply	other threads:[~2009-01-19  6:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-19  6:40 [patch 0/5] activate & deactivate dprintks individually and severally Greg Banks
2009-01-19  6:40 ` [patch 1/5] Move definitions of struct module_sect_attr back into module.h Greg Banks
2009-01-19  6:40 ` [patch 2/5] Add apply_modules() which applies a function to each module Greg Banks
2009-01-19  6:40 ` [patch 3/5] Make the dprintk() macro record information about the callsite Greg Banks
2009-01-19  6:40 ` [patch 4/5] Add the dprintk module to allow dprintks to be activated/deactivated singly Greg Banks
2009-01-19  6:40 ` Greg Banks [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090119064912.595383000@sgi.com \
    --to=gnb@sgi.com \
    --cc=fche@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox