Skip to content

Commit 130f780

Browse files
authored
Merge pull request #10075 from oech3/patch-4
fsext.rs: Replace getmntinfo with libc
2 parents bc3b613 + fbc22b2 commit 130f780

File tree

1 file changed

+2
-33
lines changed

1 file changed

+2
-33
lines changed

src/uucore/src/lib/features/fsext.rs

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -420,37 +420,6 @@ fn mount_dev_id(mount_dir: &OsStr) -> String {
420420
}
421421
}
422422

423-
#[cfg(any(
424-
target_os = "freebsd",
425-
target_vendor = "apple",
426-
target_os = "netbsd",
427-
target_os = "openbsd"
428-
))]
429-
use libc::c_int;
430-
#[cfg(any(
431-
target_os = "freebsd",
432-
target_vendor = "apple",
433-
target_os = "netbsd",
434-
target_os = "openbsd"
435-
))]
436-
unsafe extern "C" {
437-
#[cfg(all(target_vendor = "apple", target_arch = "x86_64"))]
438-
#[link_name = "getmntinfo$INODE64"]
439-
fn get_mount_info(mount_buffer_p: *mut *mut StatFs, flags: c_int) -> c_int;
440-
441-
#[cfg(any(
442-
target_os = "netbsd",
443-
target_os = "openbsd",
444-
all(target_vendor = "apple", target_arch = "aarch64")
445-
))]
446-
#[link_name = "getmntinfo"]
447-
fn get_mount_info(mount_buffer_p: *mut *mut StatFs, flags: c_int) -> c_int;
448-
449-
#[cfg(target_os = "freebsd")]
450-
#[link_name = "getmntinfo"]
451-
fn get_mount_info(mount_buffer_p: *mut *mut StatFs, flags: c_int) -> c_int;
452-
}
453-
454423
use crate::error::UResult;
455424
#[cfg(any(
456425
target_os = "freebsd",
@@ -505,9 +474,9 @@ pub fn read_fs_list() -> UResult<Vec<MountInfo>> {
505474
))]
506475
{
507476
let mut mount_buffer_ptr: *mut StatFs = ptr::null_mut();
508-
let len = unsafe { get_mount_info(&raw mut mount_buffer_ptr, 1_i32) };
477+
let len = unsafe { libc::getmntinfo(&raw mut mount_buffer_ptr, 1_i32) };
509478
if len < 0 {
510-
return Err(USimpleError::new(1, "get_mount_info() failed"));
479+
return Err(USimpleError::new(1, "getmntinfo() failed"));
511480
}
512481
let mounts = unsafe { slice::from_raw_parts(mount_buffer_ptr, len as usize) };
513482
Ok(mounts

0 commit comments

Comments
 (0)