ubifs image file confusion!

Artem Bityutskiy dedekind at infradead.org
Wed May 14 09:45:44 EDT 2008


On Tue, 2008-05-13 at 20:52 +0800, Nancy wrote:
> > dd if=/dev/mtd5 of=file
> > or
> > dd if=/dev/ubi0_0 of=file
> dd have to specify the count, blk...... I mean read size, It is
> difficult to get the size.
> And the output file is large. We need a small output file (only
> contain neccessary data).
> Cause those files will be offered online. suppose, the /dev/mtd5 is
> 1G, or /dev/ubi0_0 is 500M
> but the neccessary data only 10 or 100MiB. That waist too many space
> and our bandwidth which is unacceptable.

I see. But it is not a good reason for an additional ioctl anyway. In
Linux we try to keep the amount of ioctl's as low as possible.

What you can do instead, is to read the volume LEB by LEB, then check
the data against 0xFFs, and if it contains all 0xFFs - drop this data.

> I mean will you please make the ubifs.img(generated by mkfs.ubifs)
> contains all mapped LEBs?
Well... An UBIFS image file generated by mkfs.ubifs does contain some
LEBs which have only 0xFFs in it. And when you write this image file
using ubiupdate vol - these LEBs will be detected and UBI will leave
them unmapped.

>  fill all ubifs.img's unmapped LEBs with
> 0x00. Is that possible?

No, it is not.

I think I got it what is the problem you have hit. You drop unmapped
LEBs when you dump the volume, then you flash this dumped data back and
UBIFS cannot work anymore. Right?

Of course. UBIFS has the index which refers LEB numbers. And when you
drop unmapped LEBs the numbers change!

For example, you have mapped LEB3, unmapped LEB4, mapped LEB5. The UBIFS
index refers LEB3 and LEB5. You dump the volume and drop LEB4. Then you
flash the dumped image and LEB5 becomes LEB4! So the index now refers
incorrect LEB.

Basically speaking, you cannot do stuff like this. At least it is not
easy.

What you can do is to save the numbers of dropped LEBs in a file. And
when you write the dumped image, you feed 0xFFs instead of the LEB which
were dropped.

For example, you may improve ubiupdatevol and teach it to accept a
--unmapped=file option which would contain a list of unmapped LEB
numbers.

-- 
Best regards,
Artem Bityutskiy (Битюцкий Артём)




More information about the linux-mtd mailing list