From 34f50e5524f8d27c0d1db8d0e55b054e42a552e0 Mon Sep 17 00:00:00 2001 From: Seena Fallah Date: Wed, 24 Apr 2024 21:02:40 +0200 Subject: [PATCH] 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 --- utils/sysfs/sysfs.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/utils/sysfs/sysfs.go b/utils/sysfs/sysfs.go index e3466c08e4..9eb13876c4 100644 --- a/utils/sysfs/sysfs.go +++ b/utils/sysfs/sysfs.go @@ -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) {