
From: Vivek Goyal <vgoyal@in.ibm.com>

o Following patch exports kexec global variable "crash_notes" to user space
  through sysfs as kernel attribute in /sys/kernel.

Signed-off-by: Maneesh Soni <maneesh@in.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/arch/i386/kernel/crash.c |    2 --
 25-akpm/include/asm-i386/kexec.h |    5 +++++
 25-akpm/kernel/ksysfs.c          |   13 +++++++++++++
 3 files changed, 18 insertions(+), 2 deletions(-)

diff -puN arch/i386/kernel/crash.c~kdump-export-crash-notes-section-address-through arch/i386/kernel/crash.c
--- 25/arch/i386/kernel/crash.c~kdump-export-crash-notes-section-address-through	2005-02-24 20:59:07.000000000 -0800
+++ 25-akpm/arch/i386/kernel/crash.c	2005-02-24 20:59:07.000000000 -0800
@@ -26,8 +26,6 @@
 #include <asm/apic.h>
 #include <mach_ipi.h>
 
-#define MAX_NOTE_BYTES 1024
-typedef u32 note_buf_t[MAX_NOTE_BYTES/4];
 
 note_buf_t crash_notes[NR_CPUS];
 
diff -puN include/asm-i386/kexec.h~kdump-export-crash-notes-section-address-through include/asm-i386/kexec.h
--- 25/include/asm-i386/kexec.h~kdump-export-crash-notes-section-address-through	2005-02-24 20:59:07.000000000 -0800
+++ 25-akpm/include/asm-i386/kexec.h	2005-02-24 20:59:07.000000000 -0800
@@ -25,4 +25,9 @@
 /* The native architecture */
 #define KEXEC_ARCH KEXEC_ARCH_386
 
+#define MAX_NOTE_BYTES 1024
+typedef u32 note_buf_t[MAX_NOTE_BYTES/4];
+
+extern note_buf_t crash_notes[];
+
 #endif /* _I386_KEXEC_H */
diff -puN kernel/ksysfs.c~kdump-export-crash-notes-section-address-through kernel/ksysfs.c
--- 25/kernel/ksysfs.c~kdump-export-crash-notes-section-address-through	2005-02-24 20:59:07.000000000 -0800
+++ 25-akpm/kernel/ksysfs.c	2005-02-24 20:59:07.000000000 -0800
@@ -15,6 +15,8 @@
 #include <linux/module.h>
 #include <linux/init.h>
 
+#include <asm/kexec.h>
+
 #define KERNEL_ATTR_RO(_name) \
 static struct subsys_attribute _name##_attr = __ATTR_RO(_name)
 
@@ -30,6 +32,14 @@ static ssize_t hotplug_seqnum_show(struc
 KERNEL_ATTR_RO(hotplug_seqnum);
 #endif
 
+#ifdef CONFIG_KEXEC
+static ssize_t crash_notes_show(struct subsystem *subsys, char *page)
+{
+	return sprintf(page, "%p\n", (void *)crash_notes);
+}
+KERNEL_ATTR_RO(crash_notes);
+#endif
+
 decl_subsys(kernel, NULL, NULL);
 EXPORT_SYMBOL_GPL(kernel_subsys);
 
@@ -37,6 +47,9 @@ static struct attribute * kernel_attrs[]
 #ifdef CONFIG_HOTPLUG
 	&hotplug_seqnum_attr.attr,
 #endif
+#ifdef CONFIG_KEXEC
+	&crash_notes_attr.attr,
+#endif
 	NULL
 };
 
_
