This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Finishing up PAL'ing Unix\libc (non-networking and crypto) PInvoke calls #3257
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
17 changes: 0 additions & 17 deletions
17
src/Common/src/Interop/FreeBSD/libc/Interop.PathConfNames.cs
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
src/Common/src/Interop/Linux/libc/Interop.PathConfNames.cs
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
src/Common/src/Interop/Linux/libc/Interop.prioritywhich.cs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/Common/src/Interop/Unix/System.Native/Interop.PathConf.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class Sys | ||
{ | ||
internal static int DEFAULT_PC_NAME_MAX = 255; | ||
|
||
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, | ||
} | ||
|
||
/// <summary>The maximum path length for the system. -1 if it hasn't yet been initialized.</summary> | ||
private static int s_maxPath = -1; | ||
|
||
/// <summary>The maximum name length for the system. -1 if it hasn't yet been initialized.</summary> | ||
private static int s_maxName = -1; | ||
|
||
internal static int MaxPath | ||
{ | ||
get | ||
{ | ||
// Benign race condition on cached value | ||
if (s_maxPath < 0) | ||
{ | ||
// GetMaximumPath returns a long from PathConf | ||
// but our callers expect an int so we need to convert. | ||
long temp = GetMaximumPath(); | ||
if (temp > int.MaxValue) | ||
s_maxPath = int.MaxValue; | ||
else | ||
s_maxPath = Convert.ToInt32(temp); | ||
} | ||
return s_maxPath; | ||
} | ||
} | ||
|
||
internal static int MaxName | ||
{ | ||
get | ||
{ | ||
// Benign race condition on cached value | ||
if (s_maxName < 0) | ||
{ | ||
int result = PathConf("/", PathConfName.PC_NAME_MAX); | ||
s_maxName = result >= 0 ? result : DEFAULT_PC_NAME_MAX; | ||
} | ||
|
||
return s_maxName; | ||
} | ||
} | ||
|
||
[DllImport(Libraries.SystemNative, SetLastError = true)] | ||
private static extern int PathConf(string path, PathConfName name); | ||
|
||
[DllImport(Libraries.SystemNative)] | ||
private static extern long GetMaximumPath(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DEFAULT_PC_PATH_MAX was removed and put behind GetMaximumPath. The same thing doesn't need to be done for DEFAULT_PC_NAME_MAX?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only reason the Max Path default value needed to be pushed into the PAL was because the PATH_MAX value changes between OS X, Linux, and other *nix flavors that we support. The PC Name Max does not look to have different default values (from our original implementation) so it does not need to be pushed down into the PAL and we can use the platform-agnostic 255 value