Skip to content

Add DragonFly BSD platform support - #3303

Merged
dbwiddis merged 6 commits into
oshi:masterfrom
dbwiddis:dfbsd-port
May 27, 2026
Merged

dbwiddis merged 6 commits into
oshi:masterfrom
dbwiddis:dfbsd-port

Conversation

@dbwiddis

@dbwiddis dbwiddis commented May 26, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds DragonFly BSD as a supported platform in OSHI, using JNA for native access.

Approach

Started from the FreeBSD implementation (copy + rename), then iteratively fixed DragonFly-specific differences. Deduplicated by having DragonFly classes extend or delegate to FreeBSD equivalents where behavior is identical — only 15 DragonFly-specific files remain (down from 31 in the initial copy).

Key DragonFly BSD differences from FreeBSD

  • libc loading: JNA requires "c" not "libc" (JNA PR Include DragonFlyBSD in library loading fallback paths java-native-access/jna#1727 filed to fix upstream)
  • Thread ID: Uses lwp_gettid() instead of thr_self()
  • Process info: Uses /proc/<pid>/cmdline and /proc/<pid>/status instead of KERN_PROC_ARGS/KERN_PROC_ENV sysctls (different MIB numbers)
  • ps keywords: No group, gid, etime, lwp; uses rgid, tid, ucomm, command instead
  • Kernel threads: Report PID -1 (filtered out)
  • Priority range: -32 to 223 (0-255 offset by 32)
  • HAMMER2 filesystem: Reports 0 inodes (no fixed inode table)
  • kern.cp_times: Not available (per-CPU ticks)
  • procstat: Not available; uses FreeBSD's fstat-based fallback
  • Environment variables: Only available for current process via System.getenv()

Changes

  1. DragonFlyBsdLibc.java: JNA interface with lwp_gettid() and FreeBSD-compatible sysctl/utmpx
  2. HAL + CentralProcessor: Thin subclasses extending FreeBSD equivalents
  3. OperatingSystem, OSProcess, OSThread: Standalone implementations with DragonFly-specific ps keywords, /proc-based process info, and start time retrieval
  4. FileSystem: Standalone with DragonFly-specific config properties
  5. Static delegators: GraphicsCard, PowerSource, SoundCard, UsbDevice, HWDiskStore delegate to FreeBSD
  6. Supporting files: SystemInfo.java switch cases, module-info.java, oshi.properties, pom.xml jacoco excludes, unix.yaml CI job, test adjustments

Code Reuse Strategy

  • 4 FreeBSD classes made non-final/public for extension (CentralProcessor, HAL, InternetProtocolStats, NetworkParams)
  • 5 static factory delegators (no inheritance needed)
  • 6 classes removed entirely (FreeBSD parent creates them internally)
  • 4 standalone classes with real behavioral differences

Testing

All tests pass on DragonFly BSD 6.4.2:

Related

Summary by CodeRabbit

  • New Features

    • DragonFly BSD platform support across OS, hardware, processor, threads, CPU metrics, filesystem, /proc utilities, and related utilities.
  • Bug Fixes

    • Improved CPU/tick reporting, inode/filesystem parsing, uptime/boot-time handling, process/thread metrics, and safer open-file/limit handling.
  • Tests

    • Extended platform-specific tests and assertions to include DragonFly BSD.
  • Chores / CI

    • Added DragonFly BSD CI job; capitalized FreeBSD job name; updated coverage exclusions.
  • Documentation

    • Updated README, site docs, module docs, and unreleased changelog to list DragonFly BSD support.

Review Change Stack

dbwiddis added 3 commits May 26, 2026 19:43
- Replace thr_self() with lwp_gettid() for thread ID retrieval
- Replace KERN_PROC_ENV sysctl with /proc/<pid>/environ for
  environment variables (DragonFly lacks FreeBSD's kern.proc.env)
- Remove unsupported ps keywords (systime, majflt, minflt, nvcsw,
  nivcsw) that caused column misalignment
- Switch etimes -> etime (DragonFly uses formatted elapsed time)
- Use /proc/<pid>/cmdline for process arguments instead of
  KERN_PROC_ARGS sysctl (different MIB numbers on DragonFly)
- Simplify thread columns to LWP, STATE, ETIME, TIME, PRI
- Replace procstat (FreeBSD-only) with /proc and fstat fallback
- Downgrade kern.cp_times sysctl failure to debug level
@coderabbitai

coderabbitai Bot commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

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: 7795511b-b3cd-4ab2-b9ea-97b92f7716a4

📥 Commits

Reviewing files that changed from the base of the PR and between bc94120 and bb58d43.

📒 Files selected for processing (30)
  • .github/workflows/unix.yaml
  • CHANGELOG.md
  • README.md
  • oshi-core/src/main/java/module-info.java
  • oshi-core/src/main/java/oshi/SystemInfo.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdHardwareAbstractionLayer.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/package-info.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdComputerSystem.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdFirmware.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdGlobalMemory.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdGraphicsCard.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSensors.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSoundCard.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/BsdLibcLoader.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/DragonFlyBsdLibc.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/FreeBsdLibc.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/OpenBsdLibc.java
  • oshi-core/src/main/java/oshi/package-info.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSProcess.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSThread.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystem.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/package-info.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdNetworkParams.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOSProcess.java
  • oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/ProcstatUtil.java
  • oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/package-info.java
  • oshi-core/src/test/java/oshi/software/os/shared/OperatingSystemTest.java
  • src/site/markdown/index.md
💤 Files with no reviewable changes (1)
  • CHANGELOG.md
✅ Files skipped from review due to trivial changes (6)
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/package-info.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/DragonFlyBsdLibc.java
  • README.md
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/package-info.java
  • oshi-core/src/main/java/oshi/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/package-info.java
🚧 Files skipped from review as they are similar to previous changes (23)
  • src/site/markdown/index.md
  • .github/workflows/unix.yaml
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdGlobalMemory.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSoundCard.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdFirmware.java
  • oshi-core/src/main/java/oshi/SystemInfo.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdNetworkParams.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOSProcess.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/FreeBsdLibc.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/OpenBsdLibc.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdComputerSystem.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdHardwareAbstractionLayer.java
  • oshi-core/src/test/java/oshi/software/os/shared/OperatingSystemTest.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/BsdLibcLoader.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessor.java
  • oshi-core/src/main/java/module-info.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdCentralProcessor.java
  • oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/ProcstatUtil.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSThread.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdGraphicsCard.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSensors.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSProcess.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystem.java
📜 Recent review details
⏰ 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). (11)
  • GitHub Check: JMH Benchmarks, ubuntu-latest
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 11, windows-latest
  • GitHub Check: Test JDK 21, windows-latest
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Analyze (java)
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: JMH Benchmarks, macos-latest
  • GitHub Check: JMH Benchmarks, windows-latest
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)

📝 Walkthrough

Walkthrough

Adds DragonFly BSD platform: SystemInfo routing, DragonFly libc loader, HAL and CentralProcessor, DragonFly OS/process/thread implementations, procstat utilities; reuses and refactors FreeBSD components; updates CI, properties, JaCoCo, docs, module export, and tests.

Changes

DragonFlyBSD Platform Support

Layer / File(s) Summary
Platform routing, docs & CI
oshi-core/src/main/java/oshi/SystemInfo.java, .github/workflows/unix.yaml, oshi-common/src/main/resources/oshi.properties, pom.xml, CHANGELOG.md, README.md, src/site/markdown/index.md, module-info.java, package-info files
Registers DragonFlyBSD in SystemInfo; adds DragonFlyBSD filesystem excludes, JaCoCo exclusions, CI job for DragonFly BSD, changelog and docs/site updates, and module export.

BsdLibcLoader & FreeBSD refactors

Layer / File(s) Summary
BsdLibcLoader and libc instance changes
oshi-core/src/main/java/oshi/jna/platform/unix/BsdLibcLoader.java, oshi-core/src/main/java/oshi/jna/platform/unix/FreeBsdLibc.java, oshi-core/src/main/java/oshi/jna/platform/unix/OpenBsdLibc.java
Adds BsdLibcLoader and switches libc INSTANCE initialization to load from the current process for BSD libc JNA interfaces.
FreeBSD visibility/fixes
oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/*, oshi-core/src/main/java/oshi/software/os/unix/freebsd/*
Makes several FreeBSD classes public/non-final, updates copyright years, fixes dmesg regex, df -i inode parsing, TCP/UDP counter summation, null-safety and bounds checks, USB hub list handling, and service dir logging.

DragonFlyBSD libc, HAL & processor

Layer / File(s) Summary
DragonFly libc and HAL/processor
oshi-core/src/main/java/oshi/jna/platform/unix/DragonFlyBsdLibc.java, oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/*
Adds DragonFlyBsdLibc (lwp_gettid) and implements DragonFlyBsdHardwareAbstractionLayer and DragonFlyBsdCentralProcessor with DragonFly-specific sysctl handling for cp_time and cputime.

DragonFlyBSD OS, process, thread & procstat utils

Layer / File(s) Summary
OS/process/thread and procstat utilities
oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/*, oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/*
Implements DragonFlyBsdOperatingSystem, DragonFlyBsdOSProcess, DragonFlyBsdOSThread, and ProcstatUtil with /proc and fstat fallbacks, process/thread parsing, boot-time caching, bitness detection, resource limits, affinity, and thread details.

Tests

Layer / File(s) Summary
Test adjustments
oshi-core/src/test/java/oshi/hardware/platform/shared/CentralProcessorTest.java, oshi-core/src/test/java/oshi/software/os/shared/OperatingSystemTest.java
Adds DRAGONFLYBSD branches and conditional assertions for processor topology, process priority, uptime/environment expectations, and thread-related tests.

Sequence Diagram(s)

sequenceDiagram
  participant Caller as Caller
  participant SystemInfo as SystemInfo
  participant DragonOS as DragonFlyBsdOperatingSystem
  participant Libc as DragonFlyBsdLibc
  Caller->>SystemInfo: request OS/hardware
  SystemInfo->>DragonOS: createOperatingSystem()
  DragonOS->>Libc: sysctl(kern.boottime) / getpid() / lwp_gettid()
  DragonOS->>Caller: return OSProcess/OSThread objects
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • oshi/oshi#3112: Adds/dispatches the DRAGONFLYBSD platform and adjusts SystemInfo routing used by this PR.
  • oshi/oshi#3182: Related platform-enum and SystemInfo changes that may conflict or overlap with this PR.

"🐰 I hopped through code with nimble feet,
DragonFly joined the BSD fleet.
Threads and ticks now dance in tune,
Docs and CI welcome the new moon.
A carrot-shaped commit—how sweet!"

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.28% 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 pull request title 'Add DragonFly BSD platform support' directly and clearly summarizes the main objective of this changeset, which is to add support for the DragonFly BSD platform to the OSHI library.
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.

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

✨ 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 and usage tips.

@codecov

codecov Bot commented May 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.08%. Comparing base (eaa9b4b) to head (bb58d43).

Files with missing lines Patch % Lines
oshi-core/src/main/java/oshi/SystemInfo.java 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3303      +/-   ##
============================================
- Coverage     76.09%   76.08%   -0.01%     
  Complexity       76       76              
============================================
  Files           410      410              
  Lines         15830    15832       +2     
  Branches       2546     2546              
============================================
  Hits          12046    12046              
- Misses         2284     2285       +1     
- Partials       1500     1501       +1     
Flag Coverage Δ
linux 40.30% <0.00%> (+<0.01%) ⬆️
macos 40.82% <0.00%> (-0.01%) ⬇️
windows 48.98% <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 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.

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

🤖 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 @.github/workflows/unix.yaml:
- Around line 152-155: Replace tag-based action refs with immutable, pinned
revisions for both the checkout action and the DragonFly VM action: change uses:
actions/checkout@v6 and uses: vmactions/dragonflybsd-vm@v1 to their specific
commit SHAs (or fully qualified refs) to avoid mutable tags, and in the checkout
step (the action referenced by actions/checkout) set persist-credentials: false
to prevent leaking the workflow token to subsequent steps; locate the checkout
usage and the step with id test-dragonflybsd / vmactions/dragonflybsd-vm to make
these edits.

In
`@oshi-core/src/main/java/oshi/driver/unix/dragonflybsd/disk/GeomPartList.java`:
- Around line 58-67: When encountering a new disk header in GeomPartList (line
handling "Geom name:"), any active partition referenced by partName must be
flushed into partList before switching diskName; update the logic in the block
that processes "Geom name:" to check if partName != null and not empty and then
add the current partition object/data to partList (same approach used elsewhere)
before putting partList into partitionMap and resetting partList and diskName.
Apply the same flush-before-switch behavior to the other branch that handles
partition boundaries (the code around the "Name:" handling at the 74-81 area) so
the last partition of the previous disk is never lost or assigned to the next
disk.

In `@oshi-core/src/main/java/oshi/driver/unix/dragonflybsd/disk/Mount.java`:
- Line 22: The current MOUNT_PATTERN constant is too restrictive by forcing
device names to match "\S+p\d+" and misses other valid partition naming schemes;
update the Pattern in the Mount class (MOUNT_PATTERN) to capture any non-space
device component (for example "/dev/(\S+) on (\S+) .*") so device paths like
/dev/ada0p1, /dev/da0s1a, or other variants are all matched and downstream
partition mount points are populated correctly.

In
`@oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessor.java`:
- Around line 114-116: The regex strings in DragonFlyBsdCentralProcessor
(variables normal and hybrid) are over-escaped so they don’t match
digits/spaces; update Pattern.compile("cpu(\\\\d+): (.+) on .*") to
Pattern.compile("cpu(\\d+): (.+) on .*") and Pattern.compile("CPU\\\\s*(\\\\d+):
(.+) affinity:.*") to Pattern.compile("CPU\\s*(\\d+): (.+) affinity:.*"); make
the analogous fixes in FreeBsdCentralProcessor where the same over-escaping
occurs so dmesg parsing yields numeric CPU IDs and
createProcListFromDmesg(logProcs, dmesg) can produce physical processor data.

In
`@oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdGraphicsCard.java`:
- Around line 57-85: When starting a new device block in the parsing loop (the
branch that checks line.contains("class=0x")), reset per-device fields
productId, vendorId, versionInfo and classCode (and name if needed) to
Constants.UNKNOWN (or empty string as existing pattern expects) before
splitting/parsing the header so values from the previous device don’t carry
over; update the code around the parsing in DragonFlyBsdGraphicsCard (the block
that populates classCode, productId, vendorId, versionInfo and sets name) to
initialize those variables at the start of the new-device branch prior to the
ParseUtil.whitespaces.split loop.

In
`@oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdPowerSource.java`:
- Around line 50-52: getPowerSources() currently always returns a single
fabricated PowerSource by calling getPowerSource("BAT0"); change it to detect
when no battery exists and return an empty list instead. Specifically: update
getPowerSource(String) (the implementation around lines 54-90) to return null
when it cannot find or parse real battery data, and update getPowerSources() to
call getPowerSource("BAT0") and return Collections.emptyList() (or
Arrays.asList()) only when the result is non-null — otherwise return an empty
list. Ensure callers still get a non-null List but no fake BAT0 entry when there
is no battery.

In
`@oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdSoundCard.java`:
- Around line 67-69: The loop building DragonFlyBsdSoundCard entries can pass
nulls from productMap.get(s) and vendorMap.get(s), producing "null ..." names;
update the loop that constructs DragonFlyBsdSoundCard (the sounds iteration
where soundCards.add is called) to guard against missing entries by substituting
safe defaults (e.g., product = productMap.get(s) != null ? productMap.get(s) :
"Unknown", vendor = vendorMap.get(s) != null ? vendorMap.get(s) : "") and then
build the display name from those defaults (avoid concatenating "null"). Ensure
you use these defaulted vendor and product variables when calling the
DragonFlyBsdSoundCard constructor.

In
`@oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdUsbDevice.java`:
- Line 125: The line hubMap.put(parent, hubMap.get(usbus)) can store null when
usbus has no entry; change it to always put a non-null list for parent by
retrieving a default empty collection when usbus is absent and wrapping that in
a new mutable list before storing (so hubMap.getOrDefault(devPath, ...) later
never returns null and iterating childPaths cannot NPE); update the statement
that writes to hubMap (referencing hubMap, parent, usbus) accordingly and ensure
you use Collections.emptyList() or equivalent as the default and copy it into a
new ArrayList to avoid shared mutable state.

In
`@oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/package-info.java`:
- Around line 2-7: Update the package Javadoc in package-info.java for the
oshi.hardware.platform.unix.dragonflybsd package: replace the phrase "FreeBSD
systems" with "DragonFly BSD systems" (or "DragonFlyBSD systems") so the comment
accurately reflects the DragonFlyBSD platform; edit the top-level Javadoc block
in package-info.java to mention DragonFlyBSD and keep the rest of the
description intact.

In
`@oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdFileSystem.java`:
- Around line 113-117: The code builds a mount basename into variable "name"
from the mount path but then uses that "name" to look up UUIDs in uuidMap, which
is keyed by device names from "geom part list"; change the lookup to use a
device-derived key instead: derive deviceName from "volume" (e.g., substring
after last '/' of volume) and use that deviceName for uuidMap.get(...) when
resolving UUIDs in DragonFlyBsdFileSystem; keep existing fallback for root
mounts only for display/name, but ensure the uuid lookup always uses the
device-derived key (reference variables: name, volume and map uuidMap in class
DragonFlyBsdFileSystem).
- Around line 81-82: The inode maps are keyed by the wrong token when parsing
`df -i`: inodeFreeMap.put(split[0], ...) and inodeTotalMap.put(split[0], ...)
use the device token but later code looks up by mount path
(inodeFreeMap.get(mount) / inodeTotalMap.get(mount)), causing mismatches; update
the parsing code in DragonFlyBsdFileSystem.java to use the same key used during
mount assembly (the mount path variable, e.g., `mount` or `mountPath`) when
calling inodeFreeMap.put and inodeTotalMap.put so lookups (in the block that
reads inodeFreeMap.get(mount) and inodeTotalMap.get(mount)) return the correct
values.

In
`@oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdInternetProtocolStats.java`:
- Around line 42-43: The aggregation of TCP counters in
DragonFlyBsdInternetProtocolStats currently adds int fields (e.g.,
tcp.tcps_rcvbadsum + tcp.tcps_rcvbadoff + tcp.tcps_rcvmemdrop +
tcp.tcps_rcvshort) and only then calls ParseUtil.unsignedIntToLong, risking
32-bit overflow; fix by converting each counter to long/unsigned long first
(call ParseUtil.unsignedIntToLong on each tcp.* field) and then sum the
resulting longs (same change for the other occurrence around tcp.* fields at the
second aggregation), ensuring you use
ParseUtil.unsignedIntToLong(tcp.tcps_rcvbadsum) +
ParseUtil.unsignedIntToLong(tcp.tcps_rcvbadoff) + ... so all additions occur as
long arithmetic.

In
`@oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdNetworkParams.java`:
- Around line 46-49: getDomainName() currently trims info.ai_canonname inside
the try-with-resources and calls LIBC.freeaddrinfo(ptr.getValue()) afterward,
which will throw if ai_canonname is null and skip freeing the native addrinfo;
change the logic to first capture ai_canonname from Addrinfo safely (e.g.,
String canonname = info.ai_canonname == null ? "" : info.ai_canonname.trim())
and ensure LIBC.freeaddrinfo(ptr.getValue()) is always invoked (move the
freeaddrinfo call into a finally block or after the try-with-resources with
guaranteed execution) so Addrinfo/ptr.getValue() is freed on all paths while
preserving the returned canonname.

In
`@oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystem.java`:
- Line 76: The code in DragonFlyBsdOperatingSystem sets family using
BsdSysctlUtil.sysctl("kern.ostype", "FreeBSD"), which can misreport DragonFly
systems; update the fallback value used in the BsdSysctlUtil.sysctl call to a
DragonFly-specific string (e.g., "DragonFly") so the variable family in
DragonFlyBsdOperatingSystem reflects the correct OS when sysctl lookup fails.

In
`@oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSProcess.java`:
- Around line 440-442: The code in DragonFlyBsdOSProcess that splits
maxOpenFilesLine and calls ParseUtil.parseLongOrDefault(split[index], -1) can
throw ArrayIndexOutOfBoundsException when the line contains non-numeric tokens
like "unlimited"; update the method to guard the indexed access by verifying
split.length > index and that split[index] is non-empty before calling
ParseUtil.parseLongOrDefault, and if the check fails return -1; apply this
change around the existing maxOpenFilesLine, split, index and
ParseUtil.parseLongOrDefault usage so the method returns -1 for missing or
non-numeric tokens instead of throwing.

In
`@oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/BsdSysctlUtil.java`:
- Around line 19-21: The class Javadoc incorrectly mentions "FreeBSD" for the
DragonFlyBSD-specific class; update the Javadoc comment on class BsdSysctlUtil
to reference "DragonFlyBSD" (or a neutral term like "BSD/DragonFly") instead of
"FreeBSD" so generated docs correctly reflect the platform; locate the Javadoc
block immediately above the BsdSysctlUtil class declaration and revise its
description accordingly.

In
`@oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/package-info.java`:
- Around line 5-8: The package Javadoc in package-info.java incorrectly says
“FreeBSD”; update the comment for the package
oshi.util.platform.unix.dragonflybsd to correctly describe DragonFly BSD (e.g.,
"Provides utilities for DragonFly BSD" or "Utilities for DragonFly BSD") so the
Javadoc matches the package name and intent (edit the Javadoc block at the top
of package-info.java).

In
`@oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/ProcstatUtil.java`:
- Around line 36-44: The implementation of ProcstatUtil.getCwdMap currently only
handles pid >= 0 but the Javadoc says negative pid should mean "all processes";
update getCwdMap to handle pid < 0 by iterating over all process IDs and
populating the map: for each pid from the system-wide PID list (use the existing
method that returns all PIDs, e.g., getAllPids() or the project's PID-listing
utility) call ProcstatUtil.getCwd(pid) and, when non-empty, put it into cwdMap;
preserve the existing single-pid path (calling getCwd(pid)) and make sure to
swallow/handle any per-pid errors so a failure on one process doesn’t abort the
whole map population.
🪄 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: 36070914-8d75-4770-aa0c-7694d754fb9a

📥 Commits

Reviewing files that changed from the base of the PR and between eaa9b4b and b59e7a0.

📒 Files selected for processing (38)
  • .github/workflows/unix.yaml
  • oshi-common/src/main/resources/oshi.properties
  • oshi-core/src/main/java/module-info.java
  • oshi-core/src/main/java/oshi/SystemInfo.java
  • oshi-core/src/main/java/oshi/driver/unix/dragonflybsd/Who.java
  • oshi-core/src/main/java/oshi/driver/unix/dragonflybsd/disk/GeomDiskList.java
  • oshi-core/src/main/java/oshi/driver/unix/dragonflybsd/disk/GeomPartList.java
  • oshi-core/src/main/java/oshi/driver/unix/dragonflybsd/disk/Mount.java
  • oshi-core/src/main/java/oshi/driver/unix/dragonflybsd/disk/package-info.java
  • oshi-core/src/main/java/oshi/driver/unix/dragonflybsd/package-info.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdComputerSystem.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdFirmware.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdGlobalMemory.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdGraphicsCard.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdHWDiskStore.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdHardwareAbstractionLayer.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdPowerSource.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdSensors.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdSoundCard.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdUsbDevice.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdVirtualMemory.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/package-info.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/DragonFlyBsdLibc.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdFileSystem.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdInternetProtocolStats.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdNetworkParams.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSFileStore.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSProcess.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSThread.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystem.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/BsdSysctlUtil.java
  • oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/ProcstatUtil.java
  • oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/package-info.java
  • oshi-core/src/test/java/oshi/hardware/platform/shared/CentralProcessorTest.java
  • oshi-core/src/test/java/oshi/software/os/shared/OperatingSystemTest.java
  • pom.xml
📜 Review details
⏰ 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). (12)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 21, windows-latest
  • GitHub Check: Test JDK 11, windows-latest
  • GitHub Check: Analyze (java)
  • GitHub Check: JMH Benchmarks, windows-latest
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: JMH Benchmarks, ubuntu-latest
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: JMH Benchmarks, macos-latest
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 11, macos-latest
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-04-06T04:45:47.644Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:47.644Z
Learning: In the oshi/oshi project, only interfaces and classes in the root packages `oshi`, `oshi.hardware`, and `oshi.software.os` are considered the public API. Code in subpackages that represent specific implementations/platforms (e.g., `oshi.software.os.linux`, `oshi.hardware.platform.linux`, and similar subpackages) is implementation detail. When reviewing, do not treat changes to classes in these platform-specific subpackages as public API breaks (for example: making `LinuxOperatingSystem` abstract, narrowing constructor visibility, or adding/removing abstract methods should not be flagged as breaking public API).

Applied to files:

  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdInternetProtocolStats.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdSoundCard.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdComputerSystem.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/package-info.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdSensors.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdGlobalMemory.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdNetworkParams.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdHardwareAbstractionLayer.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/package-info.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdFileSystem.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdUsbDevice.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdFirmware.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSFileStore.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdGraphicsCard.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSThread.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystem.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdPowerSource.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdVirtualMemory.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSProcess.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdHWDiskStore.java
🪛 zizmor (1.25.2)
.github/workflows/unix.yaml

[warning] 152-152: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)


[error] 152-152: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)


[error] 155-155: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)

🔇 Additional comments (14)
oshi-common/src/main/resources/oshi.properties (1)

268-270: LGTM!

oshi-core/src/main/java/module-info.java (1)

26-26: LGTM!

oshi-core/src/main/java/oshi/SystemInfo.java (1)

16-16: LGTM!

Also applies to: 25-25, 128-129, 161-162

oshi-core/src/main/java/oshi/jna/platform/unix/DragonFlyBsdLibc.java (1)

1-105: LGTM!

oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSFileStore.java (1)

24-34: LGTM!

oshi-core/src/main/java/oshi/driver/unix/dragonflybsd/Who.java (1)

38-63: LGTM!

oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSThread.java (1)

44-169: LGTM!

oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/package-info.java (1)

1-8: LGTM!

oshi-core/src/test/java/oshi/hardware/platform/shared/CentralProcessorTest.java (1)

166-166: LGTM!

oshi-core/src/test/java/oshi/software/os/shared/OperatingSystemTest.java (1)

130-134: LGTM!

Also applies to: 422-426

pom.xml (1)

822-822: LGTM!

Also applies to: 828-828

oshi-core/src/main/java/oshi/driver/unix/dragonflybsd/disk/GeomDiskList.java (1)

33-77: LGTM!

oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdHWDiskStore.java (1)

37-107: LGTM!

oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdHardwareAbstractionLayer.java (1)

33-91: LGTM!

Comment on lines +152 to +155
- uses: actions/checkout@v6
- name: Test in DragonFly BSD
id: test-dragonflybsd
uses: vmactions/dragonflybsd-vm@v1

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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Pin action revisions and disable checkout credential persistence.

Line 152 and Line 155 use tag-based action refs (@v6, @v1) and actions/checkout keeps credentials by default. That weakens supply-chain guarantees and can leak token scope into later steps.

Suggested hardening
-      - uses: actions/checkout@v6
+      - uses: actions/checkout@<full_commit_sha>
+        with:
+          persist-credentials: false
...
-        uses: vmactions/dragonflybsd-vm@v1
+        uses: vmactions/dragonflybsd-vm@<full_commit_sha>
🧰 Tools
🪛 zizmor (1.25.2)

[warning] 152-152: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)


[error] 152-152: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)


[error] 155-155: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)

🤖 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 @.github/workflows/unix.yaml around lines 152 - 155, Replace tag-based action
refs with immutable, pinned revisions for both the checkout action and the
DragonFly VM action: change uses: actions/checkout@v6 and uses:
vmactions/dragonflybsd-vm@v1 to their specific commit SHAs (or fully qualified
refs) to avoid mutable tags, and in the checkout step (the action referenced by
actions/checkout) set persist-credentials: false to prevent leaking the workflow
token to subsequent steps; locate the checkout usage and the step with id
test-dragonflybsd / vmactions/dragonflybsd-vm to make these edits.

Comment on lines +36 to +44
public static Map<Integer, String> getCwdMap(int pid) {
Map<Integer, String> cwdMap = new HashMap<>();
if (pid >= 0) {
String cwd = getCwd(pid);
if (!cwd.isEmpty()) {
cwdMap.put(pid, cwd);
}
}
return cwdMap;

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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

getCwdMap contract doesn’t match implementation for pid < 0.

Javadoc promises “all processes” for negative PID, but Line 38 only executes for pid >= 0, so callers get an empty map for pid < 0.

Suggested fix direction
 public static Map<Integer, String> getCwdMap(int pid) {
     Map<Integer, String> cwdMap = new HashMap<>();
-    if (pid >= 0) {
+    if (pid >= 0) {
         String cwd = getCwd(pid);
         if (!cwd.isEmpty()) {
             cwdMap.put(pid, cwd);
         }
+    } else {
+        // populate all pids from /proc
+        try (Stream<Path> proc = Files.list(Paths.get("/proc"))) {
+            proc.filter(Files::isDirectory)
+                .map(Path::getFileName)
+                .map(Path::toString)
+                .filter(s -> s.chars().allMatch(Character::isDigit))
+                .mapToInt(Integer::parseInt)
+                .forEach(p -> {
+                    String cwd = getCwd(p);
+                    if (!cwd.isEmpty()) {
+                        cwdMap.put(p, cwd);
+                    }
+                });
+        } catch (IOException e) {
+            // fallback remains empty map
+        }
     }
     return cwdMap;
 }
🤖 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-core/src/main/java/oshi/util/platform/unix/dragonflybsd/ProcstatUtil.java`
around lines 36 - 44, The implementation of ProcstatUtil.getCwdMap currently
only handles pid >= 0 but the Javadoc says negative pid should mean "all
processes"; update getCwdMap to handle pid < 0 by iterating over all process IDs
and populating the map: for each pid from the system-wide PID list (use the
existing method that returns all PIDs, e.g., getAllPids() or the project's
PID-listing utility) call ProcstatUtil.getCwd(pid) and, when non-empty, put it
into cwdMap; preserve the existing single-pid path (calling getCwd(pid)) and
make sure to swallow/handle any per-pid errors so a failure on one process
doesn’t abort the whole map population.

@dbwiddis

Copy link
Copy Markdown
Member Author

CodeRabbit Review Response

Fixed (commit 3b89801):

  • ✅ Regex over-escaping in CentralProcessor (both FreeBSD + DragonFly)
  • ✅ SoundCard null safety - getOrDefault with Constants.UNKNOWN (both)
  • ✅ UsbDevice hubMap null - getOrDefault with empty list copy (both)
  • ✅ NetworkParams canonname null - null check before .trim() (both)
  • ✅ InternetProtocolStats overflow - convert each field to long before summing (both)
  • ✅ OSProcess file limit bounds - check split.length > index (both)
  • ✅ FileSystem inode map key - key by mount point not device (both)
  • ✅ Package-info javadocs - replaced "FreeBSD" with "DragonFly BSD"
  • ✅ BsdSysctlUtil javadoc - references DragonFly BSD
  • ✅ OS family fallback - "DragonFly" not "FreeBSD"

Skipped:

  • ⏭️ CI action pinning - project convention uses @v1/@v6 tags throughout all workflows; not changing for just this entry
  • ⏭️ GeomPartList flush-before-switch - same pattern as FreeBSD; the code saves the previous device when encountering a new header (line 58-63). The last device is handled after the loop (line 95-100). No data loss.
  • ⏭️ Mount MOUNT_PATTERN - same as FreeBSD; the pattern matches the specific partition naming used by geom. DragonFly may not even use geom (uses HAMMER2), so this is a future investigation item.
  • ⏭️ GraphicsCard field reset - fields are set from the current line's parsing within the same if block, and name is explicitly reset. No carryover risk.
  • ⏭️ PowerSource fake BAT0 - same pattern as FreeBSD; this is existing behavior. Changing it would be a separate improvement PR.
  • ⏭️ ProcstatUtil.getCwdMap negative pid - the negative-pid "all processes" path is not used by any caller in the DragonFly implementation. Dead code from FreeBSD copy; will be cleaned up in the refactoring PR.
  • ⏭️ FileSystem UUID lookup key - same as FreeBSD; the geom-based UUID map may not apply to DragonFly (HAMMER2). Future work.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystem.java (1)

237-237: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Error message references wrong directory.

The code checks /etc/rc.d on line 226 but the error message says /etc/init does not exist.

Proposed fix
-            LOG.error("Directory: /etc/init does not exist");
+            LOG.error("Directory: /etc/rc.d does not exist");
🤖 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-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystem.java`
at line 237, The error message in DragonFlyBsdOperatingSystem (LOG.error call)
incorrectly mentions "/etc/init" while the code is checking for "/etc/rc.d";
update the LOG.error text to reference "/etc/rc.d" so the message matches the
check performed by the class DragonFlyBsdOperatingSystem (use the existing
LOG.error invocation to change the string).
🧹 Nitpick comments (1)
oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystem.java (1)

43-46: 💤 Low value

Javadoc contains garbled/leftover text from FreeBSD.

The class documentation mixes a DragonFly description ("HAMMER2 filesystem...LWKT subsystem") with leftover FreeBSD text ("accounting for more than three-quarters of all installed simply, permissively licensed BSD systems"). This appears to be copy-paste remnants.

Suggested fix
 /**
- * DragonFly BSD is a free and open-source Unix-like operating system forked from FreeBSD 4.8 in 2003. It features the
- * HAMMER2 filesystem and a unique approach to SMP with its lightweight kernel threads (LWKT) subsystem. popular
- * open-source BSD operating system, accounting for more than three-quarters of all installed simply, permissively
- * licensed BSD systems.
+ * DragonFly BSD is a free and open-source Unix-like operating system forked from FreeBSD 4.8 in 2003. It features the
+ * HAMMER2 filesystem and a unique approach to SMP with its lightweight kernel threads (LWKT) subsystem.
  */
