Skip to content

Commit

Permalink
sysfs: trim spaces in device hidden check
Browse files Browse the repository at this point in the history
The hidden file might have an endline, so the check for equals to 1 would not be true.
Trimming the spaces would help to cover this case.

Signed-off-by: Seena Fallah <[email protected]>
  • Loading branch information
clwluvw committed Apr 24, 2024
1 parent 54dff2b commit 34f50e5
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions utils/sysfs/sysfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,8 @@ func (fs *realSysFs) IsBlockDeviceHidden(name string) (bool, error) {
if err != nil {
return false, fmt.Errorf("failed to read %s: %w", devHiddenPath, err)
}
if string(hidden) == "1" {
return true, nil
}
return false, nil

return strings.TrimSpace(string(hidden)) == "1", nil
}

func (fs *realSysFs) GetBlockDeviceScheduler(name string) (string, error) {
Expand Down

0 comments on commit 34f50e5

Please sign in to comment.