Use LOOP_CONFIGURE ioctl for attaching to loop devices
This ioctl was added to Linux0 as a faster and atomic alternative to the combination of LOOP_SET_FD and LOOP_SET_STATUS. In order to support older kernels, the function will still fallback to those syscalls if necessary.
The attach_a_backing_file_with_part_scan_default test passed, and I verified the functionality in my project that uses this crate. I was only able to test on a recent kernel:
$ uname -r
6.0.6-arch1-1
strace confirmed that the new ioctl was being used.
I can build an old kernel to try the fallback behavior, but I have not made time for that yet.
I implemented a kernel version check and depending on the result a feature loop_configure is enabled or not:
https://github.com/flxo/loopdev/tree/loop-configure
The most interesting part is that the binding generation must be moved in to a -sys crate in order to access the LINUX_KERNEL_VERSION constant from the loopdev build script.
FYI. Rebased the POC.