🤖 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-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystem.java`
around lines 43 - 46, Update the class Javadoc for DragonFlyBsdOperatingSystem
to remove the leftover FreeBSD/garbled text: replace the mixed/incorrect
sentences with a concise, accurate description mentioning DragonFly BSD, its
HAMMER2 filesystem and LWKT subsystem, fix capitalization ("popular" → "Popular"
if used) and remove phrases like "accounting for more than three-quarters..." so
the Javadoc for the DragonFlyBsdOperatingSystem class only contains correct
DragonFly-specific information.
🤖 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.

Outside diff comments:
In
`@oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystem.java`:
- Line 237: The error message in DragonFlyBsdOperatingSystem (LOG.error call)
incorrectly mentions "/etc/init" while the code is checking for "/etc/rc.d";
update the LOG.error text to reference "/etc/rc.d" so the message matches the
check performed by the class DragonFlyBsdOperatingSystem (use the existing
LOG.error invocation to change the string).

---

Nitpick comments:
In
`@oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystem.java`:
- Around line 43-46: Update the class Javadoc for DragonFlyBsdOperatingSystem to
remove the leftover FreeBSD/garbled text: replace the mixed/incorrect sentences
with a concise, accurate description mentioning DragonFly BSD, its HAMMER2
filesystem and LWKT subsystem, fix capitalization ("popular" → "Popular" if
used) and remove phrases like "accounting for more than three-quarters..." so
the Javadoc for the DragonFlyBsdOperatingSystem class only contains correct
DragonFly-specific information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 988a7bcc-3c43-47df-b4bc-cfa60c230240

📥 Commits

Reviewing files that changed from the base of the PR and between 24e78b9 and 3b89801.

📒 Files selected for processing (20)
  • oshi-core/src/main/java/oshi/driver/unix/dragonflybsd/package-info.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdSoundCard.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdUsbDevice.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/package-info.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSoundCard.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdUsbDevice.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdFileSystem.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdInternetProtocolStats.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdNetworkParams.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSProcess.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystem.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/package-info.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdFileSystem.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStats.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdNetworkParams.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOSProcess.java
  • oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/BsdSysctlUtil.java
  • oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/package-info.java
✅ Files skipped from review due to trivial changes (2)
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/package-info.java
  • oshi-core/src/main/java/oshi/driver/unix/dragonflybsd/package-info.java
📜 Review details
⏰ 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). (9)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: JMH Benchmarks, ubuntu-latest
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: JMH Benchmarks, macos-latest
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Analyze (java)
  • GitHub Check: JMH Benchmarks, windows-latest
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-04-06T04:45:47.644Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:47.644Z
Learning: In the oshi/oshi project, only interfaces and classes in the root packages `oshi`, `oshi.hardware`, and `oshi.software.os` are considered the public API. Code in subpackages that represent specific implementations/platforms (e.g., `oshi.software.os.linux`, `oshi.hardware.platform.linux`, and similar subpackages) is implementation detail. When reviewing, do not treat changes to classes in these platform-specific subpackages as public API breaks (for example: making `LinuxOperatingSystem` abstract, narrowing constructor visibility, or adding/removing abstract methods should not be flagged as breaking public API).

Applied to files:

  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdUsbDevice.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOSProcess.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdNetworkParams.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/package-info.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdFileSystem.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStats.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdInternetProtocolStats.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSoundCard.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdSoundCard.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdUsbDevice.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdFileSystem.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSProcess.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdNetworkParams.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessor.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystem.java
🔇 Additional comments (20)
oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdUsbDevice.java (1)

11-11: LGTM!

Also applies to: 126-126

oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOSProcess.java (1)

463-465: LGTM!

oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdNetworkParams.java (1)

2-2: LGTM!

Also applies to: 47-47

oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/package-info.java (1)

6-6: LGTM!

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

77-83: LGTM!

oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/package-info.java (1)

6-6: LGTM!

oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStats.java (1)

40-42: LGTM!

Also applies to: 51-52

oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdInternetProtocolStats.java (1)

42-44: LGTM!

Also applies to: 53-54

oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdCentralProcessor.java (1)

2-2: LGTM!

Also applies to: 114-116, 223-233

oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSoundCard.java (1)

2-2: LGTM!

Also applies to: 15-15, 69-71

oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdSoundCard.java (1)

15-15: LGTM!

Also applies to: 69-71

oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdUsbDevice.java (1)

11-11: LGTM!

Also applies to: 126-126

oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/BsdSysctlUtil.java (1)

20-20: LGTM!

oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdFileSystem.java (1)

77-83: LGTM!

oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSProcess.java (1)

442-444: LGTM!

oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdNetworkParams.java (1)

47-47: LGTM!

oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessor.java (2)

114-116: LGTM!


267-279: LGTM!

Also applies to: 282-312, 314-327, 382-404

oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystem.java (2)

76-76: LGTM!


108-149: LGTM!

Also applies to: 151-187, 189-213

Fix issues identified by CodeRabbit, applied to both DragonFly BSD
and FreeBSD where the same pattern exists:

- Fix over-escaped regex in CentralProcessor dmesg parsing
- Fix potential null in SoundCard name construction
- Fix potential null in UsbDevice hubMap lookup
- Fix potential null in NetworkParams canonname
- Fix integer overflow in InternetProtocolStats counter aggregation
- Fix ArrayIndexOutOfBoundsException in OSProcess file limit parsing
- Fix inode map keyed by device instead of mount point in FileSystem
- Fix DragonFly-specific: javadoc references to FreeBSD, OS family
  fallback string
@dbwiddis dbwiddis linked an issue May 26, 2026 that may be closed by this pull request
@dbwiddis
dbwiddis force-pushed the dfbsd-port branch 17 times, most recently from b1d4d42 to 8dd01c4 Compare May 27, 2026 06:10
@dbwiddis
dbwiddis force-pushed the dfbsd-port branch 3 times, most recently from 05a0b1e to 583a119 Compare May 27, 2026 06:32

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

🤖 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-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystem.java`:
- Around line 221-222: DragonFlyBsdOperatingSystem#getNetworkParams returns new
FreeBsdNetworkParams which hard-codes FreeBsdLibc.INSTANCE; change this so
DragonFly uses DragonFlyBsdLibc: either create a DragonFlyBsdNetworkParams class
that mirrors FreeBsdNetworkParams but calls DragonFlyBsdLibc.INSTANCE for
gethostname/getaddrinfo, and return new DragonFlyBsdNetworkParams() from
DragonFlyBsdOperatingSystem#getNetworkParams, or refactor FreeBsdNetworkParams
to accept a libc binding in its constructor and pass DragonFlyBsdLibc.INSTANCE
from DragonFlyBsdOperatingSystem#getNetworkParams; update references to
FreeBsdLibc.INSTANCE inside FreeBsdNetworkParams to use the injected binding.
🪄 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: 203e05bd-cf5d-4b86-b3f1-2e31edaf8838

📥 Commits

Reviewing files that changed from the base of the PR and between 05a0b1e and 583a119.

📒 Files selected for processing (27)
  • .github/workflows/unix.yaml
  • README.md
  • oshi-core/src/main/java/module-info.java
  • oshi-core/src/main/java/oshi/SystemInfo.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdHardwareAbstractionLayer.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/package-info.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdComputerSystem.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdFirmware.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdGlobalMemory.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdGraphicsCard.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSensors.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSoundCard.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/BsdLibcLoader.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/DragonFlyBsdLibc.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/FreeBsdLibc.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/OpenBsdLibc.java
  • oshi-core/src/main/java/oshi/package-info.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSProcess.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSThread.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystem.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/package-info.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdNetworkParams.java
  • oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/ProcstatUtil.java
  • oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/package-info.java
  • src/site/markdown/index.md
✅ Files skipped from review due to trivial changes (6)
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/package-info.java
  • src/site/markdown/index.md
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/package-info.java
  • README.md
  • oshi-core/src/main/java/oshi/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/package-info.java
🚧 Files skipped from review as they are similar to previous changes (18)
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSensors.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdGraphicsCard.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/BsdLibcLoader.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/DragonFlyBsdLibc.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/FreeBsdLibc.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/OpenBsdLibc.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdGlobalMemory.java
  • .github/workflows/unix.yaml
  • oshi-core/src/main/java/module-info.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdHardwareAbstractionLayer.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSoundCard.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdFirmware.java
  • oshi-core/src/main/java/oshi/SystemInfo.java
  • oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/ProcstatUtil.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSThread.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSProcess.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessor.java
