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 |
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... |
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> |
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. |
its location doesn't seem to be nailed down
|
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 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. |
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. :p
|
decent idea
just use sed instead |
Quote:
Rob |
All times are GMT -5. The time now is 07:22 PM. |