Alex Sidorenko wrote:
On March 13, 2008 05:23:58 pm Dave Anderson wrote:
Hi Dave,
even though my fix works, explanation was incorrect :-(
Yes, both strings are LF-terminated, but on Ubuntu the string in 'strings'
output has extra information appended at the end.
/proc/version:
Linux version 2.6.22-14-generic (buildd@terranova) (gcc version 4.1.3 20070929
(prerelease) (Ubuntu 4.1.2-16ubuntu2)) #1 SMP Tue Feb 12 07:42:25 UTC 2008
'strings' output:
Linux version 2.6.22-14-generic (buildd@terranova) (gcc version 4.1.3 20070929
(prerelease) (Ubuntu 4.1.2-16ubuntu2)) #1 SMP Tue Feb 12 07:42:25 UTC 2008
(Ubuntu 2.6.22-14.52-generic)
So on Ubuntu there is additional '(Ubuntu 2.6.22-14.52-generic)' after the
string itself.
This is more of the problem we discussed and fixed in
http://www.mail-archive.com/crash-utility%40redhat.com/msg00442.html
Now match_file_string() is used in two places to compare with
kt->proc_version and in one place with
if (!match_file_string(system_map, "D system_utsname", buffer))
Stripping LF makes strstr() find a partial match. This should be OK for
comparisons with /proc/version and I think it's OK for "D system_utsname"
either.
Regards,
Alex
After refreshing my memory banks, I remembered the earlier Ubuntu
inspired patch -- thanks for pulling out the post.
Anyway, since match_file_string() is used by multiple entities, and in
the future a caller may actually want to include the linefeed, it doesn't
seem appropriate to make the change there.
Can you test the attached patch on both a live system and a dumpfile?
It strips the linefeed from the version string when it's initialized,
and makes a couple other minor adjustments, including to the first Ubuntu
patch, which shouldn't be required any more.
Thanks,
Dave
Index: filesys.c
===================================================================
RCS file: /nfs/projects/cvs/crash/filesys.c,v
retrieving revision 1.65
diff -u -p -r1.65 filesys.c
--- filesys.c 21 Jan 2008 18:43:48 -0000 1.65
+++ filesys.c 14 Mar 2008 13:25:51 -0000
@@ -709,6 +709,8 @@ get_proc_version(void)
fclose(version);
+ strip_linefeeds(kt->proc_version);
+
return TRUE;
}
Index: kernel.c
===================================================================
RCS file: /nfs/projects/cvs/crash/kernel.c,v
retrieving revision 1.182
diff -u -p -r1.182 kernel.c
--- kernel.c 27 Feb 2008 18:33:57 -0000 1.182
+++ kernel.c 14 Mar 2008 13:23:33 -0000
@@ -540,7 +540,7 @@ verify_version(void)
error(WARNING, "cannot read linux_banner string\n");
if (ACTIVE()) {
- len = strlen(kt->proc_version) - 1;
+ len = strlen(kt->proc_version);
if ((len > 0) && (strncmp(buf, kt->proc_version, len) != 0)) {
if (CRASHDEBUG(1)) {
fprintf(fp, "/proc/version:\n%s",
@@ -558,7 +558,7 @@ verify_version(void)
fprintf(fp, "linux_banner:\n%s\n", buf);
goto bad_match;
}
- strcpy(kt->proc_version, buf);
+ strcpy(kt->proc_version, strip_linefeeds(buf));
}
verify_namelist();
@@ -776,7 +776,7 @@ verify_namelist()
if (!strstr(buffer, "Linux version 2."))
continue;
- if (STREQ(buffer, kt->proc_version)) {
+ if (strstr(buffer, kt->proc_version)) {
found = TRUE;
break;
}
--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/crash-utility