[PATCH] Fix for "files" command on 2.6.25 or later kernels

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

--- filesys.c	14 Mar 2008 14:16:55 -0000	1.66
+++ filesys.c	22 Oct 2008 20:54:31 -0000	1.67
@@ -1755,10 +1755,10 @@
 	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 @@
 	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 @@
                 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 @@
                         		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 @@
                         		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);
--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/crash-utility

[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux