LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 12-02-2006, 10:55 PM   #1
rcorkum
Member
 
Registered: Aug 2005
Location: Thunder Bay, Ontario, Canada
Distribution: Slackware Current
Posts: 113

Rep: Reputation: 15
anyway to extract a version string from a non running vmlinuz ?


as I said in an earlier post i am getting kernelitis and need to do some labeling now i could start tossing and redoing but if there is a way to get the version out already would make life easier and quicker (p233)

or the uncompressed vmlinux even.

thanks

Last edited by rcorkum; 12-03-2006 at 12:36 AM.
 
Old 12-03-2006, 03:23 AM   #2
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
grep reads binary files so you can get it that way. at least in a round-about fashion:

grep "2.4.33" ./vmlinuz
returns true

In other words you'd have to write a script which would loop through the possible version numbers until it finds a match. Not very dependable...
 
Old 12-07-2006, 01:46 PM   #3
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
You could improve the reliability & possibly the speed of your script if you can determine the area of the vmlinu[z|x] the the string is located in, then use dd to limit your examination to that range of bytes:
Code:
F=<target_file>
M=<irrelevant_leading_bytes>
N=<interesting_bytes>
V=<list_of_version_strings>
X=$(dd bs=1 count=$N skip=$M if=$F)
for v in $V 
do 
   grep $v $F
done
also using fgrep may be faster. Sorry I'm on the road on <barf>an XP</barf> machine & cannot test my suggested code. caveat emptor
 
Old 12-08-2006, 01:57 AM   #4
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
Yeah, at first I thought of the 'magic' bytes that rdev reads/modifies and that the version string might be readable in a similar way.
I think there's no problem with speed using grep -it returns an answer right away. But having to loop through every possible version number could take a very long time. grep returns no location info -the kernel is a single long line of code I guess.
The version info is probably in a specific spot, though as you suggest -if we could just find out where then dd would be the way to get it.
Frankly, I think the exercise is mostly useless. The OP is obviously a newbie and if he really wants to know which kernel he's running, should install a known version and label it anyway he likes. Even if we get the version number, that still tells us very little about the kernel. I can see the utility of something like this though: if the kernel would print out a copy of it's config file -like the way busybox does. That way you could duplicate the kernel if needed.
I don't mean to be unhelpful -I gave the only solution I could think of since no one had answered the post. Some sort of loop using dd/seek should be able to find the location of the bits in question, then it would be fairly simple to query any given kernel.
 
Old 12-08-2006, 09:54 AM   #5
kodon
Member
 
Registered: Jul 2004
Location: [jax][fl][usa]
Distribution: Slackware64-current
Posts: 796

Rep: Reputation: 31
its location doesn't seem to be nailed down
 
Old 12-08-2006, 10:39 AM   #6
xflow7
Member
 
Registered: May 2004
Distribution: Slackware
Posts: 215

Rep: Reputation: 45
Why iterate through every possible kernel version? Couldn't you use a regular expression as the pattern for grep. Something like:

Code:
grep -e "2\.[46]\.[0-9]*" ./vmlinuz
if you knew that it could only be a 2.4 or 2.6 kernel. (apologies if I messed up the syntax, i can't test it at the moment)

You'd want to check that grep returned a single value to protect against there happening to be some other string in the image that would match a valid kernel version number but that's an issue even if you iterate through.
 
Old 12-08-2006, 12:12 PM   #7
xflow7
Member
 
Registered: May 2004
Distribution: Slackware
Posts: 215

Rep: Reputation: 45
Oh just tried my suggestion and now I understand. grep won't return the actual match from a binary file, just whether or not it matches. Not such a hot idea after all, I guess.
 
Old 12-08-2006, 01:36 PM   #8
kodon
Member
 
Registered: Jul 2004
Location: [jax][fl][usa]
Distribution: Slackware64-current
Posts: 796

Rep: Reputation: 31
decent idea

just use sed instead
 
Old 12-08-2006, 02:33 PM   #9
rcorkum
Member
 
Registered: Aug 2005
Location: Thunder Bay, Ontario, Canada
Distribution: Slackware Current
Posts: 113

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by gnashley
Yeah, at first I thought of the 'magic' bytes that rdev reads/modifies and that the version string might be readable in a similar way.
I think there's no problem with speed using grep -it returns an answer right away. But having to loop through every possible version number could take a very long time. grep returns no location info -the kernel is a single long line of code I guess.
The version info is probably in a specific spot, though as you suggest -if we could just find out where then dd would be the way to get it.
Frankly, I think the exercise is mostly useless. The OP is obviously a newbie and if he really wants to know which kernel he's running, should install a known version and label it anyway he likes. Even if we get the version number, that still tells us very little about the kernel. I can see the utility of something like this though: if the kernel would print out a copy of it's config file -like the way busybox does. That way you could duplicate the kernel if needed.
I don't mean to be unhelpful -I gave the only solution I could think of since no one had answered the post. Some sort of loop using dd/seek should be able to find the location of the bits in question, then it would be fairly simple to query any given kernel.
oh I appreciated the help I really did, thats what I did load each one I was questioning rebooted and unamed it and then renamed the system.map and kernel to match what it was and repeated till done. just been intrigued and following the responses.

Rob
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
extract substring from string in C baddah Programming 6 02-02-2010 04:22 AM
How to extract uncompressed image from /boot/vmlinuz-2.6.11 ?? trelf Linux - Kernel 4 05-30-2006 07:51 PM
Best way to extract GNOME version ghaefb Programming 3 06-24-2005 05:18 PM
newbie -- have no vmlinuz.version.h file roshk Linux - Software 2 12-31-2004 08:27 PM
vmlinuz.version.h problem compiling D-Link PCI ethernet adapter driver dancin Linux - Networking 2 08-09-2004 02:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 10:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration