From 0ab96f67bf64d26a5b9a10f0a5e818c47a852630 Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Sat, 21 Mar 2020 23:37:32 -0700 Subject: [PATCH] Add new functions to existing classes deriving from IFileSystem --- build/CodeGen/results.csv | 11 +++++++---- src/LibHac/Fs/ResultFs.cs | 14 ++++++++++---- src/LibHac/FsSystem/AesXtsFileSystem.cs | 10 ++++++++++ src/LibHac/FsSystem/ConcatenationFileSystem.cs | 10 ++++++++++ .../FsSystem/DirectorySaveDataFileSystem.cs | 17 +++++++++++++++++ src/LibHac/FsSystem/PartitionFileSystemCore.cs | 1 + src/LibHac/FsSystem/RomFs/RomFsFileSystem.cs | 1 + src/LibHac/FsSystem/SubdirectoryFileSystem.cs | 10 ++++++++++ 8 files changed, 66 insertions(+), 8 deletions(-) diff --git a/build/CodeGen/results.csv b/build/CodeGen/results.csv index b788bb4b..23cb7ec5 100644 --- a/build/CodeGen/results.csv +++ b/build/CodeGen/results.csv @@ -128,8 +128,8 @@ Module,DescriptionStart,DescriptionEnd,Name,Summary 2,4781,,GameCardLogoDataCorrupted, 2,4791,4799,MultiCommitContextCorrupted, -2,4791,,InvalidMultiCommitContextVersion, -2,4792,,InvalidMultiCommitContextState, +2,4791,,InvalidMultiCommitContextVersion,The version of the multi-commit context file is to high for the current MultiCommitManager implementation. +2,4792,,InvalidMultiCommitContextState,The multi-commit has not been provisionally committed. # The range name is a guess. 4812 is currently the only result in it 2,4811,4819,ZeroBitmapFileCorrupted, @@ -186,14 +186,17 @@ Module,DescriptionStart,DescriptionEnd,Name,Summary 2,6351,,UnsupportedOperationInRoGameCardStorageSetSize, 2,6359,,UnsupportedOperationInConcatFsQueryEntry, 2,6364,,UnsupportedOperationModifyRomFsFileSystem, +2,6365,,UnsupportedOperationInRomFsFileSystem,Called RomFsFileSystem::CommitProvisionally. 2,6366,,UnsupportedOperationRomFsFileSystemGetSpace, 2,6367,,UnsupportedOperationModifyRomFsFile, 2,6369,,UnsupportedOperationModifyReadOnlyFileSystem, 2,6371,,UnsupportedOperationReadOnlyFileSystemGetSpace, 2,6372,,UnsupportedOperationModifyReadOnlyFile, 2,6374,,UnsupportedOperationModifyPartitionFileSystem, +2,6375,,UnsupportedOperationInPartitionFileSystem,Called PartitionFileSystemCore::CommitProvisionally. 2,6376,,UnsupportedOperationInPartitionFileSetSize, 2,6377,,UnsupportedOperationIdInPartitionFileSystem, +2,6384,,UnsupportedOperationInDirectorySaveDataFileSystem,Called DirectorySaveDataFileSystem::CommitProvisionally on a non-user savedata. 2,6400,6449,PermissionDenied, @@ -201,7 +204,7 @@ Module,DescriptionStart,DescriptionEnd,Name,Summary 2,6454,,WriteStateUnflushed, 2,6457,,WriteModeFileNotClosed, 2,6461,,AllocatorAlignmentViolation, -2,6463,,MultiCommitFileSystemAlreadyAdded, +2,6463,,MultiCommitFileSystemAlreadyAdded,The provided file system has already been added to the multi-commit manager. 2,6465,,UserNotExist, 2,6600,6699,EntryNotFound, @@ -211,7 +214,7 @@ Module,DescriptionStart,DescriptionEnd,Name,Summary 2,6706,,MappingTableFull, 2,6707,,AllocationTableInsufficientFreeBlocks, 2,6709,,OpenCountLimit, -2,6710,,MultiCommitFileSystemLimit, +2,6710,,MultiCommitFileSystemLimit,The maximum number of file systems have been added to the multi-commit manager. 2,6800,6899,MappingFailed, 2,6811,,RemapStorageMapFull, diff --git a/src/LibHac/Fs/ResultFs.cs b/src/LibHac/Fs/ResultFs.cs index 11003473..7840bb4c 100644 --- a/src/LibHac/Fs/ResultFs.cs +++ b/src/LibHac/Fs/ResultFs.cs @@ -258,9 +258,9 @@ namespace LibHac.Fs /// Error code: 2002-4791; Range: 4791-4799; Inner value: 0x256e02 public static Result.Base MultiCommitContextCorrupted { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 4791, 4799); } - /// Error code: 2002-4791; Inner value: 0x256e02 + /// The version of the multi-commit context file is to high for the current MultiCommitManager implementation.
Error code: 2002-4791; Inner value: 0x256e02
public static Result.Base InvalidMultiCommitContextVersion => new Result.Base(ModuleFs, 4791); - /// Error code: 2002-4792; Inner value: 0x257002 + /// The multi-commit has not been provisionally committed.
Error code: 2002-4792; Inner value: 0x257002
public static Result.Base InvalidMultiCommitContextState => new Result.Base(ModuleFs, 4792); /// Error code: 2002-4811; Range: 4811-4819; Inner value: 0x259602 @@ -364,6 +364,8 @@ namespace LibHac.Fs public static Result.Base UnsupportedOperationInConcatFsQueryEntry => new Result.Base(ModuleFs, 6359); /// Error code: 2002-6364; Inner value: 0x31b802 public static Result.Base UnsupportedOperationModifyRomFsFileSystem => new Result.Base(ModuleFs, 6364); + /// Called RomFsFileSystem::CommitProvisionally.
Error code: 2002-6365; Inner value: 0x31ba02
+ public static Result.Base UnsupportedOperationInRomFsFileSystem => new Result.Base(ModuleFs, 6365); /// Error code: 2002-6366; Inner value: 0x31bc02 public static Result.Base UnsupportedOperationRomFsFileSystemGetSpace => new Result.Base(ModuleFs, 6366); /// Error code: 2002-6367; Inner value: 0x31be02 @@ -376,10 +378,14 @@ namespace LibHac.Fs public static Result.Base UnsupportedOperationModifyReadOnlyFile => new Result.Base(ModuleFs, 6372); /// Error code: 2002-6374; Inner value: 0x31cc02 public static Result.Base UnsupportedOperationModifyPartitionFileSystem => new Result.Base(ModuleFs, 6374); + /// Called PartitionFileSystemCore::CommitProvisionally.
Error code: 2002-6375; Inner value: 0x31ce02
+ public static Result.Base UnsupportedOperationInPartitionFileSystem => new Result.Base(ModuleFs, 6375); /// Error code: 2002-6376; Inner value: 0x31d002 public static Result.Base UnsupportedOperationInPartitionFileSetSize => new Result.Base(ModuleFs, 6376); /// Error code: 2002-6377; Inner value: 0x31d202 public static Result.Base UnsupportedOperationIdInPartitionFileSystem => new Result.Base(ModuleFs, 6377); + /// Called DirectorySaveDataFileSystem::CommitProvisionally on a non-user savedata.
Error code: 2002-6384; Inner value: 0x31e002
+ public static Result.Base UnsupportedOperationInDirectorySaveDataFileSystem => new Result.Base(ModuleFs, 6384); /// Error code: 2002-6400; Range: 6400-6449; Inner value: 0x320002 public static Result.Base PermissionDenied { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => new Result.Base(ModuleFs, 6400, 6449); } @@ -392,7 +398,7 @@ namespace LibHac.Fs public static Result.Base WriteModeFileNotClosed => new Result.Base(ModuleFs, 6457); /// Error code: 2002-6461; Inner value: 0x327a02 public static Result.Base AllocatorAlignmentViolation => new Result.Base(ModuleFs, 6461); - /// Error code: 2002-6463; Inner value: 0x327e02 + /// The provided file system has already been added to the multi-commit manager.
Error code: 2002-6463; Inner value: 0x327e02
public static Result.Base MultiCommitFileSystemAlreadyAdded => new Result.Base(ModuleFs, 6463); /// Error code: 2002-6465; Inner value: 0x328202 public static Result.Base UserNotExist => new Result.Base(ModuleFs, 6465); @@ -410,7 +416,7 @@ namespace LibHac.Fs public static Result.Base AllocationTableInsufficientFreeBlocks => new Result.Base(ModuleFs, 6707); /// Error code: 2002-6709; Inner value: 0x346a02 public static Result.Base OpenCountLimit => new Result.Base(ModuleFs, 6709); - /// Error code: 2002-6710; Inner value: 0x346c02 + /// The maximum number of file systems have been added to the multi-commit manager.
Error code: 2002-6710; Inner value: 0x346c02
public static Result.Base MultiCommitFileSystemLimit => new Result.Base(ModuleFs, 6710); /// Error code: 2002-6800; Range: 6800-6899; Inner value: 0x352002 diff --git a/src/LibHac/FsSystem/AesXtsFileSystem.cs b/src/LibHac/FsSystem/AesXtsFileSystem.cs index 2e6abcf0..7335f93f 100644 --- a/src/LibHac/FsSystem/AesXtsFileSystem.cs +++ b/src/LibHac/FsSystem/AesXtsFileSystem.cs @@ -221,6 +221,16 @@ namespace LibHac.FsSystem return BaseFileSystem.Commit(); } + protected override Result CommitProvisionallyImpl(long commitCount) + { + return BaseFileSystem.CommitProvisionally(commitCount); + } + + protected override Result RollbackImpl() + { + return BaseFileSystem.Rollback(); + } + protected override Result QueryEntryImpl(Span outBuffer, ReadOnlySpan inBuffer, QueryId queryId, U8Span path) { diff --git a/src/LibHac/FsSystem/ConcatenationFileSystem.cs b/src/LibHac/FsSystem/ConcatenationFileSystem.cs index a572a2ec..38b9dca4 100644 --- a/src/LibHac/FsSystem/ConcatenationFileSystem.cs +++ b/src/LibHac/FsSystem/ConcatenationFileSystem.cs @@ -306,6 +306,16 @@ namespace LibHac.FsSystem return BaseFileSystem.Commit(); } + protected override Result CommitProvisionallyImpl(long commitCount) + { + return BaseFileSystem.CommitProvisionally(commitCount); + } + + protected override Result FlushImpl() + { + return BaseFileSystem.Flush(); + } + protected override Result QueryEntryImpl(Span outBuffer, ReadOnlySpan inBuffer, QueryId queryId, U8Span path) { diff --git a/src/LibHac/FsSystem/DirectorySaveDataFileSystem.cs b/src/LibHac/FsSystem/DirectorySaveDataFileSystem.cs index e775bc81..1075b7e2 100644 --- a/src/LibHac/FsSystem/DirectorySaveDataFileSystem.cs +++ b/src/LibHac/FsSystem/DirectorySaveDataFileSystem.cs @@ -299,6 +299,23 @@ namespace LibHac.FsSystem } } + protected override Result CommitProvisionallyImpl(long commitCount) + { + if (!IsUserSaveData) + return ResultFs.UnsupportedOperationIdInPartitionFileSystem.Log(); + + return Result.Success; + } + + protected override Result RollbackImpl() + { + // No old data is kept for temporary save data, so there's nothing to rollback to + if (!IsPersistentSaveData) + return Result.Success; + + return Initialize(IsPersistentSaveData, IsUserSaveData); + } + private Result ResolveFullPath(Span outPath, U8Span relativePath) { if (StringUtils.GetLength(relativePath, PathTools.MaxPathLength + 1) > PathTools.MaxPathLength) diff --git a/src/LibHac/FsSystem/PartitionFileSystemCore.cs b/src/LibHac/FsSystem/PartitionFileSystemCore.cs index 81a84b6b..f6bb15bb 100644 --- a/src/LibHac/FsSystem/PartitionFileSystemCore.cs +++ b/src/LibHac/FsSystem/PartitionFileSystemCore.cs @@ -108,6 +108,7 @@ namespace LibHac.FsSystem protected override Result DeleteFileImpl(U8Span path) => ResultFs.UnsupportedOperationModifyPartitionFileSystem.Log(); protected override Result RenameDirectoryImpl(U8Span oldPath, U8Span newPath) => ResultFs.UnsupportedOperationModifyPartitionFileSystem.Log(); protected override Result RenameFileImpl(U8Span oldPath, U8Span newPath) => ResultFs.UnsupportedOperationModifyPartitionFileSystem.Log(); + protected override Result CommitProvisionallyImpl(long commitCount) => ResultFs.UnsupportedOperationInPartitionFileSystem.Log(); private class PartitionFile : FileBase { diff --git a/src/LibHac/FsSystem/RomFs/RomFsFileSystem.cs b/src/LibHac/FsSystem/RomFs/RomFsFileSystem.cs index 764a60b5..fdc7399e 100644 --- a/src/LibHac/FsSystem/RomFs/RomFsFileSystem.cs +++ b/src/LibHac/FsSystem/RomFs/RomFsFileSystem.cs @@ -92,6 +92,7 @@ namespace LibHac.FsSystem.RomFs protected override Result DeleteFileImpl(U8Span path) => ResultFs.UnsupportedOperationModifyRomFsFileSystem.Log(); protected override Result RenameDirectoryImpl(U8Span oldPath, U8Span newPath) => ResultFs.UnsupportedOperationModifyRomFsFileSystem.Log(); protected override Result RenameFileImpl(U8Span oldPath, U8Span newPath) => ResultFs.UnsupportedOperationModifyRomFsFileSystem.Log(); + protected override Result CommitProvisionallyImpl(long commitCount) => ResultFs.UnsupportedOperationInRomFsFileSystem.Log(); protected override Result GetFreeSpaceSizeImpl(out long freeSpace, U8Span path) { diff --git a/src/LibHac/FsSystem/SubdirectoryFileSystem.cs b/src/LibHac/FsSystem/SubdirectoryFileSystem.cs index f32c92e2..d04e7071 100644 --- a/src/LibHac/FsSystem/SubdirectoryFileSystem.cs +++ b/src/LibHac/FsSystem/SubdirectoryFileSystem.cs @@ -194,6 +194,16 @@ namespace LibHac.FsSystem return BaseFileSystem.Commit(); } + protected override Result CommitProvisionallyImpl(long commitCount) + { + return BaseFileSystem.CommitProvisionally(commitCount); + } + + protected override Result RollbackImpl() + { + return BaseFileSystem.Rollback(); + } + protected override Result GetFreeSpaceSizeImpl(out long freeSpace, U8Span path) { freeSpace = default;