mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
fix(kernel): create /download0 at start-up when the title declares download data
On the console a title whose param.json declares downloadDataSize finds /download0 mounted from the start. The host directory was only created by sceAppContentDownloadDataGetAvailableSpaceKb, so a title that opens files there directly got ENOENT. libkernel now creates it when it loads, reading only the run directory's param.json, without resolving guest paths, so the libc path root is still fixed at first use. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -42,6 +42,14 @@ void ensureTitleLoaded() {
|
||||
g_titleLoaded = true;
|
||||
}
|
||||
|
||||
const bool g_downloadDataMounted = [] {
|
||||
const auto run = std::filesystem::current_path();
|
||||
const auto paramJson = run / "app0" / "sce_sys" / "param.json";
|
||||
if (!std::filesystem::exists(paramJson) || parseParamJson(paramJson).downloadDataSizeMiB == 0) return false;
|
||||
std::filesystem::create_directories(run / "download0");
|
||||
return true;
|
||||
}();
|
||||
|
||||
void ensureIconLoaded() {
|
||||
if (g_iconAttempted) return;
|
||||
g_iconAttempted = true;
|
||||
|
||||
@@ -65,6 +65,25 @@ endif()
|
||||
configure_windows_unwind(libkernel)
|
||||
|
||||
if(BUILD_TESTING)
|
||||
add_test_executable(download_data_mount_tests ${LIBS_INCLUDE_DIR}/tests/GuestDownloadDataMount.cpp)
|
||||
target_include_directories(download_data_mount_tests PRIVATE ${LIBS_INCLUDE_DIR})
|
||||
target_link_libraries(download_data_mount_tests PRIVATE libkernel libc)
|
||||
configure_windows_unwind(download_data_mount_tests)
|
||||
foreach(downloadDataCase IN ITEMS declared:256 none:0)
|
||||
string(REPLACE ":" ";" downloadDataCase ${downloadDataCase})
|
||||
list(GET downloadDataCase 0 downloadDataName)
|
||||
list(GET downloadDataCase 1 downloadDataSize)
|
||||
set(downloadDataRun ${CMAKE_CURRENT_BINARY_DIR}/download_data_mount_${downloadDataName})
|
||||
file(WRITE ${downloadDataRun}/app0/sce_sys/param.json
|
||||
"{\"titleId\":\"PPSA00000\",\"localizedParameters\":{\"en-US\":{\"titleName\":\"Example\"}},\"downloadDataSize\":${downloadDataSize},"
|
||||
"\"userDefinedParam1\":0,\"userDefinedParam2\":0,\"userDefinedParam3\":0,\"userDefinedParam4\":0}")
|
||||
add_test(NAME download_data_mount_${downloadDataName} COMMAND download_data_mount_tests ${downloadDataName}
|
||||
WORKING_DIRECTORY ${downloadDataRun})
|
||||
if(WIN32)
|
||||
set_tests_properties(download_data_mount_${downloadDataName} PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libkernel>")
|
||||
endif()
|
||||
endforeach()
|
||||
add_test_executable(param_json_parser_tests ${LIBS_INCLUDE_DIR}/tests/ParamJsonParser.cpp)
|
||||
target_include_directories(param_json_parser_tests PRIVATE ${LIBS_INCLUDE_DIR})
|
||||
target_link_libraries(param_json_parser_tests PRIVATE libkernel libc)
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#include "prx/libkernel/AppMetadata/include/AppMetadata.hpp"
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <filesystem>
|
||||
|
||||
static void Require(bool value) { if (!value) std::abort(); }
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
Require(argc == 2);
|
||||
const bool declared = std::strcmp(argv[1], "declared") == 0;
|
||||
Require(std::filesystem::is_directory("download0") == declared);
|
||||
Require(std::strcmp(GetAppTitleId_nid_postfix().value, "PPSA00000") == 0);
|
||||
std::filesystem::remove_all("download0");
|
||||
}
|
||||
Reference in New Issue
Block a user