Skip to content

Add disk type information (SSD, HDD, Removable, Virtual) - #3230

Merged
dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:feature/disk-type
May 6, 2026
Merged

dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:feature/disk-type

Conversation

@dbwiddis

@dbwiddis dbwiddis commented May 6, 2026 •

Copy link
Copy Markdown
Member

Summary

Resolves #2857

Adds a getDiskType() method to the HWDiskStore interface that reports the physical media type of a disk drive.

Returned values

Value Meaning
SSD Solid-state drive (rotational=0)
HDD Hard disk drive (rotational=1)
Removable Removable media (USB drives, SD cards, etc.)
Virtual Device-mapper / logical volume
Unknown Type could not be determined

Implementation

Linux (JNA + FFM)

Reads sysfs attributes via udev:

  • /sys/block/<name>/removable — 1 indicates removable media
  • /sys/block/<name>/queue/rotational — 0 = SSD, 1 = HDD
  • Device-mapper devices (/dev/dm-*) are reported as Virtual

Other platforms

Returns Unknown via the interface default method. Windows (WMI MediaType) and macOS (IOKit) support can be added in follow-up PRs.

API

for (HWDiskStore disk : hal.getDiskStores()) {
    System.out.printf("%s: %s (%s)%n", disk.getName(), disk.getModel(), disk.getDiskType());
}
// /dev/sda: Samsung SSD 970 EVO (SSD)
// /dev/sdb: WDC WD40EFRX (HDD)
// /dev/sdc: Kingston DataTraveler (Removable)

Changes

  • HWDiskStore.java: Added default String getDiskType() returning "Unknown"
  • AbstractHWDiskStore.java: Added diskType field, 5-arg constructor, getDiskType() override, updated toString()
  • LinuxHWDiskStore.java: Added 5-arg constructor
  • LinuxHWDiskStoreJNA.java: Added detectDiskType() using udev sysattr reads
  • LinuxHWDiskStoreFFM.java: Same detection logic using FFM udev functions
  • CHANGELOG.md: Entry for this PR

Summary by CodeRabbit

  • New Features

    • Disk type detection added: storage devices are now categorized as SSD, HDD, Removable, or Virtual, improving hardware reporting across platforms.
  • Documentation

    • Changelog updated with a 7.1.0 entry noting the new disk type information.

@dbwiddis dbwiddis self-assigned this May 6, 2026
@coderabbitai

coderabbitai Bot commented May 6, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR adds disk type classification across the hardware layer: a new default getDiskType() on HWDiskStore, storage of diskType in AbstractHWDiskStore, platform detection and wiring for Linux (FFM/JNA) and Windows (FFM/JNA), an added WMI MEDIATYPE property, and a changelog entry.

Changes

Disk Type Support

Layer / File(s) Summary
Interface Contract
oshi-common/src/main/java/oshi/hardware/HWDiskStore.java
New default method getDiskType() returning "Unknown".
Base Class Storage & Retrieval
oshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.java
Added diskType field, new 5‑arg constructor, 4‑arg ctor delegates with "Unknown", getDiskType() getter, and toString() updated to include disk type.
Platform Constructors (Linux/Windows)
oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHWDiskStore.java, oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsHWDiskStore.java
Added 5‑argument constructor overloads forwarding diskType to super; Windows adds parseWindowsMediaType(...) helper.
Linux Detection & Wiring (FFM)
oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreFFM.java
Added 5‑arg ctor; DM devices instantiated with "Virtual"; non‑DM devices call detectDiskType(...) which inspects udev attributes (removable, queue/rotational) returning "Removable", "SSD", "HDD", or "Unknown".
Linux Detection & Wiring (JNA)
oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreJNA.java
Added 5‑arg ctor; DM devices marked "Virtual"; non‑DM devices use new detectDiskType(UdevDevice) helper to determine "Removable", "SSD", "HDD", or "Unknown".
Windows Detection & Wiring (FFM)
oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsHWDiskStoreFFM.java
Added private 5‑arg ctor; disk creation updated to pass disk type derived from parseWindowsMediaType(...) mapping MEDIATYPE to "Removable", "HDD", or "Unknown".
Windows Detection & Wiring (JNA)
oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsHWDiskStoreJNA.java
Added private 5‑arg ctor; getDisks() now passes disk type parsed via new parseWindowsMediaType(...).
WMI Property Index
oshi-common/src/main/java/oshi/driver/common/windows/wmi/Win32DiskDrive.java
Inserted new enum constant MEDIATYPE into DiskDriveProperty ordering to enable reading media type.
Changelog
CHANGELOG.md
Added entry for 7.1.0: "Add disk type information (SSD, HDD, Removable, Virtual)".

Sequence Diagram(s)

sequenceDiagram
    participant Consumer
    participant Enumerator as Platform Enumerator
    participant Detector as DiskType Detector
    participant Store as HWDiskStore (ctor)
    participant Source as Sys/WMI (udev / WMI)

    Consumer->>Enumerator: request disk list
    Enumerator->>Source: enumerate devices (sysfs / WMI)
    Note right of Source: returns device attributes (removable, rotational, MEDIATYPE...)
    Enumerator->>Detector: ask detectDiskType(device attrs)
    Detector->>Source: read attributes (removable, queue/rotational, MEDIATYPE)
    Detector-->>Enumerator: return diskType ("SSD"/"HDD"/"Removable"/"Virtual"/"Unknown")
    Enumerator->>Store: instantiate HWDiskStore(name, model, serial, size, diskType)
    Store-->>Consumer: return disk object with getDiskType() available
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • oshi/oshi#3117: Related changes touching Linux FFM/JNA disk store implementations and disk-type wiring.

Poem

💾 New types awake on spinning, silent shelves,
SSDs, HDDs, removable elves.
Virtual shadows and udev's sigh,
Disk type now answers when you ask it "why".
Welcome, hardware—tell us what you are!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically summarizes the main change: adding disk type information with concrete examples of the supported types (SSD, HDD, Removable, Virtual).
Linked Issues check ✅ Passed The PR fully implements the objective from issue #2857 by adding a getDiskType() method that exposes disk type information, classifying common types (SSD, HDD, Removable, Virtual) with "Unknown" as default.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing disk type detection: interface additions, platform-specific implementations (Linux/Windows), and helper methods. No unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📋 Issue Planner

Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).

View plan for ticket: #2857

✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (3)
oshi-common/src/main/java/oshi/hardware/HWDiskStore.java (1)

54-61: ⚡ Quick win

Consider exposing the type values as public constants (or an enum) and aligning the Javadoc with what's actually returned today.

Two small things on this new API surface:

  1. The Javadoc lists Network as a possible return value, but no implementation in this PR ever returns "Network". Either drop it from the doc until it's implemented, or keep it but explicitly note that it's reserved for future use so consumers don't write code branches that will never trigger.
  2. The valid return values are part of the public API contract, but they're only documented as free-form strings. Callers will have to hardcode "SSD", "HDD", etc., which is easy to mistype and a pain to evolve. Exposing them as public constants on HWDiskStore (or, better, as a DiskType enum with an UNKNOWN default and a fromString/getType accessor) would make consumer code typo-proof and keep the platform implementations honest.
♻️ Sketch of a constants-based variant (least invasive)
+    /** Disk is a solid-state drive. */
+    String TYPE_SSD = "SSD";
+    /** Disk is a rotational hard disk drive. */
+    String TYPE_HDD = "HDD";
+    /** Disk is a removable medium (USB stick, SD card, optical, floppy, etc.). */
+    String TYPE_REMOVABLE = "Removable";
+    /** Disk is a virtual/device-mapper backed device (e.g. LVM). */
+    String TYPE_VIRTUAL = "Virtual";
+    /** Disk type could not be determined. */
+    String TYPE_UNKNOWN = "Unknown";
+
     /**
-     * The type of the disk, such as SSD, HDD, Removable, Network, Virtual, or Unknown.
+     * The type of the disk. Returns one of {`@link` `#TYPE_SSD`}, {`@link` `#TYPE_HDD`},
+     * {`@link` `#TYPE_REMOVABLE`}, {`@link` `#TYPE_VIRTUAL`}, or {`@link` `#TYPE_UNKNOWN`}.
+     * Additional values (e.g. for network or optical media) may be added in the future.
      *
      * `@return` the disk type string
      */
     default String getDiskType() {
-        return "Unknown";
+        return TYPE_UNKNOWN;
     }

An enum would be even nicer long-term, but introduces a slightly bigger API change for AbstractHWDiskStore and the platform classes.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@oshi-common/src/main/java/oshi/hardware/HWDiskStore.java` around lines 54 -
61, The Javadoc for HWDiskStore.getDiskType lists values (e.g., "Network") that
aren't actually returned and the API exposes free-form strings that invite
typos; add a well-defined set of return values by introducing either public
constants on HWDiskStore (e.g., SSD/HDD/REMOVABLE/VIRTUAL/UNKNOWN) or,
preferably, a DiskType enum with values (SSD, HDD, REMOVABLE, VIRTUAL, NETWORK,
UNKNOWN) and a DiskType.fromString/getType helper; update
HWDiskStore.getDiskType signature/documentation to reference the constants/enum
and adjust implementations (and AbstractHWDiskStore) to return the canonical
constant/enum value and align the Javadoc to mention which values are reserved
(e.g., NETWORK reserved) if not yet returned.
oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreJNA.java (2)

168-180: 💤 Low value

Optional: lift the classification logic into a shared helper.

The body of detectDiskType here is identical to the one in LinuxHWDiskStoreFFM once you ignore the device.getSysattrValue(...) vs UdevFunctions.getSysattrValue(device, ..., arena) wrappers. You could extract a small package-private helper in LinuxHWDiskStore (oshi-common) that takes the two already-read strings, e.g. classifyDiskType(String removable, String rotational), and call it from both subclasses with the platform-specific sysattr reads inlined. Keeps the policy in one place if you ever extend it (e.g. for SD/optical/network).

Not blocking — happy to leave for a follow-up given how small the helper is.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreJNA.java`
around lines 168 - 180, Both subclasses duplicate the disk-type decision logic;
extract a package-private helper classifyDiskType(String removable, String
rotational) into LinuxHWDiskStore (oshi-common) and replace the bodies of
LinuxHWDiskStoreJNA.detectDiskType and the equivalent in LinuxHWDiskStoreFFM to
simply call LinuxHWDiskStore.classifyDiskType(removable, rotational) after they
read their platform-specific sysattr strings (device.getSysattrValue(...) or
UdevFunctions.getSysattrValue(..., arena)); preserve the existing return values
("Removable", "SSD", "HDD", "Unknown") and behavior when inputs are null or
different.

168-180: 💤 Low value

Heads-up: Removable precedence hides SSD/HDD classification for hot-pluggable media.

A USB-attached SSD or an external HDD will report "Removable" rather than "SSD"/"HDD" because removable=1 short-circuits the rotational check. That's a defensible choice (it matches the PR's "Removable" bucket and the wording in issue #2857), but it does mean callers can't ask "is this disk solid-state?" purely from getDiskType() for external drives.

A couple of options if you'd rather preserve that signal:

  • Document in the Javadoc that Removable takes precedence over the rotational classification.
  • Or only return Removable when rotational is unknown/missing, otherwise fall through to SSD/HDD.

Either is fine — just worth being explicit since this is the API contract going forward.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreJNA.java`
around lines 168 - 180, The current detectDiskType(UdevDevice device) returns
"Removable" whenever removable="1", hiding SSD/HDD info for external drives;
change the logic so detectDiskType first checks the rotational sysattr
(device.getSysattrValue("queue/rotational")) and returns "SSD" for "0" or "HDD"
for "1" when that value is present, and only return "Removable" if rotational is
missing/empty (or unknown), and update the Javadoc for
detectDiskType/getDiskType to state that removable is only used when rotational
info is unavailable.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@oshi-common/src/main/java/oshi/hardware/HWDiskStore.java`:
- Around line 54-61: The Javadoc for HWDiskStore.getDiskType lists values (e.g.,
"Network") that aren't actually returned and the API exposes free-form strings
that invite typos; add a well-defined set of return values by introducing either
public constants on HWDiskStore (e.g., SSD/HDD/REMOVABLE/VIRTUAL/UNKNOWN) or,
preferably, a DiskType enum with values (SSD, HDD, REMOVABLE, VIRTUAL, NETWORK,
UNKNOWN) and a DiskType.fromString/getType helper; update
HWDiskStore.getDiskType signature/documentation to reference the constants/enum
and adjust implementations (and AbstractHWDiskStore) to return the canonical
constant/enum value and align the Javadoc to mention which values are reserved
(e.g., NETWORK reserved) if not yet returned.

In
`@oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreJNA.java`:
- Around line 168-180: Both subclasses duplicate the disk-type decision logic;
extract a package-private helper classifyDiskType(String removable, String
rotational) into LinuxHWDiskStore (oshi-common) and replace the bodies of
LinuxHWDiskStoreJNA.detectDiskType and the equivalent in LinuxHWDiskStoreFFM to
simply call LinuxHWDiskStore.classifyDiskType(removable, rotational) after they
read their platform-specific sysattr strings (device.getSysattrValue(...) or
UdevFunctions.getSysattrValue(..., arena)); preserve the existing return values
("Removable", "SSD", "HDD", "Unknown") and behavior when inputs are null or
different.
- Around line 168-180: The current detectDiskType(UdevDevice device) returns
"Removable" whenever removable="1", hiding SSD/HDD info for external drives;
change the logic so detectDiskType first checks the rotational sysattr
(device.getSysattrValue("queue/rotational")) and returns "SSD" for "0" or "HDD"
for "1" when that value is present, and only return "Removable" if rotational is
missing/empty (or unknown), and update the Javadoc for
detectDiskType/getDiskType to state that removable is only used when rotational
info is unavailable.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a717292e-b4b6-4870-924c-92148e4fadf8

📥 Commits

Reviewing files that changed from the base of the PR and between b09fcd9 and 09b042e.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • oshi-common/src/main/java/oshi/hardware/HWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHWDiskStore.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreFFM.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreJNA.java
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2026-04-12T19:22:09.716Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3149
File: oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java:159-163
Timestamp: 2026-04-12T19:22:09.716Z
Learning: When reviewing OSHI hardware platform code that uses or implements `CentralProcessor`/`PhysicalProcessor.getEfficiency()`, remember the API’s counterintuitive semantics: a *higher* efficiency-class value indicates *greater performance* (lower efficiency). P-cores/“performance cores” should therefore have higher values (e.g., 1) than E-cores/“efficiency cores” (e.g., 0), as documented in the `CentralProcessor` Javadoc. Do not flag code as incorrect solely because ARM_P_CORES or Intel P-cores are assigned higher efficiency values.

Applied to files:

  • oshi-common/src/main/java/oshi/hardware/HWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.java
📚 Learning: 2026-04-06T04:45:47.644Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:47.644Z
Learning: In the oshi/oshi project, only interfaces and classes in the root packages `oshi`, `oshi.hardware`, and `oshi.software.os` are considered the public API. Code in subpackages that represent specific implementations/platforms (e.g., `oshi.software.os.linux`, `oshi.hardware.platform.linux`, and similar subpackages) is implementation detail. When reviewing, do not treat changes to classes in these platform-specific subpackages as public API breaks (for example: making `LinuxOperatingSystem` abstract, narrowing constructor visibility, or adding/removing abstract methods should not be flagged as breaking public API).

