Commit b8acd2d2 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

DeviceLister: Fix missing terminal 0

parent 7ad25257
......@@ -129,14 +129,16 @@ std::string DeviceLister::deviceFromDeviceMapper( const std::string& devicePath
{
if ( devicePath.find( "/dev/mapper" ) != 0 )
return {};
char linkPath[PATH_MAX];
if ( readlink( devicePath.c_str(), linkPath, PATH_MAX ) < 0 )
char linkPath[PATH_MAX + 1];
auto linkSize = readlink( devicePath.c_str(), linkPath, PATH_MAX );
if ( linkSize < 0 )
{
std::stringstream err;
err << "Failed to resolve device -> mapper link: "
<< devicePath << " (" << strerror(errno) << ')';
throw std::runtime_error( err.str() );
}
linkPath[linkSize] = 0;
LOG_INFO( "Resolved ", devicePath, " to ", linkPath, " device mapper" );
const auto dmName = utils::file::fileName( linkPath );
std::string dmSlavePath = "/sys/block/" + dmName + "/slaves";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment