mirror of
https://github.com/otakuto/crazydiskinfo.git
synced 2025-07-22 22:25:27 +00:00
Fix crash by skipping S.M.A.R.T unavailable disk
This commit is contained in:
parent
1acfbf1339
commit
1b98d35985
1 changed files with 4 additions and 1 deletions
5
main.cpp
5
main.cpp
|
@ -320,6 +320,7 @@ int main()
|
||||||
init_pair(8, COLOR_YELLOW, COLOR_BLACK);
|
init_pair(8, COLOR_YELLOW, COLOR_BLACK);
|
||||||
|
|
||||||
int select = 0;
|
int select = 0;
|
||||||
|
int smart_ret = 0;
|
||||||
std::vector<SMART> smartList;
|
std::vector<SMART> smartList;
|
||||||
auto dir = opendir("/sys/block");
|
auto dir = opendir("/sys/block");
|
||||||
while (auto e = readdir(dir))
|
while (auto e = readdir(dir))
|
||||||
|
@ -336,8 +337,10 @@ int main()
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
sk_disk_smart_is_available(skdisk, &b);
|
smart_ret = sk_disk_smart_is_available(skdisk, &b);
|
||||||
sk_disk_free(skdisk);
|
sk_disk_free(skdisk);
|
||||||
|
if (smart_ret < 0)
|
||||||
|
continue;
|
||||||
if (b)
|
if (b)
|
||||||
{
|
{
|
||||||
smartList.push_back(SMART(std::string("/dev/") + std::string(e->d_name)));
|
smartList.push_back(SMART(std::string("/dev/") + std::string(e->d_name)));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue