1060:vpd-tool:Check for read only FRUs before write
This commit fixes the issue where vpd-tool tries to perform write
on request for the FRUs which are read only.
Test:
```./vpd-tool -w -O /system/chassis/motherboard/vrm0 -R VINI -K CC --value 51F3```
Read only EEPROM. Update not allowed.
Change-Id: If24d2a17e26ecb1ca603cbba8a05a2959102fa64
Signed-off-by: PriyangaRamasamy <priyanga24@in.ibm.com>
diff --git a/vpd_tool.cpp b/vpd_tool.cpp
index d23fe7f..2e51372 100644
--- a/vpd_tool.cpp
+++ b/vpd_tool.cpp
@@ -107,6 +107,11 @@
try
{
+ if (objectPath.empty())
+ {
+ throw runtime_error("Given path is empty.");
+ }
+
if ((*kw) && (keyword.size() != 2))
{
throw runtime_error("Keyword " + keyword + " not supported.");
@@ -128,6 +133,11 @@
if (*writeFlag)
{
+ if (isReadOnlyEEPROM(objectPath, jsObject))
+ {
+ throw runtime_error("Read only EEPROM. Update not allowed.");
+ }
+
if ((!*fileOption) && (!*valOption))
{
throw runtime_error("Please provide the data that needs to be "