[PATCH] UBI: Do not try to autoresize in readonly mode

Pali Rohár pali.rohar at gmail.com
Sat Aug 18 08:11:42 EDT 2012


Hello,

when I'm tried to mount ubifs image from readonly mtd device (e.g 
virtual, only for unpacking data) it failed because image has 
autoresize flag on ubi block. ubi build.c code trying to 
autoresize ubi image if has autoresize flag and if autoresize 
failed, attaching ubi failed. So it is not possible to mount 
ubifs image if ubi has autoresize flag in read only mode (because 
resizing is not possible on read only device).

I'm sending small patch which skip autoresizing ubi in readonly 
mode. I think it is really not good idea to try resize in ro 
mode.

diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 738772c..ad911ab 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -927,7 +927,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, 
int ubi_num, int vid_hdr_offset)
 		goto out_debugging;
 	}
 
-	if (ubi->autoresize_vol_id != -1) {
+	if (!ubi->ro_mode && ubi->autoresize_vol_id != -1) {
 		err = autoresize(ubi, ubi->autoresize_vol_id);
 		if (err)
 			goto out_detach;

With this patch I'm able to mount & unpack data from ubifs image 
on read only (virtual/simulated) nand device with autoresize 
flag. Consider including this patch to ubi-2.6 git tree.

BTW, is there userspace tool for unpacking data from ubifs image 
without need to simulate nand device in kernel?

-- 
Pali Rohár
pali.rohar at gmail.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.infradead.org/pipermail/linux-mtd/attachments/20120818/8e7dfc7f/attachment.sig>


More information about the linux-mtd mailing list