#loops #losetup

loopdev-erikh

Setup and control loop devices

1 unstable release

0.5.0 Nov 10, 2023

#38 in #loops

Download history 530/week @ 2024-06-24 921/week @ 2024-07-01 999/week @ 2024-07-08 1109/week @ 2024-07-15 1097/week @ 2024-07-22 1058/week @ 2024-07-29 1056/week @ 2024-08-05 968/week @ 2024-08-12 1192/week @ 2024-08-19 797/week @ 2024-08-26 671/week @ 2024-09-02 697/week @ 2024-09-09 609/week @ 2024-09-16 936/week @ 2024-09-23 1375/week @ 2024-09-30 1092/week @ 2024-10-07

4,062 downloads per month

MIT license

20KB
278 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.6MB
~39K SLoC