File crash-fix-files-2.6.25-later.diff of Package crash
Date: Fri, 24 Oct 2008 08:49:49 -0400
From: Dave Anderson <anderson@redhat.com>
To: "Discussion list for crash utility usage, maintenance and development" <crash-utility@redhat.com>
Subject: [Crash-utility] [PATCH] Fix for "files" command on 2.6.25 or later kernels
Fix for the "files" command when run on 2.6.25 and later kernels, which either
fails with an "invalid kernel virtual address" error of type
"fill_dentry_cache", or shows nonsensical/garbage "ROOT" and "CWD" directory
pathnames. This was due to the change in format of the kernel's fs_struct.
Queued for the next release.
Signed-off-by: Dave Anderson <anderson@redhat.com>
Acked-by: Bernhard Walle <bwalle@suse.de>
---
filesys.c | 32 +++++++++++++++++++++++++++-----
1 file changed, 27 insertions(+), 5 deletions(-)
--- a/filesys.c
+++ b/filesys.c
@@ -1755,10 +1755,10 @@ vfs_init(void)
MEMBER_OFFSET_INIT(file_f_dentry, "file", "f_dentry");
MEMBER_OFFSET_INIT(file_f_vfsmnt, "file", "f_vfsmnt");
MEMBER_OFFSET_INIT(file_f_count, "file", "f_count");
+ MEMBER_OFFSET_INIT(path_mnt, "path", "mnt");
+ MEMBER_OFFSET_INIT(path_dentry, "path", "dentry");
if (INVALID_MEMBER(file_f_dentry)) {
MEMBER_OFFSET_INIT(file_f_path, "file", "f_path");
- MEMBER_OFFSET_INIT(path_mnt, "path", "mnt");
- MEMBER_OFFSET_INIT(path_dentry, "path", "dentry");
ASSIGN_OFFSET(file_f_dentry) = OFFSET(file_f_path) + OFFSET(path_dentry);
ASSIGN_OFFSET(file_f_vfsmnt) = OFFSET(file_f_path) + OFFSET(path_mnt);
}
@@ -2071,7 +2071,7 @@ open_files_dump(ulong task, int flags, s
ulong fd;
ulong file;
ulong value;
- int i, j;
+ int i, j, use_path;
int header_printed = 0;
char root_pathname[BUFSIZE];
char pwd_pathname[BUFSIZE];
@@ -2112,7 +2112,12 @@ open_files_dump(ulong task, int flags, s
readmem(fs_struct_addr, KVADDR, fs_struct_buf, SIZE(fs_struct),
"fs_struct buffer", FAULT_ON_ERROR);
- root_dentry = ULONG(fs_struct_buf + OFFSET(fs_struct_root));
+ use_path = (MEMBER_TYPE("fs_struct", "root") == TYPE_CODE_STRUCT);
+ if (use_path)
+ root_dentry = ULONG(fs_struct_buf + OFFSET(fs_struct_root) +
+ OFFSET(path_dentry));
+ else
+ root_dentry = ULONG(fs_struct_buf + OFFSET(fs_struct_root));
if (root_dentry) {
if (VALID_MEMBER(fs_struct_rootmnt)) {
@@ -2120,13 +2125,23 @@ open_files_dump(ulong task, int flags, s
OFFSET(fs_struct_rootmnt));
get_pathname(root_dentry, root_pathname,
BUFSIZE, 1, vfsmnt);
+ } else if (use_path) {
+ vfsmnt = ULONG(fs_struct_buf +
+ OFFSET(fs_struct_root) +
+ OFFSET(path_mnt));
+ get_pathname(root_dentry, root_pathname,
+ BUFSIZE, 1, vfsmnt);
} else {
get_pathname(root_dentry, root_pathname,
BUFSIZE, 1, 0);
}
}
- pwd_dentry = ULONG(fs_struct_buf + OFFSET(fs_struct_pwd));
+ if (use_path)
+ pwd_dentry = ULONG(fs_struct_buf + OFFSET(fs_struct_pwd) +
+ OFFSET(path_dentry));
+ else
+ pwd_dentry = ULONG(fs_struct_buf + OFFSET(fs_struct_pwd));
if (pwd_dentry) {
if (VALID_MEMBER(fs_struct_pwdmnt)) {
@@ -2134,6 +2149,13 @@ open_files_dump(ulong task, int flags, s
OFFSET(fs_struct_pwdmnt));
get_pathname(pwd_dentry, pwd_pathname,
BUFSIZE, 1, vfsmnt);
+ } else if (use_path) {
+ vfsmnt = ULONG(fs_struct_buf +
+ OFFSET(fs_struct_pwd) +
+ OFFSET(path_mnt));
+ get_pathname(pwd_dentry, pwd_pathname,
+ BUFSIZE, 1, vfsmnt);
+
} else {
get_pathname(pwd_dentry, pwd_pathname,
BUFSIZE, 1, 0);