From 4ffed8096da9a58092447d15db20957c398dbfcb Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 16 Jun 2024 17:02:14 +0200 Subject: [PATCH] Move all drivers to /usr/lib/drivers This makes them harder to accidentally run them from the shell, which would not work. In the future this may also allow embedding the driver config in the driver executable itself without having to look at all non-driver executables too. --- initfs.toml | 10 +++++----- pcid/src/driver_handler.rs | 5 +++++ xhcid/drivers.toml | 6 +++--- xhcid/src/xhci/mod.rs | 5 +++++ 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/initfs.toml b/initfs.toml index c2a22fbaff..12290f9b38 100644 --- a/initfs.toml +++ b/initfs.toml @@ -5,21 +5,21 @@ name = "AHCI storage" class = 1 subclass = 6 -command = ["ahcid"] +command = ["/scheme/initfs/lib/drivers/ahcid"] # ided [[drivers]] name = "IDE storage" class = 1 subclass = 1 -command = ["ided"] +command = ["/scheme/initfs/lib/drivers/ided"] # nvmed [[drivers]] name = "NVME storage" class = 1 subclass = 8 -command = ["nvmed"] +command = ["/scheme/initfs/lib/drivers/nvmed"] [[drivers]] name = "virtio-blk" @@ -27,11 +27,11 @@ class = 1 subclass = 0 vendor = 0x1AF4 device = 0x1001 -command = ["virtio-blkd"] +command = ["/scheme/initfs/lib/drivers/virtio-blkd"] [[drivers]] name = "virtio-gpu" class = 3 vendor = 0x1AF4 device = 0x1050 -command = ["virtio-gpud"] +command = ["/scheme/initfs/lib/drivers/virtio-gpud"] diff --git a/pcid/src/driver_handler.rs b/pcid/src/driver_handler.rs index 7b3098101a..d34a067d3c 100644 --- a/pcid/src/driver_handler.rs +++ b/pcid/src/driver_handler.rs @@ -28,6 +28,11 @@ impl DriverHandler { let mut args = args.iter(); if let Some(program) = args.next() { + let program = if program.starts_with('/') { + program.to_owned() + } else { + "/usr/lib/drivers/".to_owned() + program + }; let mut command = Command::new(program); for arg in args { if arg.starts_with("$") { diff --git a/xhcid/drivers.toml b/xhcid/drivers.toml index 8b28dbd8d4..470ec06321 100644 --- a/xhcid/drivers.toml +++ b/xhcid/drivers.toml @@ -2,16 +2,16 @@ name = "SCSI over USB" class = 8 # Mass Storage class subclass = 6 # SCSI transparent command set -command = ["/bin/usbscsid", "$SCHEME", "$PORT", "$IF_PROTO"] +command = ["usbscsid", "$SCHEME", "$PORT", "$IF_PROTO"] [[drivers]] name = "USB HUB" class = 9 # HUB class subclass = -1 -command = ["/bin/usbhubd", "$SCHEME", "$PORT", "$IF_NUM"] +command = ["usbhubd", "$SCHEME", "$PORT", "$IF_NUM"] [[drivers]] name = "USB HID" class = 3 # HID class subclass = -1 -command = ["/bin/usbhidd", "$SCHEME", "$PORT", "$IF_NUM"] +command = ["usbhidd", "$SCHEME", "$PORT", "$IF_NUM"] diff --git a/xhcid/src/xhci/mod.rs b/xhcid/src/xhci/mod.rs index f42482f1ea..52b582adea 100644 --- a/xhcid/src/xhci/mod.rs +++ b/xhcid/src/xhci/mod.rs @@ -847,6 +847,11 @@ impl Xhci { info!("Loading subdriver \"{}\"", driver.name); let (command, args) = driver.command.split_first().ok_or(Error::new(EBADMSG))?; + let command = if command.starts_with('/') { + command.to_owned() + } else { + "/usr/lib/drivers/".to_owned() + command + }; let process = process::Command::new(command) .args( args.into_iter()