Skip to content

PhysicalDisk (macOS / Windows): adds drive health detection - #2731

Open
giovannilentini wants to merge 2 commits into
fastfetch-cli:devfrom
giovannilentini:physicaldisk-health-macos
Open

giovannilentini wants to merge 2 commits into
fastfetch-cli:devfrom
giovannilentini:physicaldisk-health-macos

Conversation

@giovannilentini

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #2728: adds the opt-in drive health detection from #2726 on macOS and Windows (NVMe). The option, fields, format args and output are the same as on Linux; only detection is new.

{ "type": "physicaldisk", "health": true }

Related issue (required for new logos for new distros)

Ref #2726

Changes

  • PhysicalDisk (macOS): adds health detection
    • reuses the existing NVMe SMART read: one SMARTReadData() now fills temperature (temp) and PERCENTAGE_USED / AVAILABLE_SPARE / CRITICAL_WARNING (health)
    • runs when temp || health, so enabling both costs the same as temp alone
  • PhysicalDisk (Windows): adds health detection
    • NVMe disks only (BusTypeNvme), only when health is enabled
    • one more IOCTL_STORAGE_QUERY_PROPERTY with StorageDeviceProtocolSpecificProperty / ProtocolTypeNvme / NVMeDataTypeLogPage / NVME_LOG_PAGE_HEALTH_INFO, read from NVME_HEALTH_INFO_LOG
    • uses the existing FILE_READ_ATTRIBUTES handle, no admin needed (tested)
    • on failure the fields stay empty, no error is printed
  • CHANGELOG entry extended to Linux / macOS / Windows

Screenshots

macOS (MacBook Air 2020, Intel/T2, macOS 15.7.9):

Physical Disk (APPLE SSD AP0256N Media): 233.76 GiB [SSD, Fixed] - 37.0°C - Health 93%
Physical Disk (Apple Disk Image Media): 338.45 MiB [Virtual, Removable, Read-only]

Windows 11 (build 26300, inbox stornvme, non-admin):

Physical Disk (Lexar SSD NM620 256GB): 238.47 GiB [SSD, Fixed] - 34.0°C - Health 97%
Physical Disk (SHPP41-1000GM): 931.51 GiB [SSD, Fixed] - 39.0°C - Health 100%

Values match smartctl -a disk0 on macOS (used 7%, spare 100%, warning 0x00), and on Windows they match udisks2 on Linux for the same two drives (dual boot: used 3 / 0, spare 100, no warnings).

Performance (-s physicaldisk, median of 31 runs):

default temp health temp + health
macOS, 1 NVMe 0.397 ms 2.391 ms 2.367 ms 2.307 ms
Windows, 2 NVMe 4.717 ms 20.915 ms 16.216 ms 28.445 ms

No cost unless health is enabled. On Windows the drive takes about 5.7 ms per disk to answer the log page request, which is still less than the existing temp query.

Checklist

  • I have tested my changes locally.
    • macOS: real Intel/T2 Mac, built from source, no warnings in the PhysicalDisk code
    • Windows: real PC (MSYS2 CLANG64), same result as normal user and as admin, 0 build warnings, ctest 22/22
    • fork CI green (except DragonFly and Haiku, which fail for unrelated packaging reasons)

Not tested: Apple Silicon Macs and Windows vendor NVMe drivers. If someone can run fastfetch there with { "type": "physicaldisk", "health": true } in their config, that would help.

Planned next, as a separate small PR: the SMART "failing" status for SATA/ATA disks (Linux, via udisks2). No percentage there, since SATA has no standard for it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant