Filesystem services: Difference between revisions

No edit summary
 
(18 intermediate revisions by 3 users not shown)
Line 47: Line 47:


== RegisterProgram ==
== RegisterProgram ==
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]]
Takes an input [[NCM_services#StorageId|StorageId]], an input u64 ProcessId, an input [[NCM_services#ProgramId|ProgramId]], a type-0x5 input buffer containing an [[NPDM#ACID|ACID]] [[NPDM#FsAccessControl|FsAccessControl]], and a type-0x5 input buffer containing an [[NPDM#ACI0|ACI0]] [[NPDM#FsAccessControl|FsAccessControl]].


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.
[20.0.0+] Now takes an additional input [[#FsAccessControlRestrictionMode]].


== UnregisterProgram ==
== UnregisterProgram ==
Takes a pid. Removes registered FS permissions for that PID.
Takes an input u64 ProcessId. No output.
 
Removes registered FS permissions for that PID.


== SetEnabledProgramVerification ==
== SetEnabledProgramVerification ==
Seems to sets a global flag to inputval & 1.
Takes an input bool. No output.


When the flag is zero, it will set ret=0 instead of ret={error} when verifying the fixed-key [[NPDM]] ACID signature fails. This also skips verifying the [[NCA_Format|NCA Header]] signature using the ACID key. Note that if verifying the fixed-key ACID signature is successful, and verifying the ACID-key NCA header signature fails, it will throw an error and abort.
When the flag is zero, it will set ret=0 instead of ret={error} when verifying the fixed-key [[NPDM]] ACID signature fails. This also skips verifying the [[NCA_Format|NCA Header]] signature using the ACID key. Note that if verifying the fixed-key ACID signature is successful, and verifying the ACID-key NCA header signature fails, it will throw an error and abort.
Line 271: Line 275:
|-
|-
| 640 || [4.0.0-7.0.1] IsSignedSystemPartitionOnSdCardValid
| 640 || [4.0.0-7.0.1] IsSignedSystemPartitionOnSdCardValid
|-
| 651 || [S2]
|-
| 660 || [S2]
|-
|-
| 700 || [5.0.0+] [[#OpenAccessFailureDetectionEventNotifier]]
| 700 || [5.0.0+] [[#OpenAccessFailureDetectionEventNotifier]]
Line 347: Line 355:


Note that the functions check whether or not at least one bit is set in the mask. This means that, you don't need to set 0xFFFFFFFFFFFFFFFF to get all permissions: it suffices to set 0x8000000000000000.
Note that the functions check whether or not at least one bit is set in the mask. This means that, you don't need to set 0xFFFFFFFFFFFFFFFF to get all permissions: it suffices to set 0x8000000000000000.
If nn::spl::IsDebugMode() is disabled (retail behavior), the FS sysmodule masks the permission descriptor with 0x3FFFFFFFFFFFFFFF upon process registration.


If the code were to request an invalid input type, panic. But this never happens.
If the code were to request an invalid input type, panic. But this never happens.
Line 631: Line 641:
| [17.0.0-19.0.0] 0x4A || CanGetProgramId || 0x8000000008000000 || GetProgramId, Removed in 20.0.0
| [17.0.0-19.0.0] 0x4A || CanGetProgramId || 0x8000000008000000 || GetProgramId, Removed in 20.0.0
|-
|-
| [20.0.0+] 0x55 || || 0x8000000000000800 ||
| [20.0.0+] 0x55 || CanGetContentStorageInfo || 0x8000000000000800 ||
|-
|-
| [20.0.0+] 0x56 || || 0x8000000004000000 ||
| [20.0.0+] 0x56 || CanDetachSdCard || 0x8000000004000000 ||
|-
|-
| [20.0.0+] 0x57 || || 0x8000000004000000 ||
| [20.0.0+] 0x57 || CanSetSdCardActivationMode || 0x8000000004000000 ||
|}
|}


Line 649: Line 659:
Takes an input [[#FileSystemProxyType]] and an input [[NCM_services#ProgramId|ProgramId]]. Returns an [[#IFileSystem]].
Takes an input [[#FileSystemProxyType]] and an input [[NCM_services#ProgramId|ProgramId]]. Returns an [[#IFileSystem]].


Web-applet loads the [[#FileSystemProxyType]] (which must be '''Manual''') from u32_table[inparam].
The [[#FileSystemProxyType]] must be '''Manual'''.


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.
Line 787: Line 797:


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.
[[NCA|PublicData]] is exempt from the [[#Permissions|permissions]] check.


== OpenDataFileSystemWithProgramIndex ==
== OpenDataFileSystemWithProgramIndex ==
Line 1,101: Line 1,113:
| 7 || [20.0.0+] SetSdCardActivationMode
| 7 || [20.0.0+] SetSdCardActivationMode
|-
|-
| 8 || [20.0.0+] TryGetSdCardInfo
| 8 || [20.0.0+] [S1] TryGetSdCardInfo
|-
|-
| 100 || [[#GetMmcCid]]
| 100 || [[#GetMmcCid]]
Line 1,127: Line 1,139:
| 119 || [20.0.0+] CheckAfterEraseMmcPartitionUserData
| 119 || [20.0.0+] CheckAfterEraseMmcPartitionUserData
|-
|-
| 200 || [[#IsGameCardInserted]]
| 200 || [S1] [[#IsGameCardInserted]]
|-
|-
| 201 || [[#EraseGameCard]]
| 201 || [S1] [[#EraseGameCard]]
|-
|-
| 202 || [[#GetGameCardHandle]]
| 202 || [S1] [[#GetGameCardHandle]]
|-
|-
| 203 || [[#GetGameCardUpdatePartitionInfo]]
| 203 || [S1] [[#GetGameCardUpdatePartitionInfo]]
|-
|-
| 204 || [[#FinalizeGameCardDriver]]
| 204 || [S1] [[#FinalizeGameCardDriver]]
|-
|-
| 205 || [[#GetGameCardAttribute]]
| 205 || [S1] [[#GetGameCardAttribute]]
|-
|-
| 206 || [[#GetGameCardDeviceCertificate]]
| 206 || [S1] [[#GetGameCardDeviceCertificate]]
|-
|-
| 207 || [[#GetGameCardAsicInfo]]
| 207 || [S1] [[#GetGameCardAsicInfo]]
|-
|-
| 208 || [[#GetGameCardIdSet]]
| 208 || [S1] [[#GetGameCardIdSet]]
|-
|-
| 209 || [[#WriteToGameCardDirectly]]
| 209 || [S1] [[#WriteToGameCardDirectly]]
|-
|-
| 210 || [[#SetVerifyWriteEnalbleFlag]]
| 210 || [S1] [[#SetVerifyWriteEnalbleFlag]]
|-
|-
| 211 || [[#GetGameCardImageHash]]
| 211 || [S1] [[#GetGameCardImageHash]]
|-
|-
| 212 || [2.0.0+] [[#GetGameCardDeviceIdForProdCard]]
| 212 || [S1] [2.0.0+] [[#GetGameCardDeviceIdForProdCard]]
|-
|-
| 213 || [2.0.0+] [[#EraseAndWriteParamDirectly]]
| 213 || [S1] [2.0.0+] [[#EraseAndWriteParamDirectly]]
|-
|-
| 214 || [2.0.0+] [[#ReadParamDirectly]]
| 214 || [S1] [2.0.0+] [[#ReadParamDirectly]]
|-
|-
| 215 || [2.0.0+] [[#ForceEraseGameCard]]
| 215 || [S1] [2.0.0+] [[#ForceEraseGameCard]]
|-
|-
| 216 || [2.0.0+] [[#GetGameCardErrorInfo]]
| 216 || [S1] [2.0.0+] [[#GetGameCardErrorInfo]]
|-
|-
| 217 || [2.1.0+] [[#GetGameCardErrorReportInfo]]
| 217 || [S1] [2.1.0+] [[#GetGameCardErrorReportInfo]]
|-
|-
| 218 || [3.0.0+] [[#GetGameCardDeviceId]]
| 218 || [S1] [3.0.0+] [[#GetGameCardDeviceId]]
|-
|-
| 219 || [8.0.0+] [[#ChallengeCardExistence]]
| 219 || [S1] [8.0.0+] [[#ChallengeCardExistence]]
|-
|-
| 220 || [9.0.0+] [[#GetGameCardCompatibilityType]]
| 220 || [S1] [9.0.0+] [[#GetGameCardCompatibilityType]]
|-
|-
| 221 || [17.0.0+] [[#GetGameCardAsicCertificate]]
| 221 || [S1] [17.0.0+] [[#GetGameCardAsicCertificate]]
|-
|-
| 222 || [18.0.0+] [[#GetGameCardCardHeader]]
| 222 || [S1] [18.0.0+] [[#GetGameCardCardHeader]]
|-
|-
| 223 || [19.0.0+] [[#SetGameCardSessionCreationDelay]]
| 223 || [S1] [19.0.0+] [[#SetGameCardSessionCreationDelay]]
|-
|-
| 224 || [19.0.0+] [[#GetGameCardApplicationIdList]]
| 224 || [S1] [19.0.0+] [[#GetGameCardApplicationIdList]]
|-
|-
| 225 || [20.0.0+] RegisterGameCardConfigurationData
| 225 || [S1] [20.0.0+] RegisterGameCardConfigurationData
|-
|-
| 226 || [20.0.0+] GetGameCardDetailedErrorReportInfo
| 226 || [S1] [20.0.0+] GetGameCardDetailedErrorReportInfo
|-
|-
| 300 || [[#SetSpeedEmulationMode]]
| 300 || [[#SetSpeedEmulationMode]]
Line 1,200: Line 1,212:
|-
|-
| 501 || [6.0.0+] [[#ClearDeviceSimulationEvent]]
| 501 || [6.0.0+] [[#ClearDeviceSimulationEvent]]
|-
| 800 || [S2] [[#OpenStorageDeviceManager]]
|}
|}


Line 1,355: Line 1,369:
== ClearDeviceSimulationEvent ==
== ClearDeviceSimulationEvent ==
Takes a total of 4-bytes of input. No output.
Takes a total of 4-bytes of input. No output.
== OpenStorageDeviceManager ==
Takes a byte. Returns an [[#IStorageDeviceManager]].


= IEventNotifier =
= IEventNotifier =
Line 1,878: Line 1,895:


= IStorageDeviceManager =
= IStorageDeviceManager =
This is "nn::fssrv::storage::sf::IStorageDeviceManager".
[S2] This is "nn::fssrv::storage::sf::IStorageDeviceManager".


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 1,884: Line 1,901:
! Cmd || Name
! Cmd || Name
|-
|-
| N/A || IsInserted
| 0 || IsInserted
|-
|-
| N/A || IsHandleValid
| 1 || IsHandleValid
|-
|-
| N/A || OpenDetectionEvent
| 2 || [[#OpenDetectionEvent]]
|-
|-
| N/A || OpenOperator
| 3 || Returns an [[#IEventNotifier]].
|-
|-
| N/A || OpenDevice
| 10 || [[#OpenOperator]]
|-
|-
| N/A || OpenStorage
| 20 || [[#OpenDevice]]
|-
|-
| N/A || Invalidate
| 21 || [[#OpenStorage]]
|-
| 34 || Invalidate
|}
|}
== OpenDetectionEvent ==
Returns an [[#IEventNotifier]].
== OpenOperator ==
Returns an [[#IStorageDeviceOperator]].
== OpenDevice ==
Returns an [[#IStorageDevice]].
== OpenStorage ==
Returns an [[#IStorage]].


= IStorageDeviceOperator =
= IStorageDeviceOperator =
This is "nn::fssrv::storage::sf::IStorageDeviceOperator".
[S2] This is "nn::fssrv::storage::sf::IStorageDeviceOperator".


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 1,906: Line 1,936:
! Cmd || Name
! Cmd || Name
|-
|-
| N/A || Operate
| 0 || Operate
|-
|-
| N/A || OperateIn
| 1 || OperateIn
|-
|-
| N/A || OperateOut
| 10 || OperateOut
|-
|-
| N/A || OperateOut2
| 11 || OperateOut2
|-
|-
| N/A || OperateInOut
| 20 || OperateInOut
|-
|-
| N/A || OperateIn2Out
| 21 || OperateIn2Out
|}
|}


= IStorageDevice =
= IStorageDevice =
This is "nn::fssrv::storage::sf::IStorageDevice".
[S2] This is "nn::fssrv::storage::sf::IStorageDevice".


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 1,926: Line 1,956:
! Cmd || Name
! Cmd || Name
|-
|-
| N/A || GetHandle
| 0 || GetHandle
|-
|-
| N/A || IsHandleValid
| 1 || IsHandleValid
|-
|-
| N/A || OpenOperator
| 10 || OpenOperator
|-
|-
| N/A || Read
| 20 || Read
|-
|-
| N/A || Write
| 21 || Write
|-
|-
| N/A || Flush
| 22 || Flush
|-
|-
| N/A || SetSize
| 23 || SetSize
|-
|-
| N/A || GetSize
| 24 || GetSize
|-
|-
| N/A || OperateRange
| 25 || OperateRange
|}
|}


= FileSystemProxyType =
= FileSystemProxyType =
This is "nn::fs::FileSystemProxyType".
This is "nn::fs::FileSystemProxyType".
sdknso converts the input [[#ContentType|ContentType]] to a FileSystemProxyType, for use with the cmd input.


{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 1,997: Line 2,029:
|-
|-
| 0 || None
| 0 || None
|-
| 1 || [S2]
|-
|-
| 15 || All
| 15 || All
Line 3,174: Line 3,208:
= InitialDataVersion2 =
= InitialDataVersion2 =
This is a 0x8210-byte struct used by [[#ISaveDataTransferManagerWithDivision]].
This is a 0x8210-byte struct used by [[#ISaveDataTransferManagerWithDivision]].
= FsAccessControlRestrictionMode =
This is "nn::fs::FsAccessControlRestrictionMode".
{| class="wikitable" border="1"
|-
! Value || Name
|-
| 0 ||
|}


[[Category:Services]]
[[Category:Services]]