From 2680c0bfee2455f422bdc6bc13afe06f2ad9ff8d Mon Sep 17 00:00:00 2001 From: David Gibson Date: Wed, 13 Oct 2021 15:04:57 +1100 Subject: [PATCH] rustjail: Provide useful context on device node creation errors create_devices() within the rustjail module is responsible for creating device nodes within the (inner) containers. Errors that occur here will be propagated up, but are likely to be low level failures of mknod() - e.g. ENOENT or EACCESS - which won't be very useful without context when reported all the way up to the runtime without the context of what we were trying to do. Add some anyhow context information giving the details of the device we were trying to create when it failed. Signed-off-by: David Gibson --- src/agent/rustjail/src/mount.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/agent/rustjail/src/mount.rs b/src/agent/rustjail/src/mount.rs index 8c021cce3..4ec36761a 100644 --- a/src/agent/rustjail/src/mount.rs +++ b/src/agent/rustjail/src/mount.rs @@ -832,14 +832,14 @@ fn create_devices(devices: &[LinuxDevice], bind: bool) -> Result<()> { let op: fn(&LinuxDevice) -> Result<()> = if bind { bind_dev } else { mknod_dev }; let old = stat::umask(Mode::from_bits_truncate(0o000)); for dev in DEFAULT_DEVICES.iter() { - op(dev)?; + op(dev).context(format!("Creating container device {:?}", dev))?; } for dev in devices { if !dev.path.starts_with("/dev") || dev.path.contains("..") { let msg = format!("{} is not a valid device path", dev.path); bail!(anyhow!(msg)); } - op(dev)?; + op(dev).context(format!("Creating container device {:?}", dev))?; } stat::umask(old); Ok(())