[Kernel] Report random device descriptors in fstat
Co-authored-by: Sekai <140012992+SekaixX@users.noreply.github.com>
This commit is contained in:
parent
cd77a68c87
commit
3d65921eb7
|
|
@ -6952,9 +6952,14 @@ public static partial class KernelMemoryCompatExports
|
|||
|
||||
string? hostPath = null;
|
||||
bool isDirectory = false;
|
||||
bool isRandomDevice = false;
|
||||
lock (_fdGate)
|
||||
{
|
||||
if (_openDirectories.TryGetValue(fd, out var directory))
|
||||
if (_randomDeviceDescriptors.Contains(fd))
|
||||
{
|
||||
isRandomDevice = true;
|
||||
}
|
||||
else if (_openDirectories.TryGetValue(fd, out var directory))
|
||||
{
|
||||
hostPath = directory.Path;
|
||||
isDirectory = true;
|
||||
|
|
@ -6965,6 +6970,14 @@ public static partial class KernelMemoryCompatExports
|
|||
}
|
||||
}
|
||||
|
||||
if (isRandomDevice)
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
LogIoTrace("fstat", "/dev/urandom", $"fd={fd} size=0 device=random");
|
||||
return TryWriteKernelStat(ctx, statAddress, isDirectory: false, size: 0,
|
||||
now, now, now, "/dev/urandom");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(hostPath))
|
||||
{
|
||||
long size = 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue