Repository navigation
Split Linux Who driver into common/JNA/FFM, add FFM utmpx and systemd - #3137
Conversation
…emd bindings Split the Linux Who session-query driver across all three modules and create FFM equivalents for the JNA utmpx and systemd native bindings. ### oshi-common - oshi.util.driver.unix.Who — Removed Linux-specific date parsing and PlatformEnum dependency; now Unix-only. Made matchUnix public for cross-package use. - oshi.util.driver.linux.Who — New. Parses who command output trying Linux date format first, falling back to matchUnix per line. Serves as command-line fallback for all Linux native implementations. ### oshi-core - oshi.driver.linux.Who → oshi.driver.linux.WhoJNA — Renamed. Fallback references updated to oshi.util.driver.linux.Who.queryWho(). - LinuxOperatingSystem.getSessions() — Uses WhoJNA.queryUtxent() and oshi.util.driver.linux.Who.queryWho() (no longer delegates to super.getSessions()). ### oshi-core-java25 - LinuxLibcFunctions — Added Linux utmpx struct layout (384 bytes, verified against glibc header), LOGIN_PROCESS/USER_PROCESS constants, setutxent/getutxent/endutxent FFM bindings, and field accessor methods. - SystemdFunctions — New. FFM bindings for sd_get_sessions, sd_session_get_username, sd_session_get_start_time, sd_session_get_tty, sd_session_get_remote_host, with lazy loading and availability check. - oshi.driver.linux.WhoFFM — New. FFM port of the Linux Who driver: systemd native (gated by oshi.os.linux.allowsystemd), utmpx via FFM, systemd file fallback, who command fallback. - LinuxOperatingSystemFFM — Added getSessions() override using WhoFFM.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
📜 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). (9)
🧰 Additional context used🧠 Learnings (7)📚 Learning: 2026-04-06T04:45:51.516ZApplied to files:
📚 Learning: 2026-03-29T20:01:06.452ZApplied to files:
📚 Learning: 2026-04-06T04:45:47.644ZApplied to files:
📚 Learning: 2026-04-10T22:44:32.055ZApplied to files:
📚 Learning: 2026-04-05T05:40:45.797ZApplied to files:
📚 Learning: 2026-04-03T02:07:47.621ZApplied to files:
📚 Learning: 2026-03-29T20:03:00.830ZApplied to files:
🔇 Additional comments (5)
📝 WalkthroughWalkthroughIntroduces Linux-specific session query implementations for both FFM (Java 21+) and JNA backends, adds native systemd and utmpx bindings, creates a shared Linux "who" command utility class, and refactors existing Unix Who utility by extracting Linux-specific logic and exposing helper methods. Changes
Sequence Diagram(s)sequenceDiagram
participant App as Application
participant OS as LinuxOperatingSystem<br/>(FFM/JNA)
participant Query as WhoFFM/Who
participant Systemd as Systemd FFM
participant Utmpx as utmpx (libc FFM)
participant File as /run/systemd/<br/>sessions
participant Fallback as Who Command
App->>OS: getSessions()
alt USE_WHO_COMMAND enabled
OS->>Query: Who.queryWho()
Query->>Query: Parse 'who' output
Query-->>OS: List<OSSession>
else FFM Backend
OS->>Query: WhoFFM.queryUtxent()
alt Systemd Available & Configured
Query->>Systemd: sdGetSessions()
Systemd-->>Query: session IDs
loop Each Session
Query->>Systemd: sdSessionGetUsername/Time/TTY
Systemd-->>Query: session details
end
else No Systemd Results
Query->>Utmpx: setutxent()
loop Each utmpx Entry
Query->>Utmpx: getutxent()
Utmpx-->>Query: entry data
Query->>Query: Filter & Validate
end
Utmpx->>Query: endutxent()
end
alt No Sessions Found
Query->>File: Read /run/systemd/sessions
File-->>Query: session files
Query->>Query: Parse key/value
end
alt Still No Sessions
Query->>Fallback: Who.queryWho()
Fallback-->>Query: List<OSSession>
end
Query-->>OS: List<OSSession>
end
OS-->>App: List<OSSession>
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3137 +/- ##
============================================
+ Coverage 61.14% 61.91% +0.77%
Complexity 12 12
============================================
Files 39 39
Lines 2329 2329
Branches 407 407
============================================
+ Hits 1424 1442 +18
+ Misses 786 768 -18
Partials 119 119 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Split the Linux Who session-query driver across all three modules and create FFM equivalents for the JNA utmpx and systemd native bindings.
oshi-common
oshi-core
oshi-core-java25
Summary by CodeRabbit
Refactor
Tests