Skip to content

devices: cannot find function statx in crate libc #431

@peppergrayxyz

Description

@peppergrayxyz

Build fails on llvm/musl/libcxx (#429)

musl 1.2.5 added support for the statx system call & rust ships unknown-linux-musl with musl 1.2.3 therefore statx doesn't exist

   Compiling devices v0.1.0 (/home/pepper/dev/ghrepos/libkrun/src/devices)
error: couldn't read `src/devices/src/virtio/fs/linux/../../../../../../init/init`: No such file or directory (os error 2)
  --> src/devices/src/virtio/fs/linux/passthrough.rs:36:29
   |
36 | static INIT_BINARY: &[u8] = include_bytes!("../../../../../../init/init");
   |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0412]: cannot find type `statx` in crate `libc`
   --> src/devices/src/virtio/fs/linux/passthrough.rs:150:39
    |
150 |       let mut stx = MaybeUninit::<libc::statx>::zeroed();
    |                                         ^^^^^ help: a struct with a similar name exists: `stat`
    |
   ::: /home/pepper/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.172/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs:10:1
    |
10  | / s! {
11  | |     pub struct stat {
12  | |         pub st_dev: crate::dev_t,
13  | |         pub st_ino: crate::ino_t,
...   |
112 | | }
    | |_- similarly named struct `stat` defined here

error[E0425]: cannot find function `statx` in crate `libc`
   --> src/devices/src/virtio/fs/linux/passthrough.rs:158:15
    |
158 |         libc::statx(                                                                                                      |               ^^^^^ help: a function with a similar name exists: `stat`
    |
   ::: /home/pepper/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.172/src/unix/mod.rs:876:5
    |
876 |     pub fn stat(path: *const c_char, buf: *mut stat) -> c_int;
    |     ---------------------------------------------------------- similarly named function `stat` defined here
                                                                                                                            error[E0425]: cannot find value `STATX_BASIC_STATS` in crate `libc`
   --> src/devices/src/virtio/fs/linux/passthrough.rs:162:19
    |
162 |             libc::STATX_BASIC_STATS | libc::STATX_MNT_ID,
    |                   ^^^^^^^^^^^^^^^^^ not found in `libc`

error[E0425]: cannot find value `STATX_MNT_ID` in crate `libc`
   --> src/devices/src/virtio/fs/linux/passthrough.rs:162:45
    |
162 |             libc::STATX_BASIC_STATS | libc::STATX_MNT_ID,
    |                                             ^^^^^^^^^^^^ not found in `libc`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions