[Kernel] Report random device descriptors in fstat

Co-authored-by: Sekai <140012992+SekaixX@users.noreply.github.com>
This commit is contained in:
ParantezTech 2026-10-08 23:44:40 +03:00
parent cd77a68c87
commit 3d65921eb7
1 changed files with 14 additions and 1 deletions

View File

@ -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;