diff options
-rw-r--r-- | src/mscorlib/corefx/Interop/Unix/System.Native/Interop.Fcntl.cs | 18 | ||||
-rw-r--r-- | src/mscorlib/corefx/System/IO/FileStream.Unix.cs | 6 | ||||
-rw-r--r-- | src/mscorlib/mscorlib.shared.sources.props | 1 |
3 files changed, 21 insertions, 4 deletions
diff --git a/src/mscorlib/corefx/Interop/Unix/System.Native/Interop.Fcntl.cs b/src/mscorlib/corefx/Interop/Unix/System.Native/Interop.Fcntl.cs new file mode 100644 index 0000000000..1dc003b28a --- /dev/null +++ b/src/mscorlib/corefx/Interop/Unix/System.Native/Interop.Fcntl.cs @@ -0,0 +1,18 @@ +// 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_LockFileRegion", SetLastError=true)] + internal static extern int LockFileRegion(SafeHandle fd, long offset, long length); + + [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_UnlockFileRegion", SetLastError=true)] + internal static extern int UnlockFileRegion(SafeHandle fd, long offset, long length); + } +} diff --git a/src/mscorlib/corefx/System/IO/FileStream.Unix.cs b/src/mscorlib/corefx/System/IO/FileStream.Unix.cs index ece19235d7..f11f97c795 100644 --- a/src/mscorlib/corefx/System/IO/FileStream.Unix.cs +++ b/src/mscorlib/corefx/System/IO/FileStream.Unix.cs @@ -801,8 +801,7 @@ namespace System.IO /// <param name="length">The range to be locked.</param> private void LockInternal(long position, long length) { - // TODO #5964: Implement this with fcntl and F_SETLK in System.Native - throw new PlatformNotSupportedException(); + CheckFileCall(Interop.Sys.LockFileRegion(_fileHandle, position, length)); } /// <summary>Allows access by other processes to all or part of a file that was previously locked.</summary> @@ -810,8 +809,7 @@ namespace System.IO /// <param name="length">The range to be unlocked.</param> private void UnlockInternal(long position, long length) { - // TODO #5964: Implement this with fcntl and F_SETLK in System.Native - throw new PlatformNotSupportedException(); + CheckFileCall(Interop.Sys.UnlockFileRegion(_fileHandle, position, length)); } /// <summary>Sets the current position of this stream to the given value.</summary> diff --git a/src/mscorlib/mscorlib.shared.sources.props b/src/mscorlib/mscorlib.shared.sources.props index 2fdfa01cb5..98fee905b2 100644 --- a/src/mscorlib/mscorlib.shared.sources.props +++ b/src/mscorlib/mscorlib.shared.sources.props @@ -1250,6 +1250,7 @@ <UnixInteropSources Include="$(CoreFxSourcesRoot)\Interop\Unix\System.Native\Interop.Close.cs" /> <UnixInteropSources Include="$(CoreFxSourcesRoot)\Interop\Unix\System.Native\Interop.GetCwd.cs" /> <UnixInteropSources Include="$(CoreFxSourcesRoot)\Interop\Unix\System.Native\Interop.GetUnixName.cs" /> + <UnixInteropSources Include="$(CoreFxSourcesRoot)\Interop\Unix\System.Native\Interop.Fcntl.cs" /> <UnixInteropSources Include="$(CoreFxSourcesRoot)\Interop\Unix\System.Native\Interop.FLock.cs" /> <UnixInteropSources Include="$(CoreFxSourcesRoot)\Interop\Unix\System.Native\Interop.FSync.cs" /> <UnixInteropSources Include="$(CoreFxSourcesRoot)\Interop\Unix\System.Native\Interop.FTruncate.cs" /> |