-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android build, additional flags, AsRawFd, IntoRawFd, CI #27
Conversation
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"` acordingly.
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`.
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.
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.
Add a build.rs to generate Rust bindings for "linux/loop.h".
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.
Running the examples in the docs fails because the loopdev actions need permissions and probably interfere with existing loop devices on the machine.
Add a runner that executes the integration tests with a sudo that is needed for for performing the various losetup actions.
The `losetup` tools tends to fail with an EBUSY when running in the CI.
Hey, thanks for this. I see you have disabled all the doc tests - I think these should be kept enabled to ensure the docs examples remain working. They suffer from the same issues as the integration tests so I don't see why they need to explicitly be disabled. You can always disable them locally by running only the integration tests with I do wonder if the metadata is required? I see you are using it in the tests to get the minor number. Might be worth exposing a function for that purpose as appose to the full metadata. Do you have any other use cases for it? We could expose some of the other more useful info as explicit functions. It might be useful but not sure I want to commit to it as part of the API just yet if there is no other use case for it. You could always ask for the path and get the meta data from that. What other info do you require from it? The rest seems good to me. |
Looks like the tests are failing due to changing how sudo is used in the tests but not updating the travis.yaml to match: should be a matter of removing the sudo from https://github.com/mdaffin/loopdev/blob/master/.travis.yml#L34 |
Hi @mdaffin. Thanks for your comments. Regarding the doc tests: Still they need a I need the metadata for passing the minor to the device mapper during for device mapper verity tables. Getting the minor from the already opened Travis: yeah...same story everywhere that it was the defacto standard. �I'll split this PR into a set of smaller ones:
|
That is annoying. Wonder if there is an equivalent for doc tests? I think keeping the doc tests working and compiling is the better thing to do though. This library does not need updating very often and it is better that the examples remain relevant than to make it more convenient to run the tests. It is a very annoying trade off to make though. But rather have that annoyance in this library then in places that use it.
You don't need an extra open call. You do need a call to stat, which you can do from a open fd or from a path. Getting the minor number I think is could be a commonly needed thing that it is worth exposing directly allowing users to let meta = ld.metadata().unwrap();
let rdev = meta.rdev();
let minor = ((rdev >> 12) & 0xFFFF_FF00) | (rdev & 0xFF); Not sure how useful metadata is on loop devices once we have that? Does
Did you miss this PR, I don't see it included in the others? |
@mdaffin Thanks for your fast reviews and merges!
Yes. I expected that the doc tests are executed with the configured runner - but that's not the case. Means currently the only solution is to
You're right. If you really need the metadata you still have File::from_raw_fd - just dangerous because of the
No - I skipped this for now. Turned out that the tests as they are today don't work in GH actions. The timings don't fit sometimes and the use of |
Created #32 |
You dont even need to do that. You can just
That issue also exists on the travis tests, would be a really nice one to solve. |
This PR contains a couple of things I'd need in
loopdev
:bionic
differs in some ways fromglibc
and others. The path to loop devices is different. Add acfg
directive fortarget_os = "android"
and not.read_only
,autoclear
anddirect io
Metadata
On the way there I added
bindgen
in abuild.rs
to gather the bindings during the build. Vagrant refused to work in my setup so I run the tests locally and added a GH actions script. The tests were flaky in GH because (as we all know) the loopdev driver sometimes lazy and just return anEBSY
. I replace one of thelosetup
calls with a call from this crate - works so far.@mdaffin Let me know which of the above things can be merged. I can prepare dedicated and clean PRs for each (and work with my master in the meantime ;-)). I did the GH actions stuff just because I'm curious....there's not need to that.