Skip to content

passthrough.rs fails with cannot find type statx in crate libc#432

Closed
peppergrayxyz wants to merge 1 commit intocontainers:mainfrom
peppergrayxyz:statx
Closed

passthrough.rs fails with cannot find type statx in crate libc#432
peppergrayxyz wants to merge 1 commit intocontainers:mainfrom
peppergrayxyz:statx

Conversation

@peppergrayxyz
Copy link
Copy Markdown
Contributor

musl 1.2.5 added support for the statx system call rust ships unknown-linux-musl with musl 1.2.3, milage on other libs may varay

Enable portability by repling libc::statx with rustix::statx

fixes #431

Comment thread src/devices/Cargo.toml
polly = { path = "../polly" }
rutabaga_gfx = { path = "../rutabaga_gfx", features = ["virgl_renderer", "virgl_renderer_next"], optional = true }
imago = { version = "0.1.4", features = ["sync-wrappers", "vm-memory"] }
rustix = { version = "1.1.2", features = ["fs"] }
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding a new dependency just for this is a bit overkill. Let's simply wait for the rust toolchain to ship a newer version of musl, shouldn't take long.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, adding the dependency for such a simple thing seems like an overkill to me too.

An alternative could be to use libc::syscall directly.

musl 1.2.5 was released on February 29, 2024, so it's taking a while 😄. Nevertheless seems like we will get it soon-ish:
rust-lang/rust#142682

Btw. I was actually considering whether we may want to start using rustix over nix - it seemed to be nicer in some areas than nix, but it's hard to say...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

statx-sys does that, but has been deprecated in favor of libc::statx and rustix. It doesn't support stx_mnt_id but can be patched easily. But we could use it, thereby avoiding pulling in rustix and also writing the wrapper from scratch.

I created a draft here:

I'd move the statx-sys fork to libkrun or just include the files in the project if we wanna go forward with this.

musl 1.2.5 added support for the statx system call
rust ships unknown-linux-musl with musl 1.2.3
milage on other libs may varay

Enable portability by repling libc::statx with rustix::statx

Fixes: containers#431
Signed-off-by: Pepper Gray <hello@peppergray.xyz>
@slp
Copy link
Copy Markdown
Collaborator

slp commented Dec 16, 2025

@peppergrayxyz Please consider using libc::syscall as @mtjhrc suggested. You can borrow the code from virtiofsd: https://gitlab.com/virtio-fs/virtiofsd/-/blob/main/src/passthrough/stat.rs?ref_type=heads#L102

@polarathene
Copy link
Copy Markdown

FWIW, the upgrade to musl 1.2.5 will land in the upcoming Rust 1.93 release.

@slp
Copy link
Copy Markdown
Collaborator

slp commented Mar 13, 2026

We're already in 1.94, so let's close this one.

@slp slp closed this Mar 13, 2026
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.

devices: cannot find function statx in crate libc

4 participants