[RFC][PATCH 3/3] Kdump: Export crash notes section address throughsysfs

From: Vivek Goyal
Date: Thu Feb 24 2005 - 10:54:11 EST




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@xxxxxxxxxx>
---

linux-2.6.11-rc4-mm1-maneesh/arch/i386/kernel/crash.c | 2 --
linux-2.6.11-rc4-mm1-maneesh/include/asm-i386/kexec.h | 5 +++++
linux-2.6.11-rc4-mm1-maneesh/kernel/ksysfs.c | 13 +++++++++++++
3 files changed, 18 insertions(+), 2 deletions(-)

diff -puN kernel/ksysfs.c~kexec-exports-thru-sysfs kernel/ksysfs.c
--- linux-2.6.11-rc4-mm1/kernel/ksysfs.c~kexec-exports-thru-sysfs 2005-02-24 13:49:27.953186392 +0530
+++ linux-2.6.11-rc4-mm1-maneesh/kernel/ksysfs.c 2005-02-24 13:49:27.969183960 +0530
@@ -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
};

diff -puN include/asm-i386/kexec.h~kexec-exports-thru-sysfs include/asm-i386/kexec.h
--- linux-2.6.11-rc4-mm1/include/asm-i386/kexec.h~kexec-exports-thru-sysfs 2005-02-24 13:49:27.957185784 +0530
+++ linux-2.6.11-rc4-mm1-maneesh/include/asm-i386/kexec.h 2005-02-24 13:49:27.970183808 +0530
@@ -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 arch/i386/kernel/crash.c~kexec-exports-thru-sysfs arch/i386/kernel/crash.c
--- linux-2.6.11-rc4-mm1/arch/i386/kernel/crash.c~kexec-exports-thru-sysfs 2005-02-24 13:49:27.960185328 +0530
+++ linux-2.6.11-rc4-mm1-maneesh/arch/i386/kernel/crash.c 2005-02-24 13:49:27.970183808 +0530
@@ -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];

_
--