Skip to content

Report Linux device names under /dev with a custom dev path - #3873

Merged
dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:dev-path-node-names
Nov 7, 2026
Merged

dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:dev-path-node-names

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

oshi.util.dev.path (#2626, for #2609) sets where OSHI reads the device filesystem, for example a host's /dev mounted at /host/dev in a Kubernetes pod. The kernel, udev, /proc/mounts and pvs still name devices /dev/.... Names built from the configured root therefore never matched those sources, and Linux disk and file store reporting broke under a custom root:

  • JNA and FFM: udev devnodes (/dev/...) were compared with DevPath.LOOP/RAM/DM (/host/dev/...), so loop and RAM disks were listed and device-mapper devices were treated as plain disks.
  • All backends: the /proc/mounts mount-point map, the LVM pvs filter, the file store Local Disk description and the disk/by-uuid lookup filtered on the configured root and matched nothing. Partitions lost their mount points, file stores lost their UUIDs and were described as Mount Point, and getLogicalVolume() reported /host/dev/dm-0.
  • Native-free: disks and partitions were named /host/dev/sda, unlike JNA and FFM.

Change

Device names are always reported under /dev/, so they match OSFileStore.getVolume() and /proc/mounts. The configured root is used only to read files.

  • DevPath gains NODE_ROOT (/dev/) and toFilePath() / toNodeName(). DM, LOOP, RAM and MAPPER are now name prefixes under NODE_ROOT; DEV and DISK_BY_UUID remain read paths. (oshi.util is not semver-locked; the values differ only under a custom root.)
  • The disk store, LVM and file system code in oshi-common uses NODE_ROOT for names, and converts paths when it reads by-uuid and mapper symlinks under the configured root.
  • No change to the JNA/FFM twins: their filters already use the DevPath name constants.

Native-free users with a custom root will see /dev/sda instead of /host/dev/sda. That output never matched any mount point, so the CHANGELOG entry is under Bug Fixes.

Testing

  • New DevPathTest, with its module-info.test opens. Existing native-free disk fixtures now name devices by NODE_ROOT.
  • oshi-common tests pass on Linux (Docker) and macOS. The -Perror-prone build, checkstyle, forbidden APIs and javadoc all pass.
  • End to end, in a privileged Linux container with a loop-backed LVM volume and a plain loop filesystem, both mounted, and /dev bind-mounted at /host/dev. The by-uuid and mapper links were made by hand, since there is no udev daemon. On master, all three backends showed the faults above. On this branch, JNA, FFM and native-free report the same disks, partitions, UUIDs, logical volumes and descriptions with -Doshi.util.dev.path=/host/dev as with the default root.

Not exercised: JNA/FFM LVM partition entries (no udev database in the container) and pvs.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed Linux disk and file-system reporting when using a custom device path. Reported device names now retain the kernel’s /dev/ prefix, including for loop, RAM, device-mapper, partition, physical-volume, and UUID-based file-system entries.

oshi.util.dev.path says where OSHI reads the device filesystem, for
example a host's /dev mounted at /host/dev in a container. The kernel,
udev, /proc/mounts and pvs still name devices /dev/..., so names built
from the configured root never matched them:

- JNA/FFM compared udev devnodes (/dev/...) with DevPath.LOOP/RAM/DM
  (/host/dev/...), so loop and RAM disks were listed and device-mapper
  devices were treated as plain disks.
- The /proc/mounts map, LVM pvs filter, file store "Local Disk"
  description and by-uuid lookup filtered on the configured root and
  matched nothing.
- Native-free named disks and partitions /host/dev/..., unlike JNA/FFM.

DevPath gains NODE_ROOT ("/dev/") with toFilePath/toNodeName. DM, LOOP,
RAM and MAPPER are now name prefixes under NODE_ROOT; DEV and
DISK_BY_UUID remain read paths. Every backend reports /dev/ names and
reads files under the configured root. JNA/FFM need no source change:
their filters already use the DevPath name constants.

Verified in a privileged Linux container with an LVM volume and a loop
filesystem and /dev bound at /host/dev: all three backends now report
the same disks, partitions, UUIDs and logical volumes as with the
default root. Not exercised: JNA/FFM LVM partitions (no udev database
in the container) and pvs.
@coderabbitai

coderabbitai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change separates the configured device-file root from the fixed /dev/ device-name root. Linux disk, volume, and filesystem path handling now uses device-node names and converts paths when accessing device files.

Changes: Linux device-node path handling

Layer / File(s) Summary
Device-path roots and conversions
oshi-common/src/main/java/oshi/util/linux/DevPath.java, oshi-common/src/main/resources/oshi.properties, oshi-common/src/test/java/oshi/util/linux/DevPathTest.java, oshi-common/src/test/java/module-info.test
DevPath distinguishes the configured filesystem root from the /dev/ device-name root. It adds conversion methods, and tests cover root constants, path conversion, and unchanged paths outside the source root. The property comment describes the configured path’s scope.
Disk and volume device names
oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHWDiskStore.java, oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxLogicalVolumeGroup.java, oshi-common/src/main/java/oshi/hardware/common/platform/linux/nativefree/LinuxHWDiskStoreNF.java, oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxLogicalVolumeGroupTest.java, oshi-common/src/test/java/oshi/hardware/common/platform/linux/nativefree/LinuxHWDiskStoreNFTest.java
Linux disk, partition, backing-store, mount-map, and physical-volume paths now use DevPath.NODE_ROOT. Native-free disk tests use the same device-name root.
Filesystem and UUID path resolution
oshi-common/src/main/java/oshi/software/common/os/linux/LinuxFileSystem.java, CHANGELOG.md
Linux filesystem UUID and logical-volume path handling converts between configured filesystem paths and device-node names. The changelog records the custom-device-path cases.

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

Change: Bug fix

Possibly related PRs

  • oshi/oshi#3856: It changes native-free disk-name handling and partition paths, which share the /dev/ device-name format updated here.
Merge Risk: Minimal · up to 9f9b8

No actionable merge-blocking issue remains. The change is ready to merge 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 main change: Linux device names are reported under /dev/ when oshi.util.dev.path points to a custom root. The raw summary and objectives confirm this is the core intent of PR #3873…
Docstring Coverage Passed Docstring coverage is 88.89% 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 main change: Linux device names are reported under /dev/ when oshi.util.dev.path points to a custom root. The raw summary and objectives confirm this is the core intent of PR #3873, including the new DevPath.NODE_ROOT constant and path-conversion methods. The title is specific and does not conflict with any changed file.

Full details: Docstring Coverage

Explanation

Docstring coverage is 88.89% 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 9 functions across 8 files. (3 skipped: 3 unsupported.)

Finishing Touches

Generate unit tests (beta)

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

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

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 /dev/ trail,
While disks and volumes leave their mark.
Paths change roots, then find their way,
UUIDs join the filesystem’s chart.
I nibble clover, pleased today!

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: 748aba7d-9158-4187-be18-c26f87316364
Commits

Reviewing files that changed from the base of the PR and between 2a0d560 and 9f9b8da.

Files selected for processing: 11

  • CHANGELOG.md
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHWDiskStore.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxLogicalVolumeGroup.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/nativefree/LinuxHWDiskStoreNF.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxFileSystem.java
  • oshi-common/src/main/java/oshi/util/linux/DevPath.java
  • oshi-common/src/main/resources/oshi.properties
  • oshi-common/src/test/java/module-info.test
  • oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxLogicalVolumeGroupTest.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/linux/nativefree/LinuxHWDiskStoreNFTest.java
  • oshi-common/src/test/java/oshi/util/linux/DevPathTest.java

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

Recent review details

Context from checks skipped due to timeout: 5

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

Code guidelines: 2

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

Source excerpt: **Language level.**

CodeRabbit inference engine (AGENTS.md)

Files:

  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/nativefree/LinuxHWDiskStoreNF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxLogicalVolumeGroup.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHWDiskStore.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxFileSystem.java
  • oshi-common/src/main/java/oshi/util/linux/DevPath.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/linux/LinuxLogicalVolumeGroupTest.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/nativefree/LinuxHWDiskStoreNF.java
  • oshi-common/src/main/resources/oshi.properties
  • oshi-common/src/test/java/module-info.test
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxLogicalVolumeGroup.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHWDiskStore.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/linux/nativefree/LinuxHWDiskStoreNFTest.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxFileSystem.java
  • oshi-common/src/main/java/oshi/util/linux/DevPath.java
  • oshi-common/src/test/java/oshi/util/linux/DevPathTest.java
Source excerpt: Runtime configuration lives in `oshi-common/src/main/resources/oshi.properties`, read through `oshi.util.GlobalConfig` or overridden with Java system properties.

CodeRabbit inference engine (AGENTS.md)

Files:

  • oshi-common/src/main/resources/oshi.properties
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/linux/LinuxLogicalVolumeGroupTest.java
  • oshi-common/src/test/java/module-info.test
  • oshi-common/src/test/java/oshi/hardware/common/platform/linux/nativefree/LinuxHWDiskStoreNFTest.java
  • oshi-common/src/test/java/oshi/util/linux/DevPathTest.java
Source excerpt: **Javadoc.**

CodeRabbit inference engine (AGENTS.md)

Files:

  • oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxLogicalVolumeGroupTest.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/nativefree/LinuxHWDiskStoreNF.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxLogicalVolumeGroup.java
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxHWDiskStore.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/linux/nativefree/LinuxHWDiskStoreNFTest.java
  • oshi-common/src/main/java/oshi/software/common/os/linux/LinuxFileSystem.java
  • oshi-common/src/main/java/oshi/util/linux/DevPath.java
  • oshi-common/src/test/java/oshi/util/linux/DevPathTest.java
Learnings: 3

Common learnings

Learnt from: CR
Repo: oshi/oshi PR: 0
File: .github/CONTRIBUTING.md:0-0
Timestamp: 2026-10-31T02:27:20.004Z
Learning: 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

## 🚦 Build and Test

Your changes should not break any existing tests. If you find a test failure unrelated to your changes, keep track of it, but make sure your code doesn't introduce new test failures. If you believe the test failure is a bug, create an issue!
Learning: 2026-10-27T00:00:11.158Z

Learnt from: dbwiddis
Repo: oshi/oshi PR: 3843
File: CHANGELOG.md:6-6
Timestamp: 2026-10-27T00:00:11.158Z
Learning: Within repository "oshi/oshi", only for files matching one of ["CHANGELOG.md"]: When reviewing CHANGELOG.md entries, check that they identify the changed feature or behavior. Allow brief context, but do not require exhaustive API behavior or default sentinel values when the linked PR description and Javadocs provide those details.

Applied to files:

  • CHANGELOG.md
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
Additional comments: 11

oshi-common/src/main/java/oshi/util/linux/DevPath.java: 1

15-92: LGTM!

oshi-common/src/main/resources/oshi.properties: 1

16-17: LGTM!

oshi-common/src/test/java/oshi/util/linux/DevPathTest.java: 1

1-52: LGTM!

oshi-common/src/test/java/module-info.test: 1

39-40: LGTM!

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

147-148: LGTM!

Also applies to: 155-155, 158-159, 167-167, 231-231, 280-280

oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxLogicalVolumeGroup.java: 1

71-71: LGTM!

Also applies to: 163-163

oshi-common/src/main/java/oshi/hardware/common/platform/linux/nativefree/LinuxHWDiskStoreNF.java: 1

61-61: LGTM!

Also applies to: 97-97, 161-161

oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxLogicalVolumeGroupTest.java: 1

34-34: LGTM!

oshi-common/src/test/java/oshi/hardware/common/platform/linux/nativefree/LinuxHWDiskStoreNFTest.java: 1

63-63: LGTM!

Also applies to: 77-78, 86-87, 93-93, 105-105, 138-138, 146-147, 159-159, 175-175

oshi-common/src/main/java/oshi/software/common/os/linux/LinuxFileSystem.java: 1

116-123: LGTM!

Also applies to: 137-137, 205-205, 218-224

CHANGELOG.md: 1

21-21: LGTM!

@codecov

codecov Bot commented Nov 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.36364% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.17%. Comparing base (2a0d560) to head (9f9b8da).

Files with missing lines Patch % Lines
...oshi/software/common/os/linux/LinuxFileSystem.java 75.00% 2 Missing ⚠️
...rdware/common/platform/linux/LinuxHWDiskStore.java 83.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3873      +/-   ##
============================================
- Coverage     81.18%   81.17%   -0.01%     
+ Complexity      923      915       -8     
============================================
  Files           726      726              
  Lines         26756    26756              
  Branches       4567     4566       -1     
============================================
- Hits          21722    21720       -2     
  Misses         2800     2800              
- Partials       2234     2236       +2     
Flag Coverage Δ
dragonflybsd 37.73% <22.72%> (-0.01%) ⬇️
freebsd 38.29% <22.72%> (+<0.01%) ⬆️
linux 42.22% <86.36%> (+0.01%) ⬆️
macos 43.20% <22.72%> (-0.05%) ⬇️
netbsd 37.59% <22.72%> (-0.02%) ⬇️
openbsd 38.13% <22.72%> (-0.02%) ⬇️
solaris 39.41% <22.72%> (ø)
windows 49.60% <0.00%> (+0.01%) ⬆️

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 036f333 into oshi:master Nov 7, 2026
21 checks passed
@dbwiddis
dbwiddis deleted the dev-path-node-names branch November 7, 2026 23:37
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