Skip to content

File system fixes and optimizations#3057

Merged
dbwiddis merged 6 commits intooshi:masterfrom
dyorgio:file-system-fixes-and-optimizations
Jan 27, 2026
Merged

File system fixes and optimizations#3057
dbwiddis merged 6 commits intooshi:masterfrom
dyorgio:file-system-fixes-and-optimizations

Conversation

@dyorgio
Copy link
Contributor

@dyorgio dyorgio commented Jan 12, 2026

Delay name filtering on MacFileSystem.getFileStoreMatching to fix non-matching that could be found with DiskArbitration.
Include local boolean on all OSFileStore objects. It is used to optimize updateAttributes() fileStore lookup.

Summary by CodeRabbit

  • New Features

    • Added OSFileStore.isLocal() to identify local (non-network) file stores.
  • Bug Fixes / Improvements

    • Improved file store detection and matching, with consistent local-vs-network filtering across macOS, Linux, Windows, FreeBSD, OpenBSD, Solaris, and AIX.
    • More reliable attribute refreshes and optimizations for filesystem enumeration and reporting.

✏️ Tip: You can customize this high-level summary in your review settings.

@codecov
Copy link

codecov bot commented Jan 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.39%. Comparing base (8de881c) to head (3c39f93).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3057      +/-   ##
==========================================
+ Coverage   84.56%   85.39%   +0.82%     
==========================================
  Files          32       32              
  Lines        1458     1458              
  Branches      215      215              
==========================================
+ Hits         1233     1245      +12     
+ Misses        130      116      -14     
- Partials       95       97       +2     

☔ 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.

@dyorgio
Copy link
Contributor Author

dyorgio commented Jan 12, 2026

I also replaced LinuxOSFileStore on FreeBsdFileSystem by correct class

Copy link
Member

@dbwiddis dbwiddis left a comment

Choose a reason for hiding this comment

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

Thanks for these fixes!

As we have a new API field and changed behavior on macOS, we definitely need a change log entry. PR title can be a bit more verbose to describe the fix.

A few comments.

@dbwiddis dbwiddis force-pushed the file-system-fixes-and-optimizations branch from 650ce05 to 1cd5230 Compare January 27, 2026 18:43
@coderabbitai
Copy link

coderabbitai bot commented Jan 27, 2026

📝 Walkthrough

Walkthrough

Adds a boolean locality flag to file store API and propagates local vs network determination through platform implementations, updating constructors, filtering logic, and file-store matching signatures across OS-specific classes.

Changes

Cohort / File(s) Summary
Base API & Core
oshi-core/src/main/java/oshi/software/os/OSFileStore.java, oshi-core/src/main/java/oshi/software/common/AbstractOSFileStore.java
Added isLocal() API; added local field and constructor parameter to AbstractOSFileStore; updated toString() to include locality.
Changelog
CHANGELOG.md
Added entry for PR #3057: FileSystem fixes and optimization.
Linux
oshi-core/src/main/java/oshi/software/os/linux/LinuxFileSystem.java, oshi-core/src/main/java/oshi/software/os/linux/LinuxOSFileStore.java
Consolidated getFileStoreMatching signature; compute isLocal from FS type; pass isLocal into LinuxOSFileStore constructor and use it for filtering.
macOS (FFM & Classic)
oshi-core-java25/src/main/java/oshi/software/os/mac/MacFileSystemFFM.java, oshi-core/src/main/java/oshi/software/os/mac/MacFileSystem.java, oshi-core/src/main/java/oshi/software/os/mac/MacOSFileStore.java
Removed single-arg overloads / adjusted visibility; determine isLocal via flags; defer name matching until after name resolution; pass isLocal into MacOSFileStore and use for filtering.
Windows
oshi-core/src/main/java/oshi/software/os/windows/WindowsFileSystem.java, oshi-core/src/main/java/oshi/software/os/windows/WindowsOSFileStore.java
Added local boolean parameter to WindowsOSFileStore constructor; determine local from drive type and branch attribute refresh logic on isLocal().
Solaris
oshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisFileSystem.java, oshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisOSFileStore.java
Removed wrapper overload; compute isLocal from NETWORK_FS_TYPES; pass isLocal to SolarisOSFileStore constructor and use it in matching.
FreeBSD
oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdFileSystem.java, oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOSFileStore.java
Switched to FreeBsdOSFileStore usage; added isLocal computation and constructor parameter; use isLocal in update/matching logic.
OpenBSD
oshi-core/src/main/java/oshi/software/os/unix/openbsd/OpenBsdFileSystem.java, oshi-core/src/main/java/oshi/software/os/unix/openbsd/OpenBsdOSFileStore.java
Removed single-arg overload; made matching method package-private; compute and pass isLocal into OpenBsdOSFileStore; use isLocal when matching.
AIX
oshi-core/src/main/java/oshi/software/os/unix/aix/AixFileSystem.java, oshi-core/src/main/java/oshi/software/os/unix/aix/AixOSFileStore.java
Removed single-arg overload; compute isLocal using NETWORK_FS_TYPES; pass isLocal to AixOSFileStore and use for filtering in updateAttributes.

