On Fri, 7 Dec 2007 15:11:13 -0800 Andrew Morton wrote:
> On Fri, 7 Dec 2007 14:15:36 -0800
> Randy Dunlap <[email protected]> wrote:
>
> > > Help would really be appreciated.
> >
> > Let's try the last_sysfs_file (name) patch.
> > I've attempted to update it for 2.6.22.14.
> > Andrew, does this change in fs/sysfs/file.c look OK?
>
> umm, yup.
>
> ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.21-rc6/2.6.21-rc6-mm1/broken-out/gregkh-driver-sysfs-crash-debugging.patch
>
> should work.
Thanks.
I produced a cleanly applying version of it for 2.6.22.14.
Vincent, please apply this patch so we can know which file in sysfs
these oopses are happening with.
---
From: Andrew Morton <[email protected]>
Display the most-recently-opened sysfs file's name when oopsing.
From: Adrian Bunk <[email protected]>
Build fix
From: Greg Kroah-Hartman <[email protected]>
Modified to make the api call cleaner, and available to all arches if
need be. Also added it to x86-64's crash dump message.
Signed-off-by: Adrian Bunk <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
arch/i386/kernel/traps.c | 1 +
arch/x86_64/kernel/traps.c | 1 +
fs/sysfs/file.c | 14 ++++++++++++++
include/linux/sysfs.h | 6 ++++++
4 files changed, 22 insertions(+)
--- linux-2.6.22.14.orig/arch/i386/kernel/traps.c
+++ linux-2.6.22.14/arch/i386/kernel/traps.c
@@ -411,6 +411,7 @@ void die(const char * str, struct pt_reg
#endif
if (nl)
printk("\n");
+ sysfs_printk_last_file();
if (notify_die(DIE_OOPS, str, regs, err,
current->thread.trap_no, SIGSEGV) !=
NOTIFY_STOP) {
--- linux-2.6.22.14.orig/arch/x86_64/kernel/traps.c
+++ linux-2.6.22.14/arch/x86_64/kernel/traps.c
@@ -516,6 +516,7 @@ void __kprobes __die(const char * str, s
printk("DEBUG_PAGEALLOC");
#endif
printk("\n");
+ sysfs_printk_last_file();
notify_die(DIE_OOPS, str, regs, err, current->thread.trap_no, SIGSEGV);
show_registers(regs);
/* Executive summary in case the oops scrolled away */
--- linux-2.6.22.14.orig/fs/sysfs/file.c
+++ linux-2.6.22.14/fs/sysfs/file.c
@@ -8,6 +8,7 @@
#include <linux/namei.h>
#include <linux/poll.h>
#include <linux/list.h>
+#include <linux/limits.h>
#include <asm/uaccess.h>
#include <asm/semaphore.h>
@@ -15,6 +16,13 @@
#define to_sattr(a) container_of(a,struct subsys_attribute, attr)
+/* used in crash dumps to help with debugging */
+static char last_sysfs_file[PATH_MAX];
+void sysfs_printk_last_file(void)
+{
+ printk(KERN_EMERG "last sysfs file: %s\n", last_sysfs_file);
+}
+
/*
* Subsystem file operations.
* These operations allow subsystems to have files that can be
@@ -253,6 +261,12 @@ static int sysfs_open_file(struct inode
struct sysfs_buffer * buffer;
struct sysfs_ops * ops = NULL;
int error = 0;
+ char *p;
+
+ p = d_path(file->f_dentry, sysfs_mount, last_sysfs_file,
+ sizeof(last_sysfs_file));
+ if (p)
+ memmove(last_sysfs_file, p, strlen(p) + 1);
if (!kobj || !attr)
goto Einval;
--- linux-2.6.22.14.orig/include/linux/sysfs.h
+++ linux-2.6.22.14/include/linux/sysfs.h
@@ -125,6 +125,7 @@ void sysfs_remove_file_from_group(struct
const struct attribute *attr, const char *group);
void sysfs_notify(struct kobject * k, char *dir, char *attr);
+void sysfs_printk_last_file(void);
extern int sysfs_make_shadowed_dir(struct kobject *kobj,
@@ -240,6 +241,11 @@ static inline int __must_check sysfs_ini
return 0;
}
+static inline void sysfs_printk_last_file(void)
+{
+ ;
+}
+
#endif /* CONFIG_SYSFS */
#endif /* _SYSFS_H_ */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]