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 | 7 +++++++ 2 files changed, 10 insertions(+) diff -puN fs/sysfs/file.c~sysfs-crash-debugging fs/sysfs/file.c --- 25/fs/sysfs/file.c~sysfs-crash-debugging 2005-07-12 05:19:19.000000000 -0600 +++ 25-akpm/fs/sysfs/file.c 2005-07-12 05:30:28.000000000 -0600 @@ -6,6 +6,8 @@ #include #include #include +#include + #include #include @@ -324,8 +326,13 @@ 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) { + d_path(filp->f_dentry, sysfs_mount, last_sysfs_file, + sizeof(last_sysfs_file)); + return check_perm(inode,filp); } diff -puN arch/i386/kernel/traps.c~sysfs-crash-debugging arch/i386/kernel/traps.c --- 25/arch/i386/kernel/traps.c~sysfs-crash-debugging 2005-07-12 05:19:19.000000000 -0600 +++ 25-akpm/arch/i386/kernel/traps.c 2005-07-12 05:30:38.000000000 -0600 @@ -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; @@ -370,6 +372,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 _