@@ -610,6 +610,9 @@ The default behavior of swupdate is to create a dynamic UBI volume. To
create a static volume, add a line ``data = "static";`` to the
respective partition entry.
+If a size of 0 is given, the volume will be deleted if it exists. This
+can be used to remove orphan volumes possibly created by older software
+versions which are not required anymore.
images
------
@@ -307,44 +307,46 @@ static int resize_volume(struct img_type *cfg, long long size)
free(ubivol);
}
- /* We do not need a volume to get the right node */
- snprintf(node, sizeof(node), "/dev/ubi%d", mtd_info->dev_info.dev_num);
-
- /*
- * Creates all other partitions as specified in the description file
- * Volumes are empty, and they are filled later by the update procedure
- */
- memset(&req, 0, sizeof(req));
- req.vol_type = req_vol_type;
- req.vol_id = UBI_VOL_NUM_AUTO;
- req.alignment = 1;
- req.bytes = size;
- req.name = cfg->volname;
- err = ubi_mkvol(nandubi->libubi, node, &req);
- if (err < 0) {
- ERROR("cannot create %s UBI volume %s of %lld bytes",
- (req_vol_type == UBI_DYNAMIC_VOLUME) ? "dynamic" : "static",
- req.name, req.bytes);
- return err;
- }
+ if (size) {
+ /* We do not need a volume to get the right node */
+ snprintf(node, sizeof(node), "/dev/ubi%d", mtd_info->dev_info.dev_num);
+
+ /*
+ * Creates all other partitions as specified in the description file
+ * Volumes are empty, and they are filled later by the update procedure
+ */
+ memset(&req, 0, sizeof(req));
+ req.vol_type = req_vol_type;
+ req.vol_id = UBI_VOL_NUM_AUTO;
+ req.alignment = 1;
+ req.bytes = size;
+ req.name = cfg->volname;
+ err = ubi_mkvol(nandubi->libubi, node, &req);
+ if (err < 0) {
+ ERROR("cannot create %s UBI volume %s of %lld bytes",
+ (req_vol_type == UBI_DYNAMIC_VOLUME) ? "dynamic" : "static",
+ req.name, req.bytes);
+ return err;
+ }
- ubivol = (struct ubi_part *)calloc(1, sizeof(struct ubi_part));
- if (!ubivol) {
- ERROR("No memory: malloc failed");
- return -ENOMEM;
- }
- err = ubi_get_vol_info1(nandubi->libubi,
- mtd_info->dev_info.dev_num, req.vol_id,
- &ubivol->vol_info);
- if (err) {
- ERROR("cannot get information about "
- "newly created UBI volume");
- return err;
+ ubivol = (struct ubi_part *)calloc(1, sizeof(struct ubi_part));
+ if (!ubivol) {
+ ERROR("No memory: malloc failed");
+ return -ENOMEM;
+ }
+ err = ubi_get_vol_info1(nandubi->libubi,
+ mtd_info->dev_info.dev_num, req.vol_id,
+ &ubivol->vol_info);
+ if (err) {
+ ERROR("cannot get information about "
+ "newly created UBI volume");
+ return err;
+ }
+ LIST_INSERT_HEAD(&mtd_info->ubi_partitions, ubivol, next);
+ TRACE("Created %s UBI volume %s of %lld bytes (old size %lld)",
+ (req_vol_type == UBI_DYNAMIC_VOLUME) ? "dynamic" : "static",
+ req.name, req.bytes, ubivol->vol_info.rsvd_bytes);
}
- LIST_INSERT_HEAD(&mtd_info->ubi_partitions, ubivol, next);
- TRACE("Created %s UBI volume %s of %lld bytes (old size %lld)",
- (req_vol_type == UBI_DYNAMIC_VOLUME) ? "dynamic" : "static",
- req.name, req.bytes, ubivol->vol_info.rsvd_bytes);
return 0;
}
The ubifs kernel driver doesn't allow creation of zero sized volumes. Check for zero size in order to avoid an error and allow the following partition description in order to get rid of volumes not required anymore: partitions: ( { type = "ubipartition"; name = "app0"; size = 0; /* remove possible orphan UBI volume */ device = "root"; }, ... ); Signed-off-by: Christian Eggers <ceggers@arri.de> --- doc/source/sw-description.rst | 3 ++ handlers/ubivol_handler.c | 74 ++++++++++++++++++++++--------------------- 2 files changed, 41 insertions(+), 36 deletions(-)