File linux-2.6-debug-sysfs-crash-debugging.patch of Package kernel
From: Andrew Morton <akpm@osdl.org>
Display the most-recently-opened sysfs file's name when oopsing.
From: Adrian Bunk <bunk@stusta.de>
Build fix
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---
arch/i386/kernel/traps.c | 5 +++++
fs/sysfs/file.c | 8 ++++++++
2 files changed, 13 insertions(+)
diff -puN fs/sysfs/file.c~sysfs-crash-debugging fs/sysfs/file.c
--- devel/fs/sysfs/file.c~sysfs-crash-debugging 2005-11-22 22:31:16.000000000 -0800
+++ devel-akpm/fs/sysfs/file.c 2005-11-22 22:31:16.000000000 -0800
@@ -7,6 +7,7 @@
#include <linux/kobject.h>
#include <linux/namei.h>
#include <linux/poll.h>
+#include <linux/limits.h>
#include <asm/uaccess.h>
#include <asm/semaphore.h>
@@ -324,8 +326,14 @@ static int check_perm(struct inode * ino
return error;
}
+char last_sysfs_file[PATH_MAX];
+
static int sysfs_open_file(struct inode * inode, struct file * filp)
{
+ char *p = d_path(filp->f_dentry, sysfs_mount, last_sysfs_file,
+ sizeof(last_sysfs_file));
+ if (p)
+ memmove(last_sysfs_file, p, strlen(p) + 1);
return check_perm(inode,filp);
}
diff -puN arch/i386/kernel/traps.c~sysfs-crash-debugging arch/i386/kernel/traps.c
--- devel/arch/i386/kernel/traps.c~sysfs-crash-debugging 2005-11-22 22:31:16.000000000 -0800
+++ devel-akpm/arch/i386/kernel/traps.c 2005-11-22 22:31:16.000000000 -0800
@@ -95,6 +95,8 @@ static int kstack_depth_to_print = 24;
struct notifier_block *i386die_chain;
static DEFINE_SPINLOCK(die_notifier_lock);
+extern char last_sysfs_file[];
+
int register_die_notifier(struct notifier_block *nb)
{
int err = 0;
@@ -388,6 +388,9 @@ void die(const char * str, struct pt_reg
#endif
if (nl)
printk("\n");
+#ifdef CONFIG_SYSFS
+ printk(KERN_ALERT "last sysfs file: %s\n", last_sysfs_file);
+#endif
if (notify_die(DIE_OOPS, str, regs, err,
current->thread.trap_no, SIGSEGV) !=
NOTIFY_STOP)
--- linux-2.6.14/arch/x86_64/kernel/traps.c~ 2005-12-02 18:38:28.000000000 -0500
+++ linux-2.6.14/arch/x86_64/kernel/traps.c 2005-12-02 18:38:57.000000000 -0500
@@ -75,6 +75,8 @@ asmlinkage void call_debug(void);
struct notifier_block *die_chain;
static DEFINE_SPINLOCK(die_notifier_lock);
+extern char last_sysfs_file[];
+
int register_die_notifier(struct notifier_block *nb)
{
int err = 0;
@@ -416,6 +416,9 @@ void __die(const char * str, struct pt_r
printk("DEBUG_PAGEALLOC");
#endif
printk("\n");
+#ifdef CONFIG_SYSFS
+ printk(KERN_ALERT "last sysfs file: %s\n", last_sysfs_file);
+#endif
notify_die(DIE_OOPS, str, regs, err, current->thread.trap_no, SIGSEGV);
show_registers(regs);
/* Executive summary in case the oops scrolled away */