2 releases

0.5.1 Mar 4, 2024
0.5.0 Dec 20, 2023

#590 in Unix APIs

Download history 6397/week @ 2024-07-21 5589/week @ 2024-07-28 4774/week @ 2024-08-04 6165/week @ 2024-08-11 6353/week @ 2024-08-18 7851/week @ 2024-08-25 5328/week @ 2024-09-01 5247/week @ 2024-09-08 3490/week @ 2024-09-15 3868/week @ 2024-09-22 3500/week @ 2024-09-29 3575/week @ 2024-10-06 5909/week @ 2024-10-13 3708/week @ 2024-10-20 6648/week @ 2024-10-27 4960/week @ 2024-11-03

21,401 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–8.5MB
~75K SLoC