📜 Review details
⏰ 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). (6)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: JMH Benchmarks, macos-latest
  • GitHub Check: Analyze (java)
  • GitHub Check: JMH Benchmarks, windows-latest
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-04-06T04:45:47.644Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:47.644Z
Learning: In the oshi/oshi project, only interfaces and classes in the root packages `oshi`, `oshi.hardware`, and `oshi.software.os` are considered the public API. Code in subpackages that represent specific implementations/platforms (e.g., `oshi.software.os.linux`, `oshi.hardware.platform.linux`, and similar subpackages) is implementation detail. When reviewing, do not treat changes to classes in these platform-specific subpackages as public API breaks (for example: making `LinuxOperatingSystem` abstract, narrowing constructor visibility, or adding/removing abstract methods should not be flagged as breaking public API).

Applied to files:

  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdComputerSystem.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdNetworkParams.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystem.java
🔇 Additional comments (2)
oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdComputerSystem.java (1)

2-2: LGTM!

Also applies to: 27-27

oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystem.java (1)

98-103: LGTM!

Also applies to: 203-217

Comment on lines +221 to +222
public NetworkParams getNetworkParams() {
return new FreeBsdNetworkParams();

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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

for name in FreeBsdNetworkParams.java DragonFlyBsdOperatingSystem.java FreeBsdLibc.java DragonFlyBsdLibc.java; do
  path="$(fd -a "^${name}$" oshi-core/src/main/java | head -n1 || true)"
  if [ -z "$path" ]; then
    echo "Missing: $name" >&2
    continue
  fi
  echo "=== $path ==="
  sed -n '1,140p' "$path"
  echo
done

Repository: oshi/oshi

Length of output: 12860


Route DragonFly getNetworkParams() through DragonFlyBsdLibc (not FreeBsdLibc)
DragonFlyBsdOperatingSystem#getNetworkParams() currently returns new FreeBsdNetworkParams(), and FreeBsdNetworkParams hard-codes FreeBsdLibc.INSTANCE for hostname/domain lookups (gethostname()/getaddrinfo()). Add a DragonFly-specific NetworkParams that uses DragonFlyBsdLibc.INSTANCE, or refactor FreeBsdNetworkParams to inject the correct libc binding.

💡 Minimal direction
     `@Override`
     public NetworkParams getNetworkParams() {
-        return new FreeBsdNetworkParams();
+        return new DragonFlyBsdNetworkParams();
     }
🤖 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-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystem.java`
around lines 221 - 222, DragonFlyBsdOperatingSystem#getNetworkParams returns new
FreeBsdNetworkParams which hard-codes FreeBsdLibc.INSTANCE; change this so
DragonFly uses DragonFlyBsdLibc: either create a DragonFlyBsdNetworkParams class
that mirrors FreeBsdNetworkParams but calls DragonFlyBsdLibc.INSTANCE for
gethostname/getaddrinfo, and return new DragonFlyBsdNetworkParams() from
DragonFlyBsdOperatingSystem#getNetworkParams, or refactor FreeBsdNetworkParams
to accept a libc binding in its constructor and pass DragonFlyBsdLibc.INSTANCE
from DragonFlyBsdOperatingSystem#getNetworkParams; update references to
FreeBsdLibc.INSTANCE inside FreeBsdNetworkParams to use the injected binding.

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

🧹 Nitpick comments (1)
oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessor.java (1)

32-49: 💤 Low value

Consider adding debug logging on sysctl failure for consistency.

queryProcessorCpuLoadTicks() logs a debug message with Native.getLastError() when the sysctl fails (line 60), but querySystemCpuLoadTicks() silently returns zeros. For consistent debugging, consider adding similar logging here.

🔧 Proposed fix
         try (CloseableSizeTByReference size = new CloseableSizeTByReference(cpTime.size())) {
-            if (0 == DragonFlyBsdLibc.INSTANCE.sysctlbyname("kern.cp_time", cpTime.getPointer(), size, null,
-                    size_t.ZERO)) {
+            String name = "kern.cp_time";
+            if (0 != DragonFlyBsdLibc.INSTANCE.sysctlbyname(name, cpTime.getPointer(), size, null,
+                    size_t.ZERO)) {
+                LOG.debug("Failed sysctl call: {}, Error code: {}", name, Native.getLastError());
+                return ticks;
+            }
-                cpTime.read();
+            cpTime.read();
 
-                ticks[TickType.USER.getIndex()] = cpTime.cpu_ticks[FreeBsdLibc.CP_USER];
-                ticks[TickType.NICE.getIndex()] = cpTime.cpu_ticks[FreeBsdLibc.CP_NICE];
-                ticks[TickType.SYSTEM.getIndex()] = cpTime.cpu_ticks[FreeBsdLibc.CP_SYS];
-                ticks[TickType.IRQ.getIndex()] = cpTime.cpu_ticks[FreeBsdLibc.CP_INTR];
-                ticks[TickType.IDLE.getIndex()] = cpTime.cpu_ticks[FreeBsdLibc.CP_IDLE];
-            }
+            ticks[TickType.USER.getIndex()] = cpTime.cpu_ticks[FreeBsdLibc.CP_USER];
+            ticks[TickType.NICE.getIndex()] = cpTime.cpu_ticks[FreeBsdLibc.CP_NICE];
+            ticks[TickType.SYSTEM.getIndex()] = cpTime.cpu_ticks[FreeBsdLibc.CP_SYS];
+            ticks[TickType.IRQ.getIndex()] = cpTime.cpu_ticks[FreeBsdLibc.CP_INTR];
+            ticks[TickType.IDLE.getIndex()] = cpTime.cpu_ticks[FreeBsdLibc.CP_IDLE];
         }
🤖 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-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessor.java`
around lines 32 - 49, The method querySystemCpuLoadTicks() currently returns
zeros on sysctl failure without logging; add a debug log like the one in
queryProcessorCpuLoadTicks() to record the failure and Native.getLastError() (or
the equivalent error code/message) when
DragonFlyBsdLibc.INSTANCE.sysctlbyname(...) returns non-zero, so you can
diagnose failures; place the log inside the try block where the sysctl call is
checked (before returning ticks) and use the same logger used by
queryProcessorCpuLoadTicks() with a clear message including "kern.cp_time" and
the native error details.
🤖 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.

Nitpick comments:
In
`@oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessor.java`:
- Around line 32-49: The method querySystemCpuLoadTicks() currently returns
zeros on sysctl failure without logging; add a debug log like the one in
queryProcessorCpuLoadTicks() to record the failure and Native.getLastError() (or
the equivalent error code/message) when
DragonFlyBsdLibc.INSTANCE.sysctlbyname(...) returns non-zero, so you can
diagnose failures; place the log inside the try block where the sysctl call is
checked (before returning ticks) and use the same logger used by
queryProcessorCpuLoadTicks() with a clear message including "kern.cp_time" and
the native error details.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2e08ba30-5a49-471c-914a-e70d5971ca3a

📥 Commits

Reviewing files that changed from the base of the PR and between 583a119 and 4b6586f.

📒 Files selected for processing (28)
  • .github/workflows/unix.yaml
  • README.md
  • oshi-core/src/main/java/module-info.java
  • oshi-core/src/main/java/oshi/SystemInfo.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdHardwareAbstractionLayer.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/package-info.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdComputerSystem.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdFirmware.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdGlobalMemory.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdGraphicsCard.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSensors.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSoundCard.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/BsdLibcLoader.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/DragonFlyBsdLibc.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/FreeBsdLibc.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/OpenBsdLibc.java
  • oshi-core/src/main/java/oshi/package-info.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSProcess.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSThread.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystem.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/package-info.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdNetworkParams.java
  • oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/ProcstatUtil.java
  • oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/package-info.java
  • oshi-core/src/test/java/oshi/software/os/shared/OperatingSystemTest.java
  • src/site/markdown/index.md
✅ Files skipped from review due to trivial changes (6)
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/package-info.java
  • oshi-core/src/main/java/oshi/package-info.java
  • src/site/markdown/index.md
  • README.md
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/package-info.java
🚧 Files skipped from review as they are similar to previous changes (20)
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdGlobalMemory.java
  • oshi-core/src/test/java/oshi/software/os/shared/OperatingSystemTest.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/DragonFlyBsdLibc.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/FreeBsdLibc.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdFirmware.java
  • .github/workflows/unix.yaml
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdNetworkParams.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdHardwareAbstractionLayer.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdGraphicsCard.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdComputerSystem.java
  • oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/ProcstatUtil.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSThread.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/BsdLibcLoader.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystem.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSProcess.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSoundCard.java
  • oshi-core/src/main/java/module-info.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/OpenBsdLibc.java
  • oshi-core/src/main/java/oshi/SystemInfo.java
📜 Review details
⏰ 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). (8)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Analyze (java)
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: JMH Benchmarks, macos-latest
  • GitHub Check: JMH Benchmarks, ubuntu-latest
  • GitHub Check: JMH Benchmarks, windows-latest
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-04-06T04:45:47.644Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:47.644Z
Learning: In the oshi/oshi project, only interfaces and classes in the root packages `oshi`, `oshi.hardware`, and `oshi.software.os` are considered the public API. Code in subpackages that represent specific implementations/platforms (e.g., `oshi.software.os.linux`, `oshi.hardware.platform.linux`, and similar subpackages) is implementation detail. When reviewing, do not treat changes to classes in these platform-specific subpackages as public API breaks (for example: making `LinuxOperatingSystem` abstract, narrowing constructor visibility, or adding/removing abstract methods should not be flagged as breaking public API).

