pnor_partition_table: Fixes for flag handling in writeUserData()
This is a collection of small fixes:
* Always initialise the field for PARTITION_ECC_PROTECTED so it doesn't
contain garbage
* Provide a warning when we encounter a flag we don't understand
* Ignore empty flags so we don't trigger the unknown flag warning
* Unset the READONLY bit if we encounter READWRITE, implementing
last-configuration-wins rather than sticky-readonly
Change-Id: I3dd45139716fe241f9d3e7997e1269d13de638ca
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/pnor_partition_table.cpp b/pnor_partition_table.cpp
index 19bee87..67b32f1 100644
--- a/pnor_partition_table.cpp
+++ b/pnor_partition_table.cpp
@@ -222,17 +222,26 @@
std::istringstream stream(data);
std::string flag{};
auto perms = 0;
+ auto state = 0;
+ MSG_DBG("Parsing ToC flags '%s'\n", data.c_str());
while (std::getline(stream, flag, ','))
{
+ if (flag == "")
+ continue;
+
if (flag == "ECC")
{
- part.data.user.data[0] = PARTITION_ECC_PROTECTED;
+ state |= PARTITION_ECC_PROTECTED;
}
else if (flag == "READONLY")
{
perms |= PARTITION_READONLY;
}
+ else if (flag == "READWRITE")
+ {
+ perms &= ~PARTITION_READONLY;
+ }
else if (flag == "PRESERVED")
{
perms |= PARTITION_PRESERVED;
@@ -249,10 +258,15 @@
{
perms |= PARTITION_CLEARECC;
}
+ else
+ {
+ MSG_INFO("Found unimplemented partition property: %s\n",
+ flag.c_str());
+ }
}
+ part.data.user.data[0] = state;
part.data.user.data[1] = perms;
-
part.data.user.data[1] |= version;
}