From 3d65921eb749a7e80e336d9f05e569bf727d755b Mon Sep 17 00:00:00 2001 From: ParantezTech <12572227+par274@users.noreply.github.com> Date: Thu, 8 Oct 2026 23:44:40 +0300 Subject: [PATCH] [Kernel] Report random device descriptors in fstat Co-authored-by: Sekai <140012992+SekaixX@users.noreply.github.com> --- .../Kernel/KernelMemoryCompatExports.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/SharpEmu.Libs/Kernel/KernelMemoryCompatExports.cs b/src/SharpEmu.Libs/Kernel/KernelMemoryCompatExports.cs index 6d2f5ad..f757baf 100644 --- a/src/SharpEmu.Libs/Kernel/KernelMemoryCompatExports.cs +++ b/src/SharpEmu.Libs/Kernel/KernelMemoryCompatExports.cs @@ -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;