List Info

Thread: A patch for match_file_string()




A patch for match_file_string()
country flaguser name
United States
2008-03-13 15:40:38
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] = '';

        sprintf(command, "/usr/bin/strings %s",
filename);
         if ((pipe = popen(command, "r")) == NULL)
{

============================================================
=========

Regards,
Alex


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

--
Crash-utility mailing list
Crash-utilityredhat.com
https://www.redhat.com/mailman/listinfo/crash-utility

Re: A patch for match_file_string()
user name
2008-03-13 16:23:58
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] = '';
> 
>         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-utilityredhat.com
https://www.redhat.com/mailman/listinfo/crash-utility

Re: A patch for match_file_string()
country flaguser name
United States
2008-03-14 08:11:02
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 (builddterranova) (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 (builddterranova) (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%40
redhat.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] = '';
> >
> >         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-utilityredhat.com
> https://www.redhat.com/mailman/listinfo/crash-utility



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

--
Crash-utility mailing list
Crash-utilityredhat.com
https://www.redhat.com/mailman/listinfo/crash-utility

Re: A patch for match_file_string()
user name
2008-03-14 08:35:59
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 (builddterranova) (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 (builddterranova) (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%40
redhat.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



--
Crash-utility mailing list
Crash-utilityredhat.com
https://www.redhat.com/mailman/listinfo/crash-utility

  
Re: A patch for match_file_string()
country flaguser name
United States
2008-03-14 08:58:41
On March 14, 2008 09:35:59 am Dave Anderson wrote:
> 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.

Hi Dave,

your patch works fine.  I agree it is safer to strip
directly kt->procversion 
as match_file_string() is a general-purpose function and can
be eventually 
used for something very different.

Regards,
Alex

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

--
Crash-utility mailing list
Crash-utilityredhat.com
https://www.redhat.com/mailman/listinfo/crash-utility

[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )