Skip to content

Conversation

@Gelbpunkt
Copy link

@Gelbpunkt Gelbpunkt commented Dec 14, 2024

rustix wraps syscalls without the libc crate, which does not expose a bunch of io-uring related APIs such as statx on musl targets.

With these changes, tokio-uring compiles fine when built for musl targets.

TODO: test and split the minvers fixes + maybe split the change for the listen syscall into their own commits, update docs, update tests

rustix wraps syscalls without the libc crate, which does not expose a
bunch of io-uring related APIs such as statx on musl targets.

With these changes, tokio-uring compiles fine when built for musl
targets.

Signed-off-by: Jens Reidel <[email protected]>
@ileixe
Copy link

ileixe commented Dec 16, 2024

Just out of curiosity, do you know what's the plan for io-uring crate (Do rustix replace it)? Looks like maintainer is same.

@Gelbpunkt
Copy link
Author

Just out of curiosity, do you know what's the plan for io-uring crate (Do rustix replace it)? Looks like maintainer is same.

The maintainers aren't the same from what I can see, rustix-uring is a fork of the io-uring crate. I'm not involved with the project so I don't know more than that.

@ileixe
Copy link

ileixe commented Dec 16, 2024

Oh I did not aware it's fork of io-uring (so I saw same maintainer in github contributor view)

Anyway, here's the reason from io-uring side:
tokio-rs/io-uring#207

I think it makes sense.

@quininer
Copy link
Member

If you want musl compatibility, there is no need to switch to rustix_uring, just use linux-raw-sys (or any other linux headers library) with io_uring.

like

use io_uring::opcode;
use linux_raw_sys::general::statx;

let statx = Box::new(statx {
    // ...
});
let op = opcode::Statx::new(fd, path, Box::into_raw(statx).cast());

@manio
Copy link

manio commented Oct 27, 2025

Much thanks for this... I was trying to compile on riscv64 with musl and encountered statx missing in libc as well.
First I was doing this kind of workarounds:

diff --git a/src/fs/statx.rs b/src/fs/statx.rs
index 5a3ccb1..7cbb13e 100644
--- a/src/fs/statx.rs
+++ b/src/fs/statx.rs
@@ -2,6 +2,9 @@ use super::File;
 use crate::io::{cstr, SharedFd};
 use crate::runtime::driver::op::Op;
 use std::{ffi::CString, io, path::Path};
+use io_uring::types::statx;
+use crate::fs::STATX_ALL;
+use crate::fs::STATX_TYPE;
 
 impl File {
     /// Returns statx(2) metadata for an open file via a uring call.
@@ -28,9 +31,9 @@ impl File {
     ///     f.close().await.unwrap();
     /// })
     /// ```
-    pub async fn statx(&self) -> io::Result<libc::statx> {
+    pub async fn statx(&self) -> io::Result<statx> {
         let flags = libc::AT_EMPTY_PATH;
-        let mask = libc::STATX_ALL;
+        let mask = STATX_ALL;
         Op::statx(Some(self.fd.clone()), None, flags, mask)?.await
     }
 
@@ -73,7 +76,7 @@ impl File {
             file: Some(self.fd.clone()),
             path: None,
             flags: libc::AT_EMPTY_PATH,
-            mask: libc::STATX_ALL,
+            mask: STATX_ALL,
         }
     }
 }

and then I encounter this PR so hopefully this is a proper fix
btw: These changes was also necessary: #334

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants