diff --git a/src/LibHac/Fs/Shim/ProgramIndexMapInfo.cs b/src/LibHac/Fs/Shim/ProgramIndexMapInfo.cs index 976e31fe..eb02288a 100644 --- a/src/LibHac/Fs/Shim/ProgramIndexMapInfo.cs +++ b/src/LibHac/Fs/Shim/ProgramIndexMapInfo.cs @@ -1,11 +1,15 @@ using System; -using System.Runtime.InteropServices; using LibHac.Common; using LibHac.FsSrv.Sf; using LibHac.Sf; namespace LibHac.Fs.Shim; +/// +/// Contains functions for registering multi-program application +/// information of the currently running application with FS. +/// +/// Based on nnSdk 13.4.0 public static class ProgramIndexMapInfoShim { /// @@ -23,10 +27,10 @@ public static class ProgramIndexMapInfoShim using SharedRef fileSystemProxy = fs.Impl.GetFileSystemProxyServiceObject(); - var mapInfoBuffer = new InBuffer(MemoryMarshal.Cast(mapInfo)); - - Result rc = fileSystemProxy.Get.RegisterProgramIndexMapInfo(mapInfoBuffer, mapInfo.Length); + Result rc = fileSystemProxy.Get.RegisterProgramIndexMapInfo(InBuffer.FromSpan(mapInfo), mapInfo.Length); fs.Impl.AbortIfNeeded(rc); - return rc; + if (rc.IsFailure()) return rc.Miss(); + + return Result.Success; } -} +} \ No newline at end of file diff --git a/src/LibHac/Fs/Shim/ProgramRegistry.cs b/src/LibHac/Fs/Shim/ProgramRegistry.cs index 844103a3..dc9b3877 100644 --- a/src/LibHac/Fs/Shim/ProgramRegistry.cs +++ b/src/LibHac/Fs/Shim/ProgramRegistry.cs @@ -1,5 +1,6 @@ using System; using LibHac.Common; +using LibHac.Diag; using LibHac.FsSrv; using LibHac.FsSrv.Sf; using LibHac.Ncm; @@ -7,6 +8,11 @@ using LibHac.Sf; namespace LibHac.Fs.Shim; +/// +/// Contains functions for registering and unregistering currently running +/// processes and their permissions in the FS program registry. +/// +/// Based on nnSdk 13.4.0 public static class ProgramRegistry { /// @@ -33,11 +39,8 @@ public static class ProgramRegistry { using SharedRef programRegistry = fs.Impl.GetProgramRegistryServiceObject(); - Result rc = programRegistry.Get.SetCurrentProcess(fs.Hos.Os.GetCurrentProcessId().Value); - if (rc.IsFailure()) return rc.Miss(); - - rc = programRegistry.Get.UnregisterProgram(processId); - if (rc.IsFailure()) return rc.Miss(); + Abort.DoAbortUnlessSuccess(programRegistry.Get.SetCurrentProcess(fs.Hos.Os.GetCurrentProcessId().Value)); + Abort.DoAbortUnlessSuccess(programRegistry.Get.UnregisterProgram(processId)); return Result.Success; } diff --git a/src/LibHac/Fs/Shim/SystemSaveData.cs b/src/LibHac/Fs/Shim/SystemSaveData.cs index 3de0cab7..880604d9 100644 --- a/src/LibHac/Fs/Shim/SystemSaveData.cs +++ b/src/LibHac/Fs/Shim/SystemSaveData.cs @@ -11,6 +11,10 @@ using IFileSystemSf = LibHac.FsSrv.Sf.IFileSystem; namespace LibHac.Fs.Shim; +/// +/// Contains functions for mounting system save data file systems. +/// +/// Based on nnSdk 13.4.0 [SkipLocalsInit] public static class SystemSaveData { @@ -19,18 +23,18 @@ public static class SystemSaveData return fs.MountSystemSaveData(mountName, saveDataId, Fs.SaveData.InvalidUserId); } - public static Result MountSystemSaveData(this FileSystemClient fs, U8Span mountName, SaveDataSpaceId spaceId, - ulong saveDataId) - { - return fs.MountSystemSaveData(mountName, spaceId, saveDataId, Fs.SaveData.InvalidUserId); - } - public static Result MountSystemSaveData(this FileSystemClient fs, U8Span mountName, ulong saveDataId, UserId userId) { return fs.MountSystemSaveData(mountName, SaveDataSpaceId.System, saveDataId, userId); } + public static Result MountSystemSaveData(this FileSystemClient fs, U8Span mountName, SaveDataSpaceId spaceId, + ulong saveDataId) + { + return fs.MountSystemSaveData(mountName, spaceId, saveDataId, Fs.SaveData.InvalidUserId); + } + public static Result MountSystemSaveData(this FileSystemClient fs, U8Span mountName, SaveDataSpaceId spaceId, ulong saveDataId, UserId userId) { @@ -58,6 +62,11 @@ public static class SystemSaveData } fs.Impl.AbortIfNeeded(rc); + if (rc.IsFailure()) return rc.Miss(); + + if (fs.Impl.IsEnabledAccessLog(AccessLogTarget.System)) + fs.Impl.EnableFileSystemAccessorAccessLog(mountName); + return rc; static Result Mount(FileSystemClient fs, U8Span mountName, SaveDataSpaceId spaceId, ulong saveDataId, @@ -86,8 +95,9 @@ public static class SystemSaveData if (spaceId == SaveDataSpaceId.System) { using var mountNameGenerator = new UniqueRef(); - return fs.Register(mountName, fileSystemAdapterRaw, ref fileSystemAdapter.Ref(), - ref mountNameGenerator.Ref(), false, null, false); + return fs.Register(mountName, multiCommitTarget: fileSystemAdapterRaw, ref fileSystemAdapter.Ref(), + ref mountNameGenerator.Ref(), useDataCache: false, storageForPurgeFileDataCache: null, + usePathCache: false); } else {