-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add LinuxHelper to detect and increase vm.max_map_count
With GUI dialogs, this should be a bit more user-friendly.
- Loading branch information
Showing
5 changed files
with
176 additions
and
6 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Runtime.Versioning; | ||
|
||
namespace Ryujinx.Ui.Common.Helper | ||
{ | ||
[SupportedOSPlatform("linux")] | ||
public static class LinuxHelper | ||
{ | ||
// NOTE: This value was determined by manual tests and might need to be increased again. | ||
public const int RecommendedVmMaxMapCount = 524288; | ||
public const string VmMaxMapCountPath = "/proc/sys/vm/max_map_count"; | ||
public const string SysCtlConfigPath = "/etc/sysctl.d/99-Ryujinx.conf"; | ||
public static int VmMaxMapCount => int.Parse(File.ReadAllText(VmMaxMapCountPath)); | ||
public static string PkExecPath { get; } = GetBinaryPath("pkexec"); | ||
|
||
private static string GetBinaryPath(string binary) | ||
{ | ||
string pathVar = Environment.GetEnvironmentVariable("PATH"); | ||
|
||
if (pathVar is null || string.IsNullOrEmpty(binary)) | ||
{ | ||
return null; | ||
} | ||
|
||
foreach (var searchPath in pathVar.Split(":", StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries)) | ||
{ | ||
string binaryPath = Path.Combine(searchPath, binary); | ||
|
||
if (File.Exists(binaryPath)) | ||
{ | ||
return binaryPath; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public static int RunPkExec(string command) | ||
{ | ||
if (PkExecPath == null) | ||
{ | ||
return 1; | ||
} | ||
|
||
using Process process = new() | ||
{ | ||
StartInfo = | ||
{ | ||
FileName = PkExecPath, | ||
Arguments = $"sh -c '{command}'" | ||
} | ||
}; | ||
|
||
process.Start(); | ||
process.WaitForExit(); | ||
|
||
return process.ExitCode; | ||
} | ||
} | ||
} |
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