Skeleton NcaFileSystemDriver

This commit is contained in:
Alex Barney 2022-03-07 14:08:05 -07:00
parent 00819731ae
commit 3e64f9ef03
2 changed files with 195 additions and 5 deletions

View file

@ -1,4 +1,5 @@
using System;
// ReSharper disable UnusedMember.Local NotAccessedField.Local
using System;
using System.Runtime.CompilerServices;
using LibHac.Diag;
using LibHac.Fs;
@ -12,9 +13,6 @@ namespace LibHac.FsSystem;
public class CompressedStorage : IStorage, IAsynchronousAccessSplitter
{
public delegate Result DecompressorFunction(Span<byte> destination, ReadOnlySpan<byte> source);
public delegate DecompressorFunction GetDecompressorFunction(CompressionType type);
public class CompressedStorageCore : IDisposable
{
private long _blockSizeMax;

View file

@ -1,5 +1,10 @@
using LibHac.Common.FixedArrays;
// ReSharper disable UnusedMember.Local
using System;
using LibHac.Common;
using LibHac.Common.FixedArrays;
using LibHac.Crypto;
using LibHac.Fs;
using LibHac.FsSrv;
namespace LibHac.FsSystem;
@ -61,3 +66,190 @@ public enum KeyType
SaveDataSeedUniqueMac = 0x63,
SaveDataTransferMac = 0x64
}
public class NcaFileSystemDriver : IDisposable
{
public struct StorageContext : IDisposable
{
public bool OpenRawStorage;
public SharedRef<IStorage> BodySubStorage;
public SharedRef<SparseStorage> CurrentSparseStorage;
public SharedRef<IStorage> SparseStorageMetaStorage;
public SharedRef<SparseStorage> OriginalSparseStorage;
// Todo: externalCurrentSparseStorage, externalOriginalSparseStorage
public SharedRef<IStorage> AesCtrExStorageMetaStorage;
public SharedRef<IStorage> AesCtrExStorageDataStorage;
public SharedRef<AesCtrCounterExtendedStorage> AesCtrExStorage;
public SharedRef<IStorage> IndirectStorageMetaStorage;
public SharedRef<IndirectStorage> IndirectStorage;
public SharedRef<IStorage> FsDataStorage;
public SharedRef<IStorage> CompressedStorageMetaStorage;
public SharedRef<CompressedStorage> CompressedStorage;
public void Dispose()
{
BodySubStorage.Destroy();
CurrentSparseStorage.Destroy();
SparseStorageMetaStorage.Destroy();
OriginalSparseStorage.Destroy();
AesCtrExStorageMetaStorage.Destroy();
AesCtrExStorageDataStorage.Destroy();
AesCtrExStorage.Destroy();
IndirectStorageMetaStorage.Destroy();
IndirectStorage.Destroy();
FsDataStorage.Destroy();
CompressedStorageMetaStorage.Destroy();
CompressedStorage.Destroy();
}
}
private enum AlignmentStorageRequirement
{
CacheBlockSize = 0,
None = 1
}
public NcaFileSystemDriver(ref SharedRef<NcaReader> ncaReader, MemoryResource allocator,
IBufferManager bufferManager, IHash256GeneratorFactorySelector hashGeneratorFactorySelector)
{
throw new NotImplementedException();
}
public NcaFileSystemDriver(ref SharedRef<NcaReader> originalNcaReader, ref SharedRef<NcaReader> currentNcaReader,
MemoryResource allocator, IBufferManager bufferManager,
IHash256GeneratorFactorySelector hashGeneratorFactorySelector)
{
throw new NotImplementedException();
}
public void Dispose()
{
throw new NotImplementedException();
}
private bool IsUsingHwAesCtrForSpeedEmulation(FileSystemServer fs)
{
throw new NotImplementedException();
}
private long GetFsOffset(NcaReader reader, int index)
{
return (long)reader.GetFsOffset(index);
}
private long GetFsEndOffset(NcaReader reader, int index)
{
return (long)reader.GetFsEndOffset(index);
}
public Result OpenStorage(ref SharedRef<IStorage> outStorage,
ref SharedRef<IAsynchronousAccessSplitter> outStorageAccessSplitter, out NcaFsHeaderReader outHeaderReader,
int fsIndex)
{
throw new NotImplementedException();
}
private Result OpenStorageImpl(ref SharedRef<IStorage> outStorage, out NcaFsHeaderReader outHeaderReader,
int fsIndex, ref StorageContext storageContext)
{
throw new NotImplementedException();
}
private Result OpenIndirectableStorageAsOriginal(ref SharedRef<IStorage> outStorage,
in NcaFsHeaderReader headerReader, ref StorageContext storageContext)
{
throw new NotImplementedException();
}
private Result CreateBodySubStorage(ref SharedRef<IStorage> outStorage, long offset, long size)
{
throw new NotImplementedException();
}
private Result CreateAesCtrStorage(ref SharedRef<IStorage> outStorage, ref SharedRef<IStorage> baseStorage,
long offset, in NcaAesCtrUpperIv upperIv, AlignmentStorageRequirement alignmentRequirement)
{
throw new NotImplementedException();
}
private Result CreateAesXtsStorage(ref SharedRef<IStorage> outStorage, ref SharedRef<IStorage> baseStorage,
long offset)
{
throw new NotImplementedException();
}
private Result CreateSparseStorageMetaStorage(ref SharedRef<IStorage> outStorage,
ref SharedRef<IStorage> baseStorage, long offset, in NcaAesCtrUpperIv upperIv, in NcaSparseInfo sparseInfo)
{
throw new NotImplementedException();
}
private Result CreateSparseStorageCore(ref SharedRef<SparseStorage> outStorage, ref SharedRef<IStorage> baseStorage,
long baseStorageSize, ref SharedRef<IStorage> sparseStorageMetaStorage, in NcaSparseInfo sparseInfo,
bool hasExternalInfo)
{
throw new NotImplementedException();
}
private Result CreateSparseStorage(ref SharedRef<IStorage> outStorage, out long outFsDataOffset,
ref SharedRef<SparseStorage> outSparseStorage, ref SharedRef<IStorage> outSparseStorageMetaStorage, int index,
in NcaAesCtrUpperIv upperIv, in NcaSparseInfo sparseInfo)
{
throw new NotImplementedException();
}
private Result CreateAesCtrExStorageMetaStorage(ref SharedRef<IStorage> outStorage,
ref SharedRef<IStorage> baseStorage, long offset, in NcaAesCtrUpperIv upperIv, in NcaPatchInfo patchInfo)
{
throw new NotImplementedException();
}
private Result CreateAesCtrExStorage(ref SharedRef<IStorage> outStorage,
ref SharedRef<AesCtrCounterExtendedStorage> outAesCtrExStorage, ref SharedRef<IStorage> baseStorage,
ref SharedRef<IStorage> aesCtrExMetaStorage, long counterOffset, in NcaAesCtrUpperIv upperIv,
in NcaPatchInfo patchInfo)
{
throw new NotImplementedException();
}
private Result CreateIndirectStorageMetaStorage(ref SharedRef<IStorage> outStorage,
ref SharedRef<IStorage> baseStorage, in NcaPatchInfo patchInfo)
{
throw new NotImplementedException();
}
private Result CreateIndirectStorage(ref SharedRef<IStorage> outStorage,
ref SharedRef<IndirectStorage> outIndirectStorage, ref SharedRef<IStorage> baseStorage,
ref SharedRef<IStorage> originalDataStorage, ref SharedRef<IStorage> indirectStorageMetaStorage,
in NcaPatchInfo patchInfo)
{
throw new NotImplementedException();
}
private Result CreateSha256Storage(ref SharedRef<IStorage> outStorage, ref SharedRef<IStorage> baseStorage,
in NcaFsHeader.HashData.HierarchicalSha256Data sha256Data)
{
throw new NotImplementedException();
}
private Result HierarchicalSha256Data(ref SharedRef<IStorage> outStorage, ref SharedRef<IStorage> baseStorage,
in NcaFsHeader.HashData.IntegrityMetaInfo metaInfo)
{
throw new NotImplementedException();
}
public static Result CreateCompressedStorage(ref SharedRef<IStorage> outStorage,
ref SharedRef<CompressedStorage> outCompressedStorage, ref SharedRef<IStorage> outMetaStorage,
ref SharedRef<IStorage> baseStorage, in NcaCompressionInfo compressionInfo,
GetDecompressorFunction getDecompressor, MemoryResource allocator, IBufferManager bufferManager)
{
throw new NotImplementedException();
}
public Result CreateCompressedStorage(ref SharedRef<IStorage> outStorage,
ref SharedRef<CompressedStorage> outCompressedStorage, ref SharedRef<IStorage> outMetaStorage,
ref SharedRef<IStorage> baseStorage, in NcaCompressionInfo compressionInfo)
{
throw new NotImplementedException();
}
}