Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksandr Zimin <[email protected]>
  • Loading branch information
AleksZimin committed Jan 25, 2024
1 parent db108d3 commit 56a35c9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions images/agent/pkg/controller/block_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,10 @@ func GetSerial(log logger.Logger, candidate internal.BlockDeviceCandidate) (stri
}

func readSerialBlockDevice(deviceName string) (string, error) {
if len(deviceName) < 6 {
return "", fmt.Errorf("device name is too short")
}

strPath := fmt.Sprintf("/sys/block/%s/serial", deviceName[5:])
serial, err := os.ReadFile(strPath)
if err != nil {
Expand All @@ -475,6 +479,10 @@ func readSerialBlockDevice(deviceName string) (string, error) {
}

func readUUIDmdRaidBlockDevice(deviceName string) (string, error) {
if len(deviceName) < 6 {
return "", fmt.Errorf("device name is too short")
}

strPath := fmt.Sprintf("/sys/block/%s/md/uuid", deviceName[5:])
uuid, err := os.ReadFile(strPath)
if err != nil {
Expand Down

0 comments on commit 56a35c9

Please sign in to comment.