--- /dev/null
+/*
+ * Copyright (C) 2010 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <linux/module.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+
+MODULE_LICENSE("GPL");
+
+static char hello[] = "Hello, world!\n";
+
+static void *hp_start(struct seq_file *s, loff_t *pos)
+{
+ loff_t hp_pos = *pos;
+ *pos += 1;
+ if (hp_pos >= sizeof(hello))
+ return NULL;
+ return (void *) hello[hp_pos];
+}
+
+static void hp_stop(struct seq_file *s, void *v)
+{
+}
+
+static void *hp_next(struct seq_file *s, void *v, loff_t *pos)
+{
+ loff_t hp_pos;
+ hp_pos = *pos;
+ *pos += 1;
+ if (hp_pos >= sizeof(hello))
+ return NULL;
+ return (void *) hello[hp_pos];
+}
+
+static int hp_show(struct seq_file *s, void *v)
+{
+ seq_putc(s, (char) v);
+ return 0;
+}
+
+static const struct seq_operations hp_seq_ops = {
+ .start = hp_start,
+ .stop = hp_stop,
+ .next = hp_next,
+ .show = hp_show,
+};
+
+static int hp_open(struct inode *ino, struct file *fp)
+{
+ return seq_open(fp, &hp_seq_ops);
+}
+
+static const struct file_operations hp_fops = {
+ .owner = THIS_MODULE,
+ .open = hp_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = seq_release,
+};
+
+static __init int hp_init(void)
+{
+ struct proc_dir_entry *pde;
+ pde = proc_create("hello", 0666, NULL, &hp_fops);
+ if (!pde)
+ return -ENOMEM;
+ return 0;
+}
+
+static __exit void hp_exit(void)
+{
+ remove_proc_entry("hello", NULL);
+}
+
+module_init(hp_init);
+module_exit(hp_exit);