From d8f28555b5a69dc542a9206c3cfa0e252e116fa9 Mon Sep 17 00:00:00 2001 From: Tim Zhang Date: Thu, 17 Jul 2025 17:19:06 +0800 Subject: [PATCH] shim/loop-dev: fix variable undefined error for musl Fixes: #413 Signed-off-by: Tim Zhang --- crates/shim/src/mount_linux.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crates/shim/src/mount_linux.rs b/crates/shim/src/mount_linux.rs index bb06c26..8343dab 100644 --- a/crates/shim/src/mount_linux.rs +++ b/crates/shim/src/mount_linux.rs @@ -813,6 +813,21 @@ pub fn setup_loop_dev(backing_file: &str, loop_dev: &str, params: &LoopParams) - info, ); #[cfg(target_env = "musl")] + let ret = libc::ioctl( + loop_dev.as_raw_fd() as libc::c_int, + LOOP_SET_STATUS64 as libc::c_int, + info, + ); + #[cfg(target_env = "gnu")] + if let Err(e) = nix::errno::Errno::result(ret) { + libc::ioctl( + loop_dev.as_raw_fd() as libc::c_int, + LOOP_CLR_FD as libc::c_ulong, + 0, + ); + return Err(Error::Nix(e)); + } + #[cfg(target_env = "musl")] if let Err(e) = nix::errno::Errno::result(ret) { libc::ioctl( loop_dev.as_raw_fd() as libc::c_int,