Applied to files:

  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreJNA.java
🔇 Additional comments (7)
oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreFFM.java (2)

200-212: Mirrors the JNA implementation as expected.

Behaviorally identical to LinuxHWDiskStoreJNA.detectDiskType. The "Removable beats SSD/HDD" precedence note and the optional-shared-helper suggestion on the JNA side both apply here as well — no need to re-discuss.


40-42: FFM constructor wiring matches the JNA path.

The new constructor, the "Virtual" literal for DM devices, and the detectDiskType(device, arena) call for non-DM devices line up cleanly with LinuxHWDiskStoreJNA, which is what we want for FFM/JNA parity.

Also applies to: 104-104, 127-130

CHANGELOG.md (1)

5-5: Changelog entry looks good.

Properly placed under the in-progress 7.1.0 section and references issue #2857 with the correct attribution.

oshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.java (2)

21-33: Clean addition with backward-compatible constructor.

Delegating the 4-arg constructor to the 5-arg one with "Unknown" keeps existing subclasses working without changes. If you adopt the constants suggestion on HWDiskStore, the literal here can be replaced by HWDiskStore.TYPE_UNKNOWN for a single source of truth.


60-75: toString update looks good.

Including the disk type in the existing (model: ... - S/N: ... - type: ...) block is consistent with the surrounding format.

oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHWDiskStore.java (1)

86-88: Straightforward pass-through constructor.

Forwards correctly to the new 5-arg superclass constructor; the old 4-arg constructor is preserved for compatibility.

oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreJNA.java (1)

90-91: DM → "Virtual" classification looks correct.

Hardcoding "Virtual" for /dev/dm-* devices matches the PR's documented behavior for device-mapper/LVM targets.

@dbwiddis
dbwiddis force-pushed the feature/disk-type branch from 09b042e to 03796dd Compare May 6, 2026 07:29
@codecov

codecov Bot commented May 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 56.66667% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.67%. Comparing base (b09fcd9) to head (b7fb13b).

Files with missing lines Patch % Lines
...i/hardware/platform/linux/LinuxHWDiskStoreFFM.java 35.29% 7 Missing and 4 partials ⚠️
...i/hardware/platform/linux/LinuxHWDiskStoreJNA.java 42.85% 4 Missing and 4 partials ⚠️
...re/common/platform/windows/WindowsHWDiskStore.java 40.00% 3 Missing and 3 partials ⚠️
...ommon/src/main/java/oshi/hardware/HWDiskStore.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3230      +/-   ##
============================================
- Coverage     63.79%   63.67%   -0.13%     
  Complexity       73       73              
============================================
  Files           420      421       +1     
  Lines         19307    19358      +51     
  Branches       3358     3366       +8     
============================================
+ Hits          12317    12326       +9     
- Misses         5289     5320      +31     
- Partials       1701     1712      +11     
Flag Coverage Δ
linux 30.05% <31.66%> (-0.06%) ⬇️
macos 32.99% <11.66%> (-0.07%) ⬇️
windows 40.78% <30.00%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsHWDiskStoreJNA.java (1)

157-170: ⚡ Quick win

parseWindowsMediaType is identical in WindowsHWDiskStoreFFM — extract to the common base class.

The method operates purely on a String with no JNA-specific types, so it can (and should) live in WindowsHWDiskStore as a protected static method, removing the duplication. As a bonus, the explanatory comment about the SSD/HDD ambiguity (present here) would then also cover the FFM path, which currently omits it.

♻️ Suggested refactor

Move the method to WindowsHWDiskStore.java:

+    /**
+     * Maps a WMI Win32_DiskDrive MediaType string to a simplified disk type.
+     * Note: WMI MediaType cannot distinguish SSD from HDD for fixed disks.
+     *
+     * `@param` mediaType the WMI MediaType string
+     * `@return` "Removable", "HDD", or "Unknown"
+     */
+    protected static String parseWindowsMediaType(String mediaType) {
+        if (mediaType == null || mediaType.isEmpty()) {
+            return "Unknown";
+        }
+        String lower = mediaType.toLowerCase(Locale.ROOT);
+        if (lower.contains("removable")) {
+            return "Removable";
+        } else if (lower.contains("fixed") || lower.contains("external")) {
+            // WMI doesn't distinguish SSD from HDD via MediaType alone;
+            // "Fixed hard disk media" could be either. Return HDD as default for fixed.
+            return "HDD";
+        }
+        return "Unknown";
+    }

