Skip to content

Commit

Permalink
user_mgmt: Recover corrupted nv files (ibm-openbmc#17)
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]>

Signed-off-by: LuluTHSu <[email protected]>
  • Loading branch information
LuluTHSu authored and anoo1 committed Jun 5, 2024
1 parent 07b4370 commit 30a41b7
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 @@ -1083,6 +1083,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 30a41b7

Please sign in to comment.