diff options
Diffstat (limited to 'netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native')
34 files changed, 0 insertions, 984 deletions
diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.Access.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.Access.cs deleted file mode 100644 index a723f572a5b..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.Access.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class Sys - { - internal enum AccessMode : int - { - F_OK = 0, /* Check for existence */ - X_OK = 1, /* Check for execute */ - W_OK = 2, /* Check for write */ - R_OK = 4, /* Check for read */ - } - - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Access", SetLastError = true)] - internal static extern int Access(string path, AccessMode mode); - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.ChDir.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.ChDir.cs deleted file mode 100644 index 3c66995182a..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.ChDir.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class Sys - { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ChDir", SetLastError = true)] - internal static extern int ChDir(string path); - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.Close.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.Close.cs deleted file mode 100644 index 8d192398a03..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.Close.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class Sys - { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Close", SetLastError = true)] - internal static extern int Close(IntPtr fd); - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.FLock.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.FLock.cs deleted file mode 100644 index 22934a3e77d..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.FLock.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Runtime.InteropServices; -using Microsoft.Win32.SafeHandles; - -internal static partial class Interop -{ - internal static partial class Sys - { - internal enum LockOperations : int - { - LOCK_SH = 1, /* shared lock */ - LOCK_EX = 2, /* exclusive lock */ - LOCK_NB = 4, /* don't block when locking*/ - LOCK_UN = 8, /* unlock */ - } - - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FLock", SetLastError = true)] - internal static extern int FLock(SafeFileHandle fd, LockOperations operation); - - /// <summary> - /// Exposing this for SafeFileHandle.ReleaseHandle() to call. - /// Normal callers should use FLock(SafeFileHandle fd). - /// </summary> - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FLock", SetLastError = true)] - internal static extern int FLock(IntPtr fd, LockOperations operation); - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.FSync.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.FSync.cs deleted file mode 100644 index e3ab9709313..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.FSync.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.InteropServices; -using Microsoft.Win32.SafeHandles; - -internal static partial class Interop -{ - internal static partial class Sys - { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FSync", SetLastError = true)] - internal static extern int FSync(SafeFileHandle fd); - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.FTruncate.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.FTruncate.cs deleted file mode 100644 index 5dad650362d..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.FTruncate.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.InteropServices; -using Microsoft.Win32.SafeHandles; - -internal static partial class Interop -{ - internal static partial class Sys - { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FTruncate", SetLastError = true)] - internal static extern int FTruncate(SafeFileHandle fd, long length); - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetCpuUtilization.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetCpuUtilization.cs deleted file mode 100644 index a630a3e82c3..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetCpuUtilization.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal unsafe partial class Sys - { - [StructLayout(LayoutKind.Sequential)] - internal struct ProcessCpuInformation - { - internal ulong lastRecordedCurrentTime; - internal ulong lastRecordedKernelTime; - internal ulong lastRecordedUserTime; - } - - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetCpuUtilization")] - internal static extern unsafe int GetCpuUtilization(ref ProcessCpuInformation previousCpuInfo); - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetCwd.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetCwd.cs deleted file mode 100644 index b339ab2f596..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetCwd.cs +++ /dev/null @@ -1,73 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Buffers; -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class Sys - { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetCwd", SetLastError = true)] - private static extern unsafe byte* GetCwd(byte* buffer, int bufferLength); - - internal static unsafe string GetCwd() - { - const int StackLimit = 256; - - // First try to get the path into a buffer on the stack - byte* stackBuf = stackalloc byte[StackLimit]; - string? result = GetCwdHelper(stackBuf, StackLimit); - if (result != null) - { - return result; - } - - // If that was too small, try increasing large buffer sizes - int bufferSize = StackLimit; - while (true) - { - checked { bufferSize *= 2; } - byte[] buf = ArrayPool<byte>.Shared.Rent(bufferSize); - try - { - fixed (byte* ptr = &buf[0]) - { - result = GetCwdHelper(ptr, buf.Length); - if (result != null) - { - return result; - } - } - } - finally - { - ArrayPool<byte>.Shared.Return(buf); - } - } - } - - private static unsafe string? GetCwdHelper(byte* ptr, int bufferSize) - { - // Call the real getcwd - byte* result = GetCwd(ptr, bufferSize); - - // If it returned non-null, the null-terminated path is in the buffer - if (result != null) - { - return Marshal.PtrToStringAnsi((IntPtr)ptr); - } - - // Otherwise, if it failed due to the buffer being too small, return null; - // for anything else, throw. - ErrorInfo errorInfo = Interop.Sys.GetLastErrorInfo(); - if (errorInfo.Error == Interop.Error.ERANGE) - { - return null; - } - throw Interop.GetExceptionForIoErrno(errorInfo); - } - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetEUid.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetEUid.cs deleted file mode 100644 index 8b525fa3272..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetEUid.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class Sys - { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetEUid")] - internal static extern uint GetEUid(); - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetHostName.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetHostName.cs deleted file mode 100644 index f2555b0fc82..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetHostName.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Diagnostics; -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class Sys - { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetHostName", SetLastError = true)] - private static extern unsafe int GetHostName(byte* name, int nameLength); - - internal static unsafe string GetHostName() - { - const int HOST_NAME_MAX = 255; - const int ArrLength = HOST_NAME_MAX + 1; - - byte* name = stackalloc byte[ArrLength]; - int err = GetHostName(name, ArrLength); - if (err != 0) - { - // This should never happen. According to the man page, - // the only possible errno for gethostname is ENAMETOOLONG, - // which should only happen if the buffer we supply isn't big - // enough, and we're using a buffer size that the man page - // says is the max for POSIX (and larger than the max for Linux). - Debug.Fail($"GetHostName failed with error {err}"); - throw new InvalidOperationException($"{nameof(GetHostName)}: {err}"); - } - - // If the hostname is truncated, it is unspecified whether the returned buffer includes a terminating null byte. - name[ArrLength - 1] = 0; - - return Marshal.PtrToStringAnsi((IntPtr)name)!; - } - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetPid.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetPid.cs deleted file mode 100644 index 02d259db7d1..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetPid.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class Sys - { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetPid")] - internal static extern int GetPid(); - } - - internal static uint GetCurrentProcessId() => (uint)Sys.GetPid(); -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetPwUid.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetPwUid.cs deleted file mode 100644 index 28b2309d03e..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetPwUid.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class Sys - { - internal unsafe struct Passwd - { - internal const int InitialBufferSize = 256; - - internal byte* Name; - internal byte* Password; - internal uint UserId; - internal uint GroupId; - internal byte* UserInfo; - internal byte* HomeDirectory; - internal byte* Shell; - } - - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetPwUidR", SetLastError = false)] - internal static extern unsafe int GetPwUidR(uint uid, out Passwd pwd, byte* buf, int bufLen); - - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetPwNamR", SetLastError = false)] - internal static extern unsafe int GetPwNamR(string name, out Passwd pwd, byte* buf, int bufLen); - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetRandomBytes.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetRandomBytes.cs deleted file mode 100644 index 858506935ae..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetRandomBytes.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Diagnostics; -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal unsafe partial class Sys - { - [DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_GetNonCryptographicallySecureRandomBytes")] - internal static extern unsafe void GetNonCryptographicallySecureRandomBytes(byte* buffer, int length); - } - - internal static unsafe void GetRandomBytes(byte* buffer, int length) - { - Sys.GetNonCryptographicallySecureRandomBytes(buffer, length); - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetSystemTimeAsTicks.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetSystemTimeAsTicks.cs deleted file mode 100644 index f02ecac13b9..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetSystemTimeAsTicks.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal unsafe partial class Sys - { - [DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_GetSystemTimeAsTicks")] - internal static extern long GetSystemTimeAsTicks(); - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetTimestamp.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetTimestamp.cs deleted file mode 100644 index 53acdbc3cc3..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetTimestamp.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class Sys - { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetTimestampResolution", ExactSpelling = true)] - internal static extern ulong GetTimestampResolution(); - - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetTimestamp", ExactSpelling = true)] - [SuppressGCTransition] - internal static extern ulong GetTimestamp(); - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetUnixName.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetUnixName.cs deleted file mode 100644 index fb925b9dca9..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetUnixName.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class Sys - { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetUnixName")] - private static extern IntPtr GetUnixNamePrivate(); - - internal static string GetUnixName() - { - IntPtr ptr = GetUnixNamePrivate(); - return Marshal.PtrToStringAnsi(ptr)!; - } - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetUnixRelease.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetUnixRelease.cs deleted file mode 100644 index 5e41ae98046..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetUnixRelease.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class Sys - { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetUnixRelease", CharSet = CharSet.Ansi, SetLastError = true)] - public static extern string GetUnixRelease(); - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.LSeek.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.LSeek.cs deleted file mode 100644 index 7f8df7c6bf9..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.LSeek.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.InteropServices; -using Microsoft.Win32.SafeHandles; - -internal static partial class Interop -{ - internal static partial class Sys - { - internal enum SeekWhence - { - SEEK_SET = 0, - SEEK_CUR = 1, - SEEK_END = 2 - } - - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LSeek", SetLastError = true)] - internal static extern long LSeek(SafeFileHandle fd, long offset, SeekWhence whence); - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.LockFileRegion.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.LockFileRegion.cs deleted file mode 100644 index 1deb9a43132..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.LockFileRegion.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class Sys - { - internal enum LockType : short - { - F_WRLCK = 1, // exclusive or write lock - F_UNLCK = 2 // unlock - } - - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LockFileRegion", SetLastError=true)] - internal static extern int LockFileRegion(SafeHandle fd, long offset, long length, LockType lockType); - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.MksTemps.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.MksTemps.cs deleted file mode 100644 index 14c2d989130..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.MksTemps.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class Sys - { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_MksTemps", SetLastError = true)] - internal static extern IntPtr MksTemps( - byte[] template, - int suffixlen); - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.MountPoints.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.MountPoints.cs deleted file mode 100644 index 134dcb92037..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.MountPoints.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class Sys - { - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - private unsafe delegate void MountPointFound(byte* name); - - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetAllMountPoints", SetLastError = true)] - private static extern int GetAllMountPoints(MountPointFound mpf); - - internal static string[] GetAllMountPoints() - { - int count = 0; - var found = new string[4]; - - unsafe - { - int result = GetAllMountPoints((byte* name) => - { - if (count == found.Length) - { - Array.Resize(ref found, count * 2); - } - found[count++] = Marshal.PtrToStringAnsi((IntPtr)name)!; - }); - } - - Array.Resize(ref found, count); - return found; - } - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.Open.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.Open.cs deleted file mode 100644 index a9a994c78c0..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.Open.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.InteropServices; -using Microsoft.Win32.SafeHandles; - -internal static partial class Interop -{ - internal static partial class Sys - { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Open", SetLastError = true)] - internal static extern SafeFileHandle Open(string filename, OpenFlags flags, int mode); - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.OpenFlags.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.OpenFlags.cs deleted file mode 100644 index f9e54c3cbcf..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.OpenFlags.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; - -internal static partial class Interop -{ - internal static partial class Sys - { - [Flags] - internal enum OpenFlags - { - // Access modes (mutually exclusive) - O_RDONLY = 0x0000, - O_WRONLY = 0x0001, - O_RDWR = 0x0002, - - // Flags (combinable) - O_CLOEXEC = 0x0010, - O_CREAT = 0x0020, - O_EXCL = 0x0040, - O_TRUNC = 0x0080, - O_SYNC = 0x0100, - } - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.PathConf.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.PathConf.cs deleted file mode 100644 index 7213cb02640..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.PathConf.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class Sys - { - internal enum PathConfName : int - { - PC_LINK_MAX = 1, - PC_MAX_CANON = 2, - PC_MAX_INPUT = 3, - PC_NAME_MAX = 4, - PC_PATH_MAX = 5, - PC_PIPE_BUF = 6, - PC_CHOWN_RESTRICTED = 7, - PC_NO_TRUNC = 8, - PC_VDISABLE = 9, - } - - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_PathConf", SetLastError = true)] - private static extern int PathConf(string path, PathConfName name); - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.Permissions.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.Permissions.cs deleted file mode 100644 index f1d13787d25..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.Permissions.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; - -internal static partial class Interop -{ - internal static partial class Sys - { - [Flags] - internal enum Permissions - { - Mask = S_IRWXU | S_IRWXG | S_IRWXO, - - S_IRWXU = S_IRUSR | S_IWUSR | S_IXUSR, - S_IRUSR = 0x100, - S_IWUSR = 0x80, - S_IXUSR = 0x40, - - S_IRWXG = S_IRGRP | S_IWGRP | S_IXGRP, - S_IRGRP = 0x20, - S_IWGRP = 0x10, - S_IXGRP = 0x8, - - S_IRWXO = S_IROTH | S_IWOTH | S_IXOTH, - S_IROTH = 0x4, - S_IWOTH = 0x2, - S_IXOTH = 0x1, - } - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.PosixFAdvise.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.PosixFAdvise.cs deleted file mode 100644 index ad8b73aed21..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.PosixFAdvise.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.InteropServices; -using Microsoft.Win32.SafeHandles; - -internal static partial class Interop -{ - internal static partial class Sys - { - internal enum FileAdvice : int - { - POSIX_FADV_NORMAL = 0, /* no special advice, the default value */ - POSIX_FADV_RANDOM = 1, /* random I/O access */ - POSIX_FADV_SEQUENTIAL = 2, /* sequential I/O access */ - POSIX_FADV_WILLNEED = 3, /* will need specified pages */ - POSIX_FADV_DONTNEED = 4, /* don't need the specified pages */ - POSIX_FADV_NOREUSE = 5, /* data will only be accessed once */ - } - - /// <summary> - /// Notifies the OS kernel that the specified file will be accessed in a particular way soon; this allows the kernel to - /// potentially optimize the access pattern of the file. - /// </summary> - /// <param name="fd">The file descriptor of the file</param> - /// <param name="offset">The start of the region to advise about</param> - /// <param name="length">The number of bytes of the region (until the end of the file if 0)</param> - /// <param name="advice">The type of advice to give the kernel about the specified region</param> - /// <returns> - /// Returns 0 on success; otherwise, the error code is returned - /// </returns> - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_PosixFAdvise", SetLastError = false /* this is explicitly called out in the man page */)] - internal static extern int PosixFAdvise(SafeFileHandle fd, long offset, long length, FileAdvice advice); - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.Read.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.Read.cs deleted file mode 100644 index 233feabdbb6..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.Read.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.InteropServices; -using Microsoft.Win32.SafeHandles; - -internal static partial class Interop -{ - internal static partial class Sys - { - /// <summary> - /// Reads a number of bytes from an open file descriptor into a specified buffer. - /// </summary> - /// <param name="fd">The open file descriptor to try to read from</param> - /// <param name="buffer">The buffer to read info into</param> - /// <param name="count">The size of the buffer</param> - /// <returns> - /// Returns the number of bytes read on success; otherwise, -1 is returned - /// Note - on fail. the position of the stream may change depending on the platform; consult man 2 read for more info - /// </returns> - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Read", SetLastError = true)] - internal static extern unsafe int Read(SafeHandle fd, byte* buffer, int count); - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.ReadDir.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.ReadDir.cs deleted file mode 100644 index cacb3664db0..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.ReadDir.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Diagnostics; -using System.Runtime.InteropServices; -using System.Text; - -internal static partial class Interop -{ - internal static partial class Sys - { - internal enum NodeType : int - { - DT_UNKNOWN = 0, - DT_FIFO = 1, - DT_CHR = 2, - DT_DIR = 4, - DT_BLK = 6, - DT_REG = 8, - DT_LNK = 10, - DT_SOCK = 12, - DT_WHT = 14 - } - - [StructLayout(LayoutKind.Sequential)] - internal unsafe struct DirectoryEntry - { - internal byte* Name; - internal int NameLength; - internal NodeType InodeType; - internal const int NameBufferSize = 256; // sizeof(dirent->d_name) == NAME_MAX + 1 - - internal ReadOnlySpan<char> GetName(Span<char> buffer) - { - // -1 for null terminator (buffer will not include one), - // and -1 because GetMaxCharCount pessimistically assumes the buffer may start with a partial surrogate - Debug.Assert(buffer.Length >= Encoding.UTF8.GetMaxCharCount(NameBufferSize - 1 - 1)); - - Debug.Assert(Name != null, "should not have a null name"); - - ReadOnlySpan<byte> nameBytes = (NameLength == -1) - // In this case the struct was allocated via struct dirent *readdir(DIR *dirp); - ? new ReadOnlySpan<byte>(Name, new ReadOnlySpan<byte>(Name, NameBufferSize).IndexOf<byte>(0)) - : new ReadOnlySpan<byte>(Name, NameLength); - - Debug.Assert(nameBytes.Length > 0, "we shouldn't have gotten a garbage value from the OS"); - - int charCount = Encoding.UTF8.GetChars(nameBytes, buffer); - ReadOnlySpan<char> value = buffer.Slice(0, charCount); - Debug.Assert(NameLength != -1 || !value.Contains('\0'), "should not have embedded nulls if we parsed the end of string"); - return value; - } - } - - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_OpenDir", SetLastError = true)] - internal static extern IntPtr OpenDir(string path); - - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetReadDirRBufferSize", SetLastError = false)] - internal static extern int GetReadDirRBufferSize(); - - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ReadDirR", SetLastError = false)] - internal static extern unsafe int ReadDirR(IntPtr dir, byte* buffer, int bufferSize, out DirectoryEntry outputEntry); - - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_CloseDir", SetLastError = true)] - internal static extern int CloseDir(IntPtr dir); - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.ReadLink.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.ReadLink.cs deleted file mode 100644 index b945bc982c5..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.ReadLink.cs +++ /dev/null @@ -1,64 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#nullable enable -using System.Runtime.InteropServices; -using System.Buffers; -using System.Text; - -internal static partial class Interop -{ - internal static partial class Sys - { - /// <summary> - /// Takes a path to a symbolic link and attempts to place the link target path into the buffer. If the buffer is too - /// small, the path will be truncated. No matter what, the buffer will not be null terminated. - /// </summary> - /// <param name="path">The path to the symlink</param> - /// <param name="buffer">The buffer to hold the output path</param> - /// <param name="bufferSize">The size of the buffer</param> - /// <returns> - /// Returns the number of bytes placed into the buffer on success; bufferSize if the buffer is too small; and -1 on error. - /// </returns> - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ReadLink", SetLastError = true)] - private static extern unsafe int ReadLink(string path, byte[] buffer, int bufferSize); - - /// <summary> - /// Takes a path to a symbolic link and returns the link target path. - /// </summary> - /// <param name="path">The path to the symlink</param> - /// <returns> - /// Returns the link to the target path on success; and null otherwise. - /// </returns> - public static string? ReadLink(string path) - { - int bufferSize = 256; - while (true) - { - byte[] buffer = ArrayPool<byte>.Shared.Rent(bufferSize); - try - { - int resultLength = Interop.Sys.ReadLink(path, buffer, buffer.Length); - if (resultLength < 0) - { - // error - return null; - } - else if (resultLength < buffer.Length) - { - // success - return Encoding.UTF8.GetString(buffer, 0, resultLength); - } - } - finally - { - ArrayPool<byte>.Shared.Return(buffer); - } - - // buffer was too small, loop around again and try with a larger buffer. - bufferSize *= 2; - } - } - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.Stat.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.Stat.cs deleted file mode 100644 index d06fbda7185..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.Stat.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Runtime.InteropServices; -using Microsoft.Win32.SafeHandles; - -internal static partial class Interop -{ - internal static partial class Sys - { - // Even though csc will by default use a sequential layout, a CS0649 warning as error - // is produced for un-assigned fields when no StructLayout is specified. - // - // Explicitly saying Sequential disables that warning/error for consumers which only - // use Stat in debug builds. - [StructLayout(LayoutKind.Sequential)] - internal struct FileStatus - { - internal FileStatusFlags Flags; - internal int Mode; - internal uint Uid; - internal uint Gid; - internal long Size; - internal long ATime; - internal long ATimeNsec; - internal long MTime; - internal long MTimeNsec; - internal long CTime; - internal long CTimeNsec; - internal long BirthTime; - internal long BirthTimeNsec; - internal long Dev; - internal long Ino; - internal uint UserFlags; - } - - internal static class FileTypes - { - internal const int S_IFMT = 0xF000; - internal const int S_IFIFO = 0x1000; - internal const int S_IFCHR = 0x2000; - internal const int S_IFDIR = 0x4000; - internal const int S_IFREG = 0x8000; - internal const int S_IFLNK = 0xA000; - internal const int S_IFSOCK = 0xC000; - } - - [Flags] - internal enum FileStatusFlags - { - None = 0, - HasBirthTime = 1, - } - - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FStat", SetLastError = true)] - internal static extern int FStat(SafeFileHandle fd, out FileStatus output); - - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Stat", SetLastError = true)] - internal static extern int Stat(string path, out FileStatus output); - - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LStat", SetLastError = true)] - internal static extern int LStat(string path, out FileStatus output); - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.SysConf.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.SysConf.cs deleted file mode 100644 index be0c0dee7bb..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.SysConf.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class Sys - { - internal enum SysConfName - { - _SC_CLK_TCK = 1, - _SC_PAGESIZE = 2 - } - - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SysConf", SetLastError = true)] - internal static extern long SysConf(SysConfName name); - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.SysLog.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.SysLog.cs deleted file mode 100644 index 2edde6fbc11..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.SysLog.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class Sys - { - internal enum SysLogPriority : int - { - // Priorities - LOG_EMERG = 0, /* system is unusable */ - LOG_ALERT = 1, /* action must be taken immediately */ - LOG_CRIT = 2, /* critical conditions */ - LOG_ERR = 3, /* error conditions */ - LOG_WARNING = 4, /* warning conditions */ - LOG_NOTICE = 5, /* normal but significant condition */ - LOG_INFO = 6, /* informational */ - LOG_DEBUG = 7, /* debug-level messages */ - // Facilities - LOG_KERN = (0<<3), /* kernel messages */ - LOG_USER = (1<<3), /* random user-level messages */ - LOG_MAIL = (2<<3), /* mail system */ - LOG_DAEMON = (3<<3), /* system daemons */ - LOG_AUTH = (4<<3), /* authorization messages */ - LOG_SYSLOG = (5<<3), /* messages generated internally by syslogd */ - LOG_LPR = (6<<3), /* line printer subsystem */ - LOG_NEWS = (7<<3), /* network news subsystem */ - LOG_UUCP = (8<<3), /* UUCP subsystem */ - LOG_CRON = (9<<3), /* clock daemon */ - LOG_AUTHPRIV = (10<<3), /* authorization messages (private) */ - LOG_FTP = (11<<3), /* ftp daemon */ - // Between FTP and Local is reserved for system use - LOG_LOCAL0 = (16<<3), /* reserved for local use */ - LOG_LOCAL1 = (17<<3), /* reserved for local use */ - LOG_LOCAL2 = (18<<3), /* reserved for local use */ - LOG_LOCAL3 = (19<<3), /* reserved for local use */ - LOG_LOCAL4 = (20<<3), /* reserved for local use */ - LOG_LOCAL5 = (21<<3), /* reserved for local use */ - LOG_LOCAL6 = (22<<3), /* reserved for local use */ - LOG_LOCAL7 = (23<<3), /* reserved for local use */ - } - - /// <summary> - /// Write a message to the system logger, which in turn writes the message to the system console, log files, etc. - /// See man 3 syslog for more info - /// </summary> - /// <param name="priority"> - /// The OR of a priority and facility in the SysLogPriority enum to declare the priority and facility of the log entry - /// </param> - /// <param name="message">The message to put in the log entry</param> - /// <param name="arg1">Like printf, the argument is passed to the variadic part of the C++ function to wildcards in the message</param> - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SysLog")] - internal static extern void SysLog(SysLogPriority priority, string message, string arg1); - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.Unlink.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.Unlink.cs deleted file mode 100644 index 829210fa7e0..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.Unlink.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System; -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class Sys - { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Unlink", SetLastError = true)] - internal static extern int Unlink(string pathname); - } -} diff --git a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.Write.cs b/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.Write.cs deleted file mode 100644 index fb06d463beb..00000000000 --- a/netcore/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.Write.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -using System.Runtime.InteropServices; -using Microsoft.Win32.SafeHandles; - -internal static partial class Interop -{ - internal static partial class Sys - { - /// <summary> - /// Writes the specified buffer to the provided open file descriptor - /// </summary> - /// <param name="fd">The file descriptor to try and write to</param> - /// <param name="buffer">The data to attempt to write</param> - /// <param name="bufferSize">The amount of data to write, in bytes</param> - /// <returns> - /// Returns the number of bytes written on success; otherwise, returns -1 and sets errno - /// </returns> - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Write", SetLastError = true)] - internal static extern unsafe int Write(SafeHandle fd, byte* buffer, int bufferSize); - - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Write", SetLastError = true)] - internal static extern unsafe int Write(int fd, byte* buffer, int bufferSize); - } -} |