[PATCH] Add --skip option similar to dd skip=N option

Artem Bityutskiy dedekind1 at gmail.com
Sat Feb 28 06:05:35 PST 2015

Hi Eric,

thanks for the patch. I know that this is what I suggested, but now,
when I actually think about this, I am not sure if this is the right way
to implement --skip.

Let see. if my image is corrupted at the area that we are skipping, do
we expect bmaptool to error out? I think now, we are not writing the
corrupted part, we should proceed. Wit this implementation, the reading
function will complain about incorrect SHA checksum and the operation
will fail.

Instead of adding the --skip implementation to the write path, we need
to add it to the read path. That is, we do not even read and verify the
part of the image that we are skipping.

It occurs to me that the right place to add the code to is the
_get_block_ranges() generator. Just make sure that it does not yield
block ranges which are in the area that we are skipping.

And I think if you do this, you'll patch will be a lot shorter.

How does this sound to you?

Also, would you please run the files you modify through 'pylint' to
ensure the style and check against small mistakes?

Thank you!

On Fri, 2015-02-27 at 16:33 -0800, Eric Seifert wrote:
> This will skip N bytes from the input file when writing the output file.
> This is useful if splitting images (say by partition). As an example, if you
> have a disk image sda.img and a bmap sda.img.bmap and you want to extract
> the first partition sda1, you can run this command:
> bmaptool copy --skip 1048576 --bmap sda.img.bmap sda.img sda1.img
> Where 1048576 bytes is the offset into the disk where to first
> partition is (2048 * 512 byte sectors).

... snip ...

More information about the Bmap-tools mailing list