P3: dep-crate warnings fixed + udev-shim driver-binding view

- redox-driver-sys: drop unused 'use std::sync::Once' in pci.rs and
  underscore-prefix unused 'vendor' in lookup_hid_quirks. Zero
  crate-local warnings (libredox's 2 are upstream fork code).
- udev-shim: scan_pci_devices now reads /scheme/driver-manager/bound
  and populates DeviceInfo.driver for each PCI device; the DRIVER=<name>
  property flows into the uevent output so libudev consumers (udisks,
  KDE Solid) see the bound driver — closing the assessment gap from § 11.
This commit is contained in:
2026-07-24 14:30:47 +09:00
parent 4b76070a77
commit 459b6f7b38
3 changed files with 39 additions and 3 deletions
@@ -764,6 +764,6 @@ bitflags::bitflags! {
}
/// Look up USB HID quirks for a vendor/product pair.
pub fn lookup_hid_quirks(vendor: u16, _product: u16) -> HidQuirkFlags {
pub fn lookup_hid_quirks(_vendor: u16, _product: u16) -> HidQuirkFlags {
HidQuirkFlags::empty()
}
@@ -33,6 +33,7 @@ pub struct DeviceInfo {
pub devnode: String,
pub scheme_target: String,
pub symlinks: Vec<String>,
pub driver: Option<String>,
}
impl DeviceInfo {
@@ -59,6 +60,7 @@ impl DeviceInfo {
devnode: devnode.to_string(),
scheme_target: scheme_target.to_string(),
symlinks: Vec::new(),
driver: None,
}
}
@@ -167,6 +169,7 @@ pub fn classify_pci_device(bus: u8, dev: u8, func: u8) -> DeviceInfo {
devnode: String::new(),
scheme_target: String::new(),
symlinks: Vec::new(),
driver: None,
}
}
@@ -330,6 +333,7 @@ mod tests {
devnode: String::new(),
scheme_target: String::new(),
symlinks: vec![],
driver: None,
};
assert_eq!(dev.id_path(), "pci-0000:02:00.0");
}
@@ -392,6 +396,7 @@ mod tests {
devnode: "/dev/dri/card0".to_string(),
scheme_target: "display:display".to_string(),
symlinks: vec![],
driver: None,
};
let props = device_properties(&dev);
let prop_map: std::collections::HashMap<&str, &str> = props
@@ -464,6 +469,7 @@ mod tests {
devnode: "/dev/dri/card0".to_string(),
scheme_target: "display:display".to_string(),
symlinks: vec!["/dev/dri/by-path/pci-0000:02:00.0-card".to_string()],
driver: None,
};
let info = format_device_info(&dev);
assert!(info.starts_with("P=/devices/pci/0000:02:00.0\n"));
@@ -531,6 +537,9 @@ pub fn device_properties(dev: &DeviceInfo) -> Vec<(String, String)> {
"PCI_CLASS".to_string(),
format!("0x{:02x}{:02x}", dev.class_code, dev.subclass),
));
if let Some(driver) = &dev.driver {
props.push(("DRIVER".to_string(), driver.clone()));
}
}
if dev.subsystem == Subsystem::Input {
@@ -1,4 +1,4 @@
use std::collections::BTreeMap;
use std::collections::{BTreeMap, HashMap};
use std::fs::File;
use std::io::Read;
@@ -104,9 +104,16 @@ impl UdevScheme {
}
}
let driver_map = read_driver_manager_bound();
pci_slots.sort_unstable();
for (bus, dev, func) in pci_slots {
self.devices.push(classify_pci_device(bus, dev, func));
let mut info = classify_pci_device(bus, dev, func);
let slot_str = format!("{:04}--{:02}--{:02}.{}", 0, bus, dev, func);
if let Some(driver) = driver_map.get(&slot_str) {
info.driver = Some(driver.clone());
}
self.devices.push(info);
}
if scheme_registered("input") {
@@ -810,3 +817,23 @@ fn storage_symlink(dev: &DeviceInfo, kernel_name: &str) -> Option<String> {
fn content_len_u64(content: String) -> u64 {
u64::try_from(content.len()).unwrap_or(u64::MAX)
}
fn read_driver_manager_bound() -> HashMap<String, String> {
let mut map = HashMap::new();
match std::fs::read_to_string("/scheme/driver-manager/bound") {
Ok(body) => {
for line in body.lines() {
let line = line.trim();
if line.is_empty() {
continue;
}
let parts: Vec<&str> = line.splitn(2, " -> ").collect();
if parts.len() == 2 {
map.insert(parts[0].to_string(), parts[1].to_string());
}
}
}
Err(_) => {}
}
map
}