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

Unix interop uses non-posix open64 #14099

Closed
kangaroo opened this issue Feb 10, 2015 · 2 comments · Fixed by dotnet/corefx#716
Closed

Unix interop uses non-posix open64 #14099

kangaroo opened this issue Feb 10, 2015 · 2 comments · Fixed by dotnet/corefx#716
Assignees
Labels
bug os-linux Linux OS (any supported distro)
Milestone

Comments

@kangaroo
Copy link
Contributor

The unix interop layer currently pinvokes open64. open64 is a non-POSIX extension. We should move to using open() with O_LARGEFILE.

This currently blocks using System.Console and System.IO on osx.

@kangaroo
Copy link
Contributor Author

Trivial fix without O_LARGEFILE:

diff --git a/src/Common/src/Interop/Unix/libc/Interop.open64.cs b/src/Common/src/Interop/Unix/libc/Interop.open64.cs
index d5810ce..e6ec079 100644
--- a/src/Common/src/Interop/Unix/libc/Interop.open64.cs
+++ b/src/Common/src/Interop/Unix/libc/Interop.open64.cs
@@ -11,7 +11,7 @@ internal static partial class Interop
     internal static partial class libc
     {
         [DllImport(Libraries.Libc, SetLastError = true)]
-        internal static extern int open64(string filename, OpenFlags flags, mode_t mode);
+        internal static extern int open(string filename, OpenFlags flags, mode_t mode);

         [Flags]
         internal enum OpenFlags
diff --git a/src/Common/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs b/src/Common/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs
index e7cf81c..49f0bed 100644
--- a/src/Common/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs
+++ b/src/Common/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs
@@ -38,7 +38,7 @@ namespace Microsoft.Win32.SafeHandles
             try { } finally
             {
                 int fd;
-                while (Interop.CheckIo(fd = Interop.libc.open64(path, flags, mode))) ;
+                while (Interop.CheckIo(fd = Interop.libc.open(path, flags, mode))) ;
                 Contract.Assert(fd >= 0);
                 handle.SetHandle((IntPtr)fd);
             }
diff --git a/src/System.Console/src/System/ConsolePal.Unix.cs b/src/System.Console/src/System/ConsolePal.Unix.cs
index a51ab83..b3de57c 100644
--- a/src/System.Console/src/System/ConsolePal.Unix.cs
+++ b/src/System.Console/src/System/ConsolePal.Unix.cs
@@ -448,7 +448,7 @@ namespace System
                     string filePath = directoryPath + "/" + term[0] + "/" + term; // filePath == /directory/termFirstLetter/term

                     int fd;
-                    while ((fd = Interop.libc.open64(filePath, Interop.libc.OpenFlags.O_RDONLY, 0)) < 0)
+                    while ((fd = Interop.libc.open(filePath, Interop.libc.OpenFlags.O_RDONLY, 0)) < 0)
                     {
                         // Don't throw in this case, as we'll be polling multiple locations looking for the file.
                         // But we still want to retry if the open is interrupted by a signal.

@stephentoub stephentoub self-assigned this Feb 10, 2015
@stephentoub
Copy link
Member

Thanks, @kangaroo. I'll fix this.

madsiberian referenced this issue in madsiberian/corefx Dec 2, 2017
add dotnet version output to release notes
@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 1.0.0-rtm milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Jan 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug os-linux Linux OS (any supported distro)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants