mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-25 15:02:45 +00:00
rustjail: Allow container devices in subdirectories
Many device nodes go directly under /dev, however some are conventionally placed in subdirectories under /dev. For example /dev/vfio/vfio or /dev/pts/ptmx. Currently, attempting to pass such a device into a Kata container will fail because mknod() will get an ENOENT because the parent directory is missing (or an equivalent error for bind_dev()). Correct that by making subdirectories as necessary in create_devices(). Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
9891efc61f
commit
175f9b06e9
@ -853,6 +853,9 @@ fn create_devices(devices: &[LinuxDevice], bind: bool) -> Result<()> {
|
|||||||
let msg = format!("{} is not a valid device path", dev.path);
|
let msg = format!("{} is not a valid device path", dev.path);
|
||||||
anyhow!(msg)
|
anyhow!(msg)
|
||||||
})?;
|
})?;
|
||||||
|
if let Some(dir) = path.parent() {
|
||||||
|
fs::create_dir_all(dir).context(format!("Creating container device {:?}", dev))?;
|
||||||
|
}
|
||||||
op(dev, path).context(format!("Creating container device {:?}", dev))?;
|
op(dev, path).context(format!("Creating container device {:?}", dev))?;
|
||||||
}
|
}
|
||||||
stat::umask(old);
|
stat::umask(old);
|
||||||
|
Loading…
Reference in New Issue
Block a user