Add DragonFly BSD platform backend#134
Merged
Merged
Conversation
Add a native DragonFly BSD implementation for systemstat. The backend covers CPU load sampling, load average, memory, swap, boot time, mounts, network enumeration, and AC-power detection where available. DragonFly has different VM, swap, and statfs details from FreeBSD, so keep the implementation separate while reusing the shared BSD and Unix helpers where they fit. Unsupported hardware- or route-specific statistics still return Unsupported explicitly. Wire DragonFly into the platform module, lazy_static setup, and platform memory/swap data exports.
Add DragonFly implementations for interface statistics, CPU temperature, and ACPI battery life. Read interface counters with SIOCGIFDATA, temperature from hw.sensors sensor sysctls, and battery state from hw.acpi.battery sysctls when present. Keep unsupported results explicit for block device and socket statistics.
Implement DragonFly block device statistics through libdevstat and socket statistics through TCP/UDP PCB list sysctls. Normalize DragonFly link-local IPv6 addresses from getifaddrs by clearing embedded scope bits, and switch mounts to getfsstat so concurrent tests do not depend on getmntinfo static storage.
valpackett
reviewed
Jun 2, 2026
| /// (integers, `timeval`, ...). Reading a 4-byte kernel field into a zeroed | ||
| /// 8-byte `c_long` is safe on little-endian amd64: sysctl writes only the | ||
| /// kernel's actual length and the high bytes stay zero. DragonFly is amd64 | ||
| /// only, so this holds. |
Owner
There was a problem hiding this comment.
Heh, maybe this should be cfg()'d to little endian just in case someone decides to port dfly to aarch64be or something 🤣
valpackett
reviewed
Jun 2, 2026
|
|
||
| fn normalize_dragonfly_ipv6(addr: Ipv6Addr) -> Ipv6Addr { | ||
| let mut segments = addr.segments(); | ||
| if segments[0] & 0xffc0 == 0xfe80 { |
Owner
|
Very cool, thanks!! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a native DragonFly BSD backend and list DragonFly BSD as a supported platform.
The backend implements the
Platformsurface with DragonFly-specific data sources:kern.cp_timesgetloadavg(3)vm.stats.vm.*page countersvm.swap_size,vm.swap_anon_use, andvm.swap_cache_usekern.boottimegetfsstat(2)libdevstatSIOCGIFDATAhw.sensors.*.temp*A few Linux-specific fields that DragonFly does not expose directly are reported as zero, such as block merge counts and orphaned TCP sockets.
Testing
Tested on DragonFly BSD:
cargo clippystill reports the existingreader_utils::read_filedead-code warning and the existing needless lifetime warning insrc/data.rs; this PR does not introduce new clippy errors.