From 0f9fbd6861ed70919c219969d0168947f1760653 Mon Sep 17 00:00:00 2001 From: Andrew Jeffery Date: Fri, 2 Mar 2018 12:00:42 +1030 Subject: 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 --- pnor_partition_table.cpp | 18 ++++++++++++++++-- test/vpnor/Makefile.am.include | 2 -- 2 files changed, 16 insertions(+), 4 deletions(-) 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 @@ static inline void writeUserdata(pnor_partition& part, uint32_t version, 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 @@ static inline void writeUserdata(pnor_partition& part, uint32_t version, { 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; } diff --git a/test/vpnor/Makefile.am.include b/test/vpnor/Makefile.am.include index 4defe01..2a39ae1 100644 --- a/test/vpnor/Makefile.am.include +++ b/test/vpnor/Makefile.am.include @@ -121,6 +121,4 @@ check_PROGRAMS += \ %reldir%/toc_no_end \ %reldir%/toc_no_version \ %reldir%/toc_flags - -XFAIL_TESTS += %reldir%/toc_flags endif -- cgit v1.2.1