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

Support for creating an UBI volume.

parent d95633e6
No related branches found
No related tags found
No related merge requests found
......@@ -76,6 +76,7 @@ struct metaInfo_t {
//-------------------------------------------------------------
const char ubiStr3[] = "metadata";
char ubiStr2[] = "cferam.000";
char ubiStr1[] = "committed";
......@@ -145,6 +146,32 @@ int ubi_erase_volume(int devId, int volId)
//-------------------------------------------------------------
// Erase an UBI volume (if exists).
int ubi_create_volume(int volId)
{
char nodePath[UBI_MAX_VOLUME_NAME];
struct ubi_mkvol_request mkReq;
memset(&mkReq, 0, sizeof(mkReq));
mkReq.vol_id = volId;
mkReq.bytes = devInfo.leb_size;
mkReq.vol_type = UBI_STATIC_VOLUME;
mkReq.name = ubiStr3;
snprintf(nodePath, UBI_MAX_VOLUME_NAME, "/dev/ubi%d", devInfo.dev_num);
errno = 0;
if(ubi_mkvol(libubi, nodePath, &mkReq)) {
fprintf(stderr, "Error creating UBI volume %d: %s\n",
volId, strerror(errno));
return -1;
}
return 0;
}
//-------------------------------------------------------------
// Init the UBI library and query system for info.
static int ubi_probe(void)
......@@ -510,9 +537,12 @@ static int meta_manage_vols(void)
}
tmpMeta = meta_by_id(newMeta);
if(tmpMeta) {
ubi_erase_volume(tmpMeta->volInfo.dev_num, tmpMeta->volInfo.vol_id);
}
if(tmpMeta) ubi_erase_volume(newMeta);
if(ubi_create_volume(newMeta)) return -1;
tmpMeta = meta_by_id(delMeta);
if(tmpMeta) ubi_erase_volume(delMeta);
//delete_volume(newMeta);
//create_new_ubi(newMeta)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment