From 3ba8e8eeacdfb9110488974e5706413b571dac5a Mon Sep 17 00:00:00 2001 From: JustSoup321 Date: Fri, 30 Aug 2024 15:57:56 -0400 Subject: [PATCH] lib: fix building with musl libc No major changes, just defines a constant that is unavailable from the libc crate under musl. --- lib/src/mountutil.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/src/mountutil.rs b/lib/src/mountutil.rs index 364928d93..f73cbba26 100644 --- a/lib/src/mountutil.rs +++ b/lib/src/mountutil.rs @@ -7,12 +7,18 @@ use anyhow::Result; use cap_std::fs::Dir; use cap_std_ext::cap_std; +// Fix musl support +#[cfg(target_env = "gnu")] +use libc::STATX_ATTR_MOUNT_ROOT; +#[cfg(target_env = "musl")] +const STATX_ATTR_MOUNT_ROOT: libc::c_int = 0x2000; + fn is_mountpoint_impl_statx(root: &Dir, path: &Path) -> Result> { // https://github.com/systemd/systemd/blob/8fbf0a214e2fe474655b17a4b663122943b55db0/src/basic/mountpoint-util.c#L176 use rustix::fs::{AtFlags, StatxFlags}; // SAFETY(unwrap): We can infallibly convert an i32 into a u64. - let mountroot_flag: u64 = libc::STATX_ATTR_MOUNT_ROOT.try_into().unwrap(); + let mountroot_flag: u64 = STATX_ATTR_MOUNT_ROOT.try_into().unwrap(); match rustix::fs::statx( root.as_fd(), path,