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

#852 in Hardware support

Download history 2477/week @ 2024-03-28 2272/week @ 2024-04-04 1923/week @ 2024-04-11 2798/week @ 2024-04-18 3407/week @ 2024-04-25 1638/week @ 2024-05-02 1262/week @ 2024-05-09 1765/week @ 2024-05-16 816/week @ 2024-05-23 1936/week @ 2024-05-30 1912/week @ 2024-06-06 1590/week @ 2024-06-13 1559/week @ 2024-06-20 1211/week @ 2024-06-27 1499/week @ 2024-07-04 1642/week @ 2024-07-11

6,156 downloads per month
Used in 4 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–2.4MB
~35K SLoC