Correct statvfs call to statfs

This was missed in the Rust port - C++ had statfs for MNT_LOCAL and not statvfs.
The effect of this is that fish never thought its filesystem was local on macOS
or BSDs (Linux was OK). This caused history race tests to fail, and also could
in rare cases result in history items being dropped with multiple concurrent
sessions.

This fixes the history race tests under macOS and FreeBSD - we weren't locking
because we thought the history was a remote file.

Cherry-picked from ba00d721f4
This commit is contained in:
Peter Ammon
2025-06-19 15:07:58 -07:00
parent 4be17bfefb
commit f3ebc68d5d

View File

@@ -713,14 +713,14 @@ fn path_remoteness(path: &wstr) -> DirRemoteness {
// In practice the only system to define it is NetBSD.
let local_flag = ST_LOCAL() | MNT_LOCAL();
if local_flag != 0 {
let mut buf: libc::statvfs = unsafe { std::mem::zeroed() };
if unsafe { libc::statvfs(narrow.as_ptr(), &mut buf) } < 0 {
let mut buf: libc::statfs = unsafe { std::mem::zeroed() };
if unsafe { libc::statfs(narrow.as_ptr(), &mut buf) } < 0 {
return DirRemoteness::unknown;
}
// statfs::f_flag is hard-coded as 64-bits on 32/64-bit FreeBSD but it's a (4-byte)
// long on 32-bit NetBSD.. and always 4-bytes on macOS (even on 64-bit builds).
#[allow(clippy::useless_conversion)]
return if u64::from(buf.f_flag) & local_flag != 0 {
return if u64::from(buf.f_flags) & local_flag != 0 {
DirRemoteness::local
} else {
DirRemoteness::remote