Then remove the identical private copies from WindowsHWDiskStoreJNA and WindowsHWDiskStoreFFM.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsHWDiskStoreJNA.java`
around lines 157 - 170, Extract the duplicate private method
parseWindowsMediaType(String) from WindowsHWDiskStoreJNA and
WindowsHWDiskStoreFFM into the common superclass WindowsHWDiskStore as a
protected static method (retain the existing logic and the SSD/HDD ambiguity
comment), then delete the private copies in WindowsHWDiskStoreJNA and
WindowsHWDiskStoreFFM so both subclasses call
WindowsHWDiskStore.parseWindowsMediaType(...).
oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreFFM.java (1)

200-216: ⚡ Quick win

Silent Throwable catch makes detectDiskType failures invisible — add a trace/debug log.

When getSysattrValue throws (e.g., due to an unexpected FFM error or a pathological device), the catch block discards the exception entirely. Adding even a LOG.trace(...) or LOG.debug(...) call makes it possible to diagnose why devices end up as "Unknown" in production without any other code change.

📋 Suggested change
     } catch (Throwable t) { // NOSONAR
-        // Unable to read sysattr, return Unknown
+        LOG.debug("Unable to read sysattr for disk type detection: {}", t.getMessage());
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreFFM.java`
around lines 200 - 216, The catch in detectDiskType currently swallows all
Throwables from UdevFunctions.getSysattrValue; update that catch to log the
throwable at trace or debug level (e.g., LOG.trace or LOG.debug) including a
brief message and the exception to aid diagnosis, then continue returning
"Unknown"; ensure you reference detectDiskType and the calls to
UdevFunctions.getSysattrValue("removable", arena) and ("queue/rotational",
arena) so the logged message identifies which sysattr failed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@oshi-common/src/main/java/oshi/hardware/HWDiskStore.java`:
- Around line 54-61: The Javadoc for HWDiskStore.getDiskType mentions "Network"
as a possible return value even though the default implementation returns
"Unknown" and no platform implementations return "Network"; update the Javadoc
for the getDiskType method to either remove "Network" from the enumerated values
or explicitly mark it as reserved/for-future-use so docs match actual
behavior—edit the Javadoc on the HWDiskStore.getDiskType declaration to reflect
this change.

---

Nitpick comments:
In
`@oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreFFM.java`:
- Around line 200-216: The catch in detectDiskType currently swallows all
Throwables from UdevFunctions.getSysattrValue; update that catch to log the
throwable at trace or debug level (e.g., LOG.trace or LOG.debug) including a
brief message and the exception to aid diagnosis, then continue returning
"Unknown"; ensure you reference detectDiskType and the calls to
UdevFunctions.getSysattrValue("removable", arena) and ("queue/rotational",
arena) so the logged message identifies which sysattr failed.

In
`@oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsHWDiskStoreJNA.java`:
- Around line 157-170: Extract the duplicate private method
parseWindowsMediaType(String) from WindowsHWDiskStoreJNA and
WindowsHWDiskStoreFFM into the common superclass WindowsHWDiskStore as a
protected static method (retain the existing logic and the SSD/HDD ambiguity
comment), then delete the private copies in WindowsHWDiskStoreJNA and
WindowsHWDiskStoreFFM so both subclasses call
WindowsHWDiskStore.parseWindowsMediaType(...).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 47fe5d56-72a5-4c2b-a570-0b6b373295a2

📥 Commits

Reviewing files that changed from the base of the PR and between 09b042e and 03796dd.

📒 Files selected for processing (10)
  • CHANGELOG.md
  • oshi-common/src/main/java/oshi/driver/common/windows/wmi/Win32DiskDrive.java
  • oshi-common/src/main/java/oshi/hardware/HWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsHWDiskStore.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreFFM.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsHWDiskStoreFFM.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsHWDiskStoreJNA.java
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 21, windows-latest
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: JMH Benchmarks, windows-latest
  • GitHub Check: JMH Benchmarks, macos-latest
  • GitHub Check: JMH Benchmarks, ubuntu-latest
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2026-04-12T19:22:09.716Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3149
File: oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java:159-163
Timestamp: 2026-04-12T19:22:09.716Z
Learning: When reviewing OSHI hardware platform code that uses or implements `CentralProcessor`/`PhysicalProcessor.getEfficiency()`, remember the API’s counterintuitive semantics: a *higher* efficiency-class value indicates *greater performance* (lower efficiency). P-cores/“performance cores” should therefore have higher values (e.g., 1) than E-cores/“efficiency cores” (e.g., 0), as documented in the `CentralProcessor` Javadoc. Do not flag code as incorrect solely because ARM_P_CORES or Intel P-cores are assigned higher efficiency values.

Applied to files:

  • oshi-common/src/main/java/oshi/driver/common/windows/wmi/Win32DiskDrive.java
  • oshi-common/src/main/java/oshi/hardware/HWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsHWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHWDiskStore.java
📚 Learning: 2026-04-06T04:45:47.644Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:47.644Z
Learning: In the oshi/oshi project, only interfaces and classes in the root packages `oshi`, `oshi.hardware`, and `oshi.software.os` are considered the public API. Code in subpackages that represent specific implementations/platforms (e.g., `oshi.software.os.linux`, `oshi.hardware.platform.linux`, and similar subpackages) is implementation detail. When reviewing, do not treat changes to classes in these platform-specific subpackages as public API breaks (for example: making `LinuxOperatingSystem` abstract, narrowing constructor visibility, or adding/removing abstract methods should not be flagged as breaking public API).

Applied to files:

  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsHWDiskStoreJNA.java
🔇 Additional comments (7)
oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsHWDiskStoreFFM.java (1)

172-183: Duplicate of the parseWindowsMediaType in WindowsHWDiskStoreJNA — covered by the refactor comment there.

Also note that the SSD/HDD ambiguity comment present in the JNA copy is absent here, which could lead to maintainers diverging the logic between the two copies in future. Extracting to the common base resolves both.

oshi-common/src/main/java/oshi/driver/common/windows/wmi/Win32DiskDrive.java (1)

23-25: LGTM — MEDIATYPE correctly added in alphabetical order.

The OSHI WMI result maps use enum constants as keys (not ordinals), so inserting MEDIATYPE between MANUFACTURER and MODEL has no impact on existing lookups. WMI property matching is case-insensitive, so MEDIATYPE maps correctly to the WMI MediaType column.

oshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.java (1)

21-33: Clean implementation — immutable diskType field with proper constructor delegation.

The final field together with the delegating 4-arg constructor ensures backward-compatible defaults and thread safety. No issues.

oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsHWDiskStore.java (1)

53-55: LGTM — straightforward delegation to the new AbstractHWDiskStore 5-arg constructor.

oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHWDiskStore.java (1)

86-88: LGTM — mirrors the same pattern applied to LinuxHWDiskStore.

oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreJNA.java (1)

168-180: detectDiskType logic is correct and well-ordered.

Checking removable before queue/rotational correctly classifies USB-attached SSDs as "Removable" rather than "SSD", which matches the PR's stated intent. The "Unknown" fallback for unexpected queue/rotational values is appropriately defensive.

oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreFFM.java (1)

36-42: ⚡ Quick win

The review comment's concern has been verified and found to be resolved by design. AbstractHWDiskStore includes a 4-arg constructor (lines 23–25 in AbstractHWDiskStore.java) that chains to the 5-arg constructor with "Unknown" as the diskType value:

protected AbstractHWDiskStore(String name, String model, String serial, long size) {
    this(name, model, serial, size, "Unknown");
}

This means the old 4-arg constructor in LinuxHWDiskStoreFFM (line 36) correctly delegates to the parent and guarantees that getDiskType() returns "Unknown" rather than null. No issue here—the code is already correct!

Resolves #2857

Adds getDiskType() to HWDiskStore interface with a default of 'Unknown'.
Linux implementation reads sysfs attributes:
- /sys/block/<name>/removable (1 = Removable)
- /sys/block/<name>/queue/rotational (0 = SSD, 1 = HDD)
- Device-mapper devices report 'Virtual'

Implemented for both JNA and FFM Linux backends.
Other platforms return 'Unknown' (can be enhanced in follow-up PRs).
@dbwiddis
dbwiddis force-pushed the feature/disk-type branch from 03796dd to b7fb13b Compare May 6, 2026 15:50

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (3)
oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreJNA.java (2)

39-45: 💤 Low value

Consider dropping the unused 4-arg constructor.

After this PR every construction site goes through the 5-arg form (DM branch passes "Virtual", non-DM passes detectDiskType(device)). The legacy 4-arg constructor is effectively dead and just defers to the parent's "Unknown" default — fine to keep if symmetry with the FFM variant matters, but otherwise easy to remove.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreJNA.java`
around lines 39 - 45, Remove the unused 4-argument constructor in class
LinuxHWDiskStoreJNA (the method LinuxHWDiskStoreJNA(String name, String model,
String serial, long size)) since all call sites now use the 5-arg constructor;
delete that constructor, ensure no remaining references expect the 4-arg form,
and update any tests or usages to call the 5-arg constructor
LinuxHWDiskStoreJNA(String name, String model, String serial, long size, String
diskType) (passing "Unknown" or an appropriate detected diskType where needed).

