Merge pull request #10075 from oech3/patch-4

fsext.rs: Replace getmntinfo with libc
This commit is contained in:
Sylvestre Ledru
2026-01-06 18:37:18 +01:00
committed by GitHub
+2 -33
View File
@@ -420,37 +420,6 @@ fn mount_dev_id(mount_dir: &OsStr) -> String {
}
}
#[cfg(any(
target_os = "freebsd",
target_vendor = "apple",
target_os = "netbsd",
target_os = "openbsd"
))]
use libc::c_int;
#[cfg(any(
target_os = "freebsd",
target_vendor = "apple",
target_os = "netbsd",
target_os = "openbsd"
))]
unsafe extern "C" {
#[cfg(all(target_vendor = "apple", target_arch = "x86_64"))]
#[link_name = "getmntinfo$INODE64"]
fn get_mount_info(mount_buffer_p: *mut *mut StatFs, flags: c_int) -> c_int;
#[cfg(any(
target_os = "netbsd",
target_os = "openbsd",
all(target_vendor = "apple", target_arch = "aarch64")
))]
#[link_name = "getmntinfo"]
fn get_mount_info(mount_buffer_p: *mut *mut StatFs, flags: c_int) -> c_int;
#[cfg(target_os = "freebsd")]
#[link_name = "getmntinfo"]
fn get_mount_info(mount_buffer_p: *mut *mut StatFs, flags: c_int) -> c_int;
}
use crate::error::UResult;
#[cfg(any(
target_os = "freebsd",
@@ -505,9 +474,9 @@ pub fn read_fs_list() -> UResult<Vec<MountInfo>> {
))]
{
let mut mount_buffer_ptr: *mut StatFs = ptr::null_mut();
let len = unsafe { get_mount_info(&raw mut mount_buffer_ptr, 1_i32) };
let len = unsafe { libc::getmntinfo(&raw mut mount_buffer_ptr, 1_i32) };
if len < 0 {
return Err(USimpleError::new(1, "get_mount_info() failed"));
return Err(USimpleError::new(1, "getmntinfo() failed"));
}
let mounts = unsafe { slice::from_raw_parts(mount_buffer_ptr, len as usize) };
Ok(mounts