Skip to content

Commit 8057d1a

Browse files
committed
freebsd: fix the 'df' command
df, and perhaps other commands, get the list of the mounted filesystems with the call to getmntinfo(3). Since Rust still use FreeBSD 11.x ABI for filesystem metadata call, it should use matching versioned symbol for getmntinfo from libc.
1 parent 6085cf1 commit 8057d1a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,13 +362,19 @@ extern "C" {
362362
fn get_mount_info(mount_buffer_p: *mut *mut StatFs, flags: c_int) -> c_int;
363363

364364
#[cfg(any(
365-
target_os = "freebsd",
366365
target_os = "netbsd",
367366
target_os = "openbsd",
368367
all(target_vendor = "apple", target_arch = "aarch64")
369368
))]
370369
#[link_name = "getmntinfo"] // spell-checker:disable-line
371370
fn get_mount_info(mount_buffer_p: *mut *mut StatFs, flags: c_int) -> c_int;
371+
372+
// Rust on FreeBSD uses 11.x ABI for filesystem metadata syscalls.
373+
// Call right version of the symbol for getmntinfo result to match
374+
// libc StatFS layout.
375+
#[cfg(target_os = "freebsd")]
376+
#[link_name = "getmntinfo@FBSD_1.0"] // spell-checker:disable-line
377+
fn get_mount_info(mount_buffer_p: *mut *mut StatFs, flags: c_int) -> c_int;
372378
}
373379

374380
#[cfg(any(target_os = "linux", target_os = "android"))]

0 commit comments

Comments
 (0)