All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mtd-utils: avoid to create two UBI_LAYOUT_VOLUME_ID volume
@ 2019-01-25  7:01 Yufen Yu
  2019-01-25  8:06 ` Richard Weinberger
  2019-01-25 11:55 ` David Oberhollenzer
  0 siblings, 2 replies; 3+ messages in thread
From: Yufen Yu @ 2019-01-25  7:01 UTC (permalink / raw)
  To: linux-mtd, richard, david.oberhollenzer

When we create a ubi image by ubinize, a UBI_LAYOUT_VOLUME_ID
volume will be created by ubigen_write_layout_vol().
However, after the commit 4c00cf2c5816 (ubiformat: remove
no-volume-table option), ubiformat remove novtbl args in format().
As a result, it will also create a layout volume.

When we attempt to do ubiattach, it will fail for ubi_compare_lebs error:
ubi0 error: ubi_compare_lebs: unsupported on-flash UBI format
ubi0 error: ubi_attach_mtd_dev: failed to attach mtd1, error -22

Signed-off-by: Yufen Yu <yuyufen@huawei.com>
---
 ubi-utils/ubiformat.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/ubi-utils/ubiformat.c b/ubi-utils/ubiformat.c
index 2ee14eb..aedb27b 100644
--- a/ubi-utils/ubiformat.c
+++ b/ubi-utils/ubiformat.c
@@ -542,7 +542,7 @@ out_close:
 
 static int format(libmtd_t libmtd, const struct mtd_dev_info *mtd,
 		  const struct ubigen_info *ui, struct ubi_scan_info *si,
-		  int start_eb)
+		  int start_eb, int novtbl)
 {
 	int eb, err, write_size;
 	struct ubi_ec_hdr *hdr;
@@ -597,7 +597,7 @@ static int format(libmtd_t libmtd, const struct mtd_dev_info *mtd,
 			continue;
 		}
 
-		if (eb1 == -1 || eb2 == -1) {
+		if ((eb1 == -1 || eb2 == -1) && !novtbl) {
 			if (eb1 == -1) {
 				eb1 = eb;
 				ec1 = ec;
@@ -642,6 +642,9 @@ static int format(libmtd_t libmtd, const struct mtd_dev_info *mtd,
 	if (!args.quiet && !args.verbose)
 		printf("\n");
 
+	if (novtbl)
+		goto out_free;
+
 	if (eb1 == -1 || eb2 == -1) {
 		errmsg("no eraseblocks for volume table");
 		goto out_free;
@@ -902,11 +905,15 @@ int main(int argc, char * const argv[])
 		if (err < 0)
 			goto out_free;
 
-		err = format(libmtd, &mtd, &ui, si, err);
+		/*
+		 * ubinize has create a UBI_LAYOUT_VOLUME_ID volume for image.
+		 * So, we don't need to create again.
+		 */
+		err = format(libmtd, &mtd, &ui, si, err, 1);
 		if (err)
 			goto out_free;
 	} else {
-		err = format(libmtd, &mtd, &ui, si, 0);
+		err = format(libmtd, &mtd, &ui, si, 0, 0);
 		if (err)
 			goto out_free;
 	}
-- 
2.13.6


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mtd-utils: avoid to create two UBI_LAYOUT_VOLUME_ID volume
  2019-01-25  7:01 [PATCH] mtd-utils: avoid to create two UBI_LAYOUT_VOLUME_ID volume Yufen Yu
@ 2019-01-25  8:06 ` Richard Weinberger
  2019-01-25 11:55 ` David Oberhollenzer
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Weinberger @ 2019-01-25  8:06 UTC (permalink / raw)
  To: Yufen Yu; +Cc: linux-mtd, david.oberhollenzer

Am Freitag, 25. Januar 2019, 08:01:24 CET schrieb Yufen Yu:
> When we create a ubi image by ubinize, a UBI_LAYOUT_VOLUME_ID
> volume will be created by ubigen_write_layout_vol().
> However, after the commit 4c00cf2c5816 (ubiformat: remove
> no-volume-table option), ubiformat remove novtbl args in format().
> As a result, it will also create a layout volume.
> 
> When we attempt to do ubiattach, it will fail for ubi_compare_lebs error:
> ubi0 error: ubi_compare_lebs: unsupported on-flash UBI format
> ubi0 error: ubi_attach_mtd_dev: failed to attach mtd1, error -22

Oh shit! Thanks alot for identifying this regression.
David, can you please check which relases need a backport,
such that distros can pick it up?

Thanks,
//richard




______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mtd-utils: avoid to create two UBI_LAYOUT_VOLUME_ID volume
  2019-01-25  7:01 [PATCH] mtd-utils: avoid to create two UBI_LAYOUT_VOLUME_ID volume Yufen Yu
  2019-01-25  8:06 ` Richard Weinberger
@ 2019-01-25 11:55 ` David Oberhollenzer
  1 sibling, 0 replies; 3+ messages in thread
From: David Oberhollenzer @ 2019-01-25 11:55 UTC (permalink / raw)
  To: Yufen Yu, linux-mtd, richard

On 1/25/19 8:01 AM, Yufen Yu wrote:
> When we create a ubi image by ubinize, a UBI_LAYOUT_VOLUME_ID
> volume will be created by ubigen_write_layout_vol().
> However, after the commit 4c00cf2c5816 (ubiformat: remove
> no-volume-table option), ubiformat remove novtbl args in format().
> As a result, it will also create a layout volume.
> 
> When we attempt to do ubiattach, it will fail for ubi_compare_lebs error:
> ubi0 error: ubi_compare_lebs: unsupported on-flash UBI format
> ubi0 error: ubi_attach_mtd_dev: failed to attach mtd1, error -22
> 
> Signed-off-by: Yufen Yu <yuyufen@huawei.com>

Thanks for testing and finding that!

I applied it to mtd-utils.git master

On 1/25/19 9:06 AM, Richard Weinberger wrote:
> Oh shit! Thanks alot for identifying this regression.
> David, can you please check which relases need a backport,
> such that distros can pick it up?

It was introduced shortly after 2.0.2, so it's not in any release yet.

David

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-01-25 11:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-25  7:01 [PATCH] mtd-utils: avoid to create two UBI_LAYOUT_VOLUME_ID volume Yufen Yu
2019-01-25  8:06 ` Richard Weinberger
2019-01-25 11:55 ` David Oberhollenzer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.