Applied to files:

  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSensors.java
🔇 Additional comments (2)
oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessor.java (1)

24-30: LGTM!

Also applies to: 51-78

oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSensors.java (1)

2-2: LGTM!

Also applies to: 21-21

@dbwiddis
dbwiddis force-pushed the dfbsd-port branch 2 times, most recently from 4495c6c to 8b375f1 Compare May 27, 2026 07:43

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSoundCard.java (1)

69-71: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Avoid leading whitespace in fallback sound card names.

When info.vendor is missing, this now produces names like " Unknown". Build the combined name conditionally, or trim it before constructing the FreeBsdSoundCard.

Proposed fix
             String product = productMap.getOrDefault(s, Constants.UNKNOWN);
             String vendor = vendorMap.getOrDefault(s, "");
-            soundCards.add(new FreeBsdSoundCard(product, vendor + " " + product, product));
+            String name = vendor.isEmpty() ? product : vendor + " " + product;
+            soundCards.add(new FreeBsdSoundCard(product, name, product));
🤖 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-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSoundCard.java`
around lines 69 - 71, The combined sound card name construction can produce a
leading space when vendorMap.getOrDefault(s, "") returns empty (e.g., "
Unknown"); update the logic around productMap, vendorMap and the
FreeBsdSoundCard constructor to either conditionally build the combined name
only when vendor is non-empty or trim the resulting string before passing it in;
specifically, when creating new FreeBsdSoundCard(product, vendor + " " +
product, product) use a safeCombined variable (e.g., vendor.isEmpty() ? product
: (vendor + " " + product)) or call .trim() on the concatenation so the display
name never has a leading space, while still keeping product and
Constants.UNKNOWN handling intact.
🧹 Nitpick comments (1)
oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessor.java (1)

51-79: ⚡ Quick win

Validate the returned kern.cputime payload before indexing it.

This derives structSize from the first size query and never revalidates after the data fetch. If the second sysctlbyname() returns a different byte count, or one that's not a whole number of per-CPU records, the offset math can read garbage or trip JNA bounds checks. Use dataSize.getValue() for the final size and bail out unless it is a positive multiple of getLogicalProcessorCount() and large enough for the tick fields.

Proposed hardening
             long arraySize = size.getValue().longValue();
             if (arraySize <= 0) {
                 return ticks;
             }
-            long structSize = arraySize / getLogicalProcessorCount();
             try (Memory m = new Memory(arraySize);
                     CloseableSizeTByReference dataSize = new CloseableSizeTByReference(arraySize)) {
                 if (0 != DragonFlyBsdLibc.INSTANCE.sysctlbyname(name, m, dataSize, null, size_t.ZERO)) {
                     LOG.debug("Failed sysctl data query: {}, Error code: {}", name, Native.getLastError());
                     return ticks;
                 }
-                for (int cpu = 0; cpu < getLogicalProcessorCount(); cpu++) {
+                int logicalCount = getLogicalProcessorCount();
+                long returnedSize = dataSize.getValue().longValue();
+                long minStructSize = (long) (FreeBsdLibc.CP_IDLE + 1) * FreeBsdLibc.UINT64_SIZE;
+                if (logicalCount <= 0 || returnedSize < logicalCount * minStructSize
+                        || returnedSize % logicalCount != 0) {
+                    LOG.debug("Unexpected {} payload size: {}", name, returnedSize);
+                    return ticks;
+                }
+                long structSize = returnedSize / logicalCount;
+                for (int cpu = 0; cpu < logicalCount; cpu++) {
                     ticks[cpu][TickType.USER.getIndex()] = m
                             .getLong(structSize * cpu + FreeBsdLibc.CP_USER * FreeBsdLibc.UINT64_SIZE);
                     ticks[cpu][TickType.NICE.getIndex()] = m
🤖 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-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessor.java`
around lines 51 - 79, The code in DragonFlyBsdCentralProcessor reads
kern.cputime into Memory using an initial size probe but doesn’t revalidate the
actual returned byte count from the second sysctlbyname call; use
dataSize.getValue() (from the CloseableSizeTByReference dataSize) to compute the
final array size, compute structSize = finalSize / getLogicalProcessorCount(),
and validate that finalSize > 0, finalSize % getLogicalProcessorCount() == 0,
and structSize is at least large enough to contain all tick fields (e.g.,
(FreeBsdLibc.CP_IDLE + 1) * FreeBsdLibc.UINT64_SIZE) before indexing
ticks[cpu][...]; if validation fails, log a debug/error and return ticks instead
of performing the unsafe offsets.
🤖 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.

