mirror of
https://github.com/Atmosphere-NX/Atmosphere-libs.git
synced 2025-07-04 08:32:15 +02:00
Compare commits
5 Commits
132558c338
...
965e05b3cc
Author | SHA1 | Date | |
---|---|---|---|
|
965e05b3cc | ||
|
944ff3d5f6 | ||
|
2125f3c404 | ||
|
8d495c256e | ||
|
74d96b5fea |
@ -583,7 +583,7 @@ namespace ams::kern {
|
||||
/* Check memory state. */
|
||||
const KProcessAddress last_addr = addr + size - 1;
|
||||
KMemoryBlockManager::const_iterator it = m_memory_block_manager.FindIterator(addr);
|
||||
R_TRY(this->CheckMemoryState(out_state, out_perm, out_attr, out_blocks_needed, it, last_addr, state_mask, state, perm_mask, perm, attr_mask, attr, ignore_attr))
|
||||
R_TRY(this->CheckMemoryState(out_state, out_perm, out_attr, out_blocks_needed, it, last_addr, state_mask, state, perm_mask, perm, attr_mask, attr, ignore_attr));
|
||||
|
||||
/* If the start address isn't aligned, we need a block. */
|
||||
if (out_blocks_needed != nullptr && util::AlignDown(GetInteger(addr), PageSize) != it->GetAddress()) {
|
||||
|
@ -239,8 +239,12 @@ namespace ams::ncm {
|
||||
Result InitializeIntegratedContentMetaDatabaseRoot(IntegratedContentMetaDatabaseRoot *out, const IntegratedContentStorageConfig *config, size_t root_idx, size_t root_count);
|
||||
|
||||
Result BuildContentMetaDatabase(StorageId storage_id);
|
||||
Result BuildContentMetaDatabaseImpl(StorageId storage_id);
|
||||
Result ImportContentMetaDatabase(StorageId storage_id, bool from_signed_partition);
|
||||
Result ImportContentMetaDatabaseImpl(ContentMetaDatabaseRoot *root, const char *import_mount_name);
|
||||
private:
|
||||
/* Helpers for unofficial functionality. */
|
||||
bool IsNeedRebuildSystemContentMetaDatabase();
|
||||
public:
|
||||
/* Actual commands. */
|
||||
Result CreateContentStorage(StorageId storage_id);
|
||||
|
@ -307,6 +307,10 @@ namespace ams::fssrv {
|
||||
AMS_ABORT("TODO");
|
||||
}
|
||||
|
||||
Result FileSystemProxyImpl::GetProgramId(ams::sf::Out<ncm::ProgramId> out_program_id, const fssrv::sf::FspPath &path, fs::ContentAttributes attr) {
|
||||
AMS_ABORT("TODO");
|
||||
}
|
||||
|
||||
Result FileSystemProxyImpl::GetRightsIdByPath(ams::sf::Out<fs::RightsId> out, const fssrv::sf::FspPath &path) {
|
||||
AMS_ABORT("TODO");
|
||||
}
|
||||
|
@ -784,8 +784,16 @@ namespace ams::ncm {
|
||||
}
|
||||
|
||||
Result ContentManagerImpl::BuildContentMetaDatabase(StorageId storage_id) {
|
||||
/* NOTE: we build on 17.0.0+, to work around a change in Nintendo save handling behavior. */
|
||||
if (hos::GetVersion() < hos::Version_5_0_0 || hos::GetVersion() >= hos::Version_17_0_0) {
|
||||
if (hos::GetVersion() < hos::Version_5_0_0) {
|
||||
/* On < 5.0.0, perform an actual build of the database. */
|
||||
R_RETURN(this->BuildContentMetaDatabaseImpl(storage_id));
|
||||
} else {
|
||||
/* On 5.0.0+, building just performs an import. */
|
||||
R_RETURN(this->ImportContentMetaDatabase(storage_id, false));
|
||||
}
|
||||
}
|
||||
|
||||
Result ContentManagerImpl::BuildContentMetaDatabaseImpl(StorageId storage_id) {
|
||||
/* Temporarily activate the database. */
|
||||
R_TRY(this->ActivateContentMetaDatabase(storage_id));
|
||||
ON_SCOPE_EXIT { this->InactivateContentMetaDatabase(storage_id); };
|
||||
@ -799,10 +807,6 @@ namespace ams::ncm {
|
||||
/* Create a builder, and build. */
|
||||
ContentMetaDatabaseBuilder builder(std::addressof(meta_db));
|
||||
R_RETURN(builder.BuildFromStorage(std::addressof(storage)));
|
||||
} else {
|
||||
/* On 5.0.0+, building just performs an import. */
|
||||
R_RETURN(this->ImportContentMetaDatabase(storage_id, false));
|
||||
}
|
||||
}
|
||||
|
||||
Result ContentManagerImpl::ImportContentMetaDatabase(StorageId storage_id, bool from_signed_partition) {
|
||||
@ -832,6 +836,31 @@ namespace ams::ncm {
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
bool ContentManagerImpl::IsNeedRebuildSystemContentMetaDatabase() {
|
||||
/* TODO: Should hos::GetVersion() >= hos::Version_17_0_0 be checked? */
|
||||
|
||||
/* If we do not actually have a content meta db, we should re-build. */
|
||||
if (R_FAILED(this->VerifyContentMetaDatabase(StorageId::BuiltInSystem))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* We have a content meta db. Temporarily, activate it. */
|
||||
if (R_FAILED(this->ActivateContentMetaDatabase(StorageId::BuiltInSystem))) {
|
||||
return true;
|
||||
}
|
||||
ON_SCOPE_EXIT { this->InactivateContentMetaDatabase(StorageId::BuiltInSystem); };
|
||||
|
||||
/* Open the content meta db. */
|
||||
ContentMetaDatabase meta_db;
|
||||
R_ABORT_UNLESS(ncm::OpenContentMetaDatabase(std::addressof(meta_db), StorageId::BuiltInSystem));
|
||||
|
||||
/* List the meta db's contents. */
|
||||
const auto list_count = meta_db.ListContentMeta(nullptr, 0);
|
||||
|
||||
/* We need to rebuild if the db has zero entries. */
|
||||
return list_count.total == 0;
|
||||
}
|
||||
|
||||
Result ContentManagerImpl::Initialize(const ContentManagerConfig &config) {
|
||||
/* Initialize based on whether integrated content is enabled. */
|
||||
if (config.IsIntegratedSystemContentEnabled()) {
|
||||
@ -942,13 +971,26 @@ namespace ams::ncm {
|
||||
}
|
||||
R_TRY(this->ActivateContentStorage(StorageId::BuiltInSystem));
|
||||
|
||||
/* NOTE: This logic is unofficial. */
|
||||
/* Beginning with 17.0.0+, save management behavior changed. The primary symptom of this is either verify fail */
|
||||
/* or an empty kvs, both of which we can fix by performing a rebuild. */
|
||||
if (this->IsNeedRebuildSystemContentMetaDatabase()) {
|
||||
/* Clean up the system content meta database, to ensure creation can succeed. */
|
||||
this->CleanupContentMetaDatabase(StorageId::BuiltInSystem);
|
||||
|
||||
/* Create the content meta database. */
|
||||
R_TRY(this->CreateContentMetaDatabase(StorageId::BuiltInSystem));
|
||||
|
||||
/* Rebuild the content meta database. */
|
||||
R_TRY(this->BuildContentMetaDatabaseImpl(StorageId::BuiltInSystem));
|
||||
}
|
||||
|
||||
/* Setup the content meta database for system. */
|
||||
if (R_FAILED(this->VerifyContentMetaDatabase(StorageId::BuiltInSystem))) {
|
||||
R_TRY(this->CreateContentMetaDatabase(StorageId::BuiltInSystem));
|
||||
|
||||
/* Try to build or import a database, depending on our configuration. */
|
||||
/* NOTE: To work around a change in save management behavior in 17.0.0+, we build the database if needed. */
|
||||
if (manager_config.ShouldBuildDatabase() || hos::GetVersion() >= hos::Version_17_0_0) {
|
||||
if (manager_config.ShouldBuildDatabase()) {
|
||||
/* If we should build the database, do so. */
|
||||
R_TRY(this->BuildContentMetaDatabase(StorageId::BuiltInSystem));
|
||||
R_TRY(this->VerifyContentMetaDatabase(StorageId::BuiltInSystem));
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
#define ATMOSPHERE_RELEASE_VERSION_MAJOR 1
|
||||
#define ATMOSPHERE_RELEASE_VERSION_MINOR 6
|
||||
#define ATMOSPHERE_RELEASE_VERSION_MICRO 0
|
||||
#define ATMOSPHERE_RELEASE_VERSION_MICRO 1
|
||||
|
||||
#define ATMOSPHERE_RELEASE_VERSION ATMOSPHERE_RELEASE_VERSION_MAJOR, ATMOSPHERE_RELEASE_VERSION_MINOR, ATMOSPHERE_RELEASE_VERSION_MICRO
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user