]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/patches/suse-2.6.27.25/patches.drivers/sysfs-crash-debugging.patch
Updated xen patches taken from suse.
[people/pmueller/ipfire-2.x.git] / src / patches / suse-2.6.27.25 / patches.drivers / sysfs-crash-debugging.patch
1 Subject: display last accessed sysfs file on kernel panic message
2 From: Andrew Morton <akpm@osdl.org>
3 Patch-mainline: never
4
5 Display the most-recently-opened sysfs file's name when oopsing.
6
7 From: Adrian Bunk <bunk@stusta.de>
8
9 Build fix
10
11 From: Greg Kroah-Hartman <gregkh@suse.de>
12
13 Modified to make the api call cleaner, and available to all arches if
14 need be. Also added it to x86-64's crash dump message.
15
16
17 Signed-off-by: Adrian Bunk <bunk@stusta.de>
18 Signed-off-by: Andrew Morton <akpm@osdl.org>
19 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
20 ---
21 arch/x86/kernel/traps_32.c | 2 ++
22 arch/x86/kernel/traps_64.c | 2 ++
23 fs/sysfs/file.c | 14 ++++++++++++++
24 fs/sysfs/mount.c | 2 +-
25 include/linux/sysfs.h | 7 +++++++
26 5 files changed, 26 insertions(+), 1 deletion(-)
27
28 --- a/arch/x86/kernel/traps_32.c
29 +++ b/arch/x86/kernel/traps_32.c
30 @@ -428,6 +428,8 @@ int __kprobes __die(const char *str, str
31 printk("DEBUG_PAGEALLOC");
32 #endif
33 printk("\n");
34 +
35 + sysfs_printk_last_file();
36 if (notify_die(DIE_OOPS, str, regs, err,
37 current->thread.trap_no, SIGSEGV) == NOTIFY_STOP)
38 return 1;
39 --- a/arch/x86/kernel/traps_64.c
40 +++ b/arch/x86/kernel/traps_64.c
41 @@ -537,6 +537,8 @@ int __kprobes __die(const char *str, str
42 printk("DEBUG_PAGEALLOC");
43 #endif
44 printk("\n");
45 +
46 + sysfs_printk_last_file();
47 if (notify_die(DIE_OOPS, str, regs, err,
48 current->thread.trap_no, SIGSEGV) == NOTIFY_STOP)
49 return 1;
50 --- a/fs/sysfs/file.c
51 +++ b/fs/sysfs/file.c
52 @@ -16,6 +16,7 @@
53 #include <linux/slab.h>
54 #include <linux/fsnotify.h>
55 #include <linux/namei.h>
56 +#include <linux/limits.h>
57 #include <linux/poll.h>
58 #include <linux/list.h>
59 #include <linux/mutex.h>
60 @@ -23,6 +24,9 @@
61
62 #include "sysfs.h"
63
64 +/* used in crash dumps to help with debugging */
65 +static char last_sysfs_file[PATH_MAX];
66 +
67 /*
68 * There's one sysfs_buffer for each open file and one
69 * sysfs_open_dirent for each sysfs_dirent with one or more open
70 @@ -328,6 +332,11 @@ static int sysfs_open_file(struct inode
71 struct sysfs_buffer *buffer;
72 struct sysfs_ops *ops;
73 int error = -EACCES;
74 + char *p;
75 +
76 + p = d_path(&file->f_path, last_sysfs_file, sizeof(last_sysfs_file));
77 + if (p)
78 + memmove(last_sysfs_file, p, strlen(p) + 1);
79
80 /* need attr_sd for attr and ops, its parent for kobj */
81 if (!sysfs_get_active_two(attr_sd))
82 @@ -389,6 +398,11 @@ static int sysfs_open_file(struct inode
83 return error;
84 }
85
86 +void sysfs_printk_last_file(void)
87 +{
88 + printk(KERN_EMERG "last sysfs file: %s\n", last_sysfs_file);
89 +}
90 +
91 static int sysfs_release(struct inode *inode, struct file *filp)
92 {
93 struct sysfs_dirent *sd = filp->f_path.dentry->d_fsdata;
94 --- a/fs/sysfs/mount.c
95 +++ b/fs/sysfs/mount.c
96 @@ -22,7 +22,7 @@
97 /* Random magic number */
98 #define SYSFS_MAGIC 0x62656572
99
100 -static struct vfsmount *sysfs_mount;
101 +struct vfsmount *sysfs_mount;
102 struct super_block * sysfs_sb = NULL;
103 struct kmem_cache *sysfs_dir_cachep;
104
105 --- a/include/linux/sysfs.h
106 +++ b/include/linux/sysfs.h
107 @@ -121,6 +121,8 @@ void sysfs_notify(struct kobject *kobj,
108
109 extern int __must_check sysfs_init(void);
110
111 +void sysfs_printk_last_file(void);
112 +
113 #else /* CONFIG_SYSFS */
114
115 static inline int sysfs_schedule_callback(struct kobject *kobj,
116 @@ -231,6 +233,11 @@ static inline int __must_check sysfs_ini
117 return 0;
118 }
119
120 +static inline void sysfs_printk_last_file(void)
121 +{
122 + ;
123 +}
124 +
125 #endif /* CONFIG_SYSFS */
126
127 #endif /* _SYSFS_H_ */