Use fstatvfs if ST_LOCAL is available

Allows us to sometimes use mmap on NetBSD (proper capitalization is
important).
This commit is contained in:
Fabian Homborg 2018-12-13 10:26:15 +01:00
parent e9ad88d4b0
commit 9b980f5e6e

View file

@ -311,7 +311,13 @@ int fd_check_is_remote(int fd) {
// Other FSes are assumed local. // Other FSes are assumed local.
return 0; 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 {}; struct statfs buf {};
if (fstatfs(fd, &buf) < 0) return -1; if (fstatfs(fd, &buf) < 0) return -1;
return (buf.f_flags & MNT_LOCAL) ? 0 : 1; return (buf.f_flags & MNT_LOCAL) ? 0 : 1;