[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4E43DA3F.7090709@suse.cz>
Date: Thu, 11 Aug 2011 15:33:51 +0200
From: Michal Marek <mmarek@...e.cz>
To: Corentin Chary <corentin.chary@...il.com>
Cc: Paul Bolle <pebolle@...cali.nl>, linux-kernel@...r.kernel.org,
Dick Streefland <dick@...eefland.net>,
WANG Cong <xiyou.wangcong@...il.com>
Subject: Re: [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 <pebolle@...cali.nl> 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.
Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists