Difference between revisions of "FS:OpenFile"

From 3dbrew
Jump to navigation Jump to search
m
m (Add categories)
 
(11 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
=Request=
 
=Request=
{| class="wikitable" border="1"
+
{{IPC/Request|Request}}
|-
+
{{IPC/RequestHeader|0x0802|7|2}}
!  Index Word
+
{{IPC/RequestEntry|Transaction (usually 0)}}
!  Description
+
{{IPC/RequestEntryRange|2|u64, Archive Handle}}
|-
+
{{IPC/RequestEntry|[[Filesystem_services#PathType|Path Type]]}}
| 0
+
{{IPC/RequestEntry|Path Size (including null-terminator)}}
| Header code [0x080201C2]
+
{{IPC/RequestEntry|[[Filesystem_services#OpenFlags|Open Flags]]}}
|-
+
{{IPC/RequestEntry|[[Filesystem_services#Attributes|Attributes]] (usually 0)}}
| 1
+
{{IPC/TranslateStaticBuffer|Path Data Pointer|0}}
| Transaction (usually 0)
+
{{IPC/RequestEnd}}
|-
 
| 2
 
| Archive handle lower word
 
|-
 
| 3
 
| Archive handle upper word
 
|-
 
| 4
 
| LowPath.Type
 
|-
 
| 5
 
| LowPath.Size
 
|-
 
| 6
 
| OpenFlags
 
|-
 
| 7
 
| Attributes (usually 0)
 
|-
 
| 8
 
| (LowPath.Size<<14)  <nowiki>|</nowiki> 2
 
|-
 
| 9
 
| LowPath.Data pointer
 
|}
 
  
 
=Response=
 
=Response=
{| class="wikitable" border="1"
+
{{IPC/Request|Response}}
|-
+
{{IPC/RequestHeader|0x0802|1|2}}
!  Index Word
+
{{IPC/RequestEntry|Result code}}
!  Description
+
{{IPC/MoveHandle|1}}
|-
+
{{IPC/MoveHandleEntry|File client session handle}}
| 0
+
{{IPC/RequestEnd}}
| Header code
 
|-
 
| 1
 
| Resultcode
 
|-
 
| 3
 
| File handle
 
|}
 
  
=OpenFlags=
+
[[Category:fs:USER commands]]
{| class="wikitable" border="1"
+
[[Category:fs:LDR commands]]
|-
 
!  Bit
 
!  Description
 
|-
 
| 0
 
| Read
 
|-
 
| 1
 
| Write
 
|-
 
| 2
 
| Create
 
|}
 
 
 
= Attributes =
 
{| class="wikitable" border="1"
 
|-
 
!  Flag
 
!  Description
 
|-
 
| 0x00000001
 
| Is Read-Only
 
|-
 
| 0x00000100
 
| Is Archive
 
|-
 
| 0x00010000
 
| Is Hidden
 
|-
 
| 0x01000000
 
| Is Directory
 
|}
 
 
 
=LowPath=
 
{| class="wikitable" border="1"
 
|-
 
!  Type
 
!  Description
 
|-
 
| 0 (INVALID)
 
| Specifies an invalid path.
 
|-
 
| 1 (EMPTY)
 
| Specifies an empty path.
 
|-
 
| 2 (BINARY)
 
| Specifies a binary path, which is non-text based.
 
|-
 
| 3 (CHAR)
 
| Specifies a text based path with a 8-bit byte per character.
 
|-
 
| 4 (WCHAR)
 
| Specifies a text based path with a 16-bit short per character.
 
|}
 
 
 
== Binary LowPath ==
 
The format of the data that a binary LowPath points to is custom per archive.
 
 
 
 
 
=== SystemSaveData Archive Path Data Format ===
 
==== FS ====
 
{| class="wikitable" border="1"
 
|-
 
!  Index word
 
!  Description
 
|-
 
| 0
 
| [[Mediatypes|Mediatype]] (must be zero for NAND)
 
|-
 
| 1
 
| saveid
 
|}
 
The file/directory lowpath is a text lowpath in the [[Savegames|savegame]] filesystem.
 
 
 
==== FSPXI ====
 
{| class="wikitable" border="1"
 
|-
 
!  Index word
 
!  Description
 
|-
 
| 0
 
| u8 [[Mediatypes|Mediatype]] (must be zero for NAND)
 
|}
 
The file lowpath is a binary lowpath containing the u64 saveid, however the high word of the saveid is always zero. The mounted file is the cleartext savegame image. Up to 32 SystemSaveData image files can be opened under a single mounted FSPXI archive.
 
 
 
=== UserSaveDataForCheck Archive Path Data Format ===
 
{| class="wikitable" border="1"
 
|-
 
!  Index word
 
!  Description
 
|-
 
| 0
 
| [[Mediatypes|Mediatype]] (must be non-zero)
 
|-
 
| 1
 
| Lower word saveid
 
|-
 
| 2
 
| Upper word saveid
 
|}
 
The file/directory lowpath for this FS archive is a text path in the [[Savegames|savegame]] filesystem.
 
 
 
=== ExtSaveData Archive Path Data Format ===
 
{| class="wikitable" border="1"
 
|-
 
!  Index word
 
!  Description
 
|-
 
| 0
 
| [[Mediatypes|Mediatype]]
 
|-
 
| 1
 
| Lower word saveid
 
|-
 
| 2
 
| Upper word saveid
 
|}
 
For FS, the file/directory lowpath is a text path in the [[extdata]] filesystem. For FSPXI, the file lowpath is a text path relative to the "/extdata/<ExtdataIDHigh>/<ExtdataIDLow>" directory on SD/NAND, for the cleartext extdata image to mount.
 
 
 
=== [[RomFS]] ===
 
The raw FS image for the main CXI RomFS(for the current app this is accessible via archiveid 0x3) can be accessed via an all-zero 0x14-byte binary file-lowpath. This allows access to the raw level-3 IVFC image: the user process must handle parsing the filesystem used in this image itself.
 
 
 
In this scenario, OpenFile returns a handle to the RomFS archive.
 

Latest revision as of 11:54, 20 September 2024

Request[edit]

Request Word Description
0
Header 0x080201C2 Cmd 0x0802 Param 7 Xlat 2
1 Transaction (usually 0)
2-3 u64, Archive Handle
4 Path Type
5 Path Size (including null-terminator)
6 Open Flags
7 Attributes (usually 0)
8 Descriptor for static buffer (id 0)
9 Path Data Pointer

Response[edit]

Response Word Description
0
Header 0x08020042 Cmd 0x0802 Param 1 Xlat 2
1 Result code
2 Descriptor for moving 1 handle
3 File client session handle