Outside diff comments:
In
`@oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSoundCard.java`:
- Around line 69-71: The combined sound card name construction can produce a
leading space when vendorMap.getOrDefault(s, "") returns empty (e.g., "
Unknown"); update the logic around productMap, vendorMap and the
FreeBsdSoundCard constructor to either conditionally build the combined name
only when vendor is non-empty or trim the resulting string before passing it in;
specifically, when creating new FreeBsdSoundCard(product, vendor + " " +
product, product) use a safeCombined variable (e.g., vendor.isEmpty() ? product
: (vendor + " " + product)) or call .trim() on the concatenation so the display
name never has a leading space, while still keeping product and
Constants.UNKNOWN handling intact.

---

Nitpick comments:
In
`@oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessor.java`:
- Around line 51-79: The code in DragonFlyBsdCentralProcessor reads kern.cputime
into Memory using an initial size probe but doesn’t revalidate the actual
returned byte count from the second sysctlbyname call; use dataSize.getValue()
(from the CloseableSizeTByReference dataSize) to compute the final array size,
compute structSize = finalSize / getLogicalProcessorCount(), and validate that
finalSize > 0, finalSize % getLogicalProcessorCount() == 0, and structSize is at
least large enough to contain all tick fields (e.g., (FreeBsdLibc.CP_IDLE + 1) *
FreeBsdLibc.UINT64_SIZE) before indexing ticks[cpu][...]; if validation fails,
log a debug/error and return ticks instead of performing the unsafe offsets.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ae253d5c-eca3-4e0c-b5d2-5006d45b6b73

📥 Commits

Reviewing files that changed from the base of the PR and between 4495c6c and 8b375f1.

📒 Files selected for processing (29)
  • .github/workflows/unix.yaml
  • CHANGELOG.md
  • README.md
  • oshi-core/src/main/java/module-info.java
  • oshi-core/src/main/java/oshi/SystemInfo.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdHardwareAbstractionLayer.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/package-info.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdComputerSystem.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdFirmware.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdGlobalMemory.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdGraphicsCard.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSensors.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSoundCard.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/BsdLibcLoader.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/DragonFlyBsdLibc.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/FreeBsdLibc.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/OpenBsdLibc.java
  • oshi-core/src/main/java/oshi/package-info.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSProcess.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSThread.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystem.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/package-info.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdNetworkParams.java
  • oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/ProcstatUtil.java
  • oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/package-info.java
  • oshi-core/src/test/java/oshi/software/os/shared/OperatingSystemTest.java
  • src/site/markdown/index.md
💤 Files with no reviewable changes (1)
  • CHANGELOG.md
✅ Files skipped from review due to trivial changes (4)
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/package-info.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/package-info.java
  • README.md
  • oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/package-info.java
🚧 Files skipped from review as they are similar to previous changes (20)
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdGraphicsCard.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSensors.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdComputerSystem.java
  • oshi-core/src/main/java/oshi/package-info.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdFirmware.java
  • oshi-core/src/main/java/module-info.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/OpenBsdLibc.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdNetworkParams.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdGlobalMemory.java
  • .github/workflows/unix.yaml
  • oshi-core/src/main/java/oshi/SystemInfo.java
  • oshi-core/src/test/java/oshi/software/os/shared/OperatingSystemTest.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdHardwareAbstractionLayer.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/BsdLibcLoader.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSProcess.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdCentralProcessor.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/FreeBsdLibc.java
  • oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/ProcstatUtil.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSThread.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystem.java
📜 Review details
⏰ 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). (10)
  • 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: Test JDK 11, macos-latest
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: JMH Benchmarks, windows-latest
  • GitHub Check: JMH Benchmarks, ubuntu-latest
  • GitHub Check: JMH Benchmarks, macos-latest
  • GitHub Check: Analyze (java)
  • GitHub Check: Codacy Static Code Analysis
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-04-06T04:45:47.644Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:47.644Z
Learning: In the oshi/oshi project, only interfaces and classes in the root packages `oshi`, `oshi.hardware`, and `oshi.software.os` are considered the public API. Code in subpackages that represent specific implementations/platforms (e.g., `oshi.software.os.linux`, `oshi.hardware.platform.linux`, and similar subpackages) is implementation detail. When reviewing, do not treat changes to classes in these platform-specific subpackages as public API breaks (for example: making `LinuxOperatingSystem` abstract, narrowing constructor visibility, or adding/removing abstract methods should not be flagged as breaking public API).

Applied to files:

  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSoundCard.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessor.java
🔇 Additional comments (4)
src/site/markdown/index.md (1)

19-19: LGTM!

oshi-core/src/main/java/oshi/jna/platform/unix/DragonFlyBsdLibc.java (1)

8-19: LGTM!

oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSoundCard.java (1)

23-23: LGTM!

oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessor.java (1)

29-43: LGTM!

@dbwiddis

Copy link
Copy Markdown
Member Author

@CodeRabbit full review

@coderabbitai

coderabbitai Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Full review triggered.

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

♻️ Duplicate comments (2)
oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystem.java (1)

212-213: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Use a DragonFly-specific NetworkParams binding instead of FreeBsdNetworkParams.

This still routes DragonFly through FreeBsdNetworkParams, which is expected to bind FreeBSD libc calls. Please switch to a DragonFly binding (or inject libc into a shared implementation).

#!/bin/bash
set -euo pipefail

echo "Locate DragonFly OS getNetworkParams implementation:"
fd -a "^DragonFlyBsdOperatingSystem.java$" oshi-core/src/main/java | while read -r f; do
  echo "== $f =="
  rg -n "getNetworkParams|FreeBsdNetworkParams|DragonFlyBsdLibc|FreeBsdLibc" "$f"
done

echo
echo "Inspect FreeBsdNetworkParams libc binding:"
fd -a "^FreeBsdNetworkParams.java$" oshi-core/src/main/java | while read -r f; do
  echo "== $f =="
  rg -n "FreeBsdLibc|DragonFlyBsdLibc|gethostname|getaddrinfo" "$f"
done

Expected result: DragonFly path should not depend on FreeBsdLibc-bound network params.