168-180: ⚡ Quick win

Mirror the FFM twin's defensive handling.

The FFM detectDiskType wraps the sysattr reads in try { … } catch (Throwable t) { LOG.debug(…); } and falls back to "Unknown". This JNA version doesn't, and getDisks() has no surrounding catch in the disk-iteration block (it only relies on device.unref() in finally), so an unexpected exception here would abort the entire disk enumeration rather than just leaving one device's type as Unknown. Aligning the two helpers keeps the platform behavior symmetric.

♻️ Suggested change
     private static String detectDiskType(UdevDevice device) {
-        String removable = device.getSysattrValue("removable");
-        if ("1".equals(removable)) {
-            return "Removable";
-        }
-        String rotational = device.getSysattrValue("queue/rotational");
-        if ("0".equals(rotational)) {
-            return "SSD";
-        } else if ("1".equals(rotational)) {
-            return "HDD";
-        }
-        return "Unknown";
+        try {
+            String removable = device.getSysattrValue("removable");
+            if ("1".equals(removable)) {
+                return "Removable";
+            }
+            String rotational = device.getSysattrValue("queue/rotational");
+            if ("0".equals(rotational)) {
+                return "SSD";
+            } else if ("1".equals(rotational)) {
+                return "HDD";
+            }
+        } catch (RuntimeException e) {
+            LOG.debug("Unable to read disk type sysattr", e);
+        }
+        return "Unknown";
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreJNA.java`
around lines 168 - 180, The detectDiskType(UdevDevice device) method should
defensively wrap the sysattr reads in a try/catch (catch Throwable) similar to
the FFM twin: surround the calls to device.getSysattrValue("removable") and
device.getSysattrValue("queue/rotational") with a try block, on any thrown
Throwable log a debug-level message identifying the device and exception (use
the existing LOG) and return "Unknown"; this prevents exceptions from aborting
getDisks() and keeps behavior symmetric with the FFM helper.
oshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.java (1)

21-33: ⚡ Quick win

Consider centralizing disk-type values as constants or an enum.

Across the PR the strings "Unknown", "SSD", "HDD", "Removable", and "Virtual" are repeated as literals in AbstractHWDiskStore, the Linux FFM/JNA detectDiskType helpers, the DM branches, and parseWindowsMediaType. A small typo in any platform-specific path would silently produce a value the rest of the system doesn't recognize. Defining them once (e.g., public string constants on HWDiskStore, or an enum like HWDiskStore.Type that exposes a stable display name) would make the contract explicit and easier to extend toward the broader categories described in #2857 (optical, network, flash, etc.).

Also a small consistency nit: the 4-arg constructor uses the literal "Unknown" here while LinuxHWDiskStoreFFM/JNA already use Constants.UNKNOWN for null model/serial fallbacks. Worth aligning regardless of whether the broader enum suggestion lands.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@oshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.java`
around lines 21 - 33, Introduce a single centralized set of disk-type
identifiers (either public constants or an enum) and replace all string literals
with those identifiers; specifically add a public enum or public static final
Strings (e.g., HWDiskStore.Type { UNKNOWN, SSD, HDD, REMOVABLE, VIRTUAL } or
HWDiskStore.UNKNOWN/SSD/etc.), update AbstractHWDiskStore to use that UNKNOWN
identifier in the 4-arg constructor and set diskType to the enum/constant in the
5-arg constructor, and refactor all platform helpers (detectDiskType methods in
LinuxFFM/JNA, DM branches, parseWindowsMediaType) to return/compare the
centralized values instead of repeating literals so every path uses the same
canonical identifiers.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@oshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.java`:
- Around line 21-33: Introduce a single centralized set of disk-type identifiers
(either public constants or an enum) and replace all string literals with those
identifiers; specifically add a public enum or public static final Strings
(e.g., HWDiskStore.Type { UNKNOWN, SSD, HDD, REMOVABLE, VIRTUAL } or
HWDiskStore.UNKNOWN/SSD/etc.), update AbstractHWDiskStore to use that UNKNOWN
identifier in the 4-arg constructor and set diskType to the enum/constant in the
5-arg constructor, and refactor all platform helpers (detectDiskType methods in
LinuxFFM/JNA, DM branches, parseWindowsMediaType) to return/compare the
centralized values instead of repeating literals so every path uses the same
canonical identifiers.

In
`@oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreJNA.java`:
- Around line 39-45: Remove the unused 4-argument constructor in class
LinuxHWDiskStoreJNA (the method LinuxHWDiskStoreJNA(String name, String model,
String serial, long size)) since all call sites now use the 5-arg constructor;
delete that constructor, ensure no remaining references expect the 4-arg form,
and update any tests or usages to call the 5-arg constructor
LinuxHWDiskStoreJNA(String name, String model, String serial, long size, String
diskType) (passing "Unknown" or an appropriate detected diskType where needed).
- Around line 168-180: The detectDiskType(UdevDevice device) method should
defensively wrap the sysattr reads in a try/catch (catch Throwable) similar to
the FFM twin: surround the calls to device.getSysattrValue("removable") and
device.getSysattrValue("queue/rotational") with a try block, on any thrown
Throwable log a debug-level message identifying the device and exception (use
the existing LOG) and return "Unknown"; this prevents exceptions from aborting
getDisks() and keeps behavior symmetric with the FFM helper.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0a32c986-2502-420c-adcc-18b67504bd1e

📥 Commits

Reviewing files that changed from the base of the PR and between 03796dd and b7fb13b.

📒 Files selected for processing (10)
  • CHANGELOG.md
  • oshi-common/src/main/java/oshi/driver/common/windows/wmi/Win32DiskDrive.java
  • oshi-common/src/main/java/oshi/hardware/HWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsHWDiskStore.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreFFM.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsHWDiskStoreFFM.java
  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsHWDiskStoreJNA.java
🚧 Files skipped from review as they are similar to previous changes (2)
  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsHWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/HWDiskStore.java
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
  • GitHub Check: Analyze (java)
  • GitHub Check: Test JDK 21, windows-latest
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: JMH Benchmarks, ubuntu-latest
  • GitHub Check: Test JDK 11, macos-latest
  • GitHub Check: Test JDK 11, windows-latest
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: JMH Benchmarks, windows-latest
  • GitHub Check: JMH Benchmarks, macos-latest
  • GitHub Check: Codacy Static Code Analysis
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2026-04-06T04:45:47.644Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:47.644Z
Learning: In the oshi/oshi project, only interfaces and classes in the root packages `oshi`, `oshi.hardware`, and `oshi.software.os` are considered the public API. Code in subpackages that represent specific implementations/platforms (e.g., `oshi.software.os.linux`, `oshi.hardware.platform.linux`, and similar subpackages) is implementation detail. When reviewing, do not treat changes to classes in these platform-specific subpackages as public API breaks (for example: making `LinuxOperatingSystem` abstract, narrowing constructor visibility, or adding/removing abstract methods should not be flagged as breaking public API).

Applied to files:

  • oshi-core/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsHWDiskStoreJNA.java
📚 Learning: 2026-04-12T19:22:09.716Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3149
File: oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java:159-163
Timestamp: 2026-04-12T19:22:09.716Z
Learning: When reviewing OSHI hardware platform code that uses or implements `CentralProcessor`/`PhysicalProcessor.getEfficiency()`, remember the API’s counterintuitive semantics: a *higher* efficiency-class value indicates *greater performance* (lower efficiency). P-cores/“performance cores” should therefore have higher values (e.g., 1) than E-cores/“efficiency cores” (e.g., 0), as documented in the `CentralProcessor` Javadoc. Do not flag code as incorrect solely because ARM_P_CORES or Intel P-cores are assigned higher efficiency values.

Applied to files:

  • oshi-common/src/main/java/oshi/driver/common/windows/wmi/Win32DiskDrive.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.java
🔇 Additional comments (9)
CHANGELOG.md (1)

5-5: LGTM!

Entry format and placement match the existing 7.1.0 in-progress section.

oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHWDiskStore.java (1)

86-89: LGTM!

Straightforward forwarding constructor that lines up with the new AbstractHWDiskStore(String, String, String, long, String) signature.

oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsHWDiskStoreFFM.java (2)

80-92: LGTM — wiring matches the JNA variant.

The MEDIATYPE → parseWindowsMediaType path mirrors WindowsHWDiskStoreJNA.getDisks(), which keeps the two implementations in lockstep. Just make sure (per the JNA-file comment) that there's a single canonical parseWindowsMediaType to avoid drift between FFM and JNA.


51-57: 💤 Low value

Same observation as the JNA variant: 4-arg constructor likely unused.

getDisks() now only constructs via the 5-arg form. Worth checking whether the 4-arg constructor still has callers, and removing it (or routing it through the 5-arg with "Unknown") so the two paths can't drift.

oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsHWDiskStoreJNA.java (2)

46-52: 💤 Low value

Check whether the 4-arg constructor is still reachable.

getDisks() now exclusively uses the 5-arg form. If nothing else calls WindowsHWDiskStoreJNA with the 4-arg signature, it's dead code that just delegates to a parent constructor that defaults diskType to "Unknown". You could remove it or have it call the 5-arg form with "Unknown" to keep the code cleaner.


75-80: ⚡ Quick win

Verify parseWindowsMediaType definition locations before proceeding.

Unable to confirm the shadowing concern due to access limitations—shell execution failed repeatedly, and web search of public OSHI sources found no evidence of parseWindowsMediaType. However, this doesn't confirm the method doesn't exist in the working codebase or that shadowing isn't occurring. Manual inspection of the actual source files is needed to verify:

  1. Whether parseWindowsMediaType exists in both the parent class (WindowsHWDiskStore) as protected static and in WindowsHWDiskStoreJNA as private static
  2. If both definitions exist, whether they can drift apart or if one intentionally shadows the other
  3. If only one canonical definition should exist (the protected one in the parent for shared behavior across JNA and FFM subclasses)
oshi-common/src/main/java/oshi/hardware/common/AbstractHWDiskStore.java (1)

60-75: 💤 Low value

Check for downstream dependencies on the toString() format change.

The toString() method format has changed from (model: <m>) S/N: <s>, size: … to (model: <m> - S/N: <s> - type: <t>) size: …. While this is a reasonable layout improvement, any code that parses or asserts against this string representation (in tests, demo code, or log analysis) should be re-checked to ensure compatibility with the new format.

oshi-common/src/main/java/oshi/driver/common/windows/wmi/Win32DiskDrive.java (1)

24-24: 💤 Low value

Verify that no code depends on DiskDriveProperty enum ordinals.

The insertion of MEDIATYPE between MANUFACTURER and MODEL shifts the ordinal positions of subsequent enum constants. While WMI lookups safely use name() rather than ordinals, if any code elsewhere uses .ordinal() directly or indexes into values() by position, this change could break that logic. A quick search of the codebase for ordinal-dependent usage of this enum would confirm it's safe.

oshi-core-ffm/src/main/java/oshi/hardware/platform/linux/LinuxHWDiskStoreFFM.java (1)

200-216: ⚡ Quick win

The nested sysattr path handling is correct.

The FFM wrapper's implementation directly allocates the sysattr string as-is via arena.allocateFrom(sysattr) without sanitizing or stripping "/" characters. This means "queue/rotational" is passed correctly to the native udev_device_get_sysattr_value call, matching the documented udev behavior. The defensive try/catch around sysattr reads is a reasonable design choice in the FFM variant and will gracefully return "Unknown" if udev fails.

@dbwiddis
dbwiddis merged commit 7830542 into oshi:master May 6, 2026
20 checks passed
@dbwiddis
dbwiddis deleted the feature/disk-type branch May 6, 2026 16:15
dbwiddis added a commit that referenced this pull request May 9, 2026
- Add native-free Linux SystemInfoProvider and Apple Silicon fix to 7.2.0
- Fix issue links to point to implementing PRs (#3230, #3232, #3227)
- Add macOS disk type (#3231) and OSFileStore fast path (#3195)
- Mention native-free Linux option in README Usage section
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.

Add disk type information

1 participant