Update with corefx PR changes
authorIan Hays <ianha@microsoft.com>
Fri, 18 Nov 2016 18:50:17 +0000 (10:50 -0800)
committerIan Hays <ianha@microsoft.com>
Fri, 18 Nov 2016 18:50:17 +0000 (10:50 -0800)
src/mscorlib/corefx/Interop/Unix/System.Native/Interop.Fcntl.cs
src/mscorlib/corefx/System/IO/FileStream.Unix.cs

index 1dc003b..e0b22e4 100644 (file)
@@ -9,10 +9,13 @@ 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);
+        internal enum LockType : short
+        {
+            F_UNLCK = 2,    // unlock
+            F_WRLCK = 3     // exclusive or write lock
+        }
         
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_UnlockFileRegion", SetLastError=true)]
-        internal static extern int UnlockFileRegion(SafeHandle fd, long offset, long length);
+        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LockFileRegion", SetLastError=true)]
+        internal static extern int LockFileRegion(SafeHandle fd, long offset, long length, LockType lockType);
     }
 }
index f11f97c..f83fc84 100644 (file)
@@ -801,7 +801,7 @@ namespace System.IO
         /// <param name="length">The range to be locked.</param>
         private void LockInternal(long position, long length)
         {
-            CheckFileCall(Interop.Sys.LockFileRegion(_fileHandle, position, length));
+            CheckFileCall(Interop.Sys.LockFileRegion(_fileHandle, position, length, Interop.Sys.LockType.F_WRLCK));
         }
 
         /// <summary>Allows access by other processes to all or part of a file that was previously locked.</summary>
@@ -809,7 +809,7 @@ namespace System.IO
         /// <param name="length">The range to be unlocked.</param>
         private void UnlockInternal(long position, long length)
         {
-            CheckFileCall(Interop.Sys.UnlockFileRegion(_fileHandle, position, length));
+            CheckFileCall(Interop.Sys.LockFileRegion(_fileHandle, position, length, Interop.Sys.LockType.F_UNLCK));
         }
 
         /// <summary>Sets the current position of this stream to the given value.</summary>