ams: fs accuracy fixes, bump to 1.3.2

This commit is contained in:
Michael Scire
2022-04-29 16:13:34 -07:00
parent d85875b910
commit 3545c0aac2
10 changed files with 57 additions and 31 deletions

View File

@@ -42,8 +42,14 @@ namespace ams::fssystem {
};
struct Entry {
enum class Encryption : u8 {
Encrypted = 0,
NotEncrypted = 1,
};
u8 offset[sizeof(s64)];
s32 reserved;
Encryption encryption_value;
u8 reserved[3];
s32 generation;
void SetOffset(s64 value) {

View File

@@ -60,8 +60,8 @@ namespace ams::fssystem {
constexpr IHash256GeneratorFactory() = default;
virtual constexpr ~IHash256GeneratorFactory() { /* ... */ }
std::unique_ptr<IHash256Generator> Create() {
return this->DoCreate();
Result Create(std::unique_ptr<IHash256Generator> *out) {
return this->DoCreate(out);
}
void GenerateHash(void *dst, size_t dst_size, const void *src, size_t src_size) {
@@ -73,11 +73,11 @@ namespace ams::fssystem {
return this->DoGenerateHash(dst, dst_size, src, src_size);
}
protected:
virtual std::unique_ptr<IHash256Generator> DoCreate() = 0;
virtual Result DoCreate(std::unique_ptr<IHash256Generator> *out) = 0;
virtual void DoGenerateHash(void *dst, size_t dst_size, const void *src, size_t src_size) = 0;
};
/* ACCURATE_TO_VERSION: 13.4.0.0 */
/* ACCURATE_TO_VERSION: 14.3.0.0 */
class IHash256GeneratorFactorySelector {
public:
constexpr IHash256GeneratorFactorySelector() = default;

View File

@@ -52,7 +52,7 @@ namespace ams::fssystem {
IntegrityVerificationStorage() : m_verification_block_size(0), m_verification_block_order(0), m_upper_layer_verification_block_size(0), m_upper_layer_verification_block_order(0), m_buffer_manager(nullptr), m_salt(util::nullopt) { /* ... */ }
virtual ~IntegrityVerificationStorage() override { this->Finalize(); }
Result Initialize(fs::SubStorage hs, fs::SubStorage ds, s64 verif_block_size, s64 upper_layer_verif_block_size, fs::IBufferManager *bm, fssystem::IHash256GeneratorFactory *hgf, const util::optional<fs::HashSalt> &salt, bool is_real_data, bool is_writable, bool allow_cleared_blocks);
void Initialize(fs::SubStorage hs, fs::SubStorage ds, s64 verif_block_size, s64 upper_layer_verif_block_size, fs::IBufferManager *bm, fssystem::IHash256GeneratorFactory *hgf, const util::optional<fs::HashSalt> &salt, bool is_real_data, bool is_writable, bool allow_cleared_blocks);
void Finalize();
virtual Result Read(s64 offset, void *buffer, size_t size) override;
@@ -66,9 +66,8 @@ namespace ams::fssystem {
virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override;
using IStorage::OperateRange;
void CalcBlockHash(BlockHash *out, const void *buffer, size_t block_size) const {
auto generator = m_hash_generator_factory->Create();
return this->CalcBlockHash(out, buffer, block_size, generator);
void CalcBlockHash(BlockHash *out, const void *buffer, std::unique_ptr<fssystem::IHash256Generator> &generator) const {
return this->CalcBlockHash(out, buffer, static_cast<size_t>(m_verification_block_size), generator);
}
s64 GetBlockSize() const {
@@ -81,10 +80,6 @@ namespace ams::fssystem {
void CalcBlockHash(BlockHash *out, const void *buffer, size_t block_size, std::unique_ptr<fssystem::IHash256Generator> &generator) const;
void CalcBlockHash(BlockHash *out, const void *buffer, std::unique_ptr<fssystem::IHash256Generator> &generator) const {
return this->CalcBlockHash(out, buffer, static_cast<size_t>(m_verification_block_size), generator);
}
Result IsCleared(bool *is_cleared, const BlockHash &hash);
private:
static void SetValidationBit(BlockHash *hash) {

View File

@@ -56,8 +56,12 @@ namespace ams::fssystem {
public:
constexpr ShaHashGeneratorFactory() = default;
protected:
virtual std::unique_ptr<IHash256Generator> DoCreate() override {
return std::unique_ptr<IHash256Generator>(new ShaHashGenerator<Traits>());
virtual Result DoCreate(std::unique_ptr<IHash256Generator> *out) override {
auto generator = std::unique_ptr<IHash256Generator>(new ShaHashGenerator<Traits>());
R_UNLESS(generator != nullptr, fs::ResultAllocationMemoryFailedNew());
*out = std::move(generator);
R_SUCCEED();
}
virtual void DoGenerateHash(void *dst, size_t dst_size, const void *src, size_t src_size) override {

View File

@@ -71,6 +71,7 @@ namespace ams::hos {
Version_13_2_1 = ::ams::TargetFirmware_13_2_1,
Version_14_0_0 = ::ams::TargetFirmware_14_0_0,
Version_14_1_0 = ::ams::TargetFirmware_14_1_0,
Version_14_1_1 = ::ams::TargetFirmware_14_1_1,
Version_Current = ::ams::TargetFirmware_Current,