Rifat Azad
4728e97f59
32-bit support
2025-05-18 10:08:27 +06:00
LoveSy
7a921f8d96
Revert "Use bindgen to generate loopdev bindings"
...
This reverts commit cb6dd02dd4 .
2024-02-05 14:54:36 +08:00
tiann
b6ca5e3ea1
Wait for ueventd to create loop device on Android
2023-02-20 10:00:36 +08:00
Felix Obenhuber
64a8ddbe1c
Add LoopControl::add ( #56 )
...
* Add LoopControl::add
Add LoopControl::add for adding/creating new loop devices via the
LOOP_CTL_ADD ioctl.
* Fixup the tests for creating new loop devs
It did not work for me as it counted the 'loop-control' file as an extra one so never failed with the file already existing.
Co-authored-by: Michael Daffin <michael@daffin.io>
2022-11-11 00:19:23 +00:00
Michael Daffin
99a366219a
Adds a test for part_scan support ( #55 )
2022-10-31 00:49:58 +00:00
Michael Daffin
d2f96c2856
Updates losetup deps and adds partscan option ( #54 )
...
Also fixes some other issues with the arguments.
2022-10-30 22:24:10 +00:00
Michael Daffin
9438762ef1
Add error docs and some fixes for clippy pendantic lints ( #53 )
2022-10-30 00:41:21 +00:00
Michael Daffin
1b66a5cec9
Run cargo fmt over the project ( #52 )
...
To make things more consistant with the recent changes to the edition
2022-10-29 23:02:58 +00:00
player-two
d9fb0c5c57
Fix the AttachOptions.part_scan function ( #50 )
...
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] 1ec9826012
Co-authored-by: player-two <>
2022-10-29 22:48:27 +00:00
Michael Daffin
d04dc379de
Upgrade to 2021 edition ( #51 )
2022-10-29 22:37:41 +00:00
mulkieran
2f5763ff71
Generalize some test code for multiple architectures ( #49 )
...
* Run rustfmt with current stable
Signed-off-by: mulhern <amulhern@redhat.com>
* Add try_into() call to convert size
On some architectures, off_t is i32.
Signed-off-by: mulhern <amulhern@redhat.com>
* Change signature of create_backing_file
Adapt caller's signatures. No signatures other than those of the direct
callers need to be adapted.
Signed-off-by: mulhern <amulhern@redhat.com>
Signed-off-by: mulhern <amulhern@redhat.com>
2022-10-10 07:53:48 +00:00
mulkieran
5ba76236aa
Remove an unused crate ( #48 )
...
Signed-off-by: mulhern <amulhern@redhat.com>
Signed-off-by: mulhern <amulhern@redhat.com>
2022-09-21 12:59:06 +01:00
banditopazzo
0c80659ada
fix: bump bindgen version ( #47 )
2022-09-21 12:58:11 +01:00
Michael Daffin
79d471558e
Bumps version to 0.4.0 ( #45 )
...
Due to minimum rust version bump.
Also fixes links to travis in the README.
2021-10-27 13:17:37 +00:00
Michael Daffin
067b633487
Bumps deps and ubuntu version in vagrant ( #44 )
...
* Bumps deps and ubuntu version in vagrant
Fixes some issues caused by this:
- we now get a warning about null pointer derefs caused by bindgen, these are now suppressed until an upstream fix is released
- tests now run serially in the CI system and it is recommended to do the same locally with
- tests now use /dev/loop3 as ubuntu 20.04 already uses 0-2 for snap
- clang added to vagrant
- remove verbose flags in travis
- bumps minimum supported rust version to 1.50.0
2021-10-27 13:12:41 +00:00
klhowell
16e7567908
When creating a read-only loopdev, do not request write access to the backing file. ( #43 )
2021-10-12 13:15:05 +01:00
jsen-
5e7cbb3108
add support for musl ( #42 )
2021-09-03 09:35:55 +00:00
Josh Triplett
7efea6b311
Disable most features of bindgen to reduce dependencies ( #41 )
...
By default, bindgen depends on everything needed to build the bindgen
command-line tool, such as clap and its various dependencies. Disable
default-features on bindgen and just enable the minimum required
features. This reduces loopdev's full dependency tree from 54 crates to
39 crates.
2021-08-09 15:38:18 +01:00
Michael Daffin
8453a6d984
Removes deprecated methods ( #40 )
...
* Removes deprecated methods
* Bumps version to 0.3.0
2021-07-02 18:26:22 +00:00
Michael Daffin
0108b3c741
Puts direct_io support behind a feature flag ( #39 )
...
Fixes #38
* Puts direct_io support behind a feature flag
* Bumps minimum version in travis
2021-06-29 00:15:18 +00:00
Michael Daffin
14af6ff6f2
Remove cleanup in travis
2021-06-17 10:31:46 +01:00
Michael Daffin
afd76e2126
Updates cargo token
2021-06-17 10:04:07 +01:00
Michael Daffin
8f4d2c6176
Removes target dir in travis
...
To stop the permission denied error we get when it tries to clean up the build dir and causing the whole pipeline to fail
2021-06-17 01:08:48 +01:00
Michael Daffin
bc3d02854d
Revert "Bump patch version for release"
...
This reverts commit 75899b02f0 .
2021-06-17 00:07:08 +01:00
Michael Daffin
75899b02f0
Bump patch version for release
2021-06-16 23:57:39 +01:00
Michael Daffin
19e8b82825
Remove mut from with and AttachOptions to make it consistant with the other methods
2021-06-01 10:45:06 +01:00
Michael Daffin
534b5a4f13
Updates documentation to use disk.img instead of test.img and adds an extra module example with the options
2021-06-01 10:45:06 +01:00
Felix Obenhuber
87a6cb2ec4
Add read_only, autoclear and direct IO
...
Allow passing the read only and autoclear flag when attaching a backing
file. Allow to pass a raw fd instead of a Path when attaching. Add a fn
to set the direct IO flag.
2021-06-01 09:51:55 +01:00
Felix Obenhuber
ef2132a4a5
Replace LoopDevice::metadata with major and minor
...
Instead of exposing `metadata` add two function to `LoopDevice` that
allow access to the the `major` and `minor` number of the device.
2021-05-31 20:13:02 +01:00
Felix Obenhuber
576a69d005
Add metadata for a LoopDevice
...
Getting the `Metadata` is usefull to access the major/minor number of
the device that is needed when using the loopdev in combination with
device-mapper.
2021-05-31 12:31:31 +01:00
Felix Obenhuber
795985823f
Implement AsRawFd and IntoRawFd for LoopControl and LoopDevice
...
Getting the raw fd of loop control can be neccecary because the
`next_free` and `attach` operation is (unfortunately) not atomic. The fd
can be used to acquire a `flock`.
Add `IntoRawFd` for LoopDevice.
2021-05-31 12:31:31 +01:00
Felix Obenhuber
fa340933ac
Bionics ioctl signature differs from glibc
...
Bionics ioctrl takes a i32 as request instead of a u64 on glibc. Add a
type based on the target_os and convert the request parameter
accordingly.
2021-05-31 11:40:36 +01:00
Felix Obenhuber
cb6dd02dd4
Use bindgen to generate loopdev bindings
...
Add a build.rs to generate Rust bindings for "linux/loop.h".
2021-05-31 11:40:36 +01:00
Felix Obenhuber
4a81d103b4
Make LOOP_PREFIX target_os specific
...
Android system setup loop devices at `/dev/block/loop` instead of
`/dev/loop`. Add a `cfg` directive to that sets the `LOOP_PREFIX` for
`target_os = "android"` accordingly.
2021-05-31 11:38:39 +01:00
Michael Daffin
506eb1494b
Change examples to use different loopback devices
2021-04-02 15:44:53 +00:00
Michael Daffin
15b271f886
Adds a couple extra doc block examples
2021-04-02 15:44:53 +00:00
Michael Daffin
0389b268e2
Adds basic docs for AttachDevice
2021-04-02 15:44:53 +00:00
Michael Daffin
bce615096f
Remove the partscan helper function
...
This was never released and the new builder pattern api should be used instead
2021-04-02 15:44:53 +00:00
Michael Daffin
898d7de60d
Bump losetup lockfile and min version
2021-03-31 01:38:08 +00:00
Michael Daffin
f042787aa8
Bumps minimum rust version
2021-03-31 01:38:08 +00:00
Michael Daffin
1ec9826012
Changes to use the builder pattern for attaching devices
...
Also bumps to version 0.2.2 and deprcates some methods in favour of the builder pattern
2021-03-31 01:38:08 +00:00
Michael Daffin
c845c150c2
Renames the loop_info64 struct
...
Makes it more rust like - apparently the name does not need to match the
C name. So really should use the rust naming convention.
2021-03-31 01:38:08 +00:00
Michael Daffin
3422a332ef
Make loop_info64 private
...
It should not be public, it is internally passed to the ioctl but users of the library should not need to know about its internal details.
2021-03-30 23:53:57 +00:00
Michael Daffin
b063c2baa0
Fixes example test and makes attach_with_loop_info consume the loop_info64 struct
...
Even though it is passed by reference to the ioctl conceptually the it should be created and consumed once per call to a attach function.
2021-03-30 23:53:57 +00:00
Rodolphe CHE
7cbcf81180
Adds automatic partition scanning function
2021-03-30 21:06:26 +00:00
Michael Daffin
090a699f39
Adds a note to the detach doc block
2019-08-11 12:38:39 +01:00
Michael Daffin
9ad0c53029
Adds tests for detach
2019-08-11 11:38:03 +00:00
Michael Daffin
63a0a32698
Adds inital intergration tests for attach
...
Also ups the minimum tested rust version as 1.20 is too old for some
libraries used in the tests.
2019-08-10 18:14:04 +00:00
Michael Daffin
b37c392fa7
Refactors the error handling to remove some duplication
2019-08-10 13:31:10 +00:00
Michael Daffin
8c94765ed5
Narrorws the scope of the unsafe blocks
2019-08-07 18:45:42 +00:00