Skip to content

Fix BSD disklabel partition mount points and NetBSD UUIDs - #3876

Merged
dbwiddis merged 2 commits into
oshi:masterfrom
dbwiddis:disklabel-mount-points
Nov 8, 2026
Merged

dbwiddis merged 2 commits into
oshi:masterfrom
dbwiddis:disklabel-mount-points

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Found during the #3844 join-key survey. OpenBSD and NetBSD share Disklabel.parseDiskParams(), which took the last whitespace token of a partition row as the mount point.

  • OpenBSD writes a partition's fstab mount point as a trailing comment (# /usr). A partition that fstab does not list has no comment, so its row ends at the cpg column, and getMountPoint() returned 12960.
  • NetBSD never writes a mount point. Its row comment is the cylinder range, # (Cyl. 0 - 63), so every disklabel partition reported 63). NetBSD also has no DUID, so getUuid() returned .a, .e and so on.

Change

  • New Disklabel.parseMountPoint(): the text after #, or empty for a row with no comment or with a cylinder range.
  • A partition's UUID is empty when the disk has no DUID.
  • NetBsdHWDiskStore fills in disklabel partitions' mount points from the df map it already reads for wedges (withMountPoints). A partition that already has a mount point, as the df fallback's do, keeps it.

Left unchanged: OpenBSD swap still reports none (it is in fstab), and rows with four or fewer columns (OpenBSD's c: … unused) are still skipped, as the existing test documents.

Testing

  • New fixtures from real output, captured as root in a throwaway workflow on the fork: disklabel vnd0 on NetBSD 10.1, and disklabel -n sd0 on OpenBSD 7.9 with a partition removed from fstab. There is also a parseMountPoint unit test and a withMountPoints test.
  • Live, by building the branch in the fork's vmactions VMs and listing getDiskStores() partitions:
    • NetBSD: a file-backed vnd0 with a real disklabel reports vnd0a with mount /mnt/data, the unmounted vnd0e with no mount, and empty UUIDs. The GPT wedges on ld0 are unchanged.
    • OpenBSD: sd0k, removed from fstab, reports an empty mount point. Every other partition is unchanged.
  • The gate passes on macOS (-Perror-prone install with tests, checkstyle, forbidden APIs, javadoc).

Summary by CodeRabbit

  • Bug Fixes
    • NetBSD disk partitions now display their mounted filesystem correctly, and partitions without a disk identifier no longer show malformed UUIDs.
    • OpenBSD partitions without an /etc/fstab entry are handled correctly.
    • Unmounted partitions and disk cylinder-range details are no longer mistaken for mount points.

The shared Disklabel parser took a partition row's last token as its
mount point. OpenBSD writes the fstab mount point in a trailing
comment, but a partition fstab does not list has no comment, so it
reported the cpg column (12960). NetBSD never writes a mount point:
its comment is the cylinder range, so partitions reported "63)".
NetBSD has no DUID either, so every UUID read ".a", ".e" and so on.

- Disklabel.parseMountPoint reads the text after '#', and nothing for
  a row with no comment or a cylinder range.
- The UUID is empty where the disk has no DUID.
- NetBSD fills disklabel partitions' mount points from the df map it
  already reads for wedges.

Fixtures are captured as root from NetBSD 10.1 and OpenBSD 7.9 in a
throwaway fork workflow, which also ran the change against a
file-backed disklabel disk on NetBSD and an fstab-less partition on
OpenBSD.
@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Disklabel parsing now handles mount comments and empty DUIDs. NetBSD disk discovery uses the mount map to fill missing mount points on disklabel partitions when no wedges are present. Tests cover OpenBSD and NetBSD disklabel output and mount-point assignment.

Changes: BSD disklabel mount-point handling

Layer / File(s) Summary
Parse disklabel identifiers and mount comments
oshi-common/src/main/java/oshi/driver/common/unix/bsd/disk/Disklabel.java, oshi-common/src/test/java/oshi/driver/common/unix/bsd/disk/DisklabelTest.java, CHANGELOG.md
Disklabel parsing uses an empty UUID when the DUID is empty. It extracts mount points from supported comments and leaves them empty for missing or parenthesized comments. Tests cover OpenBSD and NetBSD fixtures, including cylinder-range comments. The changelog records the fixes.
Fill missing NetBSD partition mount points
oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdHWDiskStore.java, oshi-common/src/test/java/oshi/hardware/common/platform/unix/netbsd/NetBsdHWDiskStoreTest.java
getDisks reuses the mount map for wedge parsing and fills missing mount points on disklabel partitions when no wedges are present. Existing mount points and other partition fields are preserved. Tests cover matching, missing, and existing mount points.

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

Change: Bug fix

Merge Risk: Minimal · up to 20e0f

No actionable merge-blocking issue is established; the change is mergeable after normal checks.

Pre-merge checks: Passed 5

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: BSD disklabel partition mount points and NetBSD UUIDs. The raw summary and PR objectives both describe a fix for mount-point parsing in Disklabel.parseDiskParams …
Docstring Coverage Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentati…
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: BSD disklabel partition mount points and NetBSD UUIDs. The raw summary and PR objectives both describe a fix for mount-point parsing in Disklabel.parseDiskParams and NetBsdHWDiskStore, plus NetBSD UUID suppression when no DUID exists. The title is specific and matches the changeset. It is a single sentence of 9 words and 57 characters.

Full details: Docstring Coverage

Explanation

Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 5 functions across 4 files. (1 skipped: 1 unsupported.)

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

I’m a rabbit by the disklabel rows,
I hop where the mounted path now goes.
Empty DUIDs leave no dotted trace,
Cylinder notes stay in their place.
NetBSD mount maps fill the gap,
Then I nibble, nap, and tap.

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: 259136e3-1ed8-4429-8b06-f33a541e0afe
Commits

Reviewing files that changed from the base of the PR and between 2a25345 and 20e0f93.

Files selected for processing: 5

  • CHANGELOG.md
  • oshi-common/src/main/java/oshi/driver/common/unix/bsd/disk/Disklabel.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdHWDiskStore.java
  • oshi-common/src/test/java/oshi/driver/common/unix/bsd/disk/DisklabelTest.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/unix/netbsd/NetBsdHWDiskStoreTest.java

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

Recent review details

Context from checks skipped due to timeout: 5

  • GitHub Check: CodeRabbit
  • GitHub Check: Test JDK 25, OpenBSD
  • GitHub Check: Test JDK 25, DragonFly BSD
  • GitHub Check: Test JDK 25, NetBSD
  • GitHub Check: Test JDK 25, OpenIndiana
Additional context used

Code guidelines: 2

AGENTS.md — auto-discovered
.github/CONTRIBUTING.md — auto-discovered
Path-based instructions: 6

Source excerpt: **Language level.**

CodeRabbit inference engine (AGENTS.md)

Files:

  • oshi-common/src/main/java/oshi/driver/common/unix/bsd/disk/Disklabel.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdHWDiskStore.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/test/java/oshi/hardware/common/platform/unix/netbsd/NetBsdHWDiskStoreTest.java
  • oshi-common/src/main/java/oshi/driver/common/unix/bsd/disk/Disklabel.java
  • oshi-common/src/test/java/oshi/driver/common/unix/bsd/disk/DisklabelTest.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdHWDiskStore.java
Applicability reference: AGENTS.md: # AGENTS.md Instructions for AI coding agents working in the OSHI repository.

CodeRabbit inference engine (.github/CONTRIBUTING.md)

Files:

  • CHANGELOG.md
Source excerpt: An entry is one bullet, on **one line however long it runs** — the longest in the file is over a thousand characters.

CodeRabbit inference engine (AGENTS.md)

Files:

  • CHANGELOG.md
Source excerpt: **Their `src/test` compiles at `release 17`**, set by `maven.compiler.testRelease` in the root `pom.xml`.

CodeRabbit inference engine (AGENTS.md)

Files:

  • oshi-common/src/test/java/oshi/hardware/common/platform/unix/netbsd/NetBsdHWDiskStoreTest.java
  • oshi-common/src/test/java/oshi/driver/common/unix/bsd/disk/DisklabelTest.java
Source excerpt: **Javadoc.**

CodeRabbit inference engine (AGENTS.md)

Files:

  • oshi-common/src/test/java/oshi/hardware/common/platform/unix/netbsd/NetBsdHWDiskStoreTest.java
  • oshi-common/src/main/java/oshi/driver/common/unix/bsd/disk/Disklabel.java
  • oshi-common/src/test/java/oshi/driver/common/unix/bsd/disk/DisklabelTest.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdHWDiskStore.java
Learnings: 2

Learning: 2026-10-31T02:27:20.004Z

Learnt from: CR
Repo: oshi/oshi PR: 0
File: .github/CONTRIBUTING.md:0-0
Timestamp: 2026-10-31T02:27:20.004Z
Learning: Applies to CHANGELOG.md : Applicability reference:
AGENTS.md: # AGENTS.md
Instructions for AI coding agents working in the OSHI repository. Humans should start with
[README.md](README.md) and [CONTRIBUTING.md](.github/CONTRIBUTING.md); this file covers what an agent
is likely to get wrong.

AGENTS.md: # AGENTS.md
## Further reading
- [CONTRIBUTING.md](.github/CONTRIBUTING.md) — fork/branch/PR workflow for humans

Source excerpt:
# 🚀 Contributing to Oshi

## 📝 Update Changelog

The Changelog lets users know what's changed. Edit [CHANGELOG](../CHANGELOG.md) to include your contribution under *Next Release*. Follow the format of other entries, including your name and a link to your GitHub account:

```markdown
* [#123](https://github.com/oshi/oshi/pull/123): Reticulated splines - [contributor](https://github.com/contributor).
```

Applied to files:

  • CHANGELOG.md
Learning: 2026-11-03T00:11:07.635Z

Learnt from: CR
Repo: oshi/oshi PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-11-03T00:11:07.635Z
Learning: Applies to **/src/test/** : Source excerpt:
# AGENTS.md

## Hard rules that CI enforces

**Their `src/test` compiles at `release 17`**, set by `maven.compiler.testRelease` in the root
`pom.xml`. Test classes are never published, so the Java 8 guarantee to consumers does not reach
them. Use text blocks for captured command or file output, `Files.writeString` over
`Files.write(path, s.getBytes(UTF_8))`, and `Stream.toList()`; `var` is fine and is already the
house style in `oshi-core-ffm`. Two cautions:

- **NullAway checks test sources too**, at ERROR, the same as main. Compiling tests at 17 put them
  on the module path, which brings `module-info.java`'s `NullMarked` into scope for test packages.
  A stub override must repeat the parent's `Nullable`; a `Map.get()` needs a local plus
  `assertNotNull`, which narrows where Hamcrest's `is(notNullValue())` does not.
- **17 is pinned from both directions.** JUnit 6 requires 17+, so it is also a floor. The ceiling is
  Solaris SPARC on the G...

Applied to files:

  • oshi-common/src/test/java/oshi/driver/common/unix/bsd/disk/DisklabelTest.java
Additional comments: 5

oshi-common/src/main/java/oshi/driver/common/unix/bsd/disk/Disklabel.java: 1

99-102: LGTM!

Also applies to: 109-124

oshi-common/src/test/java/oshi/driver/common/unix/bsd/disk/DisklabelTest.java: 1

47-47: LGTM!

Also applies to: 244-262, 264-305, 307-313

CHANGELOG.md: 1

23-23: LGTM!

oshi-common/src/main/java/oshi/hardware/common/platform/unix/netbsd/NetBsdHWDiskStore.java: 1

68-69: LGTM!

Also applies to: 122-122, 181-198

oshi-common/src/test/java/oshi/hardware/common/platform/unix/netbsd/NetBsdHWDiskStoreTest.java: 1

200-211: LGTM!

@codecov

codecov Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.23%. Comparing base (2a25345) to head (20e0f93).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3876      +/-   ##
============================================
+ Coverage     81.21%   81.23%   +0.01%     
  Complexity      937      937              
============================================
  Files           726      726              
  Lines         26773    26788      +15     
  Branches       4570     4574       +4     
============================================
+ Hits          21745    21761      +16     
+ Misses         2797     2795       -2     
- Partials       2231     2232       +1     
Flag Coverage Δ
dragonflybsd 37.79% <85.00%> (+0.04%) ⬆️
freebsd 38.35% <85.00%> (+0.04%) ⬆️
linux 42.27% <85.00%> (+0.02%) ⬆️
macos 43.26% <85.00%> (+<0.01%) ⬆️
netbsd 37.66% <100.00%> (+0.03%) ⬆️
openbsd 38.21% <85.00%> (+0.03%) ⬆️
solaris 39.46% <85.00%> (+0.01%) ⬆️
windows 49.65% <85.00%> (+0.04%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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.

@dbwiddis
dbwiddis merged commit ccec1a5 into oshi:master Nov 8, 2026
20 checks passed
@dbwiddis
dbwiddis deleted the disklabel-mount-points branch November 8, 2026 00:40
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