Skip to content

Add NetBSD platform support - #3307

Merged
dbwiddis merged 5 commits into
oshi:masterfrom
dbwiddis:netbsd-port
May 31, 2026
Merged

dbwiddis merged 5 commits into
oshi:masterfrom
dbwiddis:netbsd-port

Conversation

@dbwiddis

@dbwiddis dbwiddis commented May 30, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Add full NetBSD platform support to oshi-core (JNA implementation)
  • All tests pass on NetBSD 10.1 (vmactions/netbsd-vm in GitHub Actions)
  • JNA native library provided by pkgsrc java-jna package (libjnidispatch.so)

Key NetBSD-specific adaptations from OpenBSD

  • ps -L with lid keyword (not -H/tid) for thread/LWP display
  • /proc/PID/cmdline for process arguments (KERN_PROC_ARGS sysctl unavailable)
  • System.getenv() fallback for current process environment
  • machdep.cpu_brand and machdep.tsc_freq for CPU identification
  • _lwp_self() for thread IDs (not getthrid())
  • KERN_CP_TIME (51) with per-CPU via third MIB element
  • vmstat -s for memory and context switch stats (no Bcachestats struct)
  • readlink /proc/PID/cwd for process working directory
  • Space-separated hw.disknames (no colon suffixes like OpenBSD)
  • mount output with 6 fields (no DUID field like OpenBSD's mount -v)
  • netstat -bI/-iI for network stats (fewer columns than FreeBSD/OpenBSD)
  • iostat -d -I for disk I/O statistics

Known follow-up items

  • Disk I/O detailed stats (reads/writes/bytes) need iostat format verification
  • Network link speed always reports 0 (needs media status parsing)
  • getCurrentThread() shows state=INVALID (thread lookup refinement)
  • Disklabel partition ID format differs from OpenBSD (assertion relaxed)
  • Currently requires pkgsrc java-jna package for native library; may add helpful error message in future

Test plan

  • All oshi-common tests pass (930 tests, 0 failures)
  • All oshi-core tests pass (78 successful, 91 skipped, 0 real failures)
  • Context switches and interrupts show real values
  • Network traffic bytes/packets display correctly
  • Filesystem shows correct sizes and mount points
  • Disks listed individually with correct names
  • Verify disk I/O stats show non-zero values (follow-up)
  • Verify network speed detection (follow-up)

Summary by CodeRabbit

  • New Features

    • Added full NetBSD operating system support, enabling comprehensive hardware and OS information retrieval including processor, memory, disk storage, network interfaces, sensors, power sources, and process-level metrics.
  • Documentation

    • Updated supported platforms documentation to include NetBSD.

Copy OpenBSD platform implementation to NetBSD with key adaptations:
- ps uses -L flag with 'lid' keyword (not -H/tid) for LWP display
- Process args from /proc/PID/cmdline (KERN_PROC_ARGS sysctl fails)
- System.getenv() for current process environment variables
- CPU info from machdep.cpu_brand and machdep.tsc_freq
- _lwp_self() for thread IDs (not getthrid())
- KERN_CP_TIME (51) with per-CPU via third MIB element
- vmstat -s for memory stats (no Bcachestats struct)
- readlink /proc/PID/cwd for working directory
- fstat -p for open file count
- CTL_VM=2, removed OpenBSD-specific VFS/buffer cache code

GitHub Actions workflow uses vmactions/netbsd-vm with JNA from pkgsrc.
All tests pass (0 failures in both oshi-common and oshi-core).
@coderabbitai

coderabbitai Bot commented May 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds complete NetBSD 10.1 support to OSHI by implementing platform-specific hardware, OS, and process introspection across ~3,300 lines of new code spanning module exports, JNA bindings, hardware drivers, operating system abstractions, filesystem/network stacks, comprehensive testing, and GitHub Actions CI infrastructure.

Changes

NetBSD Platform Support

Layer / File(s) Summary
Platform wiring and SystemInfo dispatch
oshi-core/src/main/java/module-info.java, oshi-core/src/main/java/oshi/SystemInfo.java
Module exports oshi.util.platform.unix.netbsd; SystemInfo adds NETBSD cases to createOperatingSystem() and createHardware() factory methods returning NetBSD-specific implementations.
JNA bindings, sysctl/fstat utilities, Disklabel parser
oshi-core/src/main/java/oshi/jna/platform/unix/NetBsdLibc.java, oshi-core/src/main/java/oshi/util/platform/unix/netbsd/NetBsdSysctlUtil.java, oshi-core/src/main/java/oshi/util/platform/unix/netbsd/FstatUtil.java, oshi-core/src/main/java/oshi/driver/unix/netbsd/disk/Disklabel.java, oshi-core/src/main/java/oshi/util/platform/unix/netbsd/package-info.java, oshi-core/src/test/java/module-info.test
NetBsdLibc defines sysctl identifiers, CPU states, and Timeval structure. NetBsdSysctlUtil provides JNA-backed and command-line fallback overloads for sysctl queries. FstatUtil exposes process working directory and open file counts. Disklabel parses disk labels and partitions with fallback to df output. Module tests gain --add-opens directives for NetBSD packages.
Hardware abstraction layer and core components
oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdHardwareAbstractionLayer.java, oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdCentralProcessor.java, oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdComputerSystem.java, oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdFirmware.java, oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdGlobalMemory.java, oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdVirtualMemory.java
HAL wires all hardware components. CentralProcessor queries sysctl for vendor/model/stepping, dmesg for topology/cache/features, vmstat for context/interrupt counters, kern.cp_time for load ticks, and libc getloadavg. ComputerSystem exposes manufacturer/model/serial/UUID via sysctl. Firmware parses dmesg for BIOS vendor/version/date. GlobalMemory and VirtualMemory combine vmstat, sysctl, and swap info to compute memory metrics.
Hardware sensors, power, disk, and peripheral drivers
oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdSensors.java, oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdPowerSource.java, oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdHWDiskStore.java, oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdGraphicsCard.java, oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdUsbDevice.java, oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdSoundCard.java, oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdNetworkIF.java, oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/package-info.java
NetBsdSensors parses systat for CPU temperature, fan RPMs, voltage. NetBsdPowerSource queries systat for battery/sensor info, apm for state/charging/time remaining. NetBsdHWDiskStore enumerates disks via sysctl, Disklabel, and iostat. Graphics/USB/sound cards parsed from pcidump/usbdevs/dmesg output. Network interfaces updated via netstat byte/packet/error counters.
Operating system, processes, filesystem, and network
oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdOperatingSystem.java, oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdOSProcess.java, oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdOSThread.java, oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdFileSystem.java, oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdOSFileStore.java, oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdInternetProtocolStats.java, oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdNetworkParams.java, oshi-core/src/main/java/oshi/software/os/unix/netbsd/package-info.java
NetBsdOperatingSystem caches boot time via sysctl, derives version info, discovers processes/threads/services via ps and /etc/rc.d. NetBsdOSProcess parses ps output, reads command line from /proc//cmdline, environment via sysctl, working directory via fstat, affinity via schedctl. NetBsdOSThread exposes per-thread metrics including CPU time, faults, context switches. NetBsdFileSystem enumerates mounts via mount/df, applies include/exclude filters, provides inode stats. NetBsdInternetProtocolStats wraps netstat TCP/UDP queries. NetworkParams discovers IPv4/IPv6 gateways via route commands.
Tests and CI integration
oshi-core/src/test/java/oshi/driver/unix/netbsd/disk/DisklabelTest.java, oshi-core/src/test/java/oshi/util/platform/unix/netbsd/FstatUtilTest.java, oshi-core/src/test/java/oshi/hardware/platform/shared/CentralProcessorTest.java, .github/workflows/unix.yaml, CHANGELOG.md, FAQ.md, README.md, src/site/markdown/index.md, oshi-core/src/main/java/oshi/driver/unix/netbsd/disk/package-info.java
DisklabelTest validates disk enumeration and partition metadata when elevated. FstatUtilTest checks open file counts and working directory retrieval. CentralProcessorTest includes NETBSD in processor group assertions. GitHub Actions adds NetBSD 10.1 VM test job with Maven and JNA configuration. Documentation adds NetBSD 10.1 to supported platforms across CHANGELOG, FAQ, README, and site docs.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

  • oshi/oshi#3057: NetBSD FileSystem/OSFileStore implementations use the local/localOnly file-store matching flow introduced in this PR.
  • oshi/oshi#3303: Both PRs update the same platform-dispatch code paths in SystemInfo and module-info exports, but for different BSD targets (NetBSD vs DragonFly BSD).
  • oshi/oshi#3181: Both PRs modify JPMS module-access configuration (module-info.java exports and module-info.test add-opens directives) in the same module-system area.

Suggested reviewers

  • mprins

🐰 NetBSD hops into the fold,
A platform brave and bold,
Disk labels parsed with care,
System info everywhere! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add NetBSD platform support' clearly summarizes the main change—adding comprehensive NetBSD support across hardware and software abstraction layers.
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 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1079 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.45%. Comparing base (6c6c5bc) to head (5453bfa).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
.../oshi/software/os/unix/netbsd/NetBsdOSProcess.java 0.00% 170 Missing ⚠️
...e/platform/unix/netbsd/NetBsdCentralProcessor.java 0.00% 148 Missing ⚠️
...software/os/unix/netbsd/NetBsdOperatingSystem.java 0.00% 87 Missing ⚠️
...rdware/platform/unix/netbsd/NetBsdPowerSource.java 0.00% 74 Missing ⚠️
...hardware/platform/unix/netbsd/NetBsdUsbDevice.java 0.00% 61 Missing ⚠️
...oshi/software/os/unix/netbsd/NetBsdFileSystem.java 0.00% 59 Missing ⚠️
...a/oshi/software/os/unix/netbsd/NetBsdOSThread.java 0.00% 59 Missing ⚠️
...rdware/platform/unix/netbsd/NetBsdHWDiskStore.java 0.00% 58 Missing ⚠️
...hi/util/platform/unix/netbsd/NetBsdSysctlUtil.java 0.00% 51 Missing ⚠️
...n/java/oshi/driver/unix/netbsd/disk/Disklabel.java 0.00% 50 Missing ⚠️
... and 14 more
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3307      +/-   ##
============================================
- Coverage     76.38%   71.45%   -4.94%     
  Complexity       76       76              
============================================
  Files           410      433      +23     
  Lines         15838    16917    +1079     
  Branches       2546     2752     +206     
============================================
- Hits          12098    12088      -10     
- Misses         2258     3340    +1082     
- Partials       1482     1489       +7     
Flag Coverage Δ
linux 38.15% <0.00%> (-2.60%) ⬇️
macos 38.45% <0.00%> (-2.64%) ⬇️
windows 45.90% <0.00%> (-3.21%) ⬇️

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: 10

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/SystemInfo.java (1)

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

Add NetBSD to the supported-platforms list in the class Javadoc.

The module-info.java header was updated to include NetBSD, but this class-level Javadoc still omits it from the supported-platform enumeration.

📝 Proposed doc fix
- * all OSHI platforms (Windows, macOS, Linux, Android, DragonFly BSD, FreeBSD, OpenBSD, Solaris, AIX). Android is routed
+ * all OSHI platforms (Windows, macOS, Linux, Android, DragonFly BSD, FreeBSD, NetBSD, OpenBSD, Solaris, AIX). Android is
+ * routed
🤖 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/SystemInfo.java` at line 61, Update the class
Javadoc for SystemInfo to include "NetBSD" in the supported-platforms
enumeration so it matches the module-info.java change; locate the class-level
comment above the SystemInfo class declaration and add "NetBSD" to the list of
OSHI platforms (e.g., in the sentence that currently enumerates Windows, macOS,
Linux, Android, DragonFly BSD, FreeBSD, OpenBSD, Solaris, AIX).
🧹 Nitpick comments (4)
oshi-core/src/test/java/oshi/driver/unix/netbsd/disk/DisklabelTest.java (1)

27-35: 💤 Low value

Hoist the elevation check out of the loop.

new NetBsdOperatingSystem() and isElevated() are recomputed on every device iteration. Constructing the OS object and re-evaluating elevation per disk is unnecessary work; compute once before the loop.

♻️ Proposed refactor
         String[] devices = NetBsdSysctlUtil.sysctl("hw.disknames", "").trim().split("\\s+");
+        boolean elevated = new NetBsdOperatingSystem().isElevated();
         for (String device : devices) {
             String diskName = device;
             Quartet<String, String, Long, List<HWPartition>> diskdata = Disklabel.getDiskParams(diskName);
             // First 3 only available with elevation
-            if (new NetBsdOperatingSystem().isElevated()) {
+            if (elevated) {
                 assertThat("Disk label is not null", diskdata.getA(), not(nullValue()));
                 assertThat("Disk duid is not null", diskdata.getB(), not(nullValue()));
                 assertThat("Disk size is nonnegative", diskdata.getC().longValue(), greaterThanOrEqualTo(0L));
             }
         }
🤖 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/test/java/oshi/driver/unix/netbsd/disk/DisklabelTest.java`
around lines 27 - 35, The elevation check and OS construction are repeated for
each device; create a single NetBsdOperatingSystem instance and call
isElevated() once before iterating over devices, store the result in a boolean
(e.g., boolean elevated = new NetBsdOperatingSystem().isElevated()), then inside
the for loop call Disklabel.getDiskParams(diskName) as before and only run the
three assertThat checks when elevated is true; update references to
NetBsdOperatingSystem and isElevated() accordingly and remove the per-iteration
new NetBsdOperatingSystem() call.
oshi-core/src/test/java/oshi/util/platform/unix/netbsd/FstatUtilTest.java (1)

22-34: 💤 Low value

Prefer @EnabledIfSystemProperty over a runtime guard for consistency.

DisklabelTest gates with @EnabledIfSystemProperty(named = "os.name", matches = "(?i)netbsd"), which reports the test as skipped off-platform. Here the inner if makes the test pass with zero assertions on non-NetBSD hosts, hiding the fact that it never actually ran. Aligning with the annotation approach is clearer.

♻️ Proposed refactor
+import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
 import org.junit.jupiter.api.Test;

 import oshi.SystemInfo;
-import oshi.util.PlatformEnum;

 /**
  * Test general utility methods for {`@link` FstatUtil}.
  */
+@EnabledIfSystemProperty(named = "os.name", matches = "(?i)netbsd")
 class FstatUtilTest {

     `@Test`
     void testFstat() {
-        if (PlatformEnum.getCurrentPlatform().equals(NETBSD)) {
-            int pid = new SystemInfo().getOperatingSystem().getProcessId();
-            assertThat("Number of open files must be nonnegative", FstatUtil.getOpenFiles(pid),
-                    is(greaterThanOrEqualTo(0L)));
-            assertThat("Cwd should not be empty", FstatUtil.getCwd(pid), is(not(emptyString())));
-        }
+        int pid = new SystemInfo().getOperatingSystem().getProcessId();
+        assertThat("Number of open files must be nonnegative", FstatUtil.getOpenFiles(pid),
+                is(greaterThanOrEqualTo(0L)));
+        assertThat("Cwd should not be empty", FstatUtil.getCwd(pid), is(not(emptyString())));
     }
 }
🤖 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/test/java/oshi/util/platform/unix/netbsd/FstatUtilTest.java`
around lines 22 - 34, Replace the runtime platform guard inside
FstatUtilTest.testFstat with a JUnit conditional annotation: remove the if
(PlatformEnum.getCurrentPlatform().equals(NETBSD)) { ... } block and annotate
the testFstat method with `@EnabledIfSystemProperty`(named = "os.name", matches =
"(?i)netbsd") so the test is reported as skipped off-platform; keep the existing
assertions calling FstatUtil.getOpenFiles(pid) and FstatUtil.getCwd(pid), and
add the necessary import for
org.junit.jupiter.api.condition.EnabledIfSystemProperty.
oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdFileSystem.java (1)

22-25: 💤 Low value

Class Javadoc references "FreeBSD" instead of "NetBSD".

🤖 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/netbsd/NetBsdFileSystem.java`
around lines 22 - 25, The class Javadoc incorrectly refers to FreeBSD; update
the documentation on the NetBsdFileSystem class (NetBsdFileSystem.java) to
reference NetBSD instead of FreeBSD and adjust the description so it correctly
describes that this NetBsdFileSystem contains oshi.software.os.OSFileStore
entries representing storage pools/devices/partitions/volumes or other
NetBSD-specific file storage entities.
oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdPowerSource.java (1)

85-86: 💤 Low value

Clarify ||/&& precedence in voltage detection (readability only)

In NetBsdPowerSource the condition at lines 85-86 is already evaluated as split[0].contains("volt0") || (split[0].contains("volt") && line.contains("current")), and the same expression is used in OpenBsdPowerSource, so behavior should already match the intended grouping—adding explicit parentheses just improves clarity.

♻️ Suggested clarification
-                if (split[0].contains("volt0") || split[0].contains("volt") &amp;&amp; line.contains("current")) {
+                if (split[0].contains("volt0") || (split[0].contains("volt") &amp;&amp; line.contains("current"))) {
                     psVoltage = ParseUtil.parseDoubleOrDefault(split[1], -1d);
🤖 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/netbsd/NetBsdPowerSource.java`
around lines 85 - 86, The boolean expression in NetBsdPowerSource that detects
voltage is ambiguous; make the grouping explicit by changing the condition in
the voltage-detection branch (the if that checks split[0].contains("volt0") ||
split[0].contains("volt") && line.contains("current")) to use parentheses so it
reads split[0].contains("volt0") || (split[0].contains("volt") &&
line.contains("current")), mirroring the grouping used in OpenBsdPowerSource to
improve readability without changing behavior.
🤖 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/netbsd.yaml:
- Around line 4-8: The NetBSD workflow (.github/workflows/netbsd.yaml) only
triggers on workflow_dispatch and push to branch "netbsd-port", so NetBSD CI
won't run for pull_request or after merges to master; update the workflow
triggers to include pull_request (e.g., add a pull_request key alongside push)
or alternatively add the NetBSD job into the main PR workflow
(.github/workflows/pr.yaml) so NetBSD tests run on PRs and master pushes.

In `@oshi-core/src/main/java/oshi/driver/unix/netbsd/disk/Disklabel.java`:
- Around line 69-70: The code parses "total sectors" into an int via
ParseUtil.getFirstIntValue and stores it in totalSectors, which overflows for
large disks; change the parsing to use a long (e.g., call a
ParseUtil.getFirstLongValue or extract the numeric token and call
ParseUtil.parseLongOrDefault) and store the result in a long-typed totalSectors
variable, then use that long when computing totalBytes (totalSectors *
bytesPerSector) and returning the Quartet so the disk-size computation uses a
long instead of int; update any related variable declarations and the return
expression in the methods referencing totalSectors (and keep Quartet type
parameters consistent).

In
`@oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdCentralProcessor.java`:
- Around line 250-262: queryVmStats currently assigns contextSwitches and
interrupts as long but uses ParseUtil.getFirstIntValue (returns int) causing
truncation; fix by parsing the numeric tokens as long instead of int: either add
a ParseUtil.getFirstLongValue/getNthLongValue helper and call it from
queryVmStats, or in queryVmStats extract the numeric substring from each
matching vmstat line (e.g., via the same regex/utility used elsewhere) and use
Long.parseLong(...) before assigning to contextSwitches and interrupts so the
cumulative vmstat -s counters do not overflow.
- Line 151: The cpu regexes in initProcessorCounts use over-escaped patterns
("cpu(\\\\d+)") and Matcher.matches(), so they never match dmesg lines and leave
cpuMap empty; change the Pattern strings to use a single-escape form
("cpu(\\d+).*: ((ARM|AMD|Intel|Apple).+)" and the generic line "cpu(\\d+).*:
(.+)"), and use Matcher.find() (not matches()) when extracting groups to
populate cpuMap/physProcs and enable cache detection; separately, in
queryVmStats replace ParseUtil.getFirstIntValue(...) (which uses
Integer.parseInt and overflows) with a long-capable parser (e.g.,
ParseUtil.getFirstLongValue(...) or Long.parseLong on the first token) for
counters like context-switches/interrupts so values exceeding Integer.MAX_VALUE
are handled correctly.

In
`@oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdFirmware.java`:
- Around line 52-56: In the NetBsdFirmware.java block that handles lines
starting with "bios0: vendor" (inside the parse loop in class NetBsdFirmware),
the current vendor assignment vendor = line.split("vendor")[1].trim() captures
the entire remainder; change it to isolate only the manufacturer token
immediately after "vendor" (stop at the next whitespace or the keyword
"version"). Replace the assignment with logic that trims and extracts the first
token after "vendor" (or use a regex that captures vendor as the group between
"vendor" and either "\\s" or "\\sversion"), mirror the approach used in
OpenBsdFirmware, and ensure the extracted vendor is trimmed and stripped of any
surrounding quotes.

In
`@oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdHWDiskStore.java`:
- Around line 83-84: The code intended to scale bytesPerSector by 1.5 before
snapping to the nearest lower power of two, but due to operator precedence the
expression in Long.highestOneBit(bytesPerSector + bytesPerSector >> 1) evaluates
incorrectly; change the arithmetic to explicitly compute 1.5× (e.g.,
bytesPerSector + (bytesPerSector >> 1)) before calling Long.highestOneBit so the
scaling works as intended in NetBsdHWDiskStore (variable bytesPerSector, call to
Long.highestOneBit).

In
`@oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdVirtualMemory.java`:
- Around line 53-61: The methods NetBsdVirtualMemory#getSwapPagesIn and
`#getSwapPagesOut` currently multiply the vmstat counters by global.getPageSize(),
returning bytes instead of the required page counts; change both to return the
raw counters from swapInfo.get().getC() and swapInfo.get().getD() (without
multiplying by global.getPageSize()), ensuring the return types remain long and
no unit conversion is applied.

In
`@oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdNetworkParams.java`:
- Around line 21-24: The getIpv6DefaultGateway() implementation calls
ExecutingCommand.runNative with the IPv4/unspecified family command; change the
command string in NetBsdNetworkParams.getIpv6DefaultGateway() to include the
IPv6 family flag (use "route -n get -inet6 default") so searchGateway parses the
IPv6 route output; ensure you only modify the argument passed to
ExecutingCommand.runNative in the getIpv6DefaultGateway() method.

In `@oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdOSProcess.java`:
- Around line 441-448: In updateThreadCount(), the computed thread count from
ExecutingCommand.runNative("ps -axLwwo lid -p " + getProcessID()) is being
overwritten by an unconditional this.threadCount = 1; remove that unconditional
assignment and instead set this.threadCount to the computed value
(threadList.size() - 1) when the list is non-empty, otherwise default to 1;
update the method (updateThreadCount) to use threadList and getProcessID(), and
ensure threadCount is only set once based on the ps output or the safe default.
- Line 173: In queryEnvironmentVariables() in NetBsdOSProcess, guard against
ARGMAX <= 0 before allocating JNA Memory and CloseableSizeTByReference: if
ARGMAX is less than or equal to zero (it’s set to 0 when KERN_ARGMAX fails)
immediately return Collections.emptyMap() to avoid calling new Memory(ARGMAX) /
new CloseableSizeTByReference(ARGMAX) which throws IllegalArgumentException;
reference ARGMAX, queryEnvironmentVariables(), Memory, and
CloseableSizeTByReference when applying this early-return check.

---

Outside diff comments:
In `@oshi-core/src/main/java/oshi/SystemInfo.java`:
- Line 61: Update the class Javadoc for SystemInfo to include "NetBSD" in the
supported-platforms enumeration so it matches the module-info.java change;
locate the class-level comment above the SystemInfo class declaration and add
"NetBSD" to the list of OSHI platforms (e.g., in the sentence that currently
enumerates Windows, macOS, Linux, Android, DragonFly BSD, FreeBSD, OpenBSD,
Solaris, AIX).

---

Nitpick comments:
In
`@oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdPowerSource.java`:
- Around line 85-86: The boolean expression in NetBsdPowerSource that detects
voltage is ambiguous; make the grouping explicit by changing the condition in
the voltage-detection branch (the if that checks split[0].contains("volt0") ||
split[0].contains("volt") && line.contains("current")) to use parentheses so it
reads split[0].contains("volt0") || (split[0].contains("volt") &&
line.contains("current")), mirroring the grouping used in OpenBsdPowerSource to
improve readability without changing behavior.

In `@oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdFileSystem.java`:
- Around line 22-25: The class Javadoc incorrectly refers to FreeBSD; update the
documentation on the NetBsdFileSystem class (NetBsdFileSystem.java) to reference
NetBSD instead of FreeBSD and adjust the description so it correctly describes
that this NetBsdFileSystem contains oshi.software.os.OSFileStore entries
representing storage pools/devices/partitions/volumes or other NetBSD-specific
file storage entities.

In `@oshi-core/src/test/java/oshi/driver/unix/netbsd/disk/DisklabelTest.java`:
- Around line 27-35: The elevation check and OS construction are repeated for
each device; create a single NetBsdOperatingSystem instance and call
isElevated() once before iterating over devices, store the result in a boolean
(e.g., boolean elevated = new NetBsdOperatingSystem().isElevated()), then inside
the for loop call Disklabel.getDiskParams(diskName) as before and only run the
three assertThat checks when elevated is true; update references to
NetBsdOperatingSystem and isElevated() accordingly and remove the per-iteration
new NetBsdOperatingSystem() call.

In `@oshi-core/src/test/java/oshi/util/platform/unix/netbsd/FstatUtilTest.java`:
- Around line 22-34: Replace the runtime platform guard inside
FstatUtilTest.testFstat with a JUnit conditional annotation: remove the if
(PlatformEnum.getCurrentPlatform().equals(NETBSD)) { ... } block and annotate
the testFstat method with `@EnabledIfSystemProperty`(named = "os.name", matches =
"(?i)netbsd") so the test is reported as skipped off-platform; keep the existing
assertions calling FstatUtil.getOpenFiles(pid) and FstatUtil.getCwd(pid), and
add the necessary import for
org.junit.jupiter.api.condition.EnabledIfSystemProperty.
🪄 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: 2a8b8f6d-f0fb-4ee7-aa1f-0120dd72d641

📥 Commits

Reviewing files that changed from the base of the PR and between 6c6c5bc and 1ba7fb5.

📒 Files selected for processing (35)
  • .github/workflows/netbsd.yaml
  • oshi-core/src/main/java/module-info.java
  • oshi-core/src/main/java/oshi/SystemInfo.java
  • oshi-core/src/main/java/oshi/driver/unix/netbsd/disk/Disklabel.java
  • oshi-core/src/main/java/oshi/driver/unix/netbsd/disk/package-info.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdCentralProcessor.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdComputerSystem.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdFirmware.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdGlobalMemory.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdGraphicsCard.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdHWDiskStore.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdHardwareAbstractionLayer.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdNetworkIF.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdPowerSource.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdSensors.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdSoundCard.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdUsbDevice.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdVirtualMemory.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/package-info.java
  • oshi-core/src/main/java/oshi/jna/platform/unix/NetBsdLibc.java
  • oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdFileSystem.java
  • oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdInternetProtocolStats.java
  • oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdNetworkParams.java
  • oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdOSFileStore.java
  • oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdOSProcess.java
  • oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdOSThread.java
  • oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdOperatingSystem.java
  • oshi-core/src/main/java/oshi/software/os/unix/netbsd/package-info.java
  • oshi-core/src/main/java/oshi/util/platform/unix/netbsd/FstatUtil.java
  • oshi-core/src/main/java/oshi/util/platform/unix/netbsd/NetBsdSysctlUtil.java
  • oshi-core/src/main/java/oshi/util/platform/unix/netbsd/package-info.java
  • oshi-core/src/test/java/module-info.test
  • oshi-core/src/test/java/oshi/driver/unix/netbsd/disk/DisklabelTest.java
  • oshi-core/src/test/java/oshi/hardware/platform/shared/CentralProcessorTest.java
  • oshi-core/src/test/java/oshi/util/platform/unix/netbsd/FstatUtilTest.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: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: JMH Benchmarks, windows-latest
  • GitHub Check: JMH Benchmarks, ubuntu-latest
  • GitHub Check: JMH Benchmarks, macos-latest
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • 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/netbsd/NetBsdFirmware.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdVirtualMemory.java
  • oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdInternetProtocolStats.java
  • oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdNetworkParams.java
  • oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdFileSystem.java
  • oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdOSFileStore.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdHardwareAbstractionLayer.java
  • oshi-core/src/main/java/oshi/software/os/unix/netbsd/package-info.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdGlobalMemory.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdSoundCard.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdComputerSystem.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdNetworkIF.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdGraphicsCard.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdPowerSource.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdSensors.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdUsbDevice.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/package-info.java
  • oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdOSThread.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdHWDiskStore.java
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdCentralProcessor.java
  • oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdOperatingSystem.java
  • oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdOSProcess.java
🪛 zizmor (1.25.2)
.github/workflows/netbsd.yaml

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

(artipacked)


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

(unpinned-uses)


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

(unpinned-uses)

🔇 Additional comments (25)
oshi-core/src/main/java/module-info.java (1)

27-27: LGTM!

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

132-133: LGTM!

Also applies to: 167-168

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

31-38: LGTM!

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

165-173: LGTM!

.github/workflows/netbsd.yaml (1)

15-18: 💤 Low value

Keep workflow action references as version tags (no SHA pinning elsewhere).
Repo workflows consistently use tag-based uses: (e.g., actions/checkout@v6, vmactions/*@v1``) and none are pinned to commit SHAs, so this aligns with the existing convention for .github/workflows/netbsd.yaml.

oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdOperatingSystem.java (1)

63-243: LGTM!

oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdOSThread.java (1)

116-174: LGTM!

oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdInternetProtocolStats.java (1)

17-25: LGTM!

oshi-core/src/main/java/oshi/software/os/unix/netbsd/NetBsdOSFileStore.java (1)

24-34: LGTM!

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

15-68: LGTM!

oshi-core/src/main/java/oshi/util/platform/unix/netbsd/NetBsdSysctlUtil.java (1)

43-178: LGTM!

oshi-core/src/main/java/oshi/util/platform/unix/netbsd/FstatUtil.java (1)

26-49: LGTM!

oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdComputerSystem.java (1)

23-79: LGTM!

oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdGlobalMemory.java (1)

23-77: LGTM!

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

1-9: LGTM!

oshi-core/src/main/java/oshi/driver/unix/netbsd/disk/package-info.java (1)

1-9: LGTM!

oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdSensors.java (1)

44-86: LGTM!

oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdHWDiskStore.java (1)

108-116: ⚡ Quick win

Verify iostat -d -I field mapping for read/write counts and byte accounting in NetBsdHWDiskStore.

The inline comment says name KB/t xfrs MB, but the code assigns setReads(split[1]) (looks like KB/t) and setWrites(split[2]) (looks like xfrs), while readBytes/writeBytes are both computed as half of the MB value. Confirm NetBSD 10.1 iostat -d -I’s exact column order and whether separate read/write columns (especially MB and transfer counts) exist, then update the split[] indices and how readBytes/writeBytes are derived.

oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdPowerSource.java (1)

26-83: LGTM!

Also applies to: 87-147

oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdGraphicsCard.java (1)

46-107: LGTM!

oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdNetworkIF.java (1)

28-77: LGTM!

oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdUsbDevice.java (1)

42-152: LGTM!

oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdSoundCard.java (1)

50-88: LGTM!

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

1-8: LGTM!

oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdHardwareAbstractionLayer.java (1)

30-91: LGTM!

Comment thread .github/workflows/netbsd.yaml Resolved
Output fixes:
- Context switch: NetBSD vmstat says "CPU context switches" (capital)
  and "device interrupts"
- Disk names: space-separated without colon suffixes
- Filesystem: NetBSD mount output has 6 fields (no DUID), fix javadoc
- Network: Create NetBSD-specific NetworkIF for netstat format
- Disk I/O: Use iostat -d -I instead of OpenBSD's systat -ab iostat
- Clean up workflow: remove debug, ensure procfs mounted

Code review fixes:
- Disklabel: parse totalSectors as long to avoid int overflow
- CentralProcessor: fix over-escaped regex patterns (\\\\d -> \\d),
  parse vmstat counters as long instead of int
- Firmware: extract only first token after "vendor"
- HWDiskStore: fix operator precedence in bytesPerSector calculation
- VirtualMemory: getSwapPagesIn/Out return page counts not bytes
- NetworkParams: use -inet6 flag for IPv6 gateway lookup
- OSProcess: fix unconditional threadCount=1 overwrite, guard
  ARGMAX<=0 before Memory allocation in env query
- SystemInfo: add NetBSD to supported platforms javadoc
- PowerSource: add explicit parentheses in boolean expression
- Tests: use @EnabledIfSystemProperty, hoist isElevated() check

@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

🧹 Nitpick comments (1)
.github/workflows/netbsd.yaml (1)

34-63: ⚡ Quick win

Consider removing or conditionalizing the debug disk investigation block before final merge.

This 30-line debug section will clutter CI logs in production workflows. Since the PR objectives note this is for verifying iostat implementation details, you may want to remove it once verification is complete, or make it conditional (e.g., triggered by an environment variable or workflow input parameter).

🤖 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/netbsd.yaml around lines 34 - 63, The debug disk
investigation block (the series of iostat, dmesg, disklabel, and sysctl
commands) should be removed or gated behind a conditional so it doesn't always
pollute CI logs; either delete the whole block or wrap it so it runs only when a
flag is set (e.g., an environment variable DEBUG_DISK or a workflow input like
debug_disk == 'true') and check that condition before executing the
iostat/dmesg/disklabel/sysctl commands; ensure the conditional uses GitHub
Actions workflow inputs or env variables and reference the existing iostat,
dmesg, disklabel, and sysctl invocations when making the change.
🤖 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/netbsd.yaml:
- Line 65: The CI step currently runs the test command "./mvnw clean test -B
-Djacoco.skip=true || true" which masks failures; remove the trailing "|| true"
so the step runs "./mvnw clean test -B -Djacoco.skip=true" and will fail the job
on test failures, ensuring the workflow correctly fails when tests fail.

---

Nitpick comments:
In @.github/workflows/netbsd.yaml:
- Around line 34-63: The debug disk investigation block (the series of iostat,
dmesg, disklabel, and sysctl commands) should be removed or gated behind a
conditional so it doesn't always pollute CI logs; either delete the whole block
or wrap it so it runs only when a flag is set (e.g., an environment variable
DEBUG_DISK or a workflow input like debug_disk == 'true') and check that
condition before executing the iostat/dmesg/disklabel/sysctl commands; ensure
the conditional uses GitHub Actions workflow inputs or env variables and
reference the existing iostat, dmesg, disklabel, and sysctl invocations when
making the change.
🪄 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: 0eed049b-6f97-421d-88ba-ca1320b20c68

📥 Commits

Reviewing files that changed from the base of the PR and between f7423b5 and 0bc191a.

📒 Files selected for processing (1)
  • .github/workflows/netbsd.yaml
📜 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: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 11, macos-latest
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: JMH Benchmarks, macos-latest
  • GitHub Check: JMH Benchmarks, windows-latest
  • GitHub Check: JMH Benchmarks, ubuntu-latest
  • GitHub Check: Analyze (java)

Comment thread .github/workflows/netbsd.yaml Resolved
@dbwiddis
dbwiddis force-pushed the netbsd-port branch 2 times, most recently from ed3c925 to 852f99c Compare May 30, 2026 19:25

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

🤖 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/hardware/platform/unix/netbsd/NetBsdHWDiskStore.java`:
- Around line 102-117: The iostat -x parser in NetBsdHWDiskStore.java
incorrectly requires split.length >= 10 and uses wrong token indices for the
write-side and transfer time; change the guard to split.length >= 9, read writes
from split[6] (w/s) instead of split[7], read writeKBPerTransfer from split[5]
instead of split[6], and sum transfer time using split[3] and split[7] (read
time + write time) when calling
setReads/setWrites/setReadBytes/setWriteBytes/setTransferTime so the tokens
align with the header layout.
- Around line 125-126: The current queryIostat() returns output of "iostat -x"
which yields rate/averaged counters; update queryIostat() to call iostat in
running-totals mode (e.g., "iostat -Ix" or "iostat -x -I") so the disk
read/write counters map semantically to the cumulative reads/writes used by
NetBsdHWDiskStore.updateAttributes(); after changing the command, verify and
adjust any parsing logic in updateAttributes() that consumes iostat columns in
case the -I flag changes column positions or units so getReads/getWrites and
derived getReadBytes/getWriteBytes remain correct.
🪄 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: c33f6c7d-1e17-4aad-b644-0a86693f02e4

📥 Commits

Reviewing files that changed from the base of the PR and between 0bc191a and ed3c925.

📒 Files selected for processing (1)
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdHWDiskStore.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: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: JMH Benchmarks, ubuntu-latest
  • GitHub Check: JMH Benchmarks, macos-latest
  • GitHub Check: JMH Benchmarks, windows-latest
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Analyze (java)
🧰 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/netbsd/NetBsdHWDiskStore.java

@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/netbsd/NetBsdHWDiskStore.java (1)

32-32: ⚡ Quick win

Consider making the iostat supplier static to avoid redundant command executions.

Since queryIostat() returns output for all disks, each instance maintaining its own memoized supplier causes redundant iostat -x -I executions when getDisks() iterates through devices and calls updateAttributes() on each. A static supplier would let all instances share one cached result.

♻️ Proposed refactor
-    private final Supplier<List<String>> iostat = memoize(NetBsdHWDiskStore::queryIostat, defaultExpiration());
+    private static final Supplier<List<String>> IOSTAT = memoize(NetBsdHWDiskStore::queryIostat, defaultExpiration());

Then update line 101 to use IOSTAT.get() instead of iostat.get().

🤖 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/netbsd/NetBsdHWDiskStore.java`
at line 32, The instance field iostat should be changed to a static memoized
Supplier so all NetBsdHWDiskStore instances share one cached iostat result:
replace the instance field Supplier<List<String>> iostat =
memoize(NetBsdHWDiskStore::queryIostat, defaultExpiration()) with a static final
Supplier<List<String>> IOSTAT = memoize(NetBsdHWDiskStore::queryIostat,
defaultExpiration()), and then update usages (e.g., in updateAttributes and any
calls from getDisks) to call IOSTAT.get() instead of iostat.get() so the command
output is executed once and shared across instances.
🤖 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/netbsd/NetBsdHWDiskStore.java`:
- Line 32: The instance field iostat should be changed to a static memoized
Supplier so all NetBsdHWDiskStore instances share one cached iostat result:
replace the instance field Supplier<List<String>> iostat =
memoize(NetBsdHWDiskStore::queryIostat, defaultExpiration()) with a static final
Supplier<List<String>> IOSTAT = memoize(NetBsdHWDiskStore::queryIostat,
defaultExpiration()), and then update usages (e.g., in updateAttributes and any
calls from getDisks) to call IOSTAT.get() instead of iostat.get() so the command
output is executed once and shared across instances.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 928fa4cf-c16c-4565-82c5-a5249bbb3024

📥 Commits

Reviewing files that changed from the base of the PR and between 852f99c and f820303.

📒 Files selected for processing (1)
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdHWDiskStore.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: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: JMH Benchmarks, ubuntu-latest
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: JMH Benchmarks, macos-latest
  • GitHub Check: JMH Benchmarks, windows-latest
  • GitHub Check: Analyze (java)
🧰 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/netbsd/NetBsdHWDiskStore.java
🔇 Additional comments (3)
oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdHWDiskStore.java (3)

43-95: LGTM!


126-128: LGTM!


115-116: Reconcile NetBSD iostat -x -I byte calculation with the MB column totals.

NetBSD’s iostat -x -I outputs running total values, and the MB fields are total megabytes transferred (not interval averages). The current code derives bytes from KB/t * xfr and multiplies by 1024, which may diverge if NetBSD’s KB/t/xfr and the printed MB totals use different base units or rounding. Verify NetBSD’s definitions/units for KB/t, xfr, and the MB columns; if MB is the authoritative running total, compute bytes from split[4]/split[8] (with the correct MB→bytes base).

- Disk size: Parse dmesg for "bytes/sect x sectors" (physical disks)
  and "blocks at offset" (wedge devices like dk0, dk1)
- Disk I/O: Use iostat -x -I for cumulative per-device extended stats
- Fix field count (9 fields) and column indices for write stats
- Disk model: Only match SCSI-style "<Vendor, Model, Rev>" from dmesg
  (not virtio feature flags in angle brackets)
- Affinity: Return all-CPUs mask since NetBSD has no cpuset command

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

♻️ Duplicate comments (1)
.github/workflows/netbsd.yaml (1)

62-62: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

|| true still masks test failures

This is still unresolved from earlier feedback: at Line 62, || true makes the test step succeed even when Maven fails, so CI won’t catch regressions.

Suggested minimal fix
-            ./mvnw clean test -B -Djacoco.skip=true || true
+            ./mvnw clean test -B -Djacoco.skip=true
🤖 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/netbsd.yaml at line 62, The step running tests currently
appends "|| true" to the command string "./mvnw clean test -B -Djacoco.skip=true
|| true", which masks Maven test failures; remove the "|| true" from that
command so the step fails when "./mvnw clean test -B -Djacoco.skip=true" fails
(or alternatively, if you intended to allow failures, set the step's
continue-on-error flag explicitly instead of using "|| true").
🤖 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.

Duplicate comments:
In @.github/workflows/netbsd.yaml:
- Line 62: The step running tests currently appends "|| true" to the command
string "./mvnw clean test -B -Djacoco.skip=true || true", which masks Maven test
failures; remove the "|| true" from that command so the step fails when "./mvnw
clean test -B -Djacoco.skip=true" fails (or alternatively, if you intended to
allow failures, set the step's continue-on-error flag explicitly instead of
using "|| true").

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 02807e58-4a89-432a-a0d4-95112e0b2784

📥 Commits

Reviewing files that changed from the base of the PR and between 04da5d9 and 509176a.

📒 Files selected for processing (1)
  • .github/workflows/netbsd.yaml
📜 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: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
  • GitHub Check: JMH Benchmarks, windows-latest
  • GitHub Check: JMH Benchmarks, macos-latest
  • GitHub Check: JMH Benchmarks, ubuntu-latest
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Analyze (java)
🔇 Additional comments (1)
.github/workflows/netbsd.yaml (1)

34-60: LGTM!

- Thread count: Use ps -axo nlwp and sum values instead of ps -L
  (NetBSD's -L flag lists keywords, not LWPs)
- Per-process thread count: Use ps -o nlwp -p <pid>
- Thread details: Remove -L flag from ps commands (lid keyword in
  format spec is sufficient for NetBSD to show per-LWP rows)
- Affinity: Use schedctl -p <pid> to check CPU binding; fall back
  to all-CPUs mask when not bound
- Remove debug output from workflow
- Move NetBSD test job from standalone netbsd.yaml into unix.yaml
  alongside other BSD/Unix tests
- Fix AIX job name capitalization in unix.yaml
- Make iostat supplier static (shared across disk instances)
- Add NetBSD to supported platforms in README, FAQ, CHANGELOG,
  and site index

@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)
.github/workflows/unix.yaml (1)

9-9: 💤 Low value

Verify whether the netbsd-port branch trigger should remain after merge.

This trigger enables CI runs on pushes to the netbsd-port branch. Once this PR is merged to master, consider whether this branch trigger should be removed or retained for future NetBSD-specific development work.

🤖 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 at line 9, Check whether the extra push trigger
for the branch named "netbsd-port" should remain in the workflow's push branches
list; if NetBSD-specific CI is no longer needed remove the "netbsd-port" entry
from the push branches array, otherwise keep it (or add a comment explaining its
purpose) so future NetBSD work still triggers CI. Locate the "netbsd-port"
string in the workflow's push.branches configuration and either delete that
element or leave it with an inline comment describing why it must be preserved.
🤖 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 @.github/workflows/unix.yaml:
- Line 9: Check whether the extra push trigger for the branch named
"netbsd-port" should remain in the workflow's push branches list; if
NetBSD-specific CI is no longer needed remove the "netbsd-port" entry from the
push branches array, otherwise keep it (or add a comment explaining its purpose)
so future NetBSD work still triggers CI. Locate the "netbsd-port" string in the
workflow's push.branches configuration and either delete that element or leave
it with an inline comment describing why it must be preserved.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 6ae5c094-aae4-4e98-9c56-6d4817f27e51

📥 Commits

Reviewing files that changed from the base of the PR and between 53b1a79 and 5453bfa.

📒 Files selected for processing (6)
  • .github/workflows/unix.yaml
  • CHANGELOG.md
  • FAQ.md
  • README.md
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdHWDiskStore.java
  • src/site/markdown/index.md
✅ Files skipped from review due to trivial changes (4)
  • CHANGELOG.md
  • FAQ.md
  • src/site/markdown/index.md
  • README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • oshi-core/src/main/java/oshi/hardware/platform/unix/netbsd/NetBsdHWDiskStore.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: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 21, macos-latest
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Analyze (java)
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: JMH Benchmarks, ubuntu-latest
  • GitHub Check: JMH Benchmarks, macos-latest
  • GitHub Check: JMH Benchmarks, windows-latest
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
🧰 Additional context used
🪛 zizmor (1.25.2)
.github/workflows/unix.yaml

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

(artipacked)


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

(unpinned-uses)


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

(unpinned-uses)

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

109-109: LGTM!


168-189: LGTM!

@dbwiddis
dbwiddis merged commit 8b308de into oshi:master May 31, 2026
18 of 19 checks passed
@dbwiddis
dbwiddis deleted the netbsd-port branch June 6, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant