From 37b8249a8b2ae3899761c997a4e5c0c3f53ae528 Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Wed, 19 Jan 2022 12:24:28 -0700 Subject: [PATCH] Ensure more FS classes are updated for 13.1.0 - DeviceEventSimulationStorage - MultiCommitManager - DirectorySaveDataFileSystem - SubdirectoryFileSystem - FsSystem.Utility --- .../FsSrv/Impl/DeviceEventSimulationStorage.cs | 17 +++++++++++------ src/LibHac/FsSrv/Impl/MultiCommitManager.cs | 6 ++++-- .../FsSystem/DirectorySaveDataFileSystem.cs | 4 ++-- src/LibHac/FsSystem/SubdirectoryFileSystem.cs | 4 ++-- src/LibHac/FsSystem/Utility.cs | 4 ++-- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/LibHac/FsSrv/Impl/DeviceEventSimulationStorage.cs b/src/LibHac/FsSrv/Impl/DeviceEventSimulationStorage.cs index f25c67eb..7ffe4169 100644 --- a/src/LibHac/FsSrv/Impl/DeviceEventSimulationStorage.cs +++ b/src/LibHac/FsSrv/Impl/DeviceEventSimulationStorage.cs @@ -1,5 +1,6 @@ using System; using LibHac.Common; +using LibHac.Diag; using LibHac.Fs; namespace LibHac.FsSrv.Impl; @@ -7,16 +8,16 @@ namespace LibHac.FsSrv.Impl; /// /// An for simulating device failures /// -/// Based on FS 12.1.0 (nnSdk 12.3.1) +/// Based on FS 13.1.0 (nnSdk 13.4.0) internal class DeviceEventSimulationStorage : IStorage { private SharedRef _baseStorage; - private IDeviceEventSimulator _eventSimulator; + private IDeviceEventSimulator _deviceEventSimulator; - public DeviceEventSimulationStorage(ref SharedRef baseStorage, IDeviceEventSimulator eventSimulator) + public DeviceEventSimulationStorage(ref SharedRef baseStorage, IDeviceEventSimulator deviceEventSimulator) { _baseStorage = SharedRef.CreateMove(ref baseStorage); - _eventSimulator = eventSimulator; + _deviceEventSimulator = deviceEventSimulator; } public override void Dispose() @@ -27,7 +28,9 @@ internal class DeviceEventSimulationStorage : IStorage public override Result Read(long offset, Span destination) { - Result rc = _eventSimulator.CheckSimulatedAccessFailureEvent(SimulatingDeviceTargetOperation.Read); + Assert.SdkNotNull(_deviceEventSimulator); + + Result rc = _deviceEventSimulator.CheckSimulatedAccessFailureEvent(SimulatingDeviceTargetOperation.Read); if (rc.IsFailure()) return rc; return _baseStorage.Get.Read(offset, destination); @@ -35,7 +38,9 @@ internal class DeviceEventSimulationStorage : IStorage public override Result Write(long offset, ReadOnlySpan source) { - Result rc = _eventSimulator.CheckSimulatedAccessFailureEvent(SimulatingDeviceTargetOperation.Write); + Assert.SdkNotNull(_deviceEventSimulator); + + Result rc = _deviceEventSimulator.CheckSimulatedAccessFailureEvent(SimulatingDeviceTargetOperation.Write); if (rc.IsFailure()) return rc; return _baseStorage.Get.Write(offset, source); diff --git a/src/LibHac/FsSrv/Impl/MultiCommitManager.cs b/src/LibHac/FsSrv/Impl/MultiCommitManager.cs index c2f4ecf2..ce2c856f 100644 --- a/src/LibHac/FsSrv/Impl/MultiCommitManager.cs +++ b/src/LibHac/FsSrv/Impl/MultiCommitManager.cs @@ -20,7 +20,7 @@ internal struct MultiCommitManagerGlobals public void Initialize() { - MultiCommitMutex.Initialize(); + MultiCommitMutex = new SdkMutexType(); } } @@ -40,7 +40,7 @@ internal struct MultiCommitManagerGlobals /// Save data image files are designed so that minimal changes are made when fully committing a provisionally committed save. /// However if any commit fails for any reason, all other saves in the multi-commit will still be committed. /// This can especially cause issues with directory save data where finishing a commit is much more involved. -/// Based on FS 12.1.0 (nnSdk 12.3.1) +/// Based on FS 13.1.0 (nnSdk 13.4.0) /// internal class MultiCommitManager : IMultiCommitManager { @@ -501,7 +501,9 @@ internal class MultiCommitManager : IMultiCommitManager { public int Version; public CommitState State; + // ReSharper disable once NotAccessedField.Local public int FileSystemCount; + // ReSharper disable once NotAccessedField.Local public long Counter; } diff --git a/src/LibHac/FsSystem/DirectorySaveDataFileSystem.cs b/src/LibHac/FsSystem/DirectorySaveDataFileSystem.cs index 8ba03e08..61cd6549 100644 --- a/src/LibHac/FsSystem/DirectorySaveDataFileSystem.cs +++ b/src/LibHac/FsSystem/DirectorySaveDataFileSystem.cs @@ -25,7 +25,7 @@ internal struct DirectorySaveDataFileSystemGlobals /// /// Transactional commits should be atomic as long as the function of the /// underlying is atomic. -/// Based on FS 12.1.0 (nnSdk 12.3.1) +/// Based on FS 13.1.0 (nnSdk 13.4.0) /// public class DirectorySaveDataFileSystem : IFileSystem, ISaveDataExtraDataAccessor { @@ -1008,4 +1008,4 @@ public class DirectorySaveDataFileSystem : IFileSystem, ISaveDataExtraDataAccess public SaveDataSpaceId GetSaveDataSpaceId() => _spaceId; public ulong GetSaveDataId() => _saveDataId; -} +} \ No newline at end of file diff --git a/src/LibHac/FsSystem/SubdirectoryFileSystem.cs b/src/LibHac/FsSystem/SubdirectoryFileSystem.cs index 7f39d404..508c5beb 100644 --- a/src/LibHac/FsSystem/SubdirectoryFileSystem.cs +++ b/src/LibHac/FsSystem/SubdirectoryFileSystem.cs @@ -8,7 +8,7 @@ namespace LibHac.FsSystem; /// /// An that uses a directory of another as its root directory. /// -/// Based on FS 12.1.0 (nnSdk 12.3.1) +/// Based on FS 13.1.0 (nnSdk 13.4.0) public class SubdirectoryFileSystem : IFileSystem { private IFileSystem _baseFileSystem; @@ -255,4 +255,4 @@ public class SubdirectoryFileSystem : IFileSystem { return _baseFileSystem.Rollback(); } -} +} \ No newline at end of file diff --git a/src/LibHac/FsSystem/Utility.cs b/src/LibHac/FsSystem/Utility.cs index ebfcf855..96935c03 100644 --- a/src/LibHac/FsSystem/Utility.cs +++ b/src/LibHac/FsSystem/Utility.cs @@ -9,7 +9,7 @@ namespace LibHac.FsSystem; /// /// Various utility functions used by the namespace. /// -/// Based on FS 12.1.0 (nnSdk 12.3.1) +/// Based on FS 13.1.0 (nnSdk 13.4.0) internal static class Utility { public delegate Result FsIterationTask(in Path path, in DirectoryEntry entry, ref FsIterationTaskClosure closure); @@ -172,7 +172,7 @@ internal static class Utility rc = destFileSystem.OpenFile(ref destFile.Ref(), in destPath, OpenMode.Write); if (rc.IsFailure()) return rc; - // Read/Write file in work buffer sized chunks. + // Read/Write file in work-buffer-sized chunks. long remaining = fileSize; long offset = 0;