cholcombe973 / block-utils

Rust utilities for working with block devices
MIT License
22 stars 17 forks source link

Alpine 3.17's `nvme-cli` returns bugged output #41

Open richardstephens opened 1 year ago

richardstephens commented 1 year ago

When testing on Alpine 3.17, we noticed that we weren't seeing any NVMe disks. We quickly discovered the cause was that it was generating slightly different JSON output to my Debian dev machine.

{
  "Devices":[
    {
      "NameSpace":1,
      "DevicePath":"/dev/nvme0n1",
      "Firmware":"P7CR403",
      "ModelNumber":"CT1000P5PSSD8",
      "SerialNumber":"XXXXX",
      "UsedBytes":-2147483648,
      "MaximumLBA":1953525168,
      "PhysicalSize":-2147483648,
      "SectorSize":512
    }
  ]
}

I've submitted a PR to make the missing fields optional and add the Firmware field, but those negative numbers aren't going to parse into a u64.

It seems this was a bug in nvme-cli at some point - building the latest master from source fixes it. Shipping this works fine for us, but is this something we should try to handle in this project?

cholcombe973 commented 1 year ago

Well that's interesting... I guess I never expected the firmware to return a negative number for the usage haha. Yeah the thing to do here would be have that be a Result so that it's failable and then return the failure to the caller about a negative usage number.