From f4d6d6b3c8267ae33e374c56e717417fb16feb69 Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Mon, 31 May 2021 22:39:27 -0700 Subject: [PATCH] Add some docs and fix a permissions logic error --- src/LibHac/Fs/Shim/SaveDataManagement.cs | 50 +++++++++++++++++++ src/LibHac/FsSrv/SaveDataFileSystemService.cs | 4 +- 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/src/LibHac/Fs/Shim/SaveDataManagement.cs b/src/LibHac/Fs/Shim/SaveDataManagement.cs index be722d48..df5a88ed 100644 --- a/src/LibHac/Fs/Shim/SaveDataManagement.cs +++ b/src/LibHac/Fs/Shim/SaveDataManagement.cs @@ -123,6 +123,17 @@ namespace LibHac.Fs.Shim return Result.Success; } + /// + /// Writes the of the provided + /// to the save data in the specified with the provided save data ID. + /// + /// The to use. + /// The containing the save data to be written to. + /// The save data ID of the save data to be written to. + /// The containing the data to write. + /// : The operation was successful.
+ /// : The save data was not found.
+ /// : Insufficient permissions.
public static Result WriteSaveDataFileSystemExtraData(this FileSystemClientImpl fs, SaveDataSpaceId spaceId, ulong saveDataId, in SaveDataExtraData extraData) { @@ -134,6 +145,24 @@ namespace LibHac.Fs.Shim return rc; } + /// + /// Writes the provided to the save data in the specified + /// with the provided save data ID. + /// + /// The to use. + /// The containing the save data to be written to. + /// The save data ID of the save data to be written to. + /// The to write to the save data. + /// A mask specifying which bits of + /// to write to the save's extra data. 0 = don't write, 1 = write. + /// : The operation was successful.
+ /// : The save data was not found.
+ /// : Insufficient permissions.
+ /// + /// Calling programs may have permission to write to all, some or none of the save data's extra data. + /// If any bits are set in that the caller does not have the permissions + /// to write to, nothing will be written and will be returned. + /// public static Result WriteSaveDataFileSystemExtraData(this FileSystemClientImpl fs, SaveDataSpaceId spaceId, ulong saveDataId, in SaveDataExtraData extraData, in SaveDataExtraData extraDataMask) { @@ -145,6 +174,27 @@ namespace LibHac.Fs.Shim return rc; } + /// + /// Writes the provided to the save data in the specified + /// that matches the provided key. + /// The mask specifies which parts of the extra data will be written to the save data. + /// + /// The to use. + /// The containing the save data to be written to. + /// The key for the save data. + /// The to write to the save data. + /// A mask specifying which bits of + /// to write to the save's extra data. 0 = don't write, 1 = write. + /// : The operation was successful.
+ /// : The save data was not found.
+ /// : Insufficient permissions.
+ /// + /// If is set to , + /// the program ID of will be resolved to the default save data program ID of the calling program.
+ /// Calling programs may have permission to write to all, some or none of the save data's extra data. + /// If any bits are set in that the caller does not have the permissions + /// to write to, nothing will be written and will be returned. + ///
public static Result WriteSaveDataFileSystemExtraData(this FileSystemClientImpl fs, SaveDataSpaceId spaceId, in SaveDataAttribute attribute, in SaveDataExtraData extraData, in SaveDataExtraData extraDataMask) { diff --git a/src/LibHac/FsSrv/SaveDataFileSystemService.cs b/src/LibHac/FsSrv/SaveDataFileSystemService.cs index 6ed7f041..c44169c0 100644 --- a/src/LibHac/FsSrv/SaveDataFileSystemService.cs +++ b/src/LibHac/FsSrv/SaveDataFileSystemService.cs @@ -214,7 +214,9 @@ namespace LibHac.FsSrv Result rc = GetAccessibilityForSaveData(out Accessibility accessibility, programInfo, extraDataGetter); if (rc.IsFailure()) return rc; - if (accessibility.CanRead && accessibility.CanWrite) + // Note: This is correct. Even if a program only has read accessibility to another program's save data, + // Nintendo gives it full read/write accessibility as of FS 12.0.0 + if (accessibility.CanRead || accessibility.CanWrite) return Result.Success; // The program doesn't have permissions for this specific save data. Check if it has overall