From a6423a88cc068f8213db8707900a1d1b38b9566d Mon Sep 17 00:00:00 2001 From: lizzie Date: Sat, 9 May 2026 05:28:22 +0200 Subject: [PATCH] [file_sys] resize SD card size in 4GiB chunks (#3921) some homebrew theoretically would freak out when 1TB is reached... so let's just magically resize the SD card :) Signed-off-by: lizzie Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3921 Reviewed-by: CamilleLaVey --- src/core/file_sys/sdmc_factory.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/core/file_sys/sdmc_factory.cpp b/src/core/file_sys/sdmc_factory.cpp index f3e2e21f4c..a2903dbacf 100644 --- a/src/core/file_sys/sdmc_factory.cpp +++ b/src/core/file_sys/sdmc_factory.cpp @@ -1,7 +1,12 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include +#include "common/alignment.h" +#include "common/literals.h" #include "core/file_sys/registered_cache.h" #include "core/file_sys/sdmc_factory.h" #include "core/file_sys/vfs/vfs.h" @@ -9,8 +14,6 @@ namespace FileSys { -constexpr u64 SDMC_TOTAL_SIZE = 0x10000000000; // 1 TiB - SDMCFactory::SDMCFactory(VirtualDir sd_dir_, VirtualDir sd_mod_dir_) : sd_dir(std::move(sd_dir_)), sd_mod_dir(std::move(sd_mod_dir_)), contents(std::make_unique( @@ -56,7 +59,11 @@ u64 SDMCFactory::GetSDMCFreeSpace() const { } u64 SDMCFactory::GetSDMCTotalSpace() const { - return SDMC_TOTAL_SIZE; + // Resize the SD space automatically, always leaving around 4GiB last from next chunk block + using namespace Common::Literals; + auto const bytes_per_sector = 512; + auto const size_block = (sd_dir->GetSize() + 4_GiB) / 4_GiB; + return Common::AlignUp(size_block * 4_GiB, bytes_per_sector); } } // namespace FileSys