From b0ac3132c5570b8477e08e5043bee68dca4062fc Mon Sep 17 00:00:00 2001 From: Daniel Hammer Date: Tue, 14 Jul 2026 21:03:53 +0200 Subject: [PATCH] fix: raise ramdisk file table to 2048 entries, log when full The 0:/usr devkit pushed the base image to ~650 files, past the ramdisk's MaxFiles = 512. The USTAR loader silently dropped the tail of the archive and, worse, every runtime Create/Mkdir failed once the table was full - so first-boot account creation could not write the user database and every login failed with "invalid username or password". Raise MaxFiles to 2048 (256 KiB static table) and log loudly both when archive entries are dropped at load and when Create/Mkdir hit the cap, so a full table can never masquerade as an auth failure again. Verified in QEMU end to end: setup -> create account -> log in -> desktop. Co-Authored-By: Claude Fable 5 --- kernel/src/Api/BuildNo.hpp | 2 +- kernel/src/Fs/Ramdisk.cpp | 18 ++++++++++++++++-- kernel/src/Fs/Ramdisk.hpp | 4 +++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/kernel/src/Api/BuildNo.hpp b/kernel/src/Api/BuildNo.hpp index ee608fd..8100247 100644 --- a/kernel/src/Api/BuildNo.hpp +++ b/kernel/src/Api/BuildNo.hpp @@ -12,4 +12,4 @@ #pragma once -#define MONTAUK_BUILD_NUMBER 11 +#define MONTAUK_BUILD_NUMBER 12 diff --git a/kernel/src/Fs/Ramdisk.cpp b/kernel/src/Fs/Ramdisk.cpp index 8a224a5..2af8b67 100644 --- a/kernel/src/Fs/Ramdisk.cpp +++ b/kernel/src/Fs/Ramdisk.cpp @@ -161,6 +161,12 @@ namespace Fs::Ramdisk { ptr += 512 + dataBlocks * 512; } + if (fileCount >= MaxFiles && ptr + 512 <= end) { + Kt::KernelLogStream(Kt::ERROR, "Ramdisk") + << "File table full (MaxFiles=" << MaxFiles + << "), remaining archive entries were DROPPED"; + } + Kt::KernelLogStream(Kt::OK, "Ramdisk") << "Loaded " << fileCount << " entries"; } @@ -340,7 +346,11 @@ namespace Fs::Ramdisk { int Create(const char* path) { if (path == nullptr) return -1; - if (fileCount >= MaxFiles) return -1; + if (fileCount >= MaxFiles) { + Kt::KernelLogStream(Kt::ERROR, "Ramdisk") + << "Create failed: file table full (MaxFiles=" << MaxFiles << ")"; + return -1; + } // Normalize: skip leading '/' if (path[0] == '/') path++; @@ -425,7 +435,11 @@ namespace Fs::Ramdisk { int Mkdir(const char* path) { if (path == nullptr) return -1; - if (fileCount >= MaxFiles) return -1; + if (fileCount >= MaxFiles) { + Kt::KernelLogStream(Kt::ERROR, "Ramdisk") + << "Mkdir failed: file table full (MaxFiles=" << MaxFiles << ")"; + return -1; + } if (path[0] == '/') path++; // Check if directory already exists diff --git a/kernel/src/Fs/Ramdisk.hpp b/kernel/src/Fs/Ramdisk.hpp index b435c00..8d3c74e 100644 --- a/kernel/src/Fs/Ramdisk.hpp +++ b/kernel/src/Fs/Ramdisk.hpp @@ -10,7 +10,9 @@ namespace Fs::Ramdisk { - static constexpr int MaxFiles = 512; + // Static file table. The base image ships ~650 files since the + // 0:/usr devkit; keep generous headroom for runtime file creation. + static constexpr int MaxFiles = 2048; static constexpr int MaxNameLen = 100; struct FileEntry {