Commit b88ab7f
Port remaining Linux JNA classes to FFM (#3121)
* Port remaining Linux JNA classes to FFM
- Refactor LinuxCentralProcessor: move getSystemLoadAverage to base
using /proc/loadavg fallback; JNA subclass uses getloadavg() with
fallback to super; FFM subclass uses LinuxLibcFunctions with fallback
- Refactor LinuxUsbDevice: rename to LinuxUsbDeviceJNA, create abstract
LinuxUsbDevice base with shared template method; LinuxUsbDeviceFFM
extends base using UdevFunctions
- Refactor LinuxFileSystem, LinuxNetworkParams, LinuxOSProcess,
LinuxOperatingSystem: extract abstract bases in oshi-core, add JNA
subclasses, add FFM subclasses in oshi-core-java25
- Add LinuxLibcFunctions FFM bindings: getpid, gettid, getloadavg,
sysinfo, statvfs, gethostname, getaddrinfo/freeaddrinfo, getrlimit
- Add ProcPath.LOADAVG constant
- Remove redundant getProcessCount override in LinuxOperatingSystemJNA
- Update LinuxHardwareAbstractionLayerJNA to use LinuxUsbDeviceJNA
* Fix LinuxLibcFunctions libc lookup and add CHANGELOG entry
Use LINKER.defaultLookup() instead of libraryLookup("c") to resolve
libc symbols. libraryLookup maps "c" to "libc.so" via
System.mapLibraryName, which fails on Linux where the actual soname
is "libc.so.6". libc is always linked into the JVM process so the
default lookup covers all its symbols without opening the library
by name.
* Address CodeRabbit review findings
- LinuxLibcFunctions: add SYS_GETTID mappings for riscv64/loongarch64
(178), s390x (236), ppc64le (207); log unknown arch at debug level
rather than silently using a potentially wrong value
- LinuxLibcFunctions: sysinfoProcs returns int via Short.toUnsignedInt
to correctly expose the unsigned 16-bit procs field
- LinuxLibcFunctions: gethostname size_t parameter changed from
JAVA_INT to JAVA_LONG to match LP64 Linux ABI; wrapper updated to
accept long
- LinuxNetworkParamsFFM: pass long literal to gethostname call
- LinuxNetworkParamsJNA: fix getaddrinfo error check from res > 0 to
res != 0 to catch negative EAI_SYSTEM codes; call freeaddrinfo()
explicitly to release C-allocated addrinfo memory (Addrinfo.close()
is a no-op for native allocations)
- LinuxUsbDeviceJNA: null-check udev_new() return before use
- LinuxOSProcessJNA: check getrlimit() return value; fall back to
getProcessOpenFileLimit() on failure
- LinuxOSProcessFFM: same getrlimit() return value check and fallback
* Address CodeRabbit review findings (round 2); revert USB class refactoring
- LinuxOperatingSystemJNA: fix unsigned short sign-extension in
getThreadCount via Short.toUnsignedInt
- LinuxOperatingSystemJNA/FFM: use createOSProcess() in getProcess()
- LinuxFileSystem: make getFileStoreMatching a non-static instance
method so queryStatvfs dispatches polymorphically; remove null-
instance overload
- LinuxOSFileStore: store LinuxFileSystem reference; call
fs.getFileStoreMatching() in updateAttributes() so statvfs is used
on refresh
- LinuxOSProcess: handle 'unlimited' and guard array bounds in
getProcessOpenFileLimit()
- Revert USB class refactoring (LinuxUsbDeviceJNA, abstract
LinuxUsbDevice base) back to master branch state; fix HAS_UDEV
import in LinuxUsbDevice to reference LinuxOperatingSystemJNA;
USB consolidation deferred to a follow-up PR
* Fix typo
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
---------
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>1 parent 180c940 commit b88ab7f
24 files changed
Lines changed: 1131 additions & 284 deletions
File tree
- oshi-core-java25/src/main/java/oshi
- ffm/linux
- hardware/platform/linux
- software/os/linux
- oshi-core/src/main/java/oshi
- hardware/platform/linux
- software/os/linux
- util/platform/linux
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
0 commit comments