INNER CODE UNIT · Rust

setup_loopdev_file

openebs/mayastor · io-engine-tests/src/lib.rs:209

pub fn setup_loopdev_file(path: &str, sector_size: Option<u64>) -> String {
    let log_sec = sector_size.unwrap_or(512);

    let output = Command::new("losetup")
        .args(["-f", "--show", "-b", &format!("{log_sec}"), path])
        .output()
        .expect("failed exec losetup");
    assert!(output.status.success(), "{:#?}", output);
    // return the assigned loop device
    String::from_utf8(output.stdout).unwrap().trim().to_string()
}

/// Detach the provided loop device.
pub fn detach_loopdev(dev: &str) {
    let output = Command::new("losetup")
        .args(["-d", dev])
        .output()
        .expect("failed exec losetup");

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…