Skip to content

Commit 67d5c92

Browse files
authored
Use filesystem name mapping on FreeBSD (#105417)
1 parent 7e429c2 commit 67d5c92

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/native/libs/System.Native/pal_io.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,7 @@ static int16_t ConvertLockType(int16_t managedLockType)
15751575
}
15761576
}
15771577

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

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

0 commit comments

Comments
 (0)