/*1* kernel/configs.c2* Echo the kernel .config file used to build the kernel3*4* Copyright (C) 2002 Khalid Aziz <[email protected]>5* Copyright (C) 2002 Randy Dunlap <[email protected]>6* Copyright (C) 2002 Al Stone <[email protected]>7* Copyright (C) 2002 Hewlett-Packard Company8*9* This program is free software; you can redistribute it and/or modify10* it under the terms of the GNU General Public License as published by11* the Free Software Foundation; either version 2 of the License, or (at12* your option) any later version.13*14* This program is distributed in the hope that it will be useful, but15* WITHOUT ANY WARRANTY; without even the implied warranty of16* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or17* NON INFRINGEMENT. See the GNU General Public License for more18* details.19*20* You should have received a copy of the GNU General Public License21* along with this program; if not, write to the Free Software22* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.23*/2425#include <linux/kernel.h>26#include <linux/module.h>27#include <linux/proc_fs.h>28#include <linux/seq_file.h>29#include <linux/init.h>30#include <asm/uaccess.h>3132/**************************************************/33/* the actual current config file */3435/*36* Define kernel_config_data and kernel_config_data_size, which contains the37* wrapped and compressed configuration file. The file is first compressed38* with gzip and then bounded by two eight byte magic numbers to allow39* extraction from a binary kernel image:40*41* IKCFG_ST42* <image>43* IKCFG_ED44*/45#define MAGIC_START "IKCFG_ST"46#define MAGIC_END "IKCFG_ED"47#include "config_data.h"484950#define MAGIC_SIZE (sizeof(MAGIC_START) - 1)51#define kernel_config_data_size \52(sizeof(kernel_config_data) - 1 - MAGIC_SIZE * 2)5354#ifdef CONFIG_IKCONFIG_PROC5556static ssize_t57ikconfig_read_current(struct file *file, char __user *buf,58size_t len, loff_t * offset)59{60return simple_read_from_buffer(buf, len, offset,61kernel_config_data + MAGIC_SIZE,62kernel_config_data_size);63}6465static const struct file_operations ikconfig_file_ops = {66.owner = THIS_MODULE,67.read = ikconfig_read_current,68.llseek = default_llseek,69};7071static int __init ikconfig_init(void)72{73struct proc_dir_entry *entry;7475/* create the current config file */76entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,77&ikconfig_file_ops);78if (!entry)79return -ENOMEM;8081entry->size = kernel_config_data_size;8283return 0;84}8586static void __exit ikconfig_cleanup(void)87{88remove_proc_entry("config.gz", NULL);89}9091module_init(ikconfig_init);92module_exit(ikconfig_cleanup);9394MODULE_LICENSE("GPL");95MODULE_AUTHOR("Randy Dunlap");96MODULE_DESCRIPTION("Echo the kernel .config file used to build the kernel");9798#endif /* CONFIG_IKCONFIG_PROC */99100101