fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / kernel / configs.c
index 326ab7b..8fa1fb2 100644 (file)
@@ -3,7 +3,7 @@
  * Echo the kernel .config file used to build the kernel
  *
  * Copyright (C) 2002 Khalid Aziz <khalid_aziz@hp.com>
- * Copyright (C) 2002 Randy Dunlap <rddunlap@osdl.org>
+ * Copyright (C) 2002 Randy Dunlap <rdunlap@xenotime.net>
  * Copyright (C) 2002 Al Stone <ahs3@fc.hp.com>
  * Copyright (C) 2002 Hewlett-Packard Company
  *
@@ -23,7 +23,6 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/proc_fs.h>
 /**************************************************/
 /* the actual current config file                 */
 
-/* This one is for extraction from the kernel binary file image. */
-#include "ikconfig.h"
+/*
+ * Define kernel_config_data and kernel_config_data_size, which contains the
+ * wrapped and compressed configuration file.  The file is first compressed
+ * with gzip and then bounded by two eight byte magic numbers to allow
+ * extraction from a binary kernel image:
+ *
+ *   IKCFG_ST
+ *   <image>
+ *   IKCFG_ED
+ */
+#define MAGIC_START    "IKCFG_ST"
+#define MAGIC_END      "IKCFG_ED"
+#include "config_data.h"
 
-#ifdef CONFIG_IKCONFIG_PROC
 
-/* This is the data that can be read from /proc/config.gz. */
-#include "config_data.h"
+#define MAGIC_SIZE (sizeof(MAGIC_START) - 1)
+#define kernel_config_data_size \
+       (sizeof(kernel_config_data) - 1 - MAGIC_SIZE * 2)
+
+#ifdef CONFIG_IKCONFIG_PROC
 
 /**************************************************/
 /* globals and useful constants                   */
 
-static const char IKCONFIG_VERSION[] __initdata = "0.7";
-
 static ssize_t
 ikconfig_read_current(struct file *file, char __user *buf,
                      size_t len, loff_t * offset)
@@ -58,14 +68,14 @@ ikconfig_read_current(struct file *file, char __user *buf,
                return 0;
 
        count = min(len, (size_t)(kernel_config_data_size - pos));
-       if(copy_to_user(buf, kernel_config_data + pos, count))
+       if (copy_to_user(buf, kernel_config_data + MAGIC_SIZE + pos, count))
                return -EFAULT;
 
        *offset += count;
        return count;
 }
 
-static struct file_operations ikconfig_file_ops = {
+static const struct file_operations ikconfig_file_ops = {
        .owner = THIS_MODULE,
        .read = ikconfig_read_current,
 };