Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ private static DriveType GetDriveType(string fileSystemName)
// This list is based primarily on "man fs", "man mount", "mntent.h", "/proc/filesystems", coreutils "stat.c",
// and "wiki.debian.org/FileSystem". It can be extended over time as we find additional file systems that should
// be recognized as a particular drive type.
// Keep this in sync with the UnixFileSystemTypes enum in Interop.UnixFileSystemTypes.cs
switch (fileSystemName)
{
case "cddafs":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ internal enum UnixFileSystemTypes : long
befs = 0x42465331,
bdevfs = 0x62646576,
bfs = 0x1BADFACE,
bpf_fs = 0xCAFE4A11,
binfmt_misc = 0x42494E4D,
bootfs = 0xA56D3FF9,
btrfs = 0x9123683E,
Expand All @@ -53,6 +54,7 @@ internal enum UnixFileSystemTypes : long
ext2 = 0xEF53,
ext3 = 0xEF53,
ext4 = 0xEF53,
f2fs = 0xF2F52010,
fat = 0x4006,
fd = 0xF00D1E,
fhgfs = 0x19830326,
Expand Down Expand Up @@ -122,6 +124,7 @@ internal enum UnixFileSystemTypes : long
sysv2 = 0x012FF7B6,
sysv4 = 0x012FF7B5,
tmpfs = 0x01021994,
tracefs = 0x74726163,
ubifs = 0x24051905,
udf = 0x15013346,
ufs = 0x00011954,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void PollingFileProviderShouldntConsumeINotifyInstances()
}
}
}

