rocm_smi_lib: Fix rocm-smi --showfan shows 'unable to detect fan'
Code changes related to the following: * Reverts earlier fix for the same issue * Check for existence of files before reading Change-Id: I175b20c3343c414b12b79dc3fc404f53fbaabf3a Signed-off-by: Oliveira, Daniel <daniel.oliveira@amd.com>
这个提交包含在:
+12
-3
@@ -158,13 +158,15 @@ int isRegularFile(std::string fname, bool *is_reg) {
|
||||
struct stat file_stat;
|
||||
int ret;
|
||||
|
||||
assert(is_reg != nullptr);
|
||||
|
||||
ret = stat(fname.c_str(), &file_stat);
|
||||
if (ret) {
|
||||
return errno;
|
||||
}
|
||||
*is_reg = S_ISREG(file_stat.st_mode);
|
||||
|
||||
if (is_reg != nullptr) {
|
||||
*is_reg = S_ISREG(file_stat.st_mode);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -192,6 +194,13 @@ int WriteSysfsStr(std::string path, std::string val) {
|
||||
}
|
||||
|
||||
int ReadSysfsStr(std::string path, std::string *retStr) {
|
||||
// On success, zero is returned. On error, -1 is returned, and
|
||||
// errno is set to indicate the error.
|
||||
auto is_regular_file_result = isRegularFile(path, nullptr);
|
||||
if (is_regular_file_result != 0) {
|
||||
return ENOENT;
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
int ret = 0;
|
||||
std::ostringstream oss;
|
||||
|
||||
在新工单中引用
屏蔽一个用户