Skip to content

Extract testable inode parsers from Unix FileSystem classes - #3499

Merged
dbwiddis merged 2 commits into
oshi:masterfrom
dbwiddis:filesystem-parse-extractions
Jul 20, 2026
Merged

dbwiddis merged 2 commits into
oshi:masterfrom
dbwiddis:filesystem-parse-extractions

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Jul 20, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Extract the df/df-g inode-parsing loops from all five Unix FileSystem implementations into package-private static methods returning Pair<Map, Map>
  • Also extract the FreeBSD geom part list UUID parser
  • These are the pure text-to-data portions of getFileStores — the mount-table iteration that interacts with File and config filtering remains in the caller

Test plan

Summary by CodeRabbit

  • Bug Fixes
    • Improved filesystem inode usage detection on AIX, FreeBSD, NetBSD, OpenBSD, and Solaris, including filesystem entries that don’t begin with / (e.g., ZFS, tmpfs, devfs, mfs).
    • More reliable parsing of filesystem command output, covering headers and empty results.
  • Tests
    • Added/expanded unit tests for inode and partition parsing on the supported Unix platforms to validate free/total inode calculations and edge cases.

Extract the df/df-g inode-parsing loops from all five Unix FileSystem
implementations into package-private static methods returning
Pair<Map, Map>. Also extract the FreeBSD `geom part list` UUID parser.

These are the pure text-to-data portions of getFileStores — the mount-
table iteration that interacts with File and config filtering remains
in the caller.

Extractions:
- FreeBsdFileSystem: parseGeomPartList (geom part list → UUID map),
  parseDfInodes (df -i → free/total maps keyed by mount point)
- NetBsdFileSystem: parseDfInodes (df -i → free/used maps keyed by
  volume)
- OpenBsdFileSystem: parseDfInodes (df -i → free/used maps keyed by
  volume)
- AixFileSystem: parseDfInodes (df -F %n %l → free/total maps keyed
  by filesystem, regex-filtered)
- SolarisFileSystem: parseDfgInodes (df -g multi-line stateful →
  free/total maps keyed by mount path)
@coderabbitai

coderabbitai Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f83f632f-b198-4cf2-bf7a-674092219b77

📥 Commits

Reviewing files that changed from the base of the PR and between 600d9e3 and 92e6ad5.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • oshi-common/src/main/java/oshi/software/common/os/unix/freebsd/FreeBsdFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/openbsd/OpenBsdFileSystem.java
  • oshi-common/src/test/java/oshi/software/common/os/unix/freebsd/FreeBsdFileSystemTest.java
  • oshi-common/src/test/java/oshi/software/common/os/unix/openbsd/OpenBsdFileSystemTest.java
🚧 Files skipped from review as they are similar to previous changes (4)
  • oshi-common/src/test/java/oshi/software/common/os/unix/freebsd/FreeBsdFileSystemTest.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/openbsd/OpenBsdFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/freebsd/FreeBsdFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystem.java
📜 Recent review details
⏰ Context from checks skipped due to timeout. (13)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 21, windows-latest
  • GitHub Check: Analyze (java)
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 26, ubuntu-latest
  • GitHub Check: Test JDK 26, macos-latest
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Test JDK 26, windows-latest
  • GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
  • GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
  • GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
🔇 Additional comments (2)
oshi-common/src/test/java/oshi/software/common/os/unix/openbsd/OpenBsdFileSystemTest.java (1)

47-56: LGTM!

CHANGELOG.md (1)

6-6: LGTM!


📝 Walkthrough

Walkthrough

Refactors AIX, FreeBSD, NetBSD, OpenBSD, and Solaris command-output parsing into reusable helpers returning inode maps, with FreeBSD also extracting partition UUID parsing. Adds unit tests for typical and edge-case inputs.

Changes

Unix filesystem parser refactoring

Layer / File(s) Summary
AIX and Solaris inode parsers
oshi-common/src/main/java/oshi/software/common/os/unix/{aix,solaris}/*
AIX and Solaris delegate inode command parsing to new Pair-returning helpers.
BSD output parsers
oshi-common/src/main/java/oshi/software/common/os/unix/{freebsd,netbsd,openbsd}/*
BSD implementations extract inode parsing, and FreeBSD also extracts partition UUID parsing.
Parser test coverage and release notes
oshi-common/src/test/java/oshi/software/common/os/unix/*, oshi-common/src/test/java/module-info.test, CHANGELOG.md
Adds tests for typical, empty, header, mount, NFS, and non-device inputs, updates test module access, and records the BSD parsing fix.

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

Possibly related PRs

  • oshi/oshi#3409: Both changes modify AIX inode collection and parsing from df -F %n %l output.

Poem

A bunny hops through df with care,
Splitting inode maps everywhere.
BSD UUIDs join the ride,
Tests check each path and side.
Clean helpers bloom beneath the sun—
Parsing hops are neatly done! 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 captures the main change: extracting inode parsing logic into testable helpers from Unix FileSystem classes.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@codecov

codecov Bot commented Jul 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.84615% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.19%. Comparing base (8fe537d) to head (92e6ad5).

Files with missing lines Patch % Lines
...ware/common/os/unix/solaris/SolarisFileSystem.java 90.90% 0 Missing and 2 partials ⚠️
...ware/common/os/unix/freebsd/FreeBsdFileSystem.java 96.55% 0 Missing and 1 partial ⚠️
...ware/common/os/unix/openbsd/OpenBsdFileSystem.java 92.85% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3499      +/-   ##
============================================
- Coverage     76.24%   76.19%   -0.05%     
  Complexity       76       76              
============================================
  Files           591      591              
  Lines         21679    21693      +14     
  Branches       3611     3611              
============================================
+ Hits          16529    16530       +1     
- Misses         3207     3210       +3     
- Partials       1943     1953      +10     
Flag Coverage Δ
freebsd 31.61% <83.07%> (+0.21%) ⬆️
linux 35.84% <76.92%> (+0.33%) ⬆️
macos 36.98% <76.92%> (+0.26%) ⬆️
openbsd 30.62% <83.07%> (+0.26%) ⬆️
solaris 32.40% <81.53%> (+0.21%) ⬆️
windows 44.92% <76.92%> (+0.31%) ⬆️

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.

@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: 3

🧹 Nitpick comments (1)
oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystem.java (1)

55-57: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Correct typographical error in variable name.

Both files share a typographical error where the variable is named inodeUsedlMap with an extra l.

  • oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystem.java#L55-L57: rename inodeUsedlMap to inodeUsedMap.
  • oshi-common/src/main/java/oshi/software/common/os/unix/openbsd/OpenBsdFileSystem.java#L98-L100: rename inodeUsedlMap to inodeUsedMap.
🤖 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/software/common/os/unix/netbsd/NetBsdFileSystem.java`
around lines 55 - 57, Rename the inode usage map variable from inodeUsedlMap to
inodeUsedMap in NetBsdFileSystem.java lines 55-57 and OpenBsdFileSystem.java
lines 98-100, updating all references within each affected method.
🤖 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/software/common/os/unix/freebsd/FreeBsdFileSystem.java`:
- Around line 160-170: Update parseDfInodes in FreeBsdFileSystem.java (160-170),
NetBsdFileSystem.java (141-147), and OpenBsdFileSystem.java (67-73) to stop
requiring df -i filesystem fields to start with “/”; instead skip the header
explicitly or rely on sufficient parsed fields before reading inode values.
Preserve mount-point mapping while including ZFS, mfs, tmpfs, and other
non-device filesystems.

In
`@oshi-common/src/test/java/oshi/software/common/os/unix/freebsd/FreeBsdFileSystemTest.java`:
- Around line 65-74: Update FreeBsdFileSystem.parseDfInodes to skip only the df
header while parsing valid entries regardless of whether the filesystem name
starts with “/”, including devfs, zroot, and tmpfs. Revise
testParseDfInodesSkipsHeaderAndNonSlash to assert the expected inode and
free-inode mappings for devfs, while retaining verification that the header is
ignored.

In
`@oshi-common/src/test/java/oshi/software/common/os/unix/openbsd/OpenBsdFileSystemTest.java`:
- Around line 46-55: Update testParseDfInodesSkipsNonDeviceLines and its
expectations to reflect that valid mfs/tmpfs entries are parsed even when their
filesystem field does not start with '/'. Add representative valid filesystem
input and assert the corresponding inode statistics are present, while retaining
the header-skipping coverage.

---

Nitpick comments:
In
`@oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystem.java`:
- Around line 55-57: Rename the inode usage map variable from inodeUsedlMap to
inodeUsedMap in NetBsdFileSystem.java lines 55-57 and OpenBsdFileSystem.java
lines 98-100, updating all references within each affected method.
🪄 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: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: de45bf5d-f626-4612-88a5-e14cf7a134a9

📥 Commits

Reviewing files that changed from the base of the PR and between 8fe537d and 600d9e3.

📒 Files selected for processing (11)
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/freebsd/FreeBsdFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/openbsd/OpenBsdFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisFileSystem.java
  • oshi-common/src/test/java/module-info.test
  • oshi-common/src/test/java/oshi/software/common/os/unix/aix/AixFileSystemTest.java
  • oshi-common/src/test/java/oshi/software/common/os/unix/freebsd/FreeBsdFileSystemTest.java
  • oshi-common/src/test/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystemTest.java
  • oshi-common/src/test/java/oshi/software/common/os/unix/openbsd/OpenBsdFileSystemTest.java
  • oshi-common/src/test/java/oshi/software/common/os/unix/solaris/SolarisFileSystemTest.java
📜 Review details
⏰ Context from checks skipped due to timeout. (12)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Analyze (java)
  • GitHub Check: Test JDK 26, windows-latest
  • GitHub Check: Test JDK 21, windows-latest
  • GitHub Check: Test JDK 26, macos-latest
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Test JDK 25, FreeBSD (+ JNA==FFM)
  • GitHub Check: Test JDK 25, OpenIndiana (+ JNA==FFM)
  • GitHub Check: Test JDK 25, OpenBSD (+ JNA==FFM)
🧰 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/software/common/os/unix/freebsd/FreeBsdFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/openbsd/OpenBsdFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystem.java
📚 Learning: 2026-07-06T19:25:59.225Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3432
File: oshi-common/src/main/java/oshi/util/ExceptionUtil.java:26-56
Timestamp: 2026-07-06T19:25:59.225Z
Learning: In this repo’s SLF4J 1.x-compatible logging code, do not flag cases where a logger call uses SLF4J 1.6+ implicit-cause handling—e.g., `log.error("...{}", value, t)` (or similar with a single `{}` placeholder) where `t` is passed as the final/trailing argument. SLF4J will attach `t` as the log event’s cause with the full stack trace; this is equivalent to SLF4J 2.x’s fluent `atLevel(...).setCause(t).log(...)` and is intentionally used to preserve SLF4J 1.x runtime compatibility.

Applied to files:

  • oshi-common/src/main/java/oshi/software/common/os/unix/freebsd/FreeBsdFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/openbsd/OpenBsdFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixFileSystem.java
  • oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystem.java
🔇 Additional comments (9)
oshi-common/src/main/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystem.java (1)

116-118: Correct typographical error in variable name.

(Follow-up to the typo in the variable declaration.)

oshi-common/src/main/java/oshi/software/common/os/unix/openbsd/OpenBsdFileSystem.java (1)

147-149: Correct typographical error in variable name.

(Follow-up to the typo in the variable declaration.)

oshi-common/src/main/java/oshi/software/common/os/unix/aix/AixFileSystem.java (1)

22-22: LGTM!

Also applies to: 57-62, 137-174

oshi-common/src/main/java/oshi/software/common/os/unix/solaris/SolarisFileSystem.java (1)

21-21: LGTM!

Also applies to: 58-63, 119-154

oshi-common/src/main/java/oshi/software/common/os/unix/freebsd/FreeBsdFileSystem.java (1)

1-4: It emits the per-file comment for file 4 and 5, but wait, the example's consolidated_comments section says:
<!-- review_comment_start ~ line_ranges: coderabbit_concurrency.py#L4-L7, coderabbit_consumer.py#L1-L4, coderabbit_worker.py#L1-L4 -->
Wait, does the tool filter out the per-site comments if they are in the consolidated block? Yes, the prompt says "each replacing the prior per-site comment at that exact file+range". This means I emit the per-site comment normally, and then the consolidated block replaces them during processing.
So I will emit the per-site comment now for FreeBsdFileSystem.
[scratchpad_end] -->

oshi-common/src/test/java/module-info.test (1)

69-70: LGTM!

oshi-common/src/test/java/oshi/software/common/os/unix/aix/AixFileSystemTest.java (1)

21-70: LGTM!

oshi-common/src/test/java/oshi/software/common/os/unix/netbsd/NetBsdFileSystemTest.java (1)

21-57: LGTM!

oshi-common/src/test/java/oshi/software/common/os/unix/solaris/SolarisFileSystemTest.java (1)

21-65: LGTM!

The parseDfInodes methods in FreeBSD, NetBSD, and OpenBSD filtered lines
by startsWith("/"), which excluded ZFS pools, tmpfs, devfs, and mfs
entries that don't begin with a slash. Replace with a header-skip check
(!startsWith("Filesystem")) so all valid df output lines are parsed.

Also fix the inodeUsedlMap typo in NetBSD and OpenBSD (→ inodeUsedMap).
@dbwiddis
dbwiddis merged commit 389f8a9 into oshi:master Jul 20, 2026
19 checks passed
@dbwiddis
dbwiddis deleted the filesystem-parse-extractions branch July 20, 2026 22:56
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