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 <seenafallah@gmail.com>
  • Loading branch information
clwluvw committed Apr 24, 2024
1 parent 54dff2b commit 22c485c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion utils/sysfs/sysfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ 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" {
if strings.TrimSpace(string(hidden)) == "1" {
return true, nil
}
return false, nil
Expand Down

0 comments on commit 22c485c

Please sign in to comment.