mirror of https://github.com/aristocratos/btop.git
Added try->catch for get_zfs_stat_file() to avoid fs error
This commit is contained in:
parent
6282f36f8f
commit
e770cccaf8
|
@ -1936,29 +1936,32 @@ namespace Mem {
|
||||||
}
|
}
|
||||||
|
|
||||||
// looking through all files that start with 'objset' to find the one containing `device_name` object stats
|
// looking through all files that start with 'objset' to find the one containing `device_name` object stats
|
||||||
for (const auto& file: fs::directory_iterator(zfs_pool_stat_path)) {
|
try {
|
||||||
filename = file.path().filename();
|
for (const auto& file: fs::directory_iterator(zfs_pool_stat_path)) {
|
||||||
if (filename.starts_with("objset")) {
|
filename = file.path().filename();
|
||||||
filestream.open(file.path());
|
if (filename.starts_with("objset")) {
|
||||||
if (filestream.good()) {
|
filestream.open(file.path());
|
||||||
// skip first two lines
|
if (filestream.good()) {
|
||||||
for (int i = 0; i < 2; i++) filestream.ignore(numeric_limits<streamsize>::max(), '\n');
|
// skip first two lines
|
||||||
// skip characters until '7' is reached, indicating data type 7, next value will be object name
|
for (int i = 0; i < 2; i++) filestream.ignore(numeric_limits<streamsize>::max(), '\n');
|
||||||
filestream.ignore(numeric_limits<streamsize>::max(), '7');
|
// skip characters until '7' is reached, indicating data type 7, next value will be object name
|
||||||
filestream >> name_compare;
|
filestream.ignore(numeric_limits<streamsize>::max(), '7');
|
||||||
if (name_compare == device_name) {
|
filestream >> name_compare;
|
||||||
filestream.close();
|
if (name_compare == device_name) {
|
||||||
if (access(file.path().c_str(), R_OK) == 0) {
|
filestream.close();
|
||||||
return file.path();
|
if (access(file.path().c_str(), R_OK) == 0) {
|
||||||
} else {
|
return file.path();
|
||||||
Logger::debug("Can't access file: " + file.path().string());
|
} else {
|
||||||
return "";
|
Logger::debug("Can't access file: " + file.path().string());
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
filestream.close();
|
||||||
}
|
}
|
||||||
filestream.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (fs::filesystem_error& e) {}
|
||||||
|
|
||||||
Logger::debug("Could not read directory: " + zfs_pool_stat_path.string());
|
Logger::debug("Could not read directory: " + zfs_pool_stat_path.string());
|
||||||
return "";
|
return "";
|
||||||
|
|
Loading…
Reference in New Issue