linux: Canonicalize sysfs paths
For consistency with hotplug events
This commit is contained in:
parent
9458831e6e
commit
e09a4ef458
1 changed files with 5 additions and 7 deletions
|
|
@ -137,6 +137,8 @@ pub fn list_devices() -> impl MaybeFuture<Output = Result<impl Iterator<Item = D
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let path = path.canonicalize().ok()?;
|
||||||
|
|
||||||
probe_device(SysfsPath(path))
|
probe_device(SysfsPath(path))
|
||||||
.inspect_err(|e| warn!("{e}; ignoring device"))
|
.inspect_err(|e| warn!("{e}; ignoring device"))
|
||||||
.ok()
|
.ok()
|
||||||
|
|
@ -154,6 +156,8 @@ pub fn list_root_hubs() -> Result<impl Iterator<Item = DeviceInfo>, Error> {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let path = path.canonicalize().ok()?;
|
||||||
|
|
||||||
probe_device(SysfsPath(path))
|
probe_device(SysfsPath(path))
|
||||||
.inspect_err(|e| warn!("{e}; ignoring root hub"))
|
.inspect_err(|e| warn!("{e}; ignoring root hub"))
|
||||||
.ok()
|
.ok()
|
||||||
|
|
@ -164,14 +168,8 @@ pub fn list_buses() -> impl MaybeFuture<Output = Result<impl Iterator<Item = Bus
|
||||||
Ready((|| {
|
Ready((|| {
|
||||||
Ok(list_root_hubs()?.filter_map(|rh| {
|
Ok(list_root_hubs()?.filter_map(|rh| {
|
||||||
// get the parent by following the absolute symlink; root hub in /bus/usb is a symlink to a dir in parent bus
|
// get the parent by following the absolute symlink; root hub in /bus/usb is a symlink to a dir in parent bus
|
||||||
let parent_path = rh
|
let parent_path = rh.path.0.parent().map(|p| SysfsPath(p.to_owned()))?;
|
||||||
.path
|
|
||||||
.0
|
|
||||||
.canonicalize()
|
|
||||||
.ok()
|
|
||||||
.and_then(|p| p.parent().map(|p| SysfsPath(p.to_owned())))?;
|
|
||||||
|
|
||||||
debug!("Probing parent device {:?}", parent_path.0);
|
|
||||||
let driver = parent_path.readlink_attr_filename("driver").ok();
|
let driver = parent_path.readlink_attr_filename("driver").ok();
|
||||||
|
|
||||||
Some(BusInfo {
|
Some(BusInfo {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue