Skip to content

Commit

Permalink
common: is_hdd: assume file path is not on a HDD if unable to determine
Browse files Browse the repository at this point in the history
  • Loading branch information
tobtoht committed Jan 16, 2025
1 parent 1179269 commit 1ec65be
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/common/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,14 @@ namespace tools
{
return boost::none;
}

if (!boost::filesystem::exists(prefix)) {
// If the device returned by stat does not exist at /sys/dev/block/, we are likely
// inside a container. There is no way to check if file_path is on a hard drive.
MWARNING("Unable to determine whether file path '" << file_path << "' is on a HDD, assuming not");
return false;
}

std::string attr_path = prefix + "/queue/rotational";
std::ifstream f(attr_path, std::ios_base::in);
if(not f.is_open())
Expand Down

0 comments on commit 1ec65be

Please sign in to comment.