mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-06-03 08:08:39 -04:00
fssystem: Implement PartitionFileSystemCore (#856)
* fssystem: implement PartitionFileSystemMetaCore * fssystem: PartitionFileSystemMetaCore cleanup * fs: add IFile::DryWrite, update results * fssystem: implement PartitionFileSystemCore * fssystem: cleanup PartitionFileSystemCore * fssystem: implement Sha256PartitionFileSystem Co-authored-by: Michael Scire <SciresM@gmail.com>
This commit is contained in:
parent
0af2758fde
commit
3d518759da
9 changed files with 949 additions and 2 deletions
58
libraries/libvapours/include/vapours/allocator.hpp
Normal file
58
libraries/libvapours/include/vapours/allocator.hpp
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours/common.hpp>
|
||||
#include <vapours/assert.hpp>
|
||||
|
||||
namespace ams {
|
||||
|
||||
constexpr inline size_t DefaultAlignment = alignof(max_align_t);
|
||||
|
||||
using AllocateFunction = void *(*)(size_t);
|
||||
using AllocateFunctionWithUserData = void *(*)(size_t, void *);
|
||||
using AlignedAllocateFunction = void *(*)(size_t, size_t);
|
||||
using AlignedAllocateFunctionWithUserData = void *(*)(size_t, size_t, void *);
|
||||
using DeallocateFunction = void (*)(void *, size_t);
|
||||
using FreeFunction = void (*)(void *);
|
||||
using FreeFunctionWithUserData = void (*)(void *, void *);
|
||||
|
||||
class MemoryResource {
|
||||
public:
|
||||
ALWAYS_INLINE void *allocate(size_t size, size_t alignment = DefaultAlignment) {
|
||||
return this->AllocateImpl(size, alignment);
|
||||
}
|
||||
ALWAYS_INLINE void deallocate(void *buffer, size_t size, size_t alignment = DefaultAlignment) {
|
||||
this->DeallocateImpl(buffer, size, alignment);
|
||||
}
|
||||
ALWAYS_INLINE bool is_equal(const MemoryResource &resource) const {
|
||||
return this->IsEqualImpl(resource);
|
||||
}
|
||||
ALWAYS_INLINE void *Allocate(size_t size, size_t alignment = DefaultAlignment) {
|
||||
return this->AllocateImpl(size, alignment);
|
||||
}
|
||||
ALWAYS_INLINE void Deallocate(void *buffer, size_t size, size_t alignment = DefaultAlignment) {
|
||||
this->DeallocateImpl(buffer, size, alignment);
|
||||
}
|
||||
ALWAYS_INLINE bool IsEqual(const MemoryResource &resource) const {
|
||||
return this->IsEqualImpl(resource);
|
||||
}
|
||||
protected:
|
||||
virtual void *AllocateImpl(size_t size, size_t alignment) = 0;
|
||||
virtual void DeallocateImpl(void *buffer, size_t size, size_t alignment) = 0;
|
||||
virtual bool IsEqualImpl(const MemoryResource &resource) const = 0;
|
||||
};
|
||||
|
||||
}
|
|
@ -74,7 +74,14 @@ namespace ams::fs {
|
|||
R_DEFINE_ERROR_RESULT(AllocationFailureInRomFsFileSystemA, 3247);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInRomFsFileSystemB, 3248);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInRomFsFileSystemC, 3249);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInPartitionFileSystemCreatorA, 3280);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInDirectorySaveDataFileSystem, 3321);
|
||||
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInPartitionFileSystemA, 3347);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInPartitionFileSystemB, 3348);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInPartitionFileSystemC, 3349);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInPartitionFileSystemMetaA, 3350);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInPartitionFileSystemMetaB, 3351);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInRomFsFileSystemD, 3352);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInSubDirectoryFileSystem, 3355);
|
||||
R_DEFINE_ERROR_RESULT(AllocationFailureInRegisterA, 3365);
|
||||
|
@ -238,6 +245,8 @@ namespace ams::fs {
|
|||
|
||||
R_DEFINE_ERROR_RANGE(InvalidOperationForOpenMode, 6200, 6299);
|
||||
R_DEFINE_ERROR_RESULT(FileExtensionWithoutOpenModeAllowAppend, 6201);
|
||||
R_DEFINE_ERROR_RESULT(ReadNotPermitted, 6202);
|
||||
R_DEFINE_ERROR_RESULT(WriteNotPermitted, 6203);
|
||||
|
||||
R_DEFINE_ERROR_RANGE(UnsupportedOperation, 6300, 6399);
|
||||
R_DEFINE_ERROR_RESULT(UnsupportedOperationInSubStorageA, 6302);
|
||||
|
@ -256,6 +265,10 @@ namespace ams::fs {
|
|||
R_DEFINE_ERROR_RESULT(UnsupportedOperationInReadOnlyFileSystemTemplateC, 6371);
|
||||
R_DEFINE_ERROR_RESULT(UnsupportedOperationInReadOnlyFileA, 6372);
|
||||
R_DEFINE_ERROR_RESULT(UnsupportedOperationInReadOnlyFileB, 6373);
|
||||
R_DEFINE_ERROR_RESULT(UnsupportedOperationInPartitionFileSystemA, 6374);
|
||||
R_DEFINE_ERROR_RESULT(UnsupportedOperationInPartitionFileSystemB, 6375);
|
||||
R_DEFINE_ERROR_RESULT(UnsupportedOperationInPartitionFileA, 6376);
|
||||
R_DEFINE_ERROR_RESULT(UnsupportedOperationInPartitionFileB, 6377);
|
||||
|
||||
R_DEFINE_ERROR_RANGE(PermissionDenied, 6400, 6449);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue