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

Eric Seifert seiferteric at gmail.com
Sat Feb 28 10:00:54 PST 2015

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.


On Sat, Feb 28, 2015 at 6:05 AM, Artem Bityutskiy <dedekind1 at gmail.com>

> 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 ...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/bmap-tools/attachments/20150228/64a2b345/attachment.html>

More information about the Bmap-tools mailing list