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
always use fstatfs as it's available on every platform and can get us…
…e correct file system type
  • Loading branch information
adamsitnik committed Jul 8, 2021
commit 1c890ec8f6e949df45ef5388b3925c8dab0820f8
2 changes: 0 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,6 @@
#cmakedefine01 HAVE_MMAP64
#cmakedefine01 HAVE_FTRUNCATE64
#cmakedefine01 HAVE_POSIX_FADVISE64
#cmakedefine01 HAVE_STATFS64_VFS
#cmakedefine01 HAVE_STATFS64_MOUNT
#cmakedefine01 HAVE_STATFS_VFS
#cmakedefine01 HAVE_STATFS_MOUNT
#cmakedefine01 HAVE_FLOCK64
Expand Down
19 changes: 7 additions & 12 deletions src/libraries/Native/Unix/System.Native/pal_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
#if HAVE_INOTIFY
#include <sys/inotify.h>
#endif
#if HAVE_STATFS64_VFS || HAVE_STATFS_VFS // Linux
#if HAVE_STATFS_VFS // Linux
#include <sys/vfs.h>
#elif HAVE_STATFS64_MOUNT || HAVE_STATFS_MOUNT // BSD
#elif HAVE_STATFS_MOUNT // BSD
#include <sys/mount.h>
#endif

Expand Down Expand Up @@ -1386,21 +1386,16 @@ static int16_t ConvertLockType(int16_t managedLockType)

int64_t SystemNative_GetFileSystemType(intptr_t fd)
{
#if HAVE_STATFS_VFS || HAVE_STATFS_MOUNT
int statfsRes;
#if HAVE_STATFS_MOUNT && (defined(TARGET_IOS) || defined(TARGET_OSX) || defined(TARGET_WATCHOS) || defined(TARGET_TVOS) || defined(HOST_MACCAT)) // In macOS 10.6+ statfs64 is deprecated, in favor of statfs
struct statfs statfsArgs;
while ((statfsRes = fstatfs(ToFileDescriptor(fd), &statfsArgs)) == -1 && errno == EINTR) ;
#elif HAVE_STATFS64_VFS || HAVE_STATFS64_MOUNT
struct statfs64 statfsArgs;
while ((statfsRes = fstatfs64(ToFileDescriptor(fd), &statfsArgs)) == -1 && errno == EINTR) ;
#elif HAVE_STATFS_VFS || HAVE_STATFS_MOUNT
struct statfs statfsArgs;
// for our needs (get file system type) statfs is always enough and there is no need to use statfs64
// which got deprecated in macOS 10.6, in favor of statfs
while ((statfsRes = fstatfs(ToFileDescriptor(fd), &statfsArgs)) == -1 && errno == EINTR) ;
return statfsRes == -1 ? (int64_t)-1 : (int64_t)statfsArgs.f_type;
#else
#error "Platform doesn't support fstatfs64 or fstatfs"
#error "Platform doesn't support 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
22 changes: 0 additions & 22 deletions src/libraries/Native/Unix/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,6 @@ check_c_source_compiles(

# /in_pktinfo

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

check_c_source_compiles(
"
#include <sys/vfs.h>
Expand All @@ -130,17 +119,6 @@ check_c_source_compiles(
"
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>
Expand Down