[Crash-utility] A patch for match_file_string()

Alex Sidorenko asid at hp.com
Fri Mar 14 13:11:02 UTC 2008


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 at 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 at 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

> Alex Sidorenko wrote:
> > Hi Dave,
> >
> > on some distributions (e.g. Ubuntu) crash cannot find the live kernel
> > image because of a slight mismatch between kt->proc_version and 'strings'
> > output from namelist file (e.g. /boot/vmlinux-debug-2.6.22-14-generic)
> >
> > Namely, kt->proc_version is LF-terminated, but there is no LF in 'strings
> > vmlinux' output.
> >
> > If I strip LF from the end of kt->proc_version, everything works fine
> >
> > --- filesys.c.orig      2008-02-28 11:09:10.000000000 -0500
> > +++ filesys.c   2008-03-13 16:33:02.000000000 -0400
> > @@ -3689,7 +3689,10 @@
> >         int found;
> >         char command[BUFSIZE];
> >         FILE *pipe;
> > +       int slen = strlen(string);
> >
> > +       if (slen && string[slen-1] == '\n')
> > +         string[slen-1] = '\0';
> >
> >         sprintf(command, "/usr/bin/strings %s", filename);
> >          if ((pipe = popen(command, "r")) == NULL) {
> >
> > =====================================================================
> >
> > Regards,
> > Alex
>
> Hi Alex,
>
> Help me out here -- when I run it, both kt->proc_version and the buffer
> read from the strings output read by fgets() both have linefeeds.
>
> Are you saying that the fgets() call is stripping the linefeed from
> the strings output?  The "strings vmlinux" output has to have linefeeds
> or else it would be a huge mash of characters.
>
> What am I missing?
>
> Dave
>
> --
> Crash-utility mailing list
> Crash-utility at redhat.com
> https://www.redhat.com/mailman/listinfo/crash-utility



-- 
------------------------------------------------------------------
Alexandre Sidorenko             email: alexs at hplinux.canada.hp.com
Global Solutions Engineering:   Unix Networking
Hewlett-Packard (Canada)
------------------------------------------------------------------




More information about the Crash-utility mailing list