Sequence Diagram

sequenceDiagram
    participant Client as Caller
    participant FS as FileSystem Implementation
    participant STORE as OSFileStore
    participant API as OSFileStore API

    Client->>FS: getFileStores(localOnly)
    activate FS
    FS->>FS: iterate mounts
    FS->>FS: determine isLocal = !NETWORK_FS_TYPES.contains(type)
    alt localOnly && !isLocal
        FS->>FS: skip mount
    else
        FS->>STORE: new ...OSFileStore(..., uuid, isLocal, ...)
        activate STORE
        STORE->>API: super(..., uuid, local)
        API-->>STORE: initialized (local flag set)
        STORE-->>FS: constructed
        deactivate STORE
    end
    FS-->>Client: List<OSFileStore>

    Client->>STORE: isLocal()
    STORE-->>Client: boolean
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰
I hopped through mounts both near and far,
Tagged each store with a bright little star.
Local or net, now clear to see,
A rabbit's wink in filesystem harmony! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.95% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'File system fixes and optimizations' accurately reflects the main changes: bug fixes to MacFileSystem.getFileStoreMatching and optimization by adding a local boolean field to OSFileStore implementations.

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

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 05efe9e and 3c39f93.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • oshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisFileSystem.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.md
⏰ 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). (7)
  • GitHub Check: Analyze (java)
  • GitHub Check: Test JDK 11, windows-latest
  • GitHub Check: Test JDK 25, windows-latest
  • GitHub Check: Test JDK 21, windows-latest
  • GitHub Check: Test JDK 11, macos-latest
  • GitHub Check: Test JDK 25, macos-latest
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (3)
oshi-core/src/main/java/oshi/software/os/unix/solaris/SolarisFileSystem.java (3)

112-117: LGTM!

The locality logic is correctly computed and stored for reuse. The isLocal flag properly identifies local filesystems by checking against NETWORK_FS_TYPES, and the filtering condition (localOnly && !isLocal) correctly excludes network filesystems when requested.


144-146: Constructor alignment is correct. All parameters match the SolarisOSFileStore signature, including the isLocal boolean at the correct position and the clean getOrDefault(path, 0L) pattern for inode metrics.


62-63: No breaking change: method has no external consumers.

The method getFileStoreMatching() is package-private (static) and called only internally within the solaris package. No external callers outside oshi.software.os.unix.solaris were found, so the visibility change does not impact external consumers. This aligns with the pattern used across all other OS implementations.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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

dyorgio and others added 5 commits January 27, 2026 10:44
Delay name filtering on MacFileSystem.getFileStoreMatching to fix non-matching that could be found with DiskArbitration.

Include local boolean on all OSFileStore objects. It is used to optimize updateAttributes() fileStore lookup.
@dbwiddis dbwiddis force-pushed the file-system-fixes-and-optimizations branch from 1cd5230 to 05efe9e Compare January 27, 2026 18:45
@dbwiddis dbwiddis merged commit 4c203be into oshi:master Jan 27, 2026
15 checks passed
@dyorgio
Copy link
Contributor Author

dyorgio commented Jan 27, 2026

You are the best @dbwiddis !

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.

2 participants