aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYufen Yu <yuyufen@huawei.com>2019-01-25 15:01:24 +0800
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-01-25 12:50:13 +0100
commit4a5a10a3dfe13d3f546ee4acbe2a96054ae423f7 (patch)
treedfff8f4b30eacdda871e1f0684c959b24aee039c
parentb1ecfaba533af1895edbdd0ab9bdbbacb1a5ec10 (diff)
mtd-utils: avoid to create two UBI_LAYOUT_VOLUME_ID volume
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> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--ubi-utils/ubiformat.c15
1 files 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;
}