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#include <linux/kernel.h>
27#include <linux/module.h>
28#include <linux/proc_fs.h>
29#include <linux/seq_file.h>
30#include <linux/init.h>
31#include <asm/uaccess.h>
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46#define MAGIC_START "IKCFG_ST"
47#define MAGIC_END "IKCFG_ED"
48#include "config_data.h"
49
50
51#define MAGIC_SIZE (sizeof(MAGIC_START) - 1)
52#define kernel_config_data_size \
53 (sizeof(kernel_config_data) - 1 - MAGIC_SIZE * 2)
54
55#ifdef CONFIG_IKCONFIG_PROC
56
57static ssize_t
58ikconfig_read_current(struct file *file, char __user *buf,
59 size_t len, loff_t * offset)
60{
61 return simple_read_from_buffer(buf, len, offset,
62 kernel_config_data + MAGIC_SIZE,
63 kernel_config_data_size);
64}
65
66static const struct file_operations ikconfig_file_ops = {
67 .owner = THIS_MODULE,
68 .read = ikconfig_read_current,
69 .llseek = default_llseek,
70};
71
72static int __init ikconfig_init(void)
73{
74 struct proc_dir_entry *entry;
75
76
77 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
78 &ikconfig_file_ops);
79 if (!entry)
80 return -ENOMEM;
81
82 entry->size = kernel_config_data_size;
83
84 return 0;
85}
86
87static void __exit ikconfig_cleanup(void)
88{
89 remove_proc_entry("config.gz", NULL);
90}
91
92module_init(ikconfig_init);
93module_exit(ikconfig_cleanup);
94
95MODULE_LICENSE("GPL");
96MODULE_AUTHOR("Randy Dunlap");
97MODULE_DESCRIPTION("Echo the kernel .config file used to build the kernel");
98
99#endif
100