2 * Copyright (C) 2010 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include <linux/module.h>
20 #include <linux/proc_fs.h>
21 #include <linux/seq_file.h>
23 MODULE_LICENSE("GPL");
25 static char hello[] = "Hello, world!\n";
27 static void *hp_start(struct seq_file *s, loff_t *pos)
31 if (hp_pos >= sizeof(hello))
33 return (void *) hello[hp_pos];
36 static void hp_stop(struct seq_file *s, void *v)
40 static void *hp_next(struct seq_file *s, void *v, loff_t *pos)
45 if (hp_pos >= sizeof(hello))
47 return (void *) hello[hp_pos];
50 static int hp_show(struct seq_file *s, void *v)
52 seq_putc(s, (char) v);
56 static const struct seq_operations hp_seq_ops = {
63 static int hp_open(struct inode *ino, struct file *fp)
65 return seq_open(fp, &hp_seq_ops);
68 static const struct file_operations hp_fops = {
73 .release = seq_release,
76 static __init int hp_init(void)
78 struct proc_dir_entry *pde;
79 pde = proc_create("hello", 0666, NULL, &hp_fops);
85 static __exit void hp_exit(void)
87 remove_proc_entry("hello", NULL);