<div dir="ltr">Hi Artem, thanks for the comments, I will look at re-implementing as you suggest. One thing though is that since skip can be any number of bytes, the start of where we write can be mid-block, so you may have one block sent to be written where only part of it will be used. So I think at least some change in the write path will be needed to split that first block up if needed and adjust the seek offset. <div><br></div><div>-Eric</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Feb 28, 2015 at 6:05 AM, Artem Bityutskiy <span dir="ltr"><<a href="mailto:dedekind1@gmail.com" target="_blank">dedekind1@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Eric,<br>
<br>
thanks for the patch. I know that this is what I suggested, but now,<br>
when I actually think about this, I am not sure if this is the right way<br>
to implement --skip.<br>
<br>
Let see. if my image is corrupted at the area that we are skipping, do<br>
we expect bmaptool to error out? I think now, we are not writing the<br>
corrupted part, we should proceed. Wit this implementation, the reading<br>
function will complain about incorrect SHA checksum and the operation<br>
will fail.<br>
<br>
Instead of adding the --skip implementation to the write path, we need<br>
to add it to the read path. That is, we do not even read and verify the<br>
part of the image that we are skipping.<br>
<br>
It occurs to me that the right place to add the code to is the<br>
_get_block_ranges() generator. Just make sure that it does not yield<br>
block ranges which are in the area that we are skipping.<br>
<br>
And I think if you do this, you'll patch will be a lot shorter.<br>
<br>
How does this sound to you?<br>
<br>
Also, would you please run the files you modify through 'pylint' to<br>
ensure the style and check against small mistakes?<br>
<br>
Thank you!<br>
<span class=""><br>
<br>
On Fri, 2015-02-27 at 16:33 -0800, Eric Seifert wrote:<br>
> This will skip N bytes from the input file when writing the output file.<br>
> This is useful if splitting images (say by partition). As an example, if you<br>
> have a disk image sda.img and a bmap sda.img.bmap and you want to extract<br>
> the first partition sda1, you can run this command:<br>
><br>
> bmaptool copy --skip 1048576 --bmap sda.img.bmap sda.img sda1.img<br>
><br>
> Where 1048576 bytes is the offset into the disk where to first<br>
> partition is (2048 * 512 byte sectors).<br>
<br>
</span>... snip ...<br>
<br>
</blockquote></div><br></div>