From 33701bb3870d64419671f8abb79e4014e6d53da0 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Mon, 6 Dec 2021 23:11:26 -0800 Subject: [PATCH] fssrv: add skeleton getters for service object sf::SharedPointers --- .../include/stratosphere/fssrv.hpp | 1 + .../fssrv/fssrv_file_system_proxy_impl.hpp | 32 +++++++++ .../fssrv/fssrv_program_registry_impl.hpp | 68 +++++++++++++++++++ ...fssrv_file_system_proxy_service_object.cpp | 49 +++++++++++++ .../include/vapours/results/fs_results.hpp | 1 + 5 files changed, 151 insertions(+) create mode 100644 libraries/libstratosphere/include/stratosphere/fssrv/fssrv_program_registry_impl.hpp create mode 100644 libraries/libstratosphere/source/fssrv/impl/fssrv_file_system_proxy_service_object.cpp diff --git a/libraries/libstratosphere/include/stratosphere/fssrv.hpp b/libraries/libstratosphere/include/stratosphere/fssrv.hpp index a3f4b668c..56183d68a 100644 --- a/libraries/libstratosphere/include/stratosphere/fssrv.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssrv.hpp @@ -30,4 +30,5 @@ #include #include #include +#include #include diff --git a/libraries/libstratosphere/include/stratosphere/fssrv/fssrv_file_system_proxy_impl.hpp b/libraries/libstratosphere/include/stratosphere/fssrv/fssrv_file_system_proxy_impl.hpp index b602797af..3b4c0e2e2 100644 --- a/libraries/libstratosphere/include/stratosphere/fssrv/fssrv_file_system_proxy_impl.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssrv/fssrv_file_system_proxy_impl.hpp @@ -39,7 +39,39 @@ namespace ams::fssrv { ~FileSystemProxyImpl(); /* TODO */ + + public: + /* fsp-ldr */ + Result OpenCodeFileSystemDeprecated(ams::sf::Out> out_fs, const fssrv::sf::Path &path, ncm::ProgramId program_id); + Result OpenCodeFileSystem(ams::sf::Out> out_fs, ams::sf::Out out_verif, const fssrv::sf::Path &path, ncm::ProgramId program_id); + Result IsArchivedProgram(ams::sf::Out out, u64 process_id); + Result SetCurrentProcess(const ams::sf::ClientProcessId &client_pid); }; static_assert(sf::IsIFileSystemProxy); + static_assert(sf::IsIFileSystemProxyForLoader); + + class InvalidFileSystemProxyImplForLoader { + public: + Result OpenCodeFileSystemDeprecated(ams::sf::Out> out_fs, const fssrv::sf::Path &path, ncm::ProgramId program_id) { + AMS_UNUSED(out_fs, path, program_id); + return fs::ResultPortAcceptableCountLimited(); + } + + Result OpenCodeFileSystem(ams::sf::Out> out_fs, ams::sf::Out out_verif, const fssrv::sf::Path &path, ncm::ProgramId program_id) { + AMS_UNUSED(out_fs, out_verif, path, program_id); + return fs::ResultPortAcceptableCountLimited(); + } + + Result IsArchivedProgram(ams::sf::Out out, u64 process_id) { + AMS_UNUSED(out, process_id); + return fs::ResultPortAcceptableCountLimited(); + } + + Result SetCurrentProcess(const ams::sf::ClientProcessId &client_pid) { + AMS_UNUSED(client_pid); + return fs::ResultPortAcceptableCountLimited(); + } + }; + static_assert(sf::IsIFileSystemProxyForLoader); } diff --git a/libraries/libstratosphere/include/stratosphere/fssrv/fssrv_program_registry_impl.hpp b/libraries/libstratosphere/include/stratosphere/fssrv/fssrv_program_registry_impl.hpp new file mode 100644 index 000000000..5a5b0ba07 --- /dev/null +++ b/libraries/libstratosphere/include/stratosphere/fssrv/fssrv_program_registry_impl.hpp @@ -0,0 +1,68 @@ +/* + * Copyright (c) Atmosphère-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once +#include +#include + +namespace ams::fssrv { + + namespace impl { + + class ProgramInfo; + + } + + class ProgramRegistryImpl { + NON_COPYABLE(ProgramRegistryImpl); + NON_MOVEABLE(ProgramRegistryImpl); + private: + u64 m_process_id; + public: + ProgramRegistryImpl(); + ~ProgramRegistryImpl(); + public: + Result RegisterProgram(u64 process_id, u64 program_id, u8 storage_id, const ams::sf::InBuffer &data, s64 data_size, const ams::sf::InBuffer &desc, s64 desc_size); + Result UnregisterProgram(u64 process_id); + Result SetCurrentProcess(const ams::sf::ClientProcessId &client_pid); + Result SetEnabledProgramVerification(bool en); + }; + static_assert(sf::IsIProgramRegistry); + + class InvalidProgramRegistryImpl { + public: + Result RegisterProgram(u64 process_id, u64 program_id, u8 storage_id, const ams::sf::InBuffer &data, s64 data_size, const ams::sf::InBuffer &desc, s64 desc_size) { + AMS_UNUSED(process_id, program_id, storage_id, data, data_size, desc, desc_size); + return fs::ResultPortAcceptableCountLimited(); + } + + Result UnregisterProgram(u64 process_id) { + AMS_UNUSED(process_id); + return fs::ResultPortAcceptableCountLimited(); + } + + Result SetCurrentProcess(const ams::sf::ClientProcessId &client_pid) { + AMS_UNUSED(client_pid); + return fs::ResultPortAcceptableCountLimited(); + } + + Result SetEnabledProgramVerification(bool en) { + AMS_UNUSED(en); + return fs::ResultPortAcceptableCountLimited(); + } + }; + static_assert(sf::IsIProgramRegistry); + +} diff --git a/libraries/libstratosphere/source/fssrv/impl/fssrv_file_system_proxy_service_object.cpp b/libraries/libstratosphere/source/fssrv/impl/fssrv_file_system_proxy_service_object.cpp new file mode 100644 index 000000000..bab4e341b --- /dev/null +++ b/libraries/libstratosphere/source/fssrv/impl/fssrv_file_system_proxy_service_object.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (c) Atmosphère-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include +#include "fssrv_allocator_for_service_framework.hpp" + +namespace ams::fssrv::impl { + + namespace { + + using FileSystemProxyServiceFactory = ams::sf::ObjectFactory; + using ProgramRegistryServiceFactory = ams::sf::ObjectFactory; + using FileSystemProxyForLoaderServiceFactory = ams::sf::ObjectFactory; + + } + + ams::sf::EmplacedRef GetFileSystemProxyServiceObject() { + return FileSystemProxyServiceFactory::CreateSharedEmplaced(); + } + + ams::sf::SharedPointer GetProgramRegistryServiceObject() { + return ProgramRegistryServiceFactory::CreateSharedEmplaced(); + } + + ams::sf::SharedPointer GetInvalidProgramRegistryServiceObject() { + return ProgramRegistryServiceFactory::CreateSharedEmplaced(); + } + + ams::sf::SharedPointer GetFileSystemProxyForLoaderServiceObject() { + return FileSystemProxyForLoaderServiceFactory ::CreateSharedEmplaced(); + } + + ams::sf::SharedPointer GetInvalidFileSystemProxyForLoaderServiceObject() { + return FileSystemProxyForLoaderServiceFactory ::CreateSharedEmplaced(); + } + +} diff --git a/libraries/libvapours/include/vapours/results/fs_results.hpp b/libraries/libvapours/include/vapours/results/fs_results.hpp index 6633970af..61e728a3a 100644 --- a/libraries/libvapours/include/vapours/results/fs_results.hpp +++ b/libraries/libvapours/include/vapours/results/fs_results.hpp @@ -364,6 +364,7 @@ namespace ams::fs { R_DEFINE_ERROR_RANGE(PermissionDenied, 6400, 6449); + R_DEFINE_ERROR_RESULT(PortAcceptableCountLimited, 6450); R_DEFINE_ERROR_RESULT(NeedFlush, 6454); R_DEFINE_ERROR_RESULT(FileNotClosed, 6455); R_DEFINE_ERROR_RESULT(DirectoryNotClosed, 6456);