🤖 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-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystem.java`
around lines 212 - 213, The DragonFlyBsdOperatingSystem.getNetworkParams()
currently returns FreeBsdNetworkParams which binds FreeBsdLibc; change this to
return a DragonFly-specific implementation (e.g., DragonFlyBsdNetworkParams) or
refactor to a shared NetworkParams implementation that accepts the proper libc
binding; update the class returned by getNetworkParams in
DragonFlyBsdOperatingSystem and ensure the new DragonFlyBsdNetworkParams uses
DragonFlyBsdLibc (not FreeBsdLibc), adjust imports and any factory/constructor
signatures accordingly so DragonFly uses its own libc binding for
gethostname/getaddrinfo calls.
oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/ProcstatUtil.java (1)

33-44: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Align getCwdMap(int pid) behavior with its documented contract.

Javadoc says negative pid returns all processes, but current implementation returns an empty map for pid < 0.

🤖 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-core/src/main/java/oshi/util/platform/unix/dragonflybsd/ProcstatUtil.java`
around lines 33 - 44, The getCwdMap(int pid) method currently only handles pid
>= 0 but its Javadoc promises that a negative pid returns all processes; update
getCwdMap to handle pid < 0 by iterating over all process IDs and calling getCwd
for each, adding non-empty results to cwdMap. Use the existing process-listing
utility in this class or project (the method that returns all PIDs) to obtain
the PID list, then for each pid call getCwd(pid) and put non-empty values into
cwdMap.
🤖 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-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSProcess.java`:
- Around line 280-283: The affinity bit-shift can overflow for CPU indexes ≥ 64
in DragonFlyBsdOSProcess, so when computing bitMask after
ParseUtil.parseIntOrDefault (variable bitToSet) ensure you skip out-of-range
indexes before shifting; change the condition that sets bitMask (currently using
"if (bitToSet >= 0) { bitMask |= 1L << bitToSet; }") to only perform the shift
when bitToSet < Long.SIZE (or 64), e.g., check "bitToSet >= 0 && bitToSet <
Long.SIZE" and ignore values outside that range to avoid wraparound.

---

Duplicate comments:
In
`@oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystem.java`:
- Around line 212-213: The DragonFlyBsdOperatingSystem.getNetworkParams()
currently returns FreeBsdNetworkParams which binds FreeBsdLibc; change this to
return a DragonFly-specific implementation (e.g., DragonFlyBsdNetworkParams) or
refactor to a shared NetworkParams implementation that accepts the proper libc
binding; update the class returned by getNetworkParams in
DragonFlyBsdOperatingSystem and ensure the new DragonFlyBsdNetworkParams uses
DragonFlyBsdLibc (not FreeBsdLibc), adjust imports and any factory/constructor
signatures accordingly so DragonFly uses its own libc binding for
gethostname/getaddrinfo calls.

In
`@oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/ProcstatUtil.java`:
- Around line 33-44: The getCwdMap(int pid) method currently only handles pid >=
0 but its Javadoc promises that a negative pid returns all processes; update
getCwdMap to handle pid < 0 by iterating over all process IDs and calling getCwd
for each, adding non-empty results to cwdMap. Use the existing process-listing
utility in this class or project (the method that returns all PIDs) to obtain
the PID list, then for each pid call getCwd(pid) and put non-empty values into
cwdMap.
🪄 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: faac1015-1e62-4ce8-8e2a-da499b9a03b4

📥 Commits

Reviewing files that changed from the base of the PR and between eaa9b4b and bc94120.

📒 Files selected for processing (37)
  • .github/workflows/unix.yaml
  • CHANGELOG.md
  • README.md
  • oshi-common/src/main/resources/oshi.properties
  • oshi-core/src/main/java/module-info.java
  • oshi-core/src/main/java/oshi/SystemInfo.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdHardwareAbstractionLayer.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/package-info.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdComputerSystem.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdFirmware.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdGlobalMemory.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdGraphicsCard.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSensors.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSoundCard.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdUsbDevice.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/BsdLibcLoader.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/DragonFlyBsdLibc.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/FreeBsdLibc.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/OpenBsdLibc.java
  • oshi-core/src/main/java/oshi/package-info.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSProcess.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSThread.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystem.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/package-info.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdFileSystem.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStats.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdNetworkParams.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOSProcess.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOperatingSystem.java
  • oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/ProcstatUtil.java
  • oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/package-info.java
  • oshi-core/src/test/java/oshi/hardware/platform/shared/CentralProcessorTest.java
  • oshi-core/src/test/java/oshi/software/os/shared/OperatingSystemTest.java
  • pom.xml
  • src/site/markdown/index.md
📜 Review details
⏰ 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). (1)
  • GitHub Check: Codacy Static Code Analysis
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-04-06T04:45:47.644Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3121
File: oshi-core/src/main/java/oshi/software/os/linux/LinuxOperatingSystem.java:53-53
Timestamp: 2026-04-06T04:45:47.644Z
Learning: In the oshi/oshi project, only interfaces and classes in the root packages `oshi`, `oshi.hardware`, and `oshi.software.os` are considered the public API. Code in subpackages that represent specific implementations/platforms (e.g., `oshi.software.os.linux`, `oshi.hardware.platform.linux`, and similar subpackages) is implementation detail. When reviewing, do not treat changes to classes in these platform-specific subpackages as public API breaks (for example: making `LinuxOperatingSystem` abstract, narrowing constructor visibility, or adding/removing abstract methods should not be flagged as breaking public API).

Applied to files:

  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/package-info.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdGlobalMemory.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSensors.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdFirmware.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdFileSystem.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStats.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdGraphicsCard.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessor.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdNetworkParams.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSoundCard.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/package-info.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdHardwareAbstractionLayer.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdComputerSystem.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOperatingSystem.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdUsbDevice.java
  • oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOSProcess.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSThread.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSProcess.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdCentralProcessor.java
  • oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOperatingSystem.java
🪛 markdownlint-cli2 (0.22.1)
CHANGELOG.md

[warning] 3-3: Heading levels should only increment by one level at a time
Expected: h2; Actual: h5

(MD001, heading-increment)

🪛 zizmor (1.25.2)
.github/workflows/unix.yaml

[warning] 151-151: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)


[error] 151-151: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)


[error] 154-154: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)

🔇 Additional comments (35)
.github/workflows/unix.yaml (2)

151-154: The unpinned action references and credential persistence concerns were previously raised and intentionally skipped per project convention, as documented in the PR objectives.


146-165: LGTM!

CHANGELOG.md (1)

1-6: LGTM!

README.md (1)

19-19: LGTM!

oshi-common/src/main/resources/oshi.properties (1)

268-269: LGTM!

oshi-core/src/main/java/module-info.java (1)

5-5: LGTM!

Also applies to: 26-26

oshi-core/src/main/java/oshi/SystemInfo.java (1)

16-16: LGTM!

Also applies to: 25-25, 59-60, 128-129, 161-162

pom.xml (1)

822-822: LGTM!

Also applies to: 828-828

oshi-core/src/main/java/oshi/package-info.java (1)

35-35: LGTM!

src/site/markdown/index.md (1)

19-19: LGTM!

oshi-core/src/main/java/oshi/jna/platform/unix/BsdLibcLoader.java (1)

10-13: LGTM!

Also applies to: 16-17, 26-28

oshi-core/src/main/java/oshi/jna/platform/unix/FreeBsdLibc.java (1)

2-2: LGTM!

Also applies to: 19-19

oshi-core/src/main/java/oshi/jna/platform/unix/OpenBsdLibc.java (1)

2-2: LGTM!

Also applies to: 17-17

oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdCentralProcessor.java (1)

40-40: LGTM!

Also applies to: 114-117, 223-234

oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdComputerSystem.java (1)

2-2: LGTM!

Also applies to: 27-27

oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdFirmware.java (1)

2-2: LGTM!

Also applies to: 23-23

oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdGlobalMemory.java (1)

2-2: LGTM!

Also applies to: 23-23

oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdGraphicsCard.java (1)

22-22: LGTM!

oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSensors.java (1)

2-2: LGTM!

Also applies to: 21-21

oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdSoundCard.java (1)

2-2: LGTM!

Also applies to: 15-15, 23-23, 69-71

oshi-core/src/main/java/oshi/hardware/platform/unix/freebsd/FreeBsdUsbDevice.java (1)

11-11: LGTM!

Also applies to: 126-126

oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdNetworkParams.java (1)

2-2: LGTM!

Also applies to: 26-26, 47-47

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

77-83: LGTM!

oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdInternetProtocolStats.java (1)

40-42: LGTM!

Also applies to: 51-52

oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOSProcess.java (1)

463-465: LGTM!

oshi-core/src/main/java/oshi/software/os/unix/freebsd/FreeBsdOperatingSystem.java (1)

2-2: LGTM!

Also applies to: 241-241

oshi-core/src/main/java/oshi/jna/platform/unix/DragonFlyBsdLibc.java (1)

7-20: LGTM!

oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdCentralProcessor.java (1)

28-82: LGTM!

oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/DragonFlyBsdHardwareAbstractionLayer.java (1)

39-100: LGTM!

oshi-core/src/main/java/oshi/hardware/platform/unix/dragonflybsd/package-info.java (1)

5-8: LGTM!

oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/DragonFlyBsdOSThread.java (1)

44-53: LGTM!

Also applies to: 116-130, 132-168

oshi-core/src/main/java/oshi/util/platform/unix/dragonflybsd/package-info.java (1)

5-8: LGTM!

oshi-core/src/main/java/oshi/software/os/unix/dragonflybsd/package-info.java (1)

5-8: LGTM!

oshi-core/src/test/java/oshi/hardware/platform/shared/CentralProcessorTest.java (1)

166-167: LGTM!

oshi-core/src/test/java/oshi/software/os/shared/OperatingSystemTest.java (1)

87-91: LGTM!

Also applies to: 133-137, 425-429

Introduce BsdLibcLoader helper to load BSD libc via "c" (works on
both FreeBSD and DragonFly). Both FreeBsdLibc and DragonFlyBsdLibc
use this helper. DragonFlyBsdLibc now extends FreeBsdLibc, adding
only lwp_gettid().

Since FreeBsdLibc loads successfully on DragonFly, all FreeBSD
classes that use BsdSysctlUtil/FreeBsdLibc work on both platforms.
DragonFly HAL and OS now directly use FreeBSD implementations for
identical functionality (ComputerSystem, GlobalMemory, Sensors,
CentralProcessor, FileSystem, InternetProtocolStats, NetworkParams,
PowerSource, HWDiskStore, GraphicsCard, SoundCard, UsbDevice).

Only DragonFly-specific code remains:
- DragonFlyBsdLibc (lwp_gettid)
- HAL (wiring)
- OperatingSystem (ps keywords, thread ID, PID filter, boot time)
- OSProcess (args/env via /proc, start time from /proc/status)
- OSThread (different thread columns)
- ProcstatUtil (fstat-based, not procstat)

Also: remove owner guard from DragonFly CI job, fix FreeBSD job name.
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.

Support DragonFly BSD

1 participant