private HierarchicalIntegrityVerificationStream InitIvfcStream(IntegrityCheckLevel integrityCheckLevel) { IvfcHeader ivfc = Header.Ivfc; const int ivfcLevels = 5; var initInfo = new IntegrityVerificationInfo[ivfcLevels]; initInfo[0] = new IntegrityVerificationInfo { Data = Header.MasterHash, BlockSize = 0, Type = IntegrityStreamType.Save }; for (int i = 1; i < ivfcLevels; i++) { IvfcLevelHeader level = ivfc.LevelHeaders[i - 1]; Stream data = i == ivfcLevels - 1 ? JournalStreamSource.CreateStream() : MetaRemapStorage.OpenStream(level.LogicalOffset, level.HashDataSize); initInfo[i] = new IntegrityVerificationInfo { Data = data, BlockSize = 1 << level.BlockSizePower, Salt = new HMACSHA256(Encoding.ASCII.GetBytes(SaltSources[i - 1])).ComputeHash(ivfc.SaltSource), Type = IntegrityStreamType.Save }; } return(new HierarchicalIntegrityVerificationStream(initInfo, integrityCheckLevel)); }
public void FsTrim() { MetaRemapStorage.FsTrim(); DataRemapStorage.FsTrim(); DuplexStorage.FsTrim(); JournalStorage.FsTrim(); CoreDataIvfcStorage.FsTrim(); FatIvfcStorage?.FsTrim(); SaveDataFileSystemCore.FsTrim(); int unusedHeaderOffset = IsFirstHeaderInUse ? 0x4000 : 0; BaseStorage.Slice(unusedHeaderOffset, 0x4000).Fill(TrimFillValue); }
private HierarchicalIntegrityVerificationStorage InitJournalIvfcStorage(IntegrityCheckLevel integrityCheckLevel) { const int ivfcLevels = 5; IvfcHeader ivfc = Header.Ivfc; var levels = new List <IStorage> { Header.DataIvfcMaster }; for (int i = 0; i < ivfcLevels - 2; i++) { IvfcLevelHeader level = ivfc.LevelHeaders[i]; levels.Add(MetaRemapStorage.Slice(level.Offset, level.Size)); } IvfcLevelHeader dataLevel = ivfc.LevelHeaders[ivfcLevels - 2]; levels.Add(JournalStorage.Slice(dataLevel.Offset, dataLevel.Size)); return(new HierarchicalIntegrityVerificationStorage(ivfc, levels, IntegrityStorageType.Save, integrityCheckLevel, LeaveOpen)); }