From 1af810bd9f94b9a7f540919bdce29af97b80f8a7 Mon Sep 17 00:00:00 2001 From: Dan Moseley Date: Sat, 9 Mar 2019 13:54:04 -0800 Subject: [PATCH] Remove 2 suffix step 1 (dotnet/corefx#35904) Commit migrated from https://github.com/dotnet/corefx/commit/71a2e84b885f4d83697c93d25cebdb85c28a5d74 --- .../Unix/System.Native/Interop.Stat.Pipe.cs | 2 +- .../Unix/System.Native/Interop.Stat.Span.cs | 4 ++-- src/libraries/Native/Unix/System.Native/pal_io.c | 24 +++++++++++++++++----- src/libraries/Native/Unix/System.Native/pal_io.h | 21 +++++++++++++++++++ 4 files changed, 43 insertions(+), 8 deletions(-) diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Stat.Pipe.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Stat.Pipe.cs index 7985ceb..b52f565 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Stat.Pipe.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Stat.Pipe.cs @@ -10,7 +10,7 @@ internal static partial class Interop { internal static partial class Sys { - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FStat2", SetLastError = true)] + [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FStat", SetLastError = true)] internal static extern int FStat(SafePipeHandle fd, out FileStatus output); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Stat.Span.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Stat.Span.cs index 6216a6b..3ff0cba 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Stat.Span.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Stat.Span.cs @@ -14,7 +14,7 @@ internal static partial class Interop // without putting too much pressure on the stack. private const int StackBufferSize = 256; - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Stat2", SetLastError = true)] + [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Stat", SetLastError = true)] internal unsafe static extern int Stat(ref byte path, out FileStatus output); internal unsafe static int Stat(ReadOnlySpan path, out FileStatus output) @@ -26,7 +26,7 @@ internal static partial class Interop return result; } - [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LStat2", SetLastError = true)] + [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LStat", SetLastError = true)] internal static extern int LStat(ref byte path, out FileStatus output); internal unsafe static int LStat(ReadOnlySpan path, out FileStatus output) diff --git a/src/libraries/Native/Unix/System.Native/pal_io.c b/src/libraries/Native/Unix/System.Native/pal_io.c index fe0a854..eba8902 100644 --- a/src/libraries/Native/Unix/System.Native/pal_io.c +++ b/src/libraries/Native/Unix/System.Native/pal_io.c @@ -178,9 +178,7 @@ static void ConvertFileStatus(const struct stat_* src, FileStatus* dst) #endif } -// CoreCLR expects the "2" suffixes on these: they should be cleaned up in our -// next coordinated System.Native changes -int32_t SystemNative_Stat2(const char* path, FileStatus* output) +int32_t SystemNative_Stat(const char* path, FileStatus* output) { struct stat_ result; int ret; @@ -194,7 +192,7 @@ int32_t SystemNative_Stat2(const char* path, FileStatus* output) return ret; } -int32_t SystemNative_FStat2(intptr_t fd, FileStatus* output) +int32_t SystemNative_FStat(intptr_t fd, FileStatus* output) { struct stat_ result; int ret; @@ -208,7 +206,7 @@ int32_t SystemNative_FStat2(intptr_t fd, FileStatus* output) return ret; } -int32_t SystemNative_LStat2(const char* path, FileStatus* output) +int32_t SystemNative_LStat(const char* path, FileStatus* output) { struct stat_ result; int ret = lstat_(path, &result); @@ -221,6 +219,22 @@ int32_t SystemNative_LStat2(const char* path, FileStatus* output) return ret; } +// These "2" suffix functions are pending removal +int32_t SystemNative_Stat2(const char* path, FileStatus* output) +{ + return SystemNative_Stat(path, output); +} + +int32_t SystemNative_FStat2(intptr_t fd, FileStatus* output) +{ + return SystemNative_FStat(fd, output); +} + +int32_t SystemNative_LStat2(const char* path, FileStatus* output) +{ + return SystemNative_LStat(path, output); +} + static int32_t ConvertOpenFlags(int32_t flags) { int32_t ret; diff --git a/src/libraries/Native/Unix/System.Native/pal_io.h b/src/libraries/Native/Unix/System.Native/pal_io.h index 44a311a..e8a2f6e 100644 --- a/src/libraries/Native/Unix/System.Native/pal_io.h +++ b/src/libraries/Native/Unix/System.Native/pal_io.h @@ -324,6 +324,27 @@ typedef enum * * Returns 0 for success, -1 for failure. Sets errno on failure. */ +DLLEXPORT int32_t SystemNative_FStat(intptr_t fd, FileStatus* output); + +/** + * Get file status from a full path. Implemented as shim to stat(2). + * + * Returns 0 for success, -1 for failure. Sets errno on failure. + */ +DLLEXPORT int32_t SystemNative_Stat(const char* path, FileStatus* output); + +/** + * Get file stats from a full path. Implemented as shim to lstat(2). + * + * Returns 0 for success, -1 for failure. Sets errno on failure. + */ +DLLEXPORT int32_t SystemNative_LStat(const char* path, FileStatus* output); + +/** + * Get file status from a descriptor. Implemented as shim to fstat(2). + * + * Returns 0 for success, -1 for failure. Sets errno on failure. + */ DLLEXPORT int32_t SystemNative_FStat2(intptr_t fd, FileStatus* output); /** -- 2.7.4