[lkml]   [2011]   [Aug]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] scripts: add extract-vmlinux
On 11.8.2011 15:08, Corentin Chary wrote:
> On Thu, Aug 11, 2011 at 1:28 PM, Paul Bolle <> wrote:
>> On Thu, 2011-08-11 at 10:53 +0200, Corentin Chary wrote:
>>> +try_decompress()
>>> +{
>>> + for pos in `tr "$1\n$2" "\n$2=" < "$img" | grep -abo "^$2"`
>>> + do
>>> + pos=${pos%%:*}
>>> + tail -c+$pos "$img" | $3 > $tmp 2> /dev/null
>> Perhaps a few comments on the above lines would be nice. Without those
>> comments I must guess you're finding compressed data somewhere in the
>> input file. It also seems you're looping through the entire input file.
>> Or are (sequences of) commands like the above considered obvious?
> It's copied from extract-ikconfig, there was no comment in it, so I
> assumed it's obvious.
> Basically it uses brute force (tm) to find well known headers and try
> to decompress from here.

And explanation of the "tr" trick would not hurt though. It replaces the
binary magic with an ascii sequence on a new line (for older grep
versions to get it right) and tries all occurrences of that sequence, am
I right? But I wouldn't call it "obvious" :).

>>> +# That didn't work, so retry after decompression.
>>> +try_decompress '\037\213\010' xy gunzip
>>> +try_decompress '\3757zXZ\000' abcde unxz
>>> +try_decompress 'BZh' xy bunzip2
>>> +try_decompress '\135\0\0\0' xxx unlzma
>>> +try_decompress '\211\114\132' xy 'lzop -d'
>> Perhaps you could first test whether these commands are available before
>> running try_decompress() with them?
> Same as before, if it's ok for extract-ikconfig not to check the
> command, then it's ok for me.
> If it's not, then we should patch both.

Also, if you have lzma to build a lzma-compressed kernel, then you very
likely also have unlzma.


 \ /
  Last update: 2011-08-11 15:37    [W:0.089 / U:2.120 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site