Repository navigation
Report Linux device names under /dev with a custom dev path - #3873
Conversation
oshi.util.dev.path says where OSHI reads the device filesystem, for
example a host's /dev mounted at /host/dev in a container. The kernel,
udev, /proc/mounts and pvs still name devices /dev/..., so names built
from the configured root never matched them:
- JNA/FFM compared udev devnodes (/dev/...) with DevPath.LOOP/RAM/DM
(/host/dev/...), so loop and RAM disks were listed and device-mapper
devices were treated as plain disks.
- The /proc/mounts map, LVM pvs filter, file store "Local Disk"
description and by-uuid lookup filtered on the configured root and
matched nothing.
- Native-free named disks and partitions /host/dev/..., unlike JNA/FFM.
DevPath gains NODE_ROOT ("/dev/") with toFilePath/toNodeName. DM, LOOP,
RAM and MAPPER are now name prefixes under NODE_ROOT; DEV and
DISK_BY_UUID remain read paths. Every backend reports /dev/ names and
reads files under the configured root. JNA/FFM need no source change:
their filters already use the DevPath name constants.
Verified in a privileged Linux container with an LVM volume and a loop
filesystem and /dev bound at /host/dev: all three backends now report
the same disks, partitions, UUIDs and logical volumes as with the
default root. Not exercised: JNA/FFM LVM partitions (no udev database
in the container) and pvs.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3873 +/- ##
============================================
- Coverage 81.18% 81.17% -0.01%
+ Complexity 923 915 -8
============================================
Files 726 726
Lines 26756 26756
Branches 4567 4566 -1
============================================
- Hits 21722 21720 -2
Misses 2800 2800
- Partials 2234 2236 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
oshi.util.dev.path(#2626, for #2609) sets where OSHI reads the device filesystem, for example a host's/devmounted at/host/devin a Kubernetes pod. The kernel, udev,/proc/mountsandpvsstill name devices/dev/.... Names built from the configured root therefore never matched those sources, and Linux disk and file store reporting broke under a custom root:/dev/...) were compared withDevPath.LOOP/RAM/DM(/host/dev/...), so loop and RAM disks were listed and device-mapper devices were treated as plain disks./proc/mountsmount-point map, the LVMpvsfilter, the file storeLocal Diskdescription and thedisk/by-uuidlookup filtered on the configured root and matched nothing. Partitions lost their mount points, file stores lost their UUIDs and were described asMount Point, andgetLogicalVolume()reported/host/dev/dm-0./host/dev/sda, unlike JNA and FFM.Change
Device names are always reported under
/dev/, so they matchOSFileStore.getVolume()and/proc/mounts. The configured root is used only to read files.DevPathgainsNODE_ROOT(/dev/) andtoFilePath()/toNodeName().DM,LOOP,RAMandMAPPERare now name prefixes underNODE_ROOT;DEVandDISK_BY_UUIDremain read paths. (oshi.utilis not semver-locked; the values differ only under a custom root.)oshi-commonusesNODE_ROOTfor names, and converts paths when it readsby-uuidand mapper symlinks under the configured root.DevPathname constants.Native-free users with a custom root will see
/dev/sdainstead of/host/dev/sda. That output never matched any mount point, so the CHANGELOG entry is under Bug Fixes.Testing
DevPathTest, with itsmodule-info.testopens. Existing native-free disk fixtures now name devices byNODE_ROOT.oshi-commontests pass on Linux (Docker) and macOS. The-Perror-pronebuild, checkstyle, forbidden APIs and javadoc all pass./devbind-mounted at/host/dev. Theby-uuidand mapper links were made by hand, since there is no udev daemon. On master, all three backends showed the faults above. On this branch, JNA, FFM and native-free report the same disks, partitions, UUIDs, logical volumes and descriptions with-Doshi.util.dev.path=/host/devas with the default root.Not exercised: JNA/FFM LVM partition entries (no udev database in the container) and
pvs.Summary by CodeRabbit
/dev/prefix, including for loop, RAM, device-mapper, partition, physical-volume, and UUID-based file-system entries.