From: Andrew Morton Display the most-recently-opened sysfs file's name when oopsing. Signed-off-by: Andrew Morton --- arch/i386/kernel/traps.c | 3 +++ fs/sysfs/file.c | 8 ++++++++ 2 files changed, 11 insertions(+) diff -puN fs/sysfs/file.c~sysfs-crash-debugging fs/sysfs/file.c --- devel/fs/sysfs/file.c~sysfs-crash-debugging 2005-08-08 21:43:26.000000000 -0700 +++ devel-akpm/fs/sysfs/file.c 2005-08-08 21:43:41.000000000 -0700 @@ -7,6 +7,8 @@ #include #include #include +#include + #include #include @@ -340,8 +342,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-08-08 21:43:26.000000000 -0700 +++ devel-akpm/arch/i386/kernel/traps.c 2005-08-08 21:43:26.000000000 -0700 @@ -96,6 +96,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; @@ -368,6 +370,7 @@ void die(const char * str, struct pt_reg #endif if (nl) printk("\n"); + printk(KERN_ALERT "last sysfs file: %s\n", last_sysfs_file); #ifdef CONFIG_KGDB /* This is about the only place we want to go to kgdb even if in * user mode. But we must go in via a trap so within kgdb we will _