Skip to content
/ loopdev Public
forked from mdaffin/loopdev

A rust library to setup and control loopback devices

License

Notifications You must be signed in to change notification settings

tiann/loopdev

This branch is 1 commit ahead of, 4 commits behind mdaffin/loopdev:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

b6ca5e3 · Feb 20, 2023
Oct 30, 2022
Feb 20, 2023
Nov 11, 2022
Jun 1, 2021
Oct 4, 2018
Oct 27, 2021
Oct 31, 2022
May 20, 2016
Oct 27, 2021
Oct 27, 2021
May 31, 2021

Repository files navigation

Build Status crates.io

loopdev

Setup and control loop devices.

Provides rust interface with similar functionality to the Linux utility losetup.

Examples

use loopdev::LoopControl;
let lc = LoopControl::open().unwrap();
let ld = lc.next_free().unwrap();

println!("{}", ld.path().unwrap().display());

ld.attach_file("disk.img").unwrap();
// ...
ld.detach().unwrap();

Development

Running The Tests Locally

Unfortunately the tests require root only syscalls and thus must be run as root. There is little point in mocking out these syscalls as I want to test they actually function as expected and if they were to be mocked out then the tests would not really be testing anything useful.

A vagrant file is provided that can be used to create an environment to safely run these tests locally as root. With Vagrant and VirtualBox installed you can do the following to run the tests.

vagrant up
vagrant ssh
sudo -i
cd /vagrant
cargo test

Note that the tests are built with root privileges, but since vagrant maps this directory back to the host as your normal user there is minimal issues with this. At worst the vagrant box will become trashed and can be rebuilt in minutes.

About

A rust library to setup and control loopback devices

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 98.7%
  • Shell 1.3%