Skip to content

Commit

Permalink
user_mgmt: Recover corrupted nv files (#17) (#24)
Browse files Browse the repository at this point in the history
For unknown reasons the nv file size become to 0.
To not affect the service, add this condition:
If the file is 0 in size, delete the file and throw the exception.

Related Issue: openbmc/phosphor-host-ipmid#185

Tested:
	Make an empty size file, restart ipmid and confirm the recovery
	was successful.
$ rm /var/lib/ipmi/channel_access_nv.json
$ touch /var/lib/ipmi/channel_access_nv.json
$ systemctl restart phosphor-ipmi-host.service

Signed-off-by: LuluTHSu <[email protected]>
Co-authored-by: Lulu_Su <[email protected]>
  • Loading branch information
anoo1 and LuluTHSu authored Jun 4, 2024
1 parent 9884bf5 commit f29c8f7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions user_channel/channel_mgmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,15 @@ int ChannelConfig::readChannelPersistData()
log<level::DEBUG>("Error in opening IPMI Channel data file");
return -EIO;
}
else if (!std::filesystem::file_size(channelNvDataFilename))
{
log<level::DEBUG>("NV file (channelNvDataFilename) has a size of zero");
if (std::filesystem::remove(channelNvDataFilename))
{
log<level::DEBUG>("NV file (channelNvDataFilename) is deleted");
}
return -EIO;
}
try
{
// Fill in global structure
Expand Down

0 comments on commit f29c8f7

Please sign in to comment.