Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
hopefully fix the BSD build(s)
  • Loading branch information
adamsitnik committed Jul 7, 2021
commit 5d95af81cc4568490b8ff9901a9ee54c13af10bd
6 changes: 4 additions & 2 deletions src/libraries/Native/Unix/Common/pal_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
#cmakedefine01 HAVE_MMAP64
#cmakedefine01 HAVE_FTRUNCATE64
#cmakedefine01 HAVE_POSIX_FADVISE64
#cmakedefine01 HAVE_STATFS64
#cmakedefine01 HAVE_STATFS
#cmakedefine01 HAVE_STATFS64_VFS
#cmakedefine01 HAVE_STATFS64_MOUNT
#cmakedefine01 HAVE_STATFS_VFS
#cmakedefine01 HAVE_STATFS_MOUNT
#cmakedefine01 HAVE_FLOCK64
#cmakedefine01 HAVE_F_DUPFD_CLOEXEC
#cmakedefine01 HAVE_F_FULLFSYNC
Expand Down
18 changes: 11 additions & 7 deletions src/libraries/Native/Unix/System.Native/pal_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
#if HAVE_INOTIFY
#include <sys/inotify.h>
#endif
#if HAVE_STATFS64 || HAVE_STATFS
#if HAVE_STATFS64_VFS || HAVE_STATFS_VFS // Linux
#include <sys/vfs.h>
#elif HAVE_STATFS64_MOUNT || HAVE_STATFS_MOUNT // BSD
#include <sys/mount.h>
#endif

#ifdef _AIX
Expand Down Expand Up @@ -1384,16 +1386,18 @@ static int16_t ConvertLockType(int16_t managedLockType)

int64_t SystemNative_GetFileSystemType(intptr_t fd)
{
#if HAVE_STATFS64
int statfsRes;
#if HAVE_STATFS64_VFS || HAVE_STATFS64_MOUNT
struct statfs64 statfsArgs;
return fstatfs64(ToFileDescriptor(fd), &statfsArgs) == -1 ? (int64_t)-1 : (int64_t)statfsArgs.f_type;
#elif HAVE_STATFS
while ((statfsRes = fstatfs64(ToFileDescriptor(fd), &statfsArgs)) == -1 && errno == EINTR) ;
#elif HAVE_STATFS_VFS || HAVE_STATFS_MOUNT
struct statfs statfsArgs;
return fstatfs(ToFileDescriptor(fd), &statfsArgs) == -1 ? (int64_t)-1 : (int64_t)statfsArgs.f_type;
while ((statfsRes = fstatfs(ToFileDescriptor(fd), &statfsArgs)) == -1 && errno == EINTR) ;
#else
// since this is just best effort, we return 0 if fstatfs is not supported
return 0;
#error "Platform doesn't support fstatfs64 or fstatfs"
#endif

return statfsRes == -1 ? (int64_t)-1 : (int64_t)statfsArgs.f_type;
}

int32_t SystemNative_LockFileRegion(intptr_t fd, int64_t offset, int64_t length, int16_t lockType)
Expand Down
26 changes: 24 additions & 2 deletions src/libraries/Native/Unix/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ check_c_source_compiles(
return 0;
}
"
HAVE_STATFS64)
HAVE_STATFS64_VFS)

check_c_source_compiles(
"
Expand All @@ -128,7 +128,29 @@ check_c_source_compiles(
return 0;
}
"
HAVE_STATFS)
HAVE_STATFS_VFS)

check_c_source_compiles(
"
#include <sys/mount.h>
int main(void)
{
struct statfs64 s;
return 0;
}
"
HAVE_STATFS64_MOUNT)

check_c_source_compiles(
"
#include <sys/mount.h>
int main(void)
{
struct statfs s;
return 0;
}
"
HAVE_STATFS_MOUNT)

check_c_source_compiles(
"
Expand Down