Skip to content

Report FreeBSD disk types and Windows partitions without a drive letter - #3896

Merged
dbwiddis merged 3 commits into
oshi:masterfrom
dbwiddis:disk-type-partitions
Nov 14, 2026
Merged

dbwiddis merged 3 commits into
oshi:masterfrom
dbwiddis:disk-type-partitions

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Part of the pre-7.8.0 API gap work, disks and partitions group.

Changes

  • FreeBSD disk type. GeomDiskList already parsed geom disk list but skipped its rotationrate: line. Per sys/geom/geom_disk.c, the kernel prints 0 for a drive that reports itself non-rotating, the RPM for one that spins, and unknown or invalid otherwise. These now map to SSD, HDD and Unknown. The type is passed through the JNA and FFM factories to AbstractHWDiskStore's existing diskType. DragonFly BSD has no geom and still reports Unknown.
  • Windows partitions without a drive letter. Both backends skipped any Win32_DiskPartition that no Win32_LogicalDisk maps to, so EFI system, Microsoft reserved and recovery partitions were missing. They are now listed, using the Size that query already returns, with empty UUID, label and mount point. A helper in WindowsHWDiskStore serves both twins, so they cannot diverge.
  • HWDiskStore.getDiskType() javadoc now names the FreeBSD source.

Verification

  • FreeBSD: cfarm430 (QEMU disks) prints rotationrate: 0, so its disks will report SSD. The parse is covered by fixture tests for each form.
  • Windows: fixture test for the shared helper and the partition list; JNA/FFM parity is covered by WmiComparisonTest in CI. I couldn't run it locally (macOS host).

Summary by CodeRabbit

  • New Features
    • FreeBSD disk information reports media type as SSD or HDD when it can be determined.
    • Windows partition listings include partitions without drive letters, shown with an empty mount point.

GeomDiskList already read geom disk list and skipped its rotationrate line.
sys/geom/geom_disk.c prints 0 for a drive that reports itself non-rotating, the
RPM for one that spins, and unknown or invalid otherwise; map those to SSD, HDD
and Unknown, and pass the type through the JNA and FFM disk store factories.
Both backends skipped a Win32_DiskPartition that no Win32_LogicalDisk maps to,
so the EFI system, Microsoft reserved and recovery partitions were missing from
getPartitions(). Add them with the size Win32_DiskPartition already returns and
no UUID, label or mount point, through a helper shared by both backends.
@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The changes add FreeBSD disk-type reporting based on GEOM rotation-rate data and include Windows partitions that have no logical-drive mapping. The FreeBSD disk type is passed through disk-store construction. Windows unmounted partitions have empty UUID, label, and mount-point fields.

Changes: FreeBSD disk type reporting

