summaryrefslogtreecommitdiff
path: root/tests/mod_system_logger/mod_system_logger.c
blob: 1d31fdbefbf8ba6e6b0a6f974aa81554209d0170 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <linux/module.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>

int i;

static int system_proc_show(struct seq_file *m, void *v) {
  for(i=0; i<1000; i++)
    seq_printf(m, "Test Systemlogger %i\n",i);
  return 0;
}

static int system_proc_open(struct inode *inode, struct  file *file) {
  return single_open(file, system_proc_show, NULL);
}

static const struct file_operations system_proc_fops = {
  .owner = THIS_MODULE,
  .open = system_proc_open,
  .read = seq_read,
  .llseek = seq_lseek,
  .release = single_release,
};

static int __init system_proc_init(void) {
  proc_create("systemlogger", 0, NULL, &system_proc_fops);
  return 0;
}

static void __exit system_proc_exit(void) {
  remove_proc_entry("systemlogger", NULL);
}

MODULE_LICENSE("GPL");
module_init(system_proc_init);
module_exit(system_proc_exit);