Skip to content

Commit

Permalink
Use filesystem name mapping on FreeBSD (#105417)
Browse files Browse the repository at this point in the history
  • Loading branch information
am11 authored Jul 27, 2024
1 parent 7e429c2 commit 67d5c92
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/native/libs/System.Native/pal_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1575,7 +1575,7 @@ static int16_t ConvertLockType(int16_t managedLockType)
}
}

#if !HAVE_NON_LEGACY_STATFS || defined(__APPLE__)
#if !HAVE_NON_LEGACY_STATFS || defined(TARGET_APPLE) || defined(TARGET_FREEBSD)
static uint32_t MapFileSystemNameToEnum(const char* fileSystemName)
{
uint32_t result = 0;
Expand Down Expand Up @@ -1722,8 +1722,11 @@ uint32_t SystemNative_GetFileSystemType(intptr_t fd)
while ((statfsRes = fstatfs(ToFileDescriptor(fd), &statfsArgs)) == -1 && errno == EINTR) ;
if (statfsRes == -1) return 0;

#if defined(__APPLE__)
// On OSX-like systems, f_type is version-specific. Don't use it, just map the name.
#if defined(TARGET_APPLE) || defined(TARGET_FREEBSD)
// * On OSX-like systems, f_type is version-specific. Don't use it, just map the name.
// * Specifically, on FreeBSD with ZFS, f_type may return a value like 0xDE when emulating
// FreeBSD on macOS (e.g., FreeBSD-x64 on macOS ARM64). Therefore, we use f_fstypename to
// get the correct filesystem type.
return MapFileSystemNameToEnum(statfsArgs.f_fstypename);
#else
// On Linux, f_type is signed. This causes some filesystem types to be represented as
Expand Down

0 comments on commit 67d5c92

Please sign in to comment.