Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use filesystem name mapping on FreeBSD #105417

Merged
merged 5 commits into from
Jul 27, 2024
Merged
Changes from all commits
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
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
Loading