Skip to content

Commit 66a4c5f

Browse files
committed
passthrough.rs fails with cannot find type statx in crate libc
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 Intermediate solution using forked version of statx-sys to replace libc::statx until statx becomes available on musl Fixes: #431 Signed-off-by: Pepper Gray <hello@peppergray.xyz>
1 parent 246b3f7 commit 66a4c5f

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

Cargo.lock

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ resolver = "2"
99
[profile.release]
1010
#panic = "abort"
1111
lto = true
12+
13+
[patch.crates-io]
14+
statx-sys = { git = "https://github.com/peppergrayxyz/statx-sys", rev = "c0cd9f6b654279be5b4e37fd06d17004687b2ed7" }

src/devices/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ utils = { path = "../utils" }
3737
polly = { path = "../polly" }
3838
rutabaga_gfx = { path = "../rutabaga_gfx", features = ["virgl_renderer", "virgl_renderer_next"], optional = true }
3939
imago = { version = "0.1.4", features = ["sync-wrappers", "vm-memory"] }
40+
statx-sys = "0.4.1"
4041

4142
[target.'cfg(target_os = "macos")'.dependencies]
4243
hvf = { path = "../hvf" }

src/devices/src/virtio/fs/linux/passthrough.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,19 +147,19 @@ fn stat(f: &File) -> io::Result<libc::stat64> {
147147
}
148148

149149
fn statx(f: &File) -> io::Result<(libc::stat64, u64)> {
150-
let mut stx = MaybeUninit::<libc::statx>::zeroed();
150+
let mut stx = MaybeUninit::<statx_sys::statx>::zeroed();
151151

152152
// Safe because this is a constant value and a valid C string.
153153
let pathname = unsafe { CStr::from_bytes_with_nul_unchecked(EMPTY_CSTR) };
154154

155155
// Safe because the kernel will only write data in `st` and we check the return
156156
// value.
157157
let res = unsafe {
158-
libc::statx(
158+
statx_sys::statx(
159159
f.as_raw_fd(),
160160
pathname.as_ptr(),
161-
libc::AT_EMPTY_PATH | libc::AT_SYMLINK_NOFOLLOW,
162-
libc::STATX_BASIC_STATS | libc::STATX_MNT_ID,
161+
statx_sys::AT_EMPTY_PATH | statx_sys::AT_SYMLINK_NOFOLLOW,
162+
statx_sys::STATX_BASIC_STATS | statx_sys::STATX_MNT_ID,
163163
stx.as_mut_ptr(),
164164
)
165165
};

0 commit comments

Comments
 (0)