Skip to content
Snippets Groups Projects
Commit 40d54a94 authored by Ronny Nilsson's avatar Ronny Nilsson
Browse files

Turns out all UBI volumes need to have a unique name.

parent 851e166b
Branches
No related tags found
No related merge requests found
......@@ -226,14 +226,21 @@ int ubi_erase_volume(int volId)
int ubi_create_volume(int volId, long long size)
{
struct ubi_mkvol_request mkReq;
char *nodePath;
char *nodePath, *name;
if(volId < 0 || volId >= UBI_MAX_VOLUMES) return -1;
if(size <= 0ll) return -1;
// Generate a system unique name for the volume.
name = calloc(1, strlen(ubiStr3) + 8);
snprintf(name, strlen(ubiStr3) + 8, "%s_%d", ubiStr3, volId);
memset(&mkReq, 0, sizeof(mkReq));
mkReq.vol_id = volId;
mkReq.alignment = 1;
mkReq.bytes = size;
mkReq.vol_type = UBI_STATIC_VOLUME;
mkReq.name = ubiStr3;
mkReq.name = name;
nodePath = ubi_path_by_id(devInfo.dev_num, -1);
errno = 0;
......@@ -241,6 +248,7 @@ int ubi_create_volume(int volId, long long size)
fprintf(stderr, "Error creating UBI volume %d %s: %s\n",
volId, nodePath, strerror(errno));
free(nodePath);
free(name);
return -1;
}
else if (verbose) {
......@@ -248,6 +256,7 @@ int ubi_create_volume(int volId, long long size)
}
free(nodePath);
free(name);
return 0;
}
......@@ -791,6 +800,8 @@ int gen_image_ubi(const char *in_file, char *sequence_number)
if(!res) res = meta_manage_vols();
unlink("/tmp/ronny"); // Possibly erase temporary file.
// Close the UBI library.
if(libubi) {
for(i = 0; i < MAX_METAS; i++) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment