Skip to content

Commit

Permalink
user_mgmt: Recover corrupted nv files
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]>
  • Loading branch information
LuluTHSu committed Sep 19, 2022
1 parent b7edc96 commit cb7ae0b
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 @@ -1087,6 +1087,15 @@ int ChannelConfig::readChannelPersistData()
log<level::DEBUG>("Error in opening IPMI Channel data file");
return -EIO;
}
else if (!std::experimental::filesystem::file_size(channelNvDataFilename))
{
log<level::DEBUG>("NV file (channelNvDataFilename) has a size of zero");
if (std::experimental::filesystem::remove(channelNvDataFilename))
{
log<level::DEBUG>("NV file (channelNvDataFilename) is deleted");
}
return -EIO;
}
try
{
// Fill in global structure
Expand Down

0 comments on commit cb7ae0b

Please sign in to comment.