private void GetFileInfoReturnsNotFoundFileInfoForIllegalPathWithLeadingSlashes(string path)
{
using (var provider = new PhysicalFileProvider(Path.GetTempPath()))
Expand Down Expand Up @@ -936,6 +936,7 @@ public void NoopChangeTokenForFilterThatNavigatesAboveRoot()

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/34582", TestPlatforms.Windows, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/58584", TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS)]
public void TokenForEmptyFilter()
{
using (var root = new DisposableFileSystem())
Expand Down
13 changes: 12 additions & 1 deletion src/libraries/Native/Unix/System.Native/pal_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,7 @@ int64_t SystemNative_GetFileSystemType(intptr_t fd)
else if (strcmp(statfsArgs.f_basetype, "befs") == 0) result = 0x42465331;
else if (strcmp(statfsArgs.f_basetype, "bdevfs") == 0) result = 0x62646576;
else if (strcmp(statfsArgs.f_basetype, "bfs") == 0) result = 0x1BADFACE;
else if (strcmp(statfsArgs.f_basetype, "bpf_fs") == 0) result = 0xCAFE4A11;
else if (strcmp(statfsArgs.f_basetype, "binfmt_misc") == 0) result = 0x42494E4D;
else if (strcmp(statfsArgs.f_basetype, "bootfs") == 0) result = 0xA56D3FF9;
else if (strcmp(statfsArgs.f_basetype, "btrfs") == 0) result = 0x9123683E;
Expand All @@ -1452,6 +1453,7 @@ int64_t SystemNative_GetFileSystemType(intptr_t fd)
else if (strcmp(statfsArgs.f_basetype, "ext2") == 0) result = 0xEF53;
else if (strcmp(statfsArgs.f_basetype, "ext3") == 0) result = 0xEF53;
else if (strcmp(statfsArgs.f_basetype, "ext4") == 0) result = 0xEF53;
else if (strcmp(statfsArgs.f_basetype, "f2fs") == 0) result = 0xF2F52010;
else if (strcmp(statfsArgs.f_basetype, "fat") == 0) result = 0x4006;
else if (strcmp(statfsArgs.f_basetype, "fd") == 0) result = 0xF00D1E;
else if (strcmp(statfsArgs.f_basetype, "fhgfs") == 0) result = 0x19830326;
Expand Down Expand Up @@ -1519,6 +1521,7 @@ int64_t SystemNative_GetFileSystemType(intptr_t fd)
else if (strcmp(statfsArgs.f_basetype, "sysv2") == 0) result = 0x012FF7B6;
else if (strcmp(statfsArgs.f_basetype, "sysv4") == 0) result = 0x012FF7B5;
else if (strcmp(statfsArgs.f_basetype, "tmpfs") == 0) result = 0x01021994;
else if (strcmp(statfsArgs.f_basetype, "tracefs") == 0) result = 0x74726163;
else if (strcmp(statfsArgs.f_basetype, "ubifs") == 0) result = 0x24051905;
else if (strcmp(statfsArgs.f_basetype, "udf") == 0) result = 0x15013346;
else if (strcmp(statfsArgs.f_basetype, "ufs") == 0) result = 0x00011954;
Expand Down Expand Up @@ -1560,13 +1563,21 @@ int32_t SystemNative_LockFileRegion(intptr_t fd, int64_t offset, int64_t length,
struct flock lockArgs;
#endif

#if defined(TARGET_ANDROID) && defined(HAVE_FLOCK64)
// On Android, fcntl is always implemented by fcntl64 but before https://github.com/aosp-mirror/platform_bionic/commit/09e77f35ab8d291bf88302bb9673aaa518c6bcb0
// there was no remapping of F_SETLK to F_SETLK64 when _FILE_OFFSET_BITS=64 (which we set in eng/native/configurecompiler.cmake) so we need to always pass F_SETLK64
int command = F_SETLK64;
#else
int command = F_SETLK;
#endif

lockArgs.l_type = unixLockType;
lockArgs.l_whence = SEEK_SET;
lockArgs.l_start = (off_t)offset;
lockArgs.l_len = (off_t)length;

int32_t ret;
while ((ret = fcntl (ToFileDescriptor(fd), F_SETLK, &lockArgs)) < 0 && errno == EINTR);
while ((ret = fcntl (ToFileDescriptor(fd), command, &lockArgs)) < 0 && errno == EINTR);
return ret;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ public void Test_EventSourceCreatedEvents_AfterListener()
[Theory]
[InlineData(true)]
[InlineData(false)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/51382", TestPlatforms.iOS | TestPlatforms.tvOS | TestPlatforms.MacCatalyst)]
public void Test_EventListenerThrows_ExceptionIsNotRethrownToCaller(bool setThrowOnEventWriteErrorsFlag)
{
TestUtilities.CheckNoEventSourcesRunning("Start");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public void NonZeroTimeout_NoEvents_TimesOut(bool enabledBeforeWait)
[InlineData(WatcherChangeTypes.Changed, false)]
[InlineData(WatcherChangeTypes.Renamed, true)]
[InlineData(WatcherChangeTypes.All, true)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/58418", typeof(PlatformDetection), nameof(PlatformDetection.IsMacCatalyst), nameof(PlatformDetection.IsArm64Process))]
public void NonZeroTimeout_NoActivity_TimesOut(WatcherChangeTypes changeType, bool enabledBeforeWait)
{
using (var testDirectory = new TempDirectory(GetTestFilePath()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ public void ValidAccessLevelCombinations(MemoryMappedFileAccess mapAccess, Memor
}
catch (UnauthorizedAccessException)
{
if ((OperatingSystem.IsMacOS() || OperatingSystem.IsMacCatalyst() || PlatformDetection.IsInContainer) &&
if ((OperatingSystem.IsMacOS() || OperatingSystem.IsMacCatalyst() || OperatingSystem.IsIOS() || OperatingSystem.IsTvOS() || PlatformDetection.IsInContainer) &&
(viewAccess == MemoryMappedFileAccess.ReadExecute || viewAccess == MemoryMappedFileAccess.ReadWriteExecute))
{
// Containers and OSX with SIP enabled do not have execute permissions by default.
// Containers and OSXlike platforms with SIP enabled do not have execute permissions by default.
throw new SkipTestException("Insufficient execute permission.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ public void ValidAccessLevelCombinations(MemoryMappedFileAccess mapAccess, Memor
}
catch (UnauthorizedAccessException)
{
if ((OperatingSystem.IsMacOS() || OperatingSystem.IsMacCatalyst() || PlatformDetection.IsInContainer) &&
if ((OperatingSystem.IsMacOS() || OperatingSystem.IsMacCatalyst() || OperatingSystem.IsIOS() || OperatingSystem.IsTvOS() || PlatformDetection.IsInContainer) &&
(viewAccess == MemoryMappedFileAccess.ReadExecute || viewAccess == MemoryMappedFileAccess.ReadWriteExecute))
{
// Containers and OSX with SIP enabled do not have execute permissions by default.
// Containers and OSXlike platforms with SIP enabled do not have execute permissions by default.
throw new SkipTestException("Insufficient execute permission.");
}

Expand Down
1 change: 1 addition & 0 deletions src/libraries/System.Net.Http/src/System.Net.Http.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<ILLinkSubstitutionsXmls Include="$(ILLinkDirectory)ILLink.Substitutions.xml" />
<ILLinkSubstitutionsXmls Condition="'$(TargetsAndroid)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetsMacCatalyst)' == 'true' or '$(TargetsTVOS)' == 'true'"
Include="$(ILLinkDirectory)ILLink.Substitutions.mobile.xml" />
<ILLinkSuppressionsXmls Condition="'$(TargetsMobile)' == 'true'" Include="$(ILLinkDirectory)ILLink.Suppressions.Mobile.LibraryBuild.xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="System\Net\Http\ByteArrayContent.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Threading.Tasks;

using Xunit;
using Microsoft.DotNet.XUnitExtensions;

namespace System.Net.NetworkInformation.Tests
{
Expand All @@ -19,7 +20,7 @@ public class UnixPingUtilityTests
{
private const int IcmpHeaderLengthInBytes = 8;

[Theory]
[ConditionalTheory]
[InlineData(0)]
[InlineData(100)]
[InlineData(1000)]
Expand All @@ -32,13 +33,26 @@ public static void TimeoutIsRespected(int timeout)
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardOutput = true;

bool destinationNetUnreachable = false;
p.OutputDataReceived += delegate (object sendingProcess, DataReceivedEventArgs outputLine)
{
if (outputLine.Data?.Contains("Destination Net Unreachable", StringComparison.OrdinalIgnoreCase) == true)
destinationNetUnreachable = true;
};

Stopwatch stopWatch = Stopwatch.StartNew();

p.Start();
p.BeginOutputReadLine();
p.WaitForExit();

//ensure that the process takes longer than or equal to 'timeout'
Assert.True(stopWatch.ElapsedMilliseconds >= timeout);
if (destinationNetUnreachable)
{
throw new SkipTestException($"Network doesn't route {TestSettings.UnreachableAddress}, skipping test.");
}

//ensure that the process takes longer than or within 10ms of 'timeout', with a 5s maximum
Assert.InRange(stopWatch.ElapsedMilliseconds, timeout - 10, 5000);
}

[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsThreadingSupported))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,8 @@ public void GetFolderPath_Unix_PersonalIsHomeAndUserProfile()
Assert.Equal(Environment.GetEnvironmentVariable("HOME"), Environment.GetFolderPath(Environment.SpecialFolder.Personal));
Assert.Equal(Environment.GetEnvironmentVariable("HOME"), Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
}
// tvOS effectively doesn't have a HOME
if (!PlatformDetection.IstvOS)
{
Assert.Equal(Environment.GetEnvironmentVariable("HOME"), Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
}

Assert.Equal(Environment.GetEnvironmentVariable("HOME"), Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
}

[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,9 @@ public static void IsOSPlatformVersionAtLeast_InvalidArgs_Throws()
public static void TestIsOSVersionAtLeast_Android_21() => Assert.True(OperatingSystem.IsAndroidVersionAtLeast(21)); // 21 is our min supported version

[Fact, PlatformSpecific(TestPlatforms.iOS)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/56084", TestPlatforms.MacCatalyst)]
public static void TestIsOSPlatform_IOS() => TestIsOSPlatform("iOS", OperatingSystem.IsIOS);

[Fact, PlatformSpecific(TestPlatforms.iOS)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/56084", TestPlatforms.MacCatalyst)]
public static void TestIsOSVersionAtLeast_IOS() => TestIsOSVersionAtLeast("iOS");

[Fact, PlatformSpecific(TestPlatforms.OSX)]
Expand All @@ -129,11 +127,9 @@ public static void OSX_Is_Treated_as_macOS()
}

[Fact, PlatformSpecific(TestPlatforms.MacCatalyst)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/56084", TestPlatforms.MacCatalyst)]
public static void TestIsOSPlatform_MacCatalyst() => TestIsOSPlatform("MacCatalyst", OperatingSystem.IsMacCatalyst);

[Fact, PlatformSpecific(TestPlatforms.MacCatalyst)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/56084", TestPlatforms.MacCatalyst)]
public static void TestIsOSVersionAtLeast_MacCatalyst() => TestIsOSVersionAtLeast("MacCatalyst");

[Fact, PlatformSpecific(TestPlatforms.MacCatalyst)]
Expand All @@ -147,7 +143,6 @@ public static void MacCatalyst_Is_Also_iOS()
}

[Fact, PlatformSpecific(TestPlatforms.iOS)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/56084", TestPlatforms.MacCatalyst)]
public static void IOS_Is_Not_Also_MacCatalyst()
{
Assert.False(OperatingSystem.IsOSPlatform("MacCatalyst"));
Expand All @@ -172,6 +167,12 @@ private static void TestIsOSPlatform(string currentOSName, Func<bool> currentOSC
{
bool expected = currentOSName.Equals(platformName, StringComparison.OrdinalIgnoreCase);

// MacCatalyst is a special case since it also returns true for iOS
if (currentOSName == "MacCatalyst" && platformName == "iOS")
{
expected = true;
}

Assert.Equal(expected, OperatingSystem.IsOSPlatform(platformName));
Assert.Equal(expected, OperatingSystem.IsOSPlatform(platformName.ToUpper()));
Assert.Equal(expected, OperatingSystem.IsOSPlatform(platformName.ToLower()));
Expand All @@ -186,14 +187,32 @@ private static void TestIsOSPlatform(string currentOSName, Func<bool> currentOSC
OperatingSystem.IsFreeBSD(),
OperatingSystem.IsAndroid(),
OperatingSystem.IsIOS(),
OperatingSystem.IsMacOS(),
OperatingSystem.IsMacCatalyst(),
OperatingSystem.IsMacOS(),
OperatingSystem.IsTvOS(),
OperatingSystem.IsWatchOS(),
OperatingSystem.IsWindows()
};

Assert.Single(allResults, true);
// MacCatalyst is a special case since it also returns true for iOS
if (currentOSName == "MacCatalyst")
{
Assert.Equal(10, allResults.Length);
Assert.False(allResults[0]); // IsBrowser()
Assert.False(allResults[1]); // IsLinux()
Assert.False(allResults[2]); // IsFreeBSD()
Assert.False(allResults[3]); // IsAndroid()
Assert.True(allResults[4]); // IsIOS()
Assert.True(allResults[5]); // IsMacCatalyst()
Assert.False(allResults[6]); // IsMacOS()
Assert.False(allResults[7]); // IsTvOS()
Assert.False(allResults[8]); // IsWatchOS()
Assert.False(allResults[9]); // IsWindows()
}
else
{
Assert.Single(allResults, true);
}
}

private static void TestIsOSVersionAtLeast(string currentOSName)
Expand All @@ -202,13 +221,19 @@ private static void TestIsOSVersionAtLeast(string currentOSName)
{
bool isCurrentOS = currentOSName.Equals(platformName, StringComparison.OrdinalIgnoreCase);

// MacCatalyst is a special case since it also returns true for iOS
if (currentOSName == "MacCatalyst" && platformName == "iOS")
{
isCurrentOS = true;
}

AssertVersionChecks(isCurrentOS, (major, minor, build, revision) => OperatingSystem.IsOSPlatformVersionAtLeast(platformName, major, minor, build, revision));
AssertVersionChecks(isCurrentOS, (major, minor, build, revision) => OperatingSystem.IsOSPlatformVersionAtLeast(platformName.ToLower(), major, minor, build, revision));
AssertVersionChecks(isCurrentOS, (major, minor, build, revision) => OperatingSystem.IsOSPlatformVersionAtLeast(platformName.ToUpper(), major, minor, build, revision));
}

AssertVersionChecks(currentOSName.Equals("Android", StringComparison.OrdinalIgnoreCase), OperatingSystem.IsAndroidVersionAtLeast);
AssertVersionChecks(currentOSName.Equals("iOS", StringComparison.OrdinalIgnoreCase), OperatingSystem.IsIOSVersionAtLeast);
AssertVersionChecks(currentOSName == "MacCatalyst" || currentOSName.Equals("iOS", StringComparison.OrdinalIgnoreCase), OperatingSystem.IsIOSVersionAtLeast);
AssertVersionChecks(currentOSName.Equals("macOS", StringComparison.OrdinalIgnoreCase), OperatingSystem.IsMacOSVersionAtLeast);
AssertVersionChecks(currentOSName.Equals("MacCatalyst", StringComparison.OrdinalIgnoreCase), OperatingSystem.IsMacCatalystVersionAtLeast);
AssertVersionChecks(currentOSName.Equals("tvOS", StringComparison.OrdinalIgnoreCase), OperatingSystem.IsTvOSVersionAtLeast);
Expand Down
Loading