Changes

Jump to navigation Jump to search
1,500 bytes added ,  00:11, 4 April 2020
Line 14: Line 14:     
== OpenCodeFileSystem ==
 
== OpenCodeFileSystem ==
Takes an u64 TitleId and a [[#ContentPath]]. Returns an [[#IFileSystem]].
+
Takes an [[NCM_services#ProgramId|ProgramId]] and a [[#ContentPath]]. Returns an [[#IFileSystem]].
    
== IsArchivedProgram ==
 
== IsArchivedProgram ==
Line 20: Line 20:     
== SetCurrentProcess ==
 
== SetCurrentProcess ==
Takes a PID descriptor.
+
Takes a ProcessId descriptor.
    
= fsp-pr =
 
= fsp-pr =
Line 39: Line 39:     
== RegisterProgram ==
 
== RegisterProgram ==
Takes a storageID, a pid, a titleID, a 0x1C type-A buffer for the [[NPDM#FS_Access_Header| FS Access Header]], and a 0x2C type-A buffer for the [[NPDM#FS_Access_Control| FS Access Control]]
+
Takes a [[NCM_services#StorageId|StorageId]], an u64 ProcessId, a [[NCM_services#ProgramId|ProgramId]], a 0x1C type-A buffer for the [[NPDM#FS_Access_Header| FS Access Header]], and a 0x2C type-A buffer for the [[NPDM#FS_Access_Control| FS Access Control]]
    
Final FS permissions are stored as (ACI0_perms & ACID_perms). Will panic(svcBreak) when buffer sizes from ipc-rawdata are invalid.
 
Final FS permissions are stored as (ACI0_perms & ACID_perms). Will panic(svcBreak) when buffer sizes from ipc-rawdata are invalid.
Line 116: Line 116:  
| 52 || [[#OpenSaveDataFileSystemBySystemSaveDataId]]
 
| 52 || [[#OpenSaveDataFileSystemBySystemSaveDataId]]
 
|-
 
|-
| 53 || [2.0.0+] OpenReadOnlySaveDataFileSystem
+
| 53 || [2.0.0+] [[#OpenReadOnlySaveDataFileSystem]]
 
|-
 
|-
 
| 57 || [3.0.0+] [[#ReadSaveDataFileSystemExtraDataBySaveDataSpaceId]]
 
| 57 || [3.0.0+] [[#ReadSaveDataFileSystemExtraDataBySaveDataSpaceId]]
Line 527: Line 527:     
== OpenFileSystem ==
 
== OpenFileSystem ==
Takes a type-0x19 input buffer (ContentPath) and a [[#FileSystemType]] as parameters. Returns an [[#IFileSystem]].
+
Takes a type-0x19 input [[#ContentPath]] and a [[#FileSystemProxyType]] as parameters. Returns an [[#IFileSystem]].
    
[2.0.0+] This function was removed.
 
[2.0.0+] This function was removed.
Line 535: Line 535:     
== OpenFileSystemWithPatch ==
 
== OpenFileSystemWithPatch ==
Takes an input [[#FileSystemType]] and an u64 title-id. Returns an [[#IFileSystem]].
+
Takes an input [[#FileSystemProxyType]] and an u64 title-id. Returns an [[#IFileSystem]].
   −
Web-applet loads the [[#FileSystemType]] (which must be '''ContentManual''') from u32_table[inparam].
+
Web-applet loads the [[#FileSystemProxyType]] (which must be '''Manual''') from u32_table[inparam].
    
Note: web-applet strings refer to both this cmd and [[#OpenFileSystemWithId]] as "MountContent", but official nn_sf_sync symbols use "OpenXX" names.
 
Note: web-applet strings refer to both this cmd and [[#OpenFileSystemWithId]] as "MountContent", but official nn_sf_sync symbols use "OpenXX" names.
    
== OpenFileSystemWithId ==
 
== OpenFileSystemWithId ==
Takes a type-0x19 input buffer, an [[#FileSystemType]] and an u64 title-id. Returns an [[#IFileSystem]].
+
Takes a type-0x19 input buffer, an [[#FileSystemProxyType]] and an u64 title-id. Returns an [[#IFileSystem]].
   −
The [[#IFileSystem]] must be '''ContentMeta''' if the NCA type is 0 (control).
+
The [[#IFileSystem]] must be '''Meta''' if the NCA type is 0.
    
The input buffer is the output string path from [[NS_Services#GetApplicationContentPath|GetApplicationContentPath]].
 
The input buffer is the output string path from [[NS_Services#GetApplicationContentPath|GetApplicationContentPath]].
Line 550: Line 550:  
May return errors when attempting to access NCA-paths for an update-title with a gamecard, when the gamecard isn't inserted. May return error 0x7D402 in some cases with update-titles. Non-val2 in32 values with NCA-type1 are unusable, even for normal titles.
 
May return errors when attempting to access NCA-paths for an update-title with a gamecard, when the gamecard isn't inserted. May return error 0x7D402 in some cases with update-titles. Non-val2 in32 values with NCA-type1 are unusable, even for normal titles.
   −
The official "MountApplicationPackage" func uses this with in64=0 and [[#FileSystemType]] '''ApplicationPackage'''.
+
The official "MountApplicationPackage" func uses this with in64=0 and [[#FileSystemProxyType]] '''Package'''.
   −
After the [[#FileSystemType]] specific permissions are checked, it then gets the func retval for permissions-type 0x25 and func0.
+
After the [[#FileSystemProxyType]] specific permissions are checked, it then gets the func retval for permissions-type 0x25 and func0.
   −
When [[#FileSystemType]] is '''ContentMeta''', it uses in64=0xffffffffffffffff internally, otherwise it checks if in64 is set to 0xffffffffffffffff then throws an error if so. When the in64 used internally is not 0xffffffffffffffff, it's compared with the NCA titleID, then an error is thrown on mismatch.
+
When [[#FileSystemProxyType]] is '''Meta''', it uses in64=0xffffffffffffffff internally, otherwise it checks if in64 is set to 0xffffffffffffffff then throws an error if so. When the in64 used internally is not 0xffffffffffffffff, it's compared with the NCA [[NCM_services#ProgramId|ProgramId]], then an error is thrown on mismatch.
    
== OpenBisFileSystem ==
 
== OpenBisFileSystem ==
Takes a type-0x19 input buffer string and a u32 [[Flash_Filesystem|Bis partitionID]]. Official user-process code sets instr[0] = 0 normally. Returns an [[#IFileSystem]].
+
Takes a type-0x19 input buffer string and a [[#BisPartitionId]]. Official user-process code sets instr[0] = 0 normally. Returns an [[#IFileSystem]].
    
Only partitionIDs for FAT partitions are usable with this, otherwise error 0x2EE202 is returned. Seems to be about the same as [[#OpenBisStorage]] except this mounts the partition filesystem instead of allowing direct access to the partition sectors.
 
Only partitionIDs for FAT partitions are usable with this, otherwise error 0x2EE202 is returned. Seems to be about the same as [[#OpenBisStorage]] except this mounts the partition filesystem instead of allowing direct access to the partition sectors.
Line 608: Line 608:     
Mounts savedata in the SYSTEM [[Flash_Filesystem|NAND]] partition.
 
Mounts savedata in the SYSTEM [[Flash_Filesystem|NAND]] partition.
 +
 +
== OpenReadOnlySaveDataFileSystem ==
 +
Takes an input u8 [[#SaveDataSpaceId]] and a 0x40-byte [[#SaveDataAttribute]], and returns an [[#IFileSystem]].
 +
 +
Mounts SaveData as ReadOnly.
    
== ReadSaveDataFileSystemExtraDataBySaveDataSpaceId ==
 
== ReadSaveDataFileSystemExtraDataBySaveDataSpaceId ==
Line 656: Line 661:     
== OpenDataStorageByDataId ==
 
== OpenDataStorageByDataId ==
Takes a [[NCM_services#StorageId|StorageID]] and a TitleID.
+
Takes a [[NCM_services#StorageId|StorageID]] and a [[NCM_services#DataId|DataId]].
    
Returns a [[IPC_Marshalling#Domain_message|domain object ID]] implementing the [[#IStorage]] interface for data archives.
 
Returns a [[IPC_Marshalling#Domain_message|domain object ID]] implementing the [[#IStorage]] interface for data archives.
Line 778: Line 783:  
There are two main implementations of this interface:
 
There are two main implementations of this interface:
   −
* '''RomFS''': Filesystem implementation statically linked in the binary. Uses an [[#IStorage]] interface as underlying raw device.
+
* '''nn::fs::fsa::IFileSystem''': The main IFileSystem implementation. Filesystem classes implement this interface, and FS code usually operates on this interface.
* '''IPC proxy''': Used for all non-RomFS filesystems. In this case, actual filesystem implementation is in the FS process.
+
* '''nn::fssrv::sf::IFileSystem''': Used for sending an IFileSystem over IPC. Not used outside of IPC code.
 +
 
 +
There are two adapter classes to convert between these interfaces:
 +
 
 +
* '''nn::fssrv::detail::FileSystemInterfaceAdapter''': Allows access to an nn::fs::fsa::IFileSystem via the nn::fssrv::sf::IFileSystem interface.
 +
* '''nn::fs::detail::FileSystemServiceObjectAdapter''': Allows access to an nn::fssrv::sf::IFileSystem via the nn::fs::fsa::IFileSystem interface.
 +
 
 +
When the FS process returns a filesystem, it will wrap the filesystem object in a FileSystemInterfaceAdapter to return it over IPC.
 +
Then when FS application code receives that filesystem, it will wrap the nn::fssrv::sf::IFileSystem object in a FileSystemServiceObjectAdapter before using it.
    
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
Line 1,036: Line 1,049:     
== GetGameCardUpdatePartitionInfo ==
 
== GetGameCardUpdatePartitionInfo ==
Returns a titleID and the title-version for it.
+
Returns a [[NCM_services#ProgramId|ProgramId]] and the title-version for it.
    
* Output u32 with ARMS-gamecard: title-version v131162. This is the title-version for [[2.1.0]], which is the sysupdate included with this gamecard. Launch-day gamecards return title-version v450.
 
* Output u32 with ARMS-gamecard: title-version v131162. This is the title-version for [[2.1.0]], which is the sysupdate included with this gamecard. Launch-day gamecards return title-version v450.
* Output u64 with ARMS-gamecard: titleID 0100000000000816.
+
* Output u64 with ARMS-gamecard: [[NCM_services#ProgramId|ProgramId]] 0100000000000816.
   −
[[NS_Services|NS]] appears to only use this with [[Content_Manager_services#GetTitleIdInfo]] and [[Content_Manager_services#GetUpdateTitleList]] with storageid=nandsys, for checking whether a sysupdate is required.
+
[[NS_Services|NS]] appears to only use this with [[NCM_services|NCM]] for checking whether a sysupdate is required.
    
== GetGameCardDeviceCertificate ==
 
== GetGameCardDeviceCertificate ==
Line 1,497: Line 1,510:  
No input/output.
 
No input/output.
   −
= FileSystemType =
+
= FileSystemProxyType =
 +
This is "nn::fs::FileSystemProxyType".
 +
 
 
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
|-
 
|-
Line 1,504: Line 1,519:  
| 0 || Code
 
| 0 || Code
 
|-
 
|-
| 1 || Data
+
| 1 || Rom
 
|-
 
|-
 
| 2 || Logo
 
| 2 || Logo
 
|-
 
|-
| 3 || ContentControl
+
| 3 || Control
 
|-
 
|-
| 4 || ContentManual
+
| 4 || Manual
 
|-
 
|-
| 5 || ContentMeta
+
| 5 || Meta
 
|-
 
|-
| 6 || ContentData
+
| 6 || Data
 
|-
 
|-
| 7 || ApplicationPackage
+
| 7 || Package
 
|-
 
|-
 
| 8 || [4.0.0+] RegisteredUpdate
 
| 8 || [4.0.0+] RegisteredUpdate
Line 1,572: Line 1,587:  
| 100 || [3.0.0+] ProperSystem
 
| 100 || [3.0.0+] ProperSystem
 
|-
 
|-
| 100 || [3.0.0+] SafeMode
+
| 101 || [3.0.0+] SafeMode
 
|}
 
|}
   Line 1,633: Line 1,648:  
|-
 
|-
 
| 4 || KeepAfterResettingSystemSaveDataWithoutUserSaveData
 
| 4 || KeepAfterResettingSystemSaveDataWithoutUserSaveData
 +
|-
 +
| 8 || NeedsSecureDelete
 
|}
 
|}
   Line 1,872: Line 1,889:  
| 2 || HistoryEraseFlag
 
| 2 || HistoryEraseFlag
 
|-
 
|-
| 4 || RepairToolFlag
+
| 4 || [4.0.0+] RepairToolFlag
 +
|-
 +
| 8 || [9.0.0+] DifferentRegionCupToTerraDeviceFlag
 +
|-
 +
| 16 || [9.0.0+] DifferentRegionCupToGlobalDeviceFlag
 
|}
 
|}
   Line 2,024: Line 2,045:  
| 0x0
 
| 0x0
 
| 0x8
 
| 0x8
| TitleId (0 for SystemSaveData)</br>SaveData: 0 can be used for accessing the savedata associated with the current FS session titleID, otherwise when set this is the titleID associated with the savedata to access.
+
| [[NCM_services#ApplicationId|ApplicationId]] (0 for SystemSaveData)</br>SaveData: 0 can be used for accessing the savedata associated with the current FS session [[NCM_services#ApplicationId|ApplicationId]], otherwise when set this is the [[NCM_services#ApplicationId|ApplicationId]] associated with the savedata to access.
 
|-
 
|-
 
| 0x8
 
| 0x8
Line 2,065: Line 2,086:  
Total size is 0x40-bytes.
 
Total size is 0x40-bytes.
   −
For DeviceSaveData, this struct is all-zero except for the [[#SaveDataType]] field.
+
For DeviceSaveData, this struct is all-zero except for the [[#SaveDataType]] field (and optionally the ApplicationId if specified).
    
= SaveDataCreationInfo =
 
= SaveDataCreationInfo =
Line 2,078: Line 2,099:  
| 0x0
 
| 0x0
 
| 0x8
 
| 0x8
| Save data size.
+
| SaveDataSize
 
|-
 
|-
 
| 0x8
 
| 0x8
 
| 0x8
 
| 0x8
| Save data journal size.
+
| JournalSize
 
|-
 
|-
 
| 0x10
 
| 0x10
 
| 0x8
 
| 0x8
| Save data block size. 0x4000 for SystemSaveData/SaveData/DeviceSaveData/BcatSaveData.
+
| AvailableSize</br>0x4000 for SystemSaveData/SaveData/DeviceSaveData/BcatSaveData.
 
|-
 
|-
 
| 0x18
 
| 0x18
 
| 0x8
 
| 0x8
| Save data owner id. Official user-processes only uses 0 here for SystemSaveData/SaveData. For the dedicated save-creation code with SaveData/DeviceSaveData, this value comes from an input param with official user-processes. For BcatSaveData, this is the hard-coded [[Title_list|titleID]] of the bcat-sysmodule.
+
| OwnerId</br>Official user-processes only uses 0 here for SystemSaveData/SaveData. For the dedicated save-creation code with SaveData/DeviceSaveData, this value comes from an input param with official user-processes. For BcatSaveData, this is the hard-coded [[NCM_services#ProgramId|ProgramId]] of the bcat-sysmodule.
 
|-
 
|-
 
| 0x20
 
| 0x20
 
| 0x4
 
| 0x4
| Save data flags. Written using an input param for official user-processes. Hard-coded 0 for BcatSaveData.
+
| [[#SaveDataFlags]]</br>Written using an input param for official user-processes. Hard-coded 0 for BcatSaveData.
 
|-
 
|-
 
| 0x24
 
| 0x24
 
| 0x1
 
| 0x1
| [[#SaveDataSpaceId]]. Official user-processes only uses 0 here for SystemSaveData, 1 for SaveData/DeviceSaveData/BcatSaveData.
+
| [[#SaveDataSpaceId]]</br>Official user-processes only uses 0 here for SystemSaveData, 1 for SaveData/DeviceSaveData/BcatSaveData.
 
|-
 
|-
 
| 0x25
 
| 0x25
Line 2,115: Line 2,136:     
= BcatSaveData =
 
= BcatSaveData =
This is accessed using the same commands for SaveData with the same input u8. The [[#SaveDataAttribute]] is the same as DeviceSaveData, except that the titleID field is set to <input titleID>. See above regarding [[#SaveDataCreationInfo]].
+
This is accessed using the same commands for SaveData with the same input u8. The [[#SaveDataAttribute]] is the same as DeviceSaveData (besides the SaveDataType), except that the [[NCM_services#ApplicationId|ApplicationId]] field is always set to <input ApplicationId> (unlike DeviceSaveData where it's optional). See above regarding [[#SaveDataCreationInfo]].
    
The 0x10-byte struct passed to [[#CreateSaveDataFileSystem]] has the first 0x5-bytes set to all-zero.
 
The 0x10-byte struct passed to [[#CreateSaveDataFileSystem]] has the first 0x5-bytes set to all-zero.
 +
 +
MountSystemBcatSaveData uses [[#OpenSaveDataFileSystemBySystemSaveDataId]] with [[#SaveDataSpaceId]] System. The [[#SaveDataAttribute]] is all-zero, except for the SaveDataType, and SystemSaveDataId is set to the input param.
    
= SaveDataInfo =
 
= SaveDataInfo =
Line 2,130: Line 2,153:  
| 0x0
 
| 0x0
 
| 0x8
 
| 0x8
| Unknown saveID
+
| SaveDataId
 
|-
 
|-
 
| 0x8
 
| 0x8
Line 2,146: Line 2,169:  
| 0x10
 
| 0x10
 
| 0x10
 
| 0x10
| userID
+
| UserId
 
|-
 
|-
 
| 0x20
 
| 0x20
 
| 0x8
 
| 0x8
| saveID, 0 for regular SaveData.
+
| SystemSaveDataId (0 for regular SaveData)
 
|-
 
|-
 
| 0x28
 
| 0x28
 
| 0x8
 
| 0x8
| Application titleID, for regular SaveData.
+
| [[NCM_services#ApplicationId|ApplicationId]] (for regular SaveData)
 
|-
 
|-
 
| 0x30
 
| 0x30
Line 2,162: Line 2,185:  
| 0x38
 
| 0x38
 
| 0x2
 
| 0x2
| Save data index
+
| SaveDataIndex
 
|-
 
|-
 
| 0x3A
 
| 0x3A
 
| 0x1
 
| 0x1
| Save data 'rank' or 'precedence'. 0 if this save data is considered the primary save data. 1 if it's considered the secondary save data.
+
| [[#SaveDataRank]]
 
|-
 
|-
 
| 0x3B
 
| 0x3B

Navigation menu