0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include <linux/kernel.h>
0013 #include <linux/module.h>
0014 #include <linux/proc_fs.h>
0015 #include <linux/seq_file.h>
0016 #include <linux/init.h>
0017 #include <linux/uaccess.h>
0018
0019
0020
0021
0022
0023 asm (
0024 " .pushsection .rodata, \"a\" \n"
0025 " .ascii \"IKCFG_ST\" \n"
0026 " .global kernel_config_data \n"
0027 "kernel_config_data: \n"
0028 " .incbin \"kernel/config_data.gz\" \n"
0029 " .global kernel_config_data_end \n"
0030 "kernel_config_data_end: \n"
0031 " .ascii \"IKCFG_ED\" \n"
0032 " .popsection \n"
0033 );
0034
0035 #ifdef CONFIG_IKCONFIG_PROC
0036
0037 extern char kernel_config_data;
0038 extern char kernel_config_data_end;
0039
0040 static ssize_t
0041 ikconfig_read_current(struct file *file, char __user *buf,
0042 size_t len, loff_t * offset)
0043 {
0044 return simple_read_from_buffer(buf, len, offset,
0045 &kernel_config_data,
0046 &kernel_config_data_end -
0047 &kernel_config_data);
0048 }
0049
0050 static const struct proc_ops config_gz_proc_ops = {
0051 .proc_read = ikconfig_read_current,
0052 .proc_lseek = default_llseek,
0053 };
0054
0055 static int __init ikconfig_init(void)
0056 {
0057 struct proc_dir_entry *entry;
0058
0059
0060 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
0061 &config_gz_proc_ops);
0062 if (!entry)
0063 return -ENOMEM;
0064
0065 proc_set_size(entry, &kernel_config_data_end - &kernel_config_data);
0066
0067 return 0;
0068 }
0069
0070 static void __exit ikconfig_cleanup(void)
0071 {
0072 remove_proc_entry("config.gz", NULL);
0073 }
0074
0075 module_init(ikconfig_init);
0076 module_exit(ikconfig_cleanup);
0077
0078 #endif
0079
0080 MODULE_LICENSE("GPL");
0081 MODULE_AUTHOR("Randy Dunlap");
0082 MODULE_DESCRIPTION("Echo the kernel .config file used to build the kernel");