Skip to content

Commit

Permalink
Merge pull request #1603 from Furisto/dev-syscall
Browse files Browse the repository at this point in the history
Allow specification of syscall impl for devices
  • Loading branch information
Furisto authored Mar 1, 2023
2 parents 1836346 + a4e91e3 commit 60f0a25
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions crates/libcontainer/src/rootfs/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ impl Device {
}
}

pub fn new_with_syscall(syscall: Box<dyn Syscall>) -> Device {
Device { syscall }
}

pub fn create_devices<'a, I>(&self, rootfs: &Path, devices: I, bind: bool) -> Result<()>
where
I: IntoIterator<Item = &'a LinuxDevice>,
Expand Down Expand Up @@ -132,7 +136,7 @@ mod tests {
#[test]
fn test_bind_dev() {
let tmp_dir = TempDir::new("/tmp/test_bind_dev").unwrap();
let device = Device::new();
let device = Device::new_with_syscall(Box::<TestHelperSyscall>::default());
assert!(device
.bind_dev(
tmp_dir.path(),
Expand Down Expand Up @@ -162,7 +166,7 @@ mod tests {
#[test]
fn test_mknod_dev() {
let tmp_dir = TempDir::new("/tmp/test_mknod_dev").unwrap();
let device = Device::new();
let device = Device::new_with_syscall(Box::<TestHelperSyscall>::default());
assert!(device
.mknod_dev(
tmp_dir.path(),
Expand Down Expand Up @@ -210,7 +214,8 @@ mod tests {
#[test]
fn test_create_devices() {
let tmp_dir = TempDir::new("/tmp/test_create_devices").unwrap();
let device = Device::new();
let device = Device::new_with_syscall(Box::<TestHelperSyscall>::default());

let devices = vec![LinuxDeviceBuilder::default()
.path(PathBuf::from("/dev/null"))
.major(1)
Expand Down

0 comments on commit 60f0a25

Please sign in to comment.