- Rust 100%
The function currently writes a value of 16 to lo_flags, but 16 is the value for
LO_FLAGS_DIRECT_IO. The intended flag, LO_FLAGS_PARTSCAN, has a value of 8 [0].
It looks like this was a regression when deprecating attach_with_partscan[1],
which had the correct value of 8. That same commit introduces this bug.
[0] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/loop.h?h=v5.15#n25
[1]
|
History
|
|
|---|---|---|
| losetup | ||
| src | ||
| tests | ||
| .gitignore | ||
| .travis-deploy | ||
| .travis.yml | ||
| build.rs | ||
| Cargo.toml | ||
| LICENSE | ||
| README.md | ||
| Vagrantfile | ||
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.