From 9b980f5e6e6d586bbfc48ca8b2f695389574323e Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Thu, 13 Dec 2018 10:26:15 +0100 Subject: [PATCH] Use fstatvfs if ST_LOCAL is available Allows us to sometimes use mmap on NetBSD (proper capitalization is important). --- src/wutil.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/wutil.cpp b/src/wutil.cpp index ceb3620c5..13001bef6 100644 --- a/src/wutil.cpp +++ b/src/wutil.cpp @@ -311,7 +311,13 @@ int fd_check_is_remote(int fd) { // Other FSes are assumed local. return 0; } -#elif defined(MNT_LOCAL) && !defined(__NetBSD__) +#elif defined(ST_LOCAL) + // ST_LOCAL is a flag to statvfs, which is itself standardized. + // In practice the only system to use this path is NetBSD. + struct statvfs buf {}; + if (fstatvfs(fd, &buf) < 0) return -1; + return (buf.f_flag & ST_LOCAL) ? 0 : 1; +#elif defined(MNT_LOCAL) struct statfs buf {}; if (fstatfs(fd, &buf) < 0) return -1; return (buf.f_flags & MNT_LOCAL) ? 0 : 1;