parseScan parses the output of smartctl --scan -j and returns the discovered devices.
(output []byte)
| 599 | |
| 600 | // parseScan parses the output of smartctl --scan -j and returns the discovered devices. |
| 601 | func (sm *SmartManager) parseScan(output []byte) ([]*DeviceInfo, bool) { |
| 602 | scan := &scanOutput{} |
| 603 | |
| 604 | if err := json.Unmarshal(output, scan); err != nil { |
| 605 | return nil, false |
| 606 | } |
| 607 | |
| 608 | if len(scan.Devices) == 0 { |
| 609 | slog.Debug("no devices found in smartctl scan") |
| 610 | return nil, false |
| 611 | } |
| 612 | |
| 613 | devices := make([]*DeviceInfo, 0, len(scan.Devices)) |
| 614 | for _, device := range scan.Devices { |
| 615 | slog.Debug("smartctl scan", "name", device.Name, "type", device.Type, "protocol", device.Protocol) |
| 616 | devices = append(devices, &DeviceInfo{ |
| 617 | Name: device.Name, |
| 618 | Type: device.Type, |
| 619 | InfoName: device.InfoName, |
| 620 | Protocol: device.Protocol, |
| 621 | }) |
| 622 | } |
| 623 | |
| 624 | return devices, true |
| 625 | } |
| 626 | |
| 627 | // mergeDeviceLists combines scanned and configured SMART devices, preferring |
| 628 | // configured SMART_DEVICES when both sources reference the same device. |
no outgoing calls