2 releases

0.5.1 Mar 4, 2024
0.5.0 Dec 20, 2023

#326 in Unix APIs

Download history 1974/week @ 2024-03-17 2871/week @ 2024-03-24 3050/week @ 2024-03-31 3577/week @ 2024-04-07 2592/week @ 2024-04-14 2937/week @ 2024-04-21 3132/week @ 2024-04-28 6018/week @ 2024-05-05 4098/week @ 2024-05-12 3741/week @ 2024-05-19 4252/week @ 2024-05-26 5110/week @ 2024-06-02 3527/week @ 2024-06-09 6207/week @ 2024-06-16 5863/week @ 2024-06-23 1589/week @ 2024-06-30

17,422 downloads per month
Used in 4 crates

MIT license

20KB
277 lines

loopdev

Setup and control loop devices.

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

Documentation

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.

Dependencies

~0–10MB
~81K SLoC