9 unstable releases (3 breaking)

Uses old Rust 2015

0.4.0 Oct 27, 2021
0.3.0 Jul 2, 2021
0.2.2 Jun 17, 2021
0.2.1 Oct 4, 2018
0.1.0 May 20, 2016

#4 in #loop

Download history 4337/week @ 2022-03-10 5205/week @ 2022-03-17 5873/week @ 2022-03-24 6179/week @ 2022-03-31 6459/week @ 2022-04-07 5577/week @ 2022-04-14 5689/week @ 2022-04-21 7780/week @ 2022-04-28 6302/week @ 2022-05-05 4944/week @ 2022-05-12 2011/week @ 2022-05-19 1990/week @ 2022-05-26 1832/week @ 2022-06-02 2598/week @ 2022-06-09 1874/week @ 2022-06-16 2139/week @ 2022-06-23

8,874 downloads per month
Used in fewer than 6 crates

MIT license

16KB
264 lines

Build Status crates.io

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–1.4MB
~30K SLoC