Skip to content

Commit 34f50e5

Browse files
committed
sysfs: trim spaces in device hidden check
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]>
1 parent 54dff2b commit 34f50e5

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

utils/sysfs/sysfs.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,8 @@ func (fs *realSysFs) IsBlockDeviceHidden(name string) (bool, error) {
229229
if err != nil {
230230
return false, fmt.Errorf("failed to read %s: %w", devHiddenPath, err)
231231
}
232-
if string(hidden) == "1" {
233-
return true, nil
234-
}
235-
return false, nil
232+
233+
return strings.TrimSpace(string(hidden)) == "1", nil
236234
}
237235

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

0 commit comments

Comments
 (0)