Layer / File(s) Summary
Parse GEOM rotation rates
oshi-common/src/main/java/oshi/driver/common/unix/freebsd/disk/GeomDiskList.java, oshi-common/src/test/java/oshi/driver/common/unix/freebsd/disk/*
GEOM disk records now include a type: 0 maps to SSD, a positive integer maps to HDD, and other values map to Unknown. Tests cover these results and parser fallback cases.
Pass disk type to FreeBSD stores
oshi-common/src/main/java/oshi/hardware/common/platform/unix/freebsd/FreeBsdHWDiskStore.java, oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdHWDiskStoreJNA.java, oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdHWDiskStoreFFM.java, oshi-common/src/main/java/oshi/hardware/HWDiskStore.java
FreeBSD store construction now accepts and passes disk type. The getDiskType() documentation identifies GEOM rotation rate as a FreeBSD source.

Windows unmounted partitions

Layer / File(s) Summary
Map partitions without logical drives
oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsHWDiskStore.java, oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsHWDiskStoreJNA.java, oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsHWDiskStoreFFM.java, oshi-common/src/test/java/oshi/hardware/common/platform/windows/WindowsHWDiskStorePartitionsTest.java, CHANGELOG.md
JNA and FFM partition queries now add partitions without logical-drive mappings. The test checks that the EFI partition is present with an empty mount point. The changelog records both the FreeBSD and Windows changes.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Merge Risk: Minimal · up to 3b93a

This change adds FreeBSD disk type reporting and lists Windows partitions that have no drive letter. No concrete merge-blocking problem was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the two main changes in the PR: FreeBSD disk type reporting (parsing rotationrate from geom disk list into SSD/HDD/Unknown) and Windows partitions without a drive letter being included…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the two main changes in the PR: FreeBSD disk type reporting (parsing rotationrate from geom disk list into SSD/HDD/Unknown) and Windows partitions without a drive letter being included in the partition list. The summaries and objectives confirm both changes are present in the changeset, so the title matches the main change.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

A rabbit checks the disks at night
“Zero spins? SSD looks right!”
An unmounted partition joins the list
Its empty mount is hard to miss
I nibble clover, pleased with this!

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9afeac0e-8714-414e-b641-32b888bd98dd
Commits

Reviewing files that changed from the base of the PR and between 1ce3674 and 3b93a6e.

Files selected for processing: 10

  • CHANGELOG.md
  • oshi-common/src/main/java/oshi/driver/common/unix/freebsd/disk/GeomDiskList.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/freebsd/FreeBsdHWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsHWDiskStore.java
  • oshi-common/src/test/java/oshi/driver/common/unix/freebsd/disk/DiskDriversTest.java
  • oshi-common/src/test/java/oshi/driver/common/unix/freebsd/disk/GeomDiskListTest.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdHWDiskStoreFFM.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsHWDiskStoreFFM.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdHWDiskStoreJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsHWDiskStoreJNA.java
Files skipped from review as they are similar to previous changes: 1

  • CHANGELOG.md

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 2 remain after this review.

Recent review details

Context from checks skipped due to timeout: 13

  • GitHub Check: Test JDK 25, NetBSD
  • GitHub Check: Test JDK 25, FreeBSD
  • GitHub Check: Test JDK 25, DragonFly BSD
  • GitHub Check: Test JDK 25, OpenBSD
  • GitHub Check: Test JDK 25, OpenIndiana
  • GitHub Check: CodeRabbit
  • GitHub Check: Test JDK 26, ubuntu-latest
  • GitHub Check: Lint (ForbiddenAPIs, Javadoc, SLF4J)
  • GitHub Check: Error Prone
  • GitHub Check: Test JDK 25, ubuntu-latest
  • GitHub Check: Test JDK 25, macos-latest
  • GitHub Check: Test JDK 25, windows-latest
  • GitHub Check: Analyze (java)
Additional context used

Code guidelines: 2

FAQ.md — auto-discovered
AGENTS.md — auto-discovered
Path-based instructions: 4

Applicability reference: AGENTS.md: # AGENTS.md **API compatibility.**

CodeRabbit inference engine (FAQ.md)

Files:

  • oshi-common/src/main/java/oshi/driver/common/unix/freebsd/disk/GeomDiskList.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/freebsd/FreeBsdHWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsHWDiskStore.java
  • oshi-common/src/test/java/oshi/driver/common/unix/freebsd/disk/DiskDriversTest.java
  • oshi-common/src/test/java/oshi/driver/common/unix/freebsd/disk/GeomDiskListTest.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdHWDiskStoreFFM.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsHWDiskStoreFFM.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdHWDiskStoreJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsHWDiskStoreJNA.java
Source excerpt: **Banned APIs** (`config/forbidden-apis.txt` and friends, enforced by `forbiddenapis:check`): `oshi-core-ffm` may not reference `com.sun.jna.**`.

CodeRabbit inference engine (AGENTS.md)

Files:

  • oshi-core-ffm/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdHWDiskStoreFFM.java
  • oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsHWDiskStoreFFM.java
Source excerpt: **Banned APIs** (`config/forbidden-apis.txt` and friends, enforced by `forbiddenapis:check`): `oshi-common` may not reference `com.sun.jna.**`, `java.lang.foreign.**`, or any `System.load`/`loadLibrary`.

CodeRabbit inference engine (AGENTS.md)

Files:

  • oshi-common/src/main/java/oshi/driver/common/unix/freebsd/disk/GeomDiskList.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/freebsd/FreeBsdHWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsHWDiskStore.java
  • oshi-common/src/test/java/oshi/driver/common/unix/freebsd/disk/DiskDriversTest.java
  • oshi-common/src/test/java/oshi/driver/common/unix/freebsd/disk/GeomDiskListTest.java
Source excerpt: **Language level.**

CodeRabbit inference engine (AGENTS.md)

Files:

  • oshi-common/src/main/java/oshi/driver/common/unix/freebsd/disk/GeomDiskList.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/freebsd/FreeBsdHWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/windows/WindowsHWDiskStore.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdHWDiskStoreJNA.java
  • oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsHWDiskStoreJNA.java
Additional comments: 3

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

367-370: LGTM!

oshi-core-ffm/src/main/java/oshi/hardware/platform/windows/WindowsHWDiskStoreFFM.java: 1

246-252: LGTM!

oshi-core/src/main/java/oshi/hardware/platform/windows/WindowsHWDiskStoreJNA.java: 1

241-247: LGTM!

@dbwiddis
dbwiddis merged commit 5e219c5 into oshi:master Nov 14, 2026
18 of 19 checks passed
@dbwiddis
dbwiddis deleted the disk-type-partitions branch November 14, 2026 19:17
dbwiddis added a commit that referenced this pull request Nov 14, 2026
* Report Solaris thread page faults

SolarisOSThread already read each LWP's lwpusage for times and context
switches but dropped pr_minf and pr_majf, which SolarisOSProcess reads from
the same struct. The OSThread javadoc said Linux only, though every BSD also
reports both counts. The CHANGELOG includes #3896's entry, which merges first.

* Read Solaris and NetBSD thread usage from the thread, not the process

Review round 1. PsInfo.queryPrUsage read /proc/<pid>/lwp/<tid>/usage, which
does not exist; proc(4) names it lwpusage (504 bytes, the same prusage_t as
the process's usage, on Solaris 11.4 SPARC). Pre-existing: every Solaris
thread fell back to lwpsinfo, so kernel time and context switches were always
0. SolarisOSThread now assigns each field once, so an unlocked reader never
sees a transient zero.

NetBSD's ps reads cputime, majflt, minflt, nvcsw and nivcsw from the process
(PUVAR in bin/ps/keyword.c), so every LWP row repeated the process totals.
Threads now read ltime, the LWP's own CPU time, and no longer request the
others, which the kernel does not keep per LWP. The OSThread javadoc drops
NetBSD from the fault and context-switch platforms.
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