Skip to content

Commit

Permalink
fix: read device serial like in v1
Browse files Browse the repository at this point in the history
Restore previous behavior. I couldn't find any meaningful device which
provides serial this way today, except for probably USB devices.

See siderolabs/talos#9951

Signed-off-by: Andrey Smirnov <[email protected]>
  • Loading branch information
smira committed Dec 17, 2024
1 parent 8853e37 commit 57e15ed
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion block/device_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ func (d *Device) GetProperties() (*DeviceProperties, error) {

props := &DeviceProperties{
Model: readSysFsFile(filepath.Join(sysFsPath, "device", "model")),
Serial: readSysFsFile(filepath.Join(sysFsPath, "device", "serial")),
Serial: readSysFsFile(filepath.Join(sysFsPath, "serial")),
Modalias: readSysFsFile(filepath.Join(sysFsPath, "device", "modalias")),
WWID: readSysFsFile(filepath.Join(sysFsPath, "wwid")),
}
Expand All @@ -350,6 +350,10 @@ func (d *Device) GetProperties() (*DeviceProperties, error) {
props.WWID = readSysFsFile(filepath.Join(sysFsPath, "device", "wwid"))
}

if props.Serial == "" {
props.Serial = readSysFsFile(filepath.Join(sysFsPath, "device", "serial"))
}

fullPath, err := os.Readlink(sysFsPath)
if err == nil {
props.BusPath = filepath.Dir(filepath.Dir(strings.TrimPrefix(fullPath, "../../devices")))
Expand Down

0 comments on commit 57e15ed

Please sign in to comment.