libctru  v2.4.0
fs.h
Go to the documentation of this file.
1 /**
2  * @file fs.h
3  * @brief Filesystem Services
4  */
5 #pragma once
6 
7 #include <3ds/types.h>
8 
9 /// Open flags.
10 enum
11 {
12  FS_OPEN_READ = BIT(0), ///< Open for reading.
13  FS_OPEN_WRITE = BIT(1), ///< Open for writing.
14  FS_OPEN_CREATE = BIT(2), ///< Create file.
15 };
16 
17 /// Write flags.
18 enum
19 {
20  FS_WRITE_FLUSH = BIT(0), ///< Flush.
21  FS_WRITE_UPDATE_TIME = BIT(8), ///< Update file timestamp.
22 };
23 
24 /// Attribute flags.
25 enum
26 {
27  FS_ATTRIBUTE_DIRECTORY = BIT(0), ///< Directory.
28  FS_ATTRIBUTE_HIDDEN = BIT(8), ///< Hidden.
29  FS_ATTRIBUTE_ARCHIVE = BIT(16), ///< Archive.
30  FS_ATTRIBUTE_READ_ONLY = BIT(24), ///< Read-only.
31 };
32 
33 /// Media types.
34 typedef enum
35 {
36  MEDIATYPE_NAND = 0, ///< NAND.
37  MEDIATYPE_SD = 1, ///< SD card.
38  MEDIATYPE_GAME_CARD = 2, ///< Game card.
39 } FS_MediaType;
40 
41 /// System media types.
42 typedef enum
43 {
44  SYSTEM_MEDIATYPE_CTR_NAND = 0, ///< CTR NAND.
45  SYSTEM_MEDIATYPE_TWL_NAND = 1, ///< TWL NAND.
46  SYSTEM_MEDIATYPE_SD = 2, ///< SD card.
47  SYSTEM_MEDIATYPE_TWL_PHOTO = 3, ///< TWL Photo.
49 
50 /// Archive IDs.
51 typedef enum
52 {
53  ARCHIVE_ROMFS = 0x00000003, ///< RomFS archive.
54  ARCHIVE_SAVEDATA = 0x00000004, ///< Save data archive.
55  ARCHIVE_EXTDATA = 0x00000006, ///< Ext data archive.
56  ARCHIVE_SHARED_EXTDATA = 0x00000007, ///< Shared ext data archive.
57  ARCHIVE_SYSTEM_SAVEDATA = 0x00000008, ///< System save data archive.
58  ARCHIVE_SDMC = 0x00000009, ///< SDMC archive.
59  ARCHIVE_SDMC_WRITE_ONLY = 0x0000000A, ///< Write-only SDMC archive.
60  ARCHIVE_BOSS_EXTDATA = 0x12345678, ///< BOSS ext data archive.
61  ARCHIVE_CARD_SPIFS = 0x12345679, ///< Card SPI FS archive.
62  ARCHIVE_EXTDATA_AND_BOSS_EXTDATA = 0x1234567B, ///< Ext data and BOSS ext data archive.
63  ARCHIVE_SYSTEM_SAVEDATA2 = 0x1234567C, ///< System save data archive.
64  ARCHIVE_NAND_RW = 0x1234567D, ///< Read-write NAND archive.
65  ARCHIVE_NAND_RO = 0x1234567E, ///< Read-only NAND archive.
66  ARCHIVE_NAND_RO_WRITE_ACCESS = 0x1234567F, ///< Read-only write access NAND archive.
67  ARCHIVE_SAVEDATA_AND_CONTENT = 0x2345678A, ///< User save data and ExeFS/RomFS archive.
68  ARCHIVE_SAVEDATA_AND_CONTENT2 = 0x2345678E, ///< User save data and ExeFS/RomFS archive (only ExeFS for fs:LDR).
69  ARCHIVE_NAND_CTR_FS = 0x567890AB, ///< NAND CTR FS archive.
70  ARCHIVE_TWL_PHOTO = 0x567890AC, ///< TWL PHOTO archive.
71  ARCHIVE_TWL_SOUND = 0x567890AD, ///< TWL SOUND archive.
72  ARCHIVE_NAND_TWL_FS = 0x567890AE, ///< NAND TWL FS archive.
73  ARCHIVE_NAND_W_FS = 0x567890AF, ///< NAND W FS archive.
74  ARCHIVE_GAMECARD_SAVEDATA = 0x567890B1, ///< Game card save data archive.
75  ARCHIVE_USER_SAVEDATA = 0x567890B2, ///< User save data archive.
76  ARCHIVE_DEMO_SAVEDATA = 0x567890B4, ///< Demo save data archive.
77 } FS_ArchiveID;
78 
79 /// Path types.
80 typedef enum
81 {
82  PATH_INVALID = 0, ///< Invalid path.
83  PATH_EMPTY = 1, ///< Empty path.
84  PATH_BINARY = 2, ///< Binary path. Meaning is per-archive.
85  PATH_ASCII = 3, ///< ASCII text path.
86  PATH_UTF16 = 4, ///< UTF-16 text path.
87 } FS_PathType;
88 
89 /// Secure value slot.
90 typedef enum
91 {
92  SECUREVALUE_SLOT_SD = 0x1000, ///< SD application.
94 
95 /// Card SPI baud rate.
96 typedef enum
97 {
98  BAUDRATE_512KHZ = 0, ///< 512KHz.
99  BAUDRATE_1MHZ = 1, ///< 1MHz.
100  BAUDRATE_2MHZ = 2, ///< 2MHz.
101  BAUDRATE_4MHZ = 3, ///< 4MHz.
102  BAUDRATE_8MHZ = 4, ///< 8MHz.
103  BAUDRATE_16MHZ = 5, ///< 16MHz.
105 
106 /// Card SPI bus mode.
107 typedef enum
108 {
109  BUSMODE_1BIT = 0, ///< 1-bit.
110  BUSMODE_4BIT = 1, ///< 4-bit.
112 
113 /// Card SPI bus mode.
114 typedef enum
115 {
116  SPECIALCONTENT_UPDATE = 1, ///< Update.
117  SPECIALCONTENT_MANUAL = 2, ///< Manual.
118  SPECIALCONTENT_DLP_CHILD = 3, ///< DLP child.
120 
121 typedef enum
122 {
123  CARD_CTR = 0, ///< CTR card.
124  CARD_TWL = 1, ///< TWL card.
125 } FS_CardType;
126 
127 /// FS control actions.
128 typedef enum
129 {
130  FS_ACTION_UNKNOWN = 0,
131 } FS_Action;
132 
133 /// Archive control actions.
134 typedef enum
135 {
136  ARCHIVE_ACTION_COMMIT_SAVE_DATA = 0, ///< Commits save data changes. No inputs/outputs.
137  ARCHIVE_ACTION_GET_TIMESTAMP = 1, ///< Retrieves a file's last-modified timestamp. In: "u16*, UTF-16 Path", Out: "u64, Time Stamp".
138  ARCHIVE_ACTION_UNKNOWN = 0x789D, //< Unknown action; calls FSPXI command 0x56. In: "FS_Path instance", Out: "u32[4], Unknown"
140 
141 /// Secure save control actions.
142 typedef enum
143 {
144  SECURESAVE_ACTION_DELETE = 0, ///< Deletes a save's secure value. In: "u64, ((SecureValueSlot << 32) | (TitleUniqueId << 8) | TitleVariation)", Out: "u8, Value Existed"
145  SECURESAVE_ACTION_FORMAT = 1, ///< Formats a save. No inputs/outputs.
147 
148 /// File control actions.
149 typedef enum
150 {
151  FILE_ACTION_UNKNOWN = 0,
152 } FS_FileAction;
153 
154 /// Directory control actions.
155 typedef enum
156 {
157  DIRECTORY_ACTION_UNKNOWN = 0,
159 
160 /// Directory entry.
161 typedef struct
162 {
163  u16 name[0x106]; ///< UTF-16 directory name.
164  char shortName[0x0A]; ///< File name.
165  char shortExt[0x04]; ///< File extension.
166  u8 valid; ///< Valid flag. (Always 1)
167  u8 reserved; ///< Reserved.
168  u32 attributes; ///< Attributes.
169  u64 fileSize; ///< File size.
171 
172 /// Archive resource information.
173 typedef struct
174 {
175  u32 sectorSize; ///< Size of each sector, in bytes.
176  u32 clusterSize; ///< Size of each cluster, in bytes.
177  u32 totalClusters; ///< Total number of clusters.
178  u32 freeClusters; ///< Number of free clusters.
180 
181 /// Program information.
182 typedef struct
183 {
184  u64 programId; ///< Program ID.
185  FS_MediaType mediaType : 8; ///< Media type.
186  u8 padding[7]; ///< Padding.
188 
189 /// Product information.
190 typedef struct
191 {
192  char productCode[0x10]; ///< Product code.
193  char companyCode[0x2]; ///< Company code.
194  u16 remasterVersion; ///< Remaster version.
196 
197 /// Integrity verification seed.
198 typedef struct
199 {
200  u8 aesCbcMac[0x10]; ///< AES-CBC MAC over a SHA256 hash, which hashes the first 0x110-bytes of the cleartext SEED.
201  u8 movableSed[0x120]; ///< The "nand/private/movable.sed", encrypted with AES-CTR using the above MAC for the counter.
203 
204 /// Ext save data information.
205 typedef struct CTR_PACKED
206 {
207  FS_MediaType mediaType : 8; ///< Media type.
208  u8 unknown; ///< Unknown.
209  u16 reserved1; ///< Reserved.
210  u64 saveId; ///< Save ID.
211  u32 reserved2; ///< Reserved.
213 
214 /// System save data information.
215 typedef struct
216 {
217  FS_MediaType mediaType : 8; ///< Media type.
218  u8 unknown; ///< Unknown.
219  u16 reserved; ///< Reserved.
220  u32 saveId; ///< Save ID.
222 
223 /// Device move context.
224 typedef struct
225 {
226  u8 ivs[0x10]; ///< IVs.
227  u8 encryptParameter[0x10]; ///< Encrypt parameter.
229 
230 /// Filesystem path data, detailing the specific target of an operation.
231 typedef struct
232 {
233  FS_PathType type; ///< FS path type.
234  u32 size; ///< FS path size.
235  const void* data; ///< Pointer to FS path data.
236 } FS_Path;
237 
238 /// SDMC/NAND speed information
239 typedef struct
240 {
241  bool highSpeedModeEnabled; ///< Whether or not High Speed Mode is enabled.
242  bool usesHighestClockRate; ///< Whether or not a clock divider of 2 is being used.
243  u16 sdClkCtrl; ///< The value of the SD_CLK_CTRL register.
245 
246 /// Filesystem archive handle, providing access to a filesystem's contents.
247 typedef u64 FS_Archive;
248 
249 /// Initializes FS.
251 
252 /// Exits FS.
253 void fsExit(void);
254 
255 /**
256  * @brief Sets the FSUSER session to use in the current thread.
257  * @param session The handle of the FSUSER session to use.
258  */
259 void fsUseSession(Handle session);
260 
261 /// Disables the FSUSER session override in the current thread.
262 void fsEndUseSession(void);
263 
264 /**
265  * @brief Exempts an archive from using alternate FS session handles provided with @ref fsUseSession
266  * Instead, the archive will use the default FS session handle, opened with @ref srvGetSessionHandle
267  * @param archive Archive to exempt.
268  */
270 
271 /**
272  * @brief Unexempts an archive from using alternate FS session handles provided with @ref fsUseSession
273  * @param archive Archive to remove from the exemption list.
274  */
276 
277 /**
278  * @brief Creates an FS_Path instance.
279  * @param type Type of path.
280  * @param path Path to use.
281  * @return The created FS_Path instance.
282  */
283 FS_Path fsMakePath(FS_PathType type, const void* path);
284 
285 /**
286  * @brief Gets the current FS session handle.
287  * @return The current FS session handle.
288  */
290 
291 /**
292  * @brief Performs a control operation on the filesystem.
293  * @param action Action to perform.
294  * @param input Buffer to read input from.
295  * @param inputSize Size of the input.
296  * @param output Buffer to write output to.
297  * @param outputSize Size of the output.
298  */
299 Result FSUSER_Control(FS_Action action, void* input, u32 inputSize, void* output, u32 outputSize);
300 
301 /**
302  * @brief Initializes a FSUSER session.
303  * @param session The handle of the FSUSER session to initialize.
304  */
306 
307 /**
308  * @brief Opens a file.
309  * @param out Pointer to output the file handle to.
310  * @param archive Archive containing the file.
311  * @param path Path of the file.
312  * @param openFlags Flags to open the file with.
313  * @param attributes Attributes of the file.
314  */
315 Result FSUSER_OpenFile(Handle* out, FS_Archive archive, FS_Path path, u32 openFlags, u32 attributes);
316 
317 /**
318  * @brief Opens a file directly, bypassing the requirement of an opened archive handle.
319  * @param out Pointer to output the file handle to.
320  * @param archiveId ID of the archive containing the file.
321  * @param archivePath Path of the archive containing the file.
322  * @param filePath Path of the file.
323  * @param openFlags Flags to open the file with.
324  * @param attributes Attributes of the file.
325  */
326 Result FSUSER_OpenFileDirectly(Handle* out, FS_ArchiveID archiveId, FS_Path archivePath, FS_Path filePath, u32 openFlags, u32 attributes);
327 
328 /**
329  * @brief Deletes a file.
330  * @param archive Archive containing the file.
331  * @param path Path of the file.
332  */
334 
335 /**
336  * @brief Renames a file.
337  * @param srcArchive Archive containing the source file.
338  * @param srcPath Path of the source file.
339  * @param dstArchive Archive containing the destination file.
340  * @param dstPath Path of the destination file.
341  */
342 Result FSUSER_RenameFile(FS_Archive srcArchive, FS_Path srcPath, FS_Archive dstArchive, FS_Path dstPath);
343 
344 /**
345  * @brief Deletes a directory, failing if it is not empty.
346  * @param archive Archive containing the directory.
347  * @param path Path of the directory.
348  */
350 
351 /**
352  * @brief Deletes a directory, also deleting its contents.
353  * @param archive Archive containing the directory.
354  * @param path Path of the directory.
355  */
357 
358 /**
359  * @brief Creates a file.
360  * @param archive Archive to create the file in.
361  * @param path Path of the file.
362  * @param attributes Attributes of the file.
363  * @param fileSize Size of the file.
364  */
365 Result FSUSER_CreateFile(FS_Archive archive, FS_Path path, u32 attributes, u64 fileSize);
366 
367 /**
368  * @brief Creates a directory
369  * @param archive Archive to create the directory in.
370  * @param path Path of the directory.
371  * @param attributes Attributes of the directory.
372  */
374 
375 /**
376  * @brief Renames a directory.
377  * @param srcArchive Archive containing the source directory.
378  * @param srcPath Path of the source directory.
379  * @param dstArchive Archive containing the destination directory.
380  * @param dstPath Path of the destination directory.
381  */
382 Result FSUSER_RenameDirectory(FS_Archive srcArchive, FS_Path srcPath, FS_Archive dstArchive, FS_Path dstPath);
383 
384 /**
385  * @brief Opens a directory.
386  * @param out Pointer to output the directory handle to.
387  * @param archive Archive containing the directory.
388  * @param path Path of the directory.
389  */
391 
392 /**
393  * @brief Opens an archive.
394  * @param archive Pointer to output the opened archive to.
395  * @param id ID of the archive.
396  * @param path Path of the archive.
397  */
399 
400 /**
401  * @brief Performs a control operation on an archive.
402  * @param archive Archive to control.
403  * @param action Action to perform.
404  * @param input Buffer to read input from.
405  * @param inputSize Size of the input.
406  * @param output Buffer to write output to.
407  * @param outputSize Size of the output.
408  */
409 Result FSUSER_ControlArchive(FS_Archive archive, FS_ArchiveAction action, void* input, u32 inputSize, void* output, u32 outputSize);
410 
411 /**
412  * @brief Closes an archive.
413  * @param archive Archive to close.
414  */
416 
417 /**
418  * @brief Gets the number of free bytes within an archive.
419  * @param freeBytes Pointer to output the free bytes to.
420  * @param archive Archive to check.
421  */
423 
424 /**
425  * @brief Gets the inserted card type.
426  * @param type Pointer to output the card type to.
427  */
429 
430 /**
431  * @brief Gets the SDMC archive resource information.
432  * @param archiveResource Pointer to output the archive resource information to.
433  */
435 
436 /**
437  * @brief Gets the NAND archive resource information.
438  * @param archiveResource Pointer to output the archive resource information to.
439  */
441 
442 /**
443  * @brief Gets the last SDMC fatfs error.
444  * @param error Pointer to output the error to.
445  */
447 
448 /**
449  * @brief Gets whether an SD card is detected.
450  * @param detected Pointer to output the detection status to.
451  */
453 
454 /**
455  * @brief Gets whether the SD card is writable.
456  * @param writable Pointer to output the writable status to.
457  */
459 
460 /**
461  * @brief Gets the SDMC CID.
462  * @param out Pointer to output the CID to.
463  * @param length Length of the CID buffer. (should be 0x10)
464  */
466 
467 /**
468  * @brief Gets the NAND CID.
469  * @param out Pointer to output the CID to.
470  * @param length Length of the CID buffer. (should be 0x10)
471  */
473 
474 /**
475  * @brief Gets the SDMC speed info.
476  * @param speedInfo Pointer to output the speed info to.
477  */
479 
480 /**
481  * @brief Gets the NAND speed info.
482  * @param speedInfo Pointer to output the speed info to.
483  */
485 
486 /**
487  * @brief Gets the SDMC log.
488  * @param out Pointer to output the log to.
489  * @param length Length of the log buffer.
490  */
492 
493 /**
494  * @brief Gets the NAND log.
495  * @param out Pointer to output the log to.
496  * @param length Length of the log buffer.
497  */
499 
500 /// Clears the SDMC log.
502 
503 /// Clears the NAND log.
505 
506 /**
507  * @brief Gets whether a card is inserted.
508  * @param inserted Pointer to output the insertion status to.
509  */
511 
512 /**
513  * @brief Powers on the card slot.
514  * @param status Pointer to output the power status to.
515  */
517 
518 /**
519  * @brief Powers off the card slot.
520  * @param status Pointer to output the power status to.
521  */
523 
524 /**
525  * @brief Gets the card's power status.
526  * @param status Pointer to output the power status to.
527  */
529 
530 /**
531  * @brief Executes a CARDNOR direct command.
532  * @param commandId ID of the command.
533  */
535 
536 /**
537  * @brief Executes a CARDNOR direct command with an address.
538  * @param commandId ID of the command.
539  * @param address Address to provide.
540  */
542 
543 /**
544  * @brief Executes a CARDNOR direct read.
545  * @param commandId ID of the command.
546  * @param size Size of the output buffer.
547  * @param output Output buffer.
548  */
549 Result FSUSER_CardNorDirectRead(u8 commandId, u32 size, void* output);
550 
551 /**
552  * @brief Executes a CARDNOR direct read with an address.
553  * @param commandId ID of the command.
554  * @param address Address to provide.
555  * @param size Size of the output buffer.
556  * @param output Output buffer.
557  */
558 Result FSUSER_CardNorDirectReadWithAddress(u8 commandId, u32 address, u32 size, void* output);
559 
560 /**
561  * @brief Executes a CARDNOR direct write.
562  * @param commandId ID of the command.
563  * @param size Size of the input buffer.
564  * @param output Input buffer.
565  */
566 Result FSUSER_CardNorDirectWrite(u8 commandId, u32 size, const void* input);
567 
568 /**
569  * @brief Executes a CARDNOR direct write with an address.
570  * @param commandId ID of the command.
571  * @param address Address to provide.
572  * @param size Size of the input buffer.
573  * @param input Input buffer.
574  */
575 Result FSUSER_CardNorDirectWriteWithAddress(u8 commandId, u32 address, u32 size, const void* input);
576 
577 /**
578  * @brief Executes a CARDNOR 4xIO direct read.
579  * @param commandId ID of the command.
580  * @param address Address to provide.
581  * @param size Size of the output buffer.
582  * @param output Output buffer.
583  */
584 Result FSUSER_CardNorDirectRead_4xIO(u8 commandId, u32 address, u32 size, void* output);
585 
586 /**
587  * @brief Executes a CARDNOR direct CPU write without verify.
588  * @param address Address to provide.
589  * @param size Size of the input buffer.
590  * @param output Input buffer.
591  */
592 Result FSUSER_CardNorDirectCpuWriteWithoutVerify(u32 address, u32 size, const void* input);
593 
594 /**
595  * @brief Executes a CARDNOR direct sector erase without verify.
596  * @param address Address to provide.
597  */
599 
600 /**
601  * @brief Gets a process's product info.
602  * @param info Pointer to output the product info to.
603  * @param processId ID of the process.
604  */
606 
607 /**
608  * @brief Gets a process's program launch info.
609  * @param info Pointer to output the program launch info to.
610  * @param processId ID of the process.
611  */
613 
614 /**
615  * @brief Sets the CARDSPI baud rate.
616  * @param baudRate Baud rate to set.
617  */
619 
620 /**
621  * @brief Sets the CARDSPI bus mode.
622  * @param busMode Bus mode to set.
623  */
625 
626 /// Sends initialization info to ARM9.
628 
629 /**
630  * @brief Gets a special content's index.
631  * @param index Pointer to output the index to.
632  * @param mediaType Media type of the special content.
633  * @param programId Program ID owning the special content.
634  * @param type Type of special content.
635  */
637 
638 /**
639  * @brief Gets the legacy ROM header of a program.
640  * @param mediaType Media type of the program.
641  * @param programId ID of the program.
642  * @param header Pointer to output the legacy ROM header to. (size = 0x3B4)
643  */
644 Result FSUSER_GetLegacyRomHeader(FS_MediaType mediaType, u64 programId, void* header);
645 
646 /**
647  * @brief Gets the legacy banner data of a program.
648  * @param mediaType Media type of the program.
649  * @param programId ID of the program.
650  * @param banner Pointer to output the legacy banner data to. (size = 0x23C0)
651  */
652 Result FSUSER_GetLegacyBannerData(FS_MediaType mediaType, u64 programId, void* banner);
653 
654 /**
655  * @brief Checks a process's authority to access a save data archive.
656  * @param access Pointer to output the access status to.
657  * @param mediaType Media type of the save data.
658  * @param saveId ID of the save data.
659  * @param processId ID of the process to check.
660  */
661 Result FSUSER_CheckAuthorityToAccessExtSaveData(bool* access, FS_MediaType mediaType, u64 saveId, u32 processId);
662 
663 /**
664  * @brief Queries the total quota size of a save data archive.
665  * @param quotaSize Pointer to output the quota size to.
666  * @param directories Number of directories.
667  * @param files Number of files.
668  * @param fileSizeCount Number of file sizes to provide.
669  * @param fileSizes File sizes to provide.
670  */
671 Result FSUSER_QueryTotalQuotaSize(u64* quotaSize, u32 directories, u32 files, u32 fileSizeCount, u64* fileSizes);
672 
673 /**
674  * @brief Abnegates an access right.
675  * @param accessRight Access right to abnegate.
676  */
678 
679 /// Deletes the 3DS SDMC root.
681 
682 /// Deletes all ext save data on the NAND.
684 
685 /// Initializes the CTR file system.
687 
688 /// Creates the FS seed.
690 
691 /**
692  * @brief Retrieves archive format info.
693  * @param totalSize Pointer to output the total size to.
694  * @param directories Pointer to output the number of directories to.
695  * @param files Pointer to output the number of files to.
696  * @param duplicateData Pointer to output whether to duplicate data to.
697  * @param archiveId ID of the archive.
698  * @param path Path of the archive.
699  */
700 Result FSUSER_GetFormatInfo(u32* totalSize, u32* directories, u32* files, bool* duplicateData, FS_ArchiveID archiveId, FS_Path path);
701 
702 /**
703  * @brief Gets the legacy ROM header of a program.
704  * @param headerSize Size of the ROM header.
705  * @param mediaType Media type of the program.
706  * @param programId ID of the program.
707  * @param header Pointer to output the legacy ROM header to.
708  */
709 Result FSUSER_GetLegacyRomHeader2(u32 headerSize, FS_MediaType mediaType, u64 programId, void* header);
710 
711 /**
712  * @brief Gets the CTR SDMC root path.
713  * @param out Pointer to output the root path to.
714  * @param length Length of the output buffer.
715  */
717 
718 /**
719  * @brief Gets an archive's resource information.
720  * @param archiveResource Pointer to output the archive resource information to.
721  * @param mediaType System media type to check.
722  */
724 
725 /**
726  * @brief Exports the integrity verification seed.
727  * @param seed Pointer to output the seed to.
728  */
730 
731 /**
732  * @brief Imports an integrity verification seed.
733  * @param seed Seed to import.
734  */
736 
737 /**
738  * @brief Formats save data.
739  * @param archiveId ID of the save data archive.
740  * @param path Path of the save data.
741  * @param blocks Size of the save data in blocks. (512 bytes)
742  * @param directories Number of directories.
743  * @param files Number of files.
744  * @param directoryBuckets Directory hash tree bucket count.
745  * @param fileBuckets File hash tree bucket count.
746  * @param duplicateData Whether to store an internal duplicate of the data.
747  */
748 Result FSUSER_FormatSaveData(FS_ArchiveID archiveId, FS_Path path, u32 blocks, u32 directories, u32 files, u32 directoryBuckets, u32 fileBuckets, bool duplicateData);
749 
750 /**
751  * @brief Gets the legacy sub banner data of a program.
752  * @param bannerSize Size of the banner.
753  * @param mediaType Media type of the program.
754  * @param programId ID of the program.
755  * @param header Pointer to output the legacy sub banner data to.
756  */
757 Result FSUSER_GetLegacySubBannerData(u32 bannerSize, FS_MediaType mediaType, u64 programId, void* banner);
758 
759 /**
760  * @brief Hashes the given data and outputs a SHA256 hash.
761  * @param data Pointer to the data to be hashed.
762  * @param inputSize The size of the data.
763  * @param hash Hash output pointer.
764  */
765 Result FSUSER_UpdateSha256Context(const void* data, u32 inputSize, u8* hash);
766 
767 /**
768  * @brief Reads from a special file.
769  * @param bytesRead Pointer to output the number of bytes read to.
770  * @param fileOffset Offset of the file.
771  * @param size Size of the buffer.
772  * @param data Buffer to read to.
773  */
774 Result FSUSER_ReadSpecialFile(u32* bytesRead, u64 fileOffset, u32 size, void* data);
775 
776 /**
777  * @brief Gets the size of a special file.
778  * @param fileSize Pointer to output the size to.
779  */
781 
782 /**
783  * @brief Creates ext save data.
784  * @param info Info of the save data.
785  * @param directories Number of directories.
786  * @param files Number of files.
787  * @param sizeLimit Size limit of the save data.
788  * @param smdhSize Size of the save data's SMDH data.
789  * @param smdh SMDH data.
790  */
791 Result FSUSER_CreateExtSaveData(FS_ExtSaveDataInfo info, u32 directories, u32 files, u64 sizeLimit, u32 smdhSize, u8* smdh);
792 
793 /**
794  * @brief Deletes ext save data.
795  * @param info Info of the save data.
796  */
798 
799 /**
800  * @brief Reads the SMDH icon of ext save data.
801  * @param bytesRead Pointer to output the number of bytes read to.
802  * @param info Info of the save data.
803  * @param smdhSize Size of the save data SMDH.
804  * @param smdh Pointer to output SMDH data to.
805  */
806 Result FSUSER_ReadExtSaveDataIcon(u32* bytesRead, FS_ExtSaveDataInfo info, u32 smdhSize, u8* smdh);
807 
808 /**
809  * @brief Gets an ext data archive's block information.
810  * @param totalBlocks Pointer to output the total blocks to.
811  * @param freeBlocks Pointer to output the free blocks to.
812  * @param blockSize Pointer to output the block size to.
813  * @param info Info of the save data.
814  */
815 Result FSUSER_GetExtDataBlockSize(u64* totalBlocks, u64* freeBlocks, u32* blockSize, FS_ExtSaveDataInfo info);
816 
817 /**
818  * @brief Enumerates ext save data.
819  * @param idsWritten Pointer to output the number of IDs written to.
820  * @param idsSize Size of the IDs buffer.
821  * @param mediaType Media type to enumerate over.
822  * @param idSize Size of each ID element.
823  * @param shared Whether to enumerate shared ext save data.
824  * @param ids Pointer to output IDs to.
825  */
826 Result FSUSER_EnumerateExtSaveData(u32* idsWritten, u32 idsSize, FS_MediaType mediaType, u32 idSize, bool shared, u8* ids);
827 
828 /**
829  * @brief Creates system save data.
830  * @param info Info of the save data.
831  * @param totalSize Total size of the save data.
832  * @param blockSize Block size of the save data. (usually 0x1000)
833  * @param directories Number of directories.
834  * @param files Number of files.
835  * @param directoryBuckets Directory hash tree bucket count.
836  * @param fileBuckets File hash tree bucket count.
837  * @param duplicateData Whether to store an internal duplicate of the data.
838  */
839 Result FSUSER_CreateSystemSaveData(FS_SystemSaveDataInfo info, u32 totalSize, u32 blockSize, u32 directories, u32 files, u32 directoryBuckets, u32 fileBuckets, bool duplicateData);
840 
841 /**
842  * @brief Deletes system save data.
843  * @param info Info of the save data.
844  */
846 
847 /**
848  * @brief Initiates a device move as the source device.
849  * @param context Pointer to output the context to.
850  */
852 
853 /**
854  * @brief Initiates a device move as the destination device.
855  * @param context Context to use.
856  * @param clear Whether to clear the device's data first.
857  */
859 
860 /**
861  * @brief Sets an archive's priority.
862  * @param archive Archive to use.
863  * @param priority Priority to set.
864  */
866 
867 /**
868  * @brief Gets an archive's priority.
869  * @param priority Pointer to output the priority to.
870  * @param archive Archive to use.
871  */
873 
874 /**
875  * @brief Configures CTRCARD latency emulation.
876  * @param latency Latency to apply, in milliseconds.
877  * @param emulateEndurance Whether to emulate card endurance.
878  */
879 Result FSUSER_SetCtrCardLatencyParameter(u64 latency, bool emulateEndurance);
880 
881 /**
882  * @brief Toggles cleaning up invalid save data.
883  * @param enable Whether to enable cleaning up invalid save data.
884  */
886 
887 /**
888  * @brief Enumerates system save data.
889  * @param idsWritten Pointer to output the number of IDs written to.
890  * @param idsSize Size of the IDs buffer.
891  * @param ids Pointer to output IDs to.
892  */
893 Result FSUSER_EnumerateSystemSaveData(u32* idsWritten, u32 idsSize, u32* ids);
894 
895 /**
896  * @brief Initializes a FSUSER session with an SDK version.
897  * @param session The handle of the FSUSER session to initialize.
898  * @param version SDK version to initialize with.
899  */
901 
902 /**
903  * @brief Sets the file system priority.
904  * @param priority Priority to set.
905  */
907 
908 /**
909  * @brief Gets the file system priority.
910  * @param priority Pointer to output the priority to.
911  */
913 
914 /**
915  * @brief Sets the save data secure value.
916  * @param value Secure value to set.
917  * @param slot Slot of the secure value.
918  * @param titleUniqueId Unique ID of the title. (default = 0)
919  * @param titleVariation Variation of the title. (default = 0)
920  */
921 Result FSUSER_SetSaveDataSecureValue(u64 value, FS_SecureValueSlot slot, u32 titleUniqueId, u8 titleVariation);
922 
923 /**
924  * @brief Gets the save data secure value.
925  * @param exists Pointer to output whether the secure value exists to.
926  * @param value Pointer to output the secure value to.
927  * @param slot Slot of the secure value.
928  * @param titleUniqueId Unique ID of the title. (default = 0)
929  * @param titleVariation Variation of the title. (default = 0)
930  */
931 Result FSUSER_GetSaveDataSecureValue(bool* exists, u64* value, FS_SecureValueSlot slot, u32 titleUniqueId, u8 titleVariation);
932 
933 /**
934  * @brief Performs a control operation on a secure save.
935  * @param action Action to perform.
936  * @param input Buffer to read input from.
937  * @param inputSize Size of the input.
938  * @param output Buffer to write output to.
939  * @param outputSize Size of the output.
940  */
941 Result FSUSER_ControlSecureSave(FS_SecureSaveAction action, void* input, u32 inputSize, void* output, u32 outputSize);
942 
943 /**
944  * @brief Gets the media type of the current application.
945  * @param mediaType Pointer to output the media type to.
946  */
948 
949 /**
950  * @brief Performs a control operation on a file.
951  * @param handle Handle of the file.
952  * @param action Action to perform.
953  * @param input Buffer to read input from.
954  * @param inputSize Size of the input.
955  * @param output Buffer to write output to.
956  * @param outputSize Size of the output.
957  */
958 Result FSFILE_Control(Handle handle, FS_FileAction action, void* input, u32 inputSize, void* output, u32 outputSize);
959 
960 /**
961  * @brief Opens a handle to a sub-section of a file.
962  * @param handle Handle of the file.
963  * @param subFile Pointer to output the sub-file to.
964  * @param offset Offset of the sub-section.
965  * @param size Size of the sub-section.
966  */
967 Result FSFILE_OpenSubFile(Handle handle, Handle* subFile, u64 offset, u64 size);
968 
969 /**
970  * @brief Reads from a file.
971  * @param handle Handle of the file.
972  * @param bytesRead Pointer to output the number of bytes read to.
973  * @param offset Offset to read from.
974  * @param buffer Buffer to read to.
975  * @param size Size of the buffer.
976  */
977 Result FSFILE_Read(Handle handle, u32* bytesRead, u64 offset, void* buffer, u32 size);
978 
979 /**
980  * @brief Writes to a file.
981  * @param handle Handle of the file.
982  * @param bytesWritten Pointer to output the number of bytes written to.
983  * @param offset Offset to write to.
984  * @param buffer Buffer to write from.
985  * @param size Size of the buffer.
986  * @param flags Flags to use when writing.
987  */
988 Result FSFILE_Write(Handle handle, u32* bytesWritten, u64 offset, const void* buffer, u32 size, u32 flags);
989 
990 /**
991  * @brief Gets the size of a file.
992  * @param handle Handle of the file.
993  * @param size Pointer to output the size to.
994  */
996 
997 /**
998  * @brief Sets the size of a file.
999  * @param handle Handle of the file.
1000  * @param size Size to set.
1001  */
1003 
1004 /**
1005  * @brief Gets the attributes of a file.
1006  * @param handle Handle of the file.
1007  * @param attributes Pointer to output the attributes to.
1008  */
1009 Result FSFILE_GetAttributes(Handle handle, u32* attributes);
1010 
1011 /**
1012  * @brief Sets the attributes of a file.
1013  * @param handle Handle of the file.
1014  * @param attributes Attributes to set.
1015  */
1017 
1018 /**
1019  * @brief Closes a file.
1020  * @param handle Handle of the file.
1021  */
1023 
1024 /**
1025  * @brief Flushes a file's contents.
1026  * @param handle Handle of the file.
1027  */
1029 
1030 /**
1031  * @brief Sets a file's priority.
1032  * @param handle Handle of the file.
1033  * @param priority Priority to set.
1034  */
1036 
1037 /**
1038  * @brief Gets a file's priority.
1039  * @param handle Handle of the file.
1040  * @param priority Pointer to output the priority to.
1041  */
1043 
1044 /**
1045  * @brief Opens a duplicate handle to a file.
1046  * @param handle Handle of the file.
1047  * @param linkFile Pointer to output the link handle to.
1048  */
1050 
1051 /**
1052  * @brief Performs a control operation on a directory.
1053  * @param handle Handle of the directory.
1054  * @param action Action to perform.
1055  * @param input Buffer to read input from.
1056  * @param inputSize Size of the input.
1057  * @param output Buffer to write output to.
1058  * @param outputSize Size of the output.
1059  */
1060 Result FSDIR_Control(Handle handle, FS_DirectoryAction action, void* input, u32 inputSize, void* output, u32 outputSize);
1061 
1062 /**
1063  * @brief Reads one or more directory entries.
1064  * @param handle Handle of the directory.
1065  * @param entriesRead Pointer to output the number of entries read to.
1066  * @param entryCount Number of entries to read.
1067  * @param entryOut Pointer to output directory entries to.
1068  */
1069 Result FSDIR_Read(Handle handle, u32* entriesRead, u32 entryCount, FS_DirectoryEntry* entries);
1070 
1071 /**
1072  * @brief Closes a directory.
1073  * @param handle Handle of the directory.
1074  */
1076 
1077 /**
1078  * @brief Sets a directory's priority.
1079  * @param handle Handle of the directory.
1080  * @param priority Priority to set.
1081  */
1083 
1084 /**
1085  * @brief Gets a directory's priority.
1086  * @param handle Handle of the directory.
1087  * @param priority Pointer to output the priority to.
1088  */
1089 Result FSDIR_GetPriority(Handle handle, u32* priority);
Result FSUSER_EnumerateSystemSaveData(u32 *idsWritten, u32 idsSize, u32 *ids)
Enumerates system save data.
Result FSUSER_GetArchivePriority(u32 *priority, FS_Archive archive)
Gets an archive's priority.
Result FSUSER_GetFormatInfo(u32 *totalSize, u32 *directories, u32 *files, bool *duplicateData, FS_ArchiveID archiveId, FS_Path path)
Retrieves archive format info.
Result FSUSER_GetLegacyBannerData(FS_MediaType mediaType, u64 programId, void *banner)
Gets the legacy banner data of a program.
Result FSFILE_Flush(Handle handle)
Flushes a file's contents.
Result FSUSER_DeleteExtSaveData(FS_ExtSaveDataInfo info)
Deletes ext save data.
Result FSUSER_GetMediaType(FS_MediaType *mediaType)
Gets the media type of the current application.
Result FSUSER_GetSdmcArchiveResource(FS_ArchiveResource *archiveResource)
Gets the SDMC archive resource information.
Result FSUSER_CreateExtSaveData(FS_ExtSaveDataInfo info, u32 directories, u32 files, u64 sizeLimit, u32 smdhSize, u8 *smdh)
Creates ext save data.
Result FSUSER_GetNandLog(u8 *out, u32 length)
Gets the NAND log.
Result FSUSER_DeleteSdmcRoot(void)
Deletes the 3DS SDMC root.
Result FSFILE_GetSize(Handle handle, u64 *size)
Gets the size of a file.
Result FSFILE_OpenLinkFile(Handle handle, Handle *linkFile)
Opens a duplicate handle to a file.
Result FSUSER_OpenDirectory(Handle *out, FS_Archive archive, FS_Path path)
Opens a directory.
Result FSUSER_GetSdmcFatfsError(u32 *error)
Gets the last SDMC fatfs error.
Result FSUSER_SendInitializeInfoTo9(void)
Sends initialization info to ARM9.
Result FSUSER_CardNorDirectWriteWithAddress(u8 commandId, u32 address, u32 size, const void *input)
Executes a CARDNOR direct write with an address.
Result FSUSER_CardNorDirectCommand(u8 commandId)
Executes a CARDNOR direct command.
FS_ArchiveID
Archive IDs.
Definition: fs.h:52
@ ARCHIVE_NAND_W_FS
NAND W FS archive.
Definition: fs.h:73
@ ARCHIVE_SYSTEM_SAVEDATA2
System save data archive.
Definition: fs.h:63
@ ARCHIVE_SDMC
SDMC archive.
Definition: fs.h:58
@ ARCHIVE_USER_SAVEDATA
User save data archive.
Definition: fs.h:75
@ ARCHIVE_SHARED_EXTDATA
Shared ext data archive.
Definition: fs.h:56
@ ARCHIVE_ROMFS
RomFS archive.
Definition: fs.h:53
@ ARCHIVE_TWL_SOUND
TWL SOUND archive.
Definition: fs.h:71
@ ARCHIVE_SAVEDATA_AND_CONTENT
User save data and ExeFS/RomFS archive.
Definition: fs.h:67
@ ARCHIVE_NAND_RO
Read-only NAND archive.
Definition: fs.h:65
@ ARCHIVE_EXTDATA_AND_BOSS_EXTDATA
Ext data and BOSS ext data archive.
Definition: fs.h:62
@ ARCHIVE_TWL_PHOTO
TWL PHOTO archive.
Definition: fs.h:70
@ ARCHIVE_SDMC_WRITE_ONLY
Write-only SDMC archive.
Definition: fs.h:59
@ ARCHIVE_NAND_CTR_FS
NAND CTR FS archive.
Definition: fs.h:69
@ ARCHIVE_SAVEDATA
Save data archive.
Definition: fs.h:54
@ ARCHIVE_SAVEDATA_AND_CONTENT2
User save data and ExeFS/RomFS archive (only ExeFS for fs:LDR).
Definition: fs.h:68
@ ARCHIVE_SYSTEM_SAVEDATA
System save data archive.
Definition: fs.h:57
@ ARCHIVE_NAND_RO_WRITE_ACCESS
Read-only write access NAND archive.
Definition: fs.h:66
@ ARCHIVE_NAND_RW
Read-write NAND archive.
Definition: fs.h:64
@ ARCHIVE_GAMECARD_SAVEDATA
Game card save data archive.
Definition: fs.h:74
@ ARCHIVE_CARD_SPIFS
Card SPI FS archive.
Definition: fs.h:61
@ ARCHIVE_BOSS_EXTDATA
BOSS ext data archive.
Definition: fs.h:60
@ ARCHIVE_DEMO_SAVEDATA
Demo save data archive.
Definition: fs.h:76
@ ARCHIVE_EXTDATA
Ext data archive.
Definition: fs.h:55
@ ARCHIVE_NAND_TWL_FS
NAND TWL FS archive.
Definition: fs.h:72
Result FSUSER_GetLegacySubBannerData(u32 bannerSize, FS_MediaType mediaType, u64 programId, void *banner)
Gets the legacy sub banner data of a program.
Result FSUSER_CardNorDirectReadWithAddress(u8 commandId, u32 address, u32 size, void *output)
Executes a CARDNOR direct read with an address.
Result FSUSER_GetProductInfo(FS_ProductInfo *info, u32 processId)
Gets a process's product info.
Result FSUSER_FormatSaveData(FS_ArchiveID archiveId, FS_Path path, u32 blocks, u32 directories, u32 files, u32 directoryBuckets, u32 fileBuckets, bool duplicateData)
Formats save data.
FS_PathType
Path types.
Definition: fs.h:81
@ PATH_BINARY
Binary path. Meaning is per-archive.
Definition: fs.h:84
@ PATH_INVALID
Invalid path.
Definition: fs.h:82
@ PATH_EMPTY
Empty path.
Definition: fs.h:83
@ PATH_ASCII
ASCII text path.
Definition: fs.h:85
@ PATH_UTF16
UTF-16 text path.
Definition: fs.h:86
Result FSUSER_CreateFile(FS_Archive archive, FS_Path path, u32 attributes, u64 fileSize)
Creates a file.
Result FSUSER_QueryTotalQuotaSize(u64 *quotaSize, u32 directories, u32 files, u32 fileSizeCount, u64 *fileSizes)
Queries the total quota size of a save data archive.
Result FSDIR_GetPriority(Handle handle, u32 *priority)
Gets a directory's priority.
Result FSUSER_SetCardSpiBusMode(FS_CardSpiBusMode busMode)
Sets the CARDSPI bus mode.
Result FSUSER_CloseArchive(FS_Archive archive)
Closes an archive.
Result FSFILE_OpenSubFile(Handle handle, Handle *subFile, u64 offset, u64 size)
Opens a handle to a sub-section of a file.
Result FSUSER_GetExtDataBlockSize(u64 *totalBlocks, u64 *freeBlocks, u32 *blockSize, FS_ExtSaveDataInfo info)
Gets an ext data archive's block information.
FS_MediaType
Media types.
Definition: fs.h:35
@ MEDIATYPE_GAME_CARD
Game card.
Definition: fs.h:38
@ MEDIATYPE_SD
SD card.
Definition: fs.h:37
@ MEDIATYPE_NAND
NAND.
Definition: fs.h:36
void fsExemptFromSession(FS_Archive archive)
Exempts an archive from using alternate FS session handles provided with fsUseSession Instead,...
Result FSUSER_GetNandSpeedInfo(FS_SdMmcSpeedInfo *speedInfo)
Gets the NAND speed info.
void fsExit(void)
Exits FS.
Result FSUSER_DeleteSystemSaveData(FS_SystemSaveDataInfo info)
Deletes system save data.
Result FSUSER_IsSdmcDetected(bool *detected)
Gets whether an SD card is detected.
Result FSUSER_CardSlotPowerOn(bool *status)
Powers on the card slot.
Result FSUSER_SetCtrCardLatencyParameter(u64 latency, bool emulateEndurance)
Configures CTRCARD latency emulation.
Result FSUSER_GetNandCid(u8 *out, u32 length)
Gets the NAND CID.
FS_Action
FS control actions.
Definition: fs.h:129
FS_DirectoryAction
Directory control actions.
Definition: fs.h:156
Result FSUSER_CardNorDirectSectorEraseWithoutVerify(u32 address)
Executes a CARDNOR direct sector erase without verify.
Result FSDIR_SetPriority(Handle handle, u32 priority)
Sets a directory's priority.
void fsUnexemptFromSession(FS_Archive archive)
Unexempts an archive from using alternate FS session handles provided with fsUseSession.
Result FSUSER_CheckAuthorityToAccessExtSaveData(bool *access, FS_MediaType mediaType, u64 saveId, u32 processId)
Checks a process's authority to access a save data archive.
Result FSUSER_GetSdmcSpeedInfo(FS_SdMmcSpeedInfo *speedInfo)
Gets the SDMC speed info.
Result FSFILE_SetSize(Handle handle, u64 size)
Sets the size of a file.
Result FSUSER_OpenFileDirectly(Handle *out, FS_ArchiveID archiveId, FS_Path archivePath, FS_Path filePath, u32 openFlags, u32 attributes)
Opens a file directly, bypassing the requirement of an opened archive handle.
@ FS_OPEN_WRITE
Open for writing.
Definition: fs.h:13
@ FS_OPEN_CREATE
Create file.
Definition: fs.h:14
@ FS_OPEN_READ
Open for reading.
Definition: fs.h:12
Result FSUSER_GetArchiveResource(FS_ArchiveResource *archiveResource, FS_SystemMediaType mediaType)
Gets an archive's resource information.
Result FSUSER_ReadSpecialFile(u32 *bytesRead, u64 fileOffset, u32 size, void *data)
Reads from a special file.
Result FSUSER_GetNandArchiveResource(FS_ArchiveResource *archiveResource)
Gets the NAND archive resource information.
Result FSUSER_GetPriority(u32 *priority)
Gets the file system priority.
u64 FS_Archive
Filesystem archive handle, providing access to a filesystem's contents.
Definition: fs.h:247
Result FSUSER_GetLegacyRomHeader2(u32 headerSize, FS_MediaType mediaType, u64 programId, void *header)
Gets the legacy ROM header of a program.
Result FSUSER_Initialize(Handle session)
Initializes a FSUSER session.
Result FSFILE_GetAttributes(Handle handle, u32 *attributes)
Gets the attributes of a file.
Result FSUSER_GetCardType(FS_CardType *type)
Gets the inserted card type.
Result FSUSER_RenameFile(FS_Archive srcArchive, FS_Path srcPath, FS_Archive dstArchive, FS_Path dstPath)
Renames a file.
Result FSUSER_CardNorDirectRead(u8 commandId, u32 size, void *output)
Executes a CARDNOR direct read.
Result FSUSER_GetSpecialFileSize(u64 *fileSize)
Gets the size of a special file.
Result FSUSER_ImportIntegrityVerificationSeed(FS_IntegrityVerificationSeed *seed)
Imports an integrity verification seed.
Result FSUSER_CardNorDirectRead_4xIO(u8 commandId, u32 address, u32 size, void *output)
Executes a CARDNOR 4xIO direct read.
FS_CardSpiBusMode
Card SPI bus mode.
Definition: fs.h:108
@ BUSMODE_4BIT
4-bit.
Definition: fs.h:110
@ BUSMODE_1BIT
1-bit.
Definition: fs.h:109
Result FSUSER_ControlSecureSave(FS_SecureSaveAction action, void *input, u32 inputSize, void *output, u32 outputSize)
Performs a control operation on a secure save.
Result FSUSER_Control(FS_Action action, void *input, u32 inputSize, void *output, u32 outputSize)
Performs a control operation on the filesystem.
Result FSUSER_GetFreeBytes(u64 *freeBytes, FS_Archive archive)
Gets the number of free bytes within an archive.
Result FSUSER_CreateSystemSaveData(FS_SystemSaveDataInfo info, u32 totalSize, u32 blockSize, u32 directories, u32 files, u32 directoryBuckets, u32 fileBuckets, bool duplicateData)
Creates system save data.
Result FSUSER_CardSlotGetCardIFPowerStatus(bool *status)
Gets the card's power status.
Result FSUSER_SetCardSpiBaudRate(FS_CardSpiBaudRate baudRate)
Sets the CARDSPI baud rate.
Result fsInit(void)
Initializes FS.
Result FSUSER_GetSaveDataSecureValue(bool *exists, u64 *value, FS_SecureValueSlot slot, u32 titleUniqueId, u8 titleVariation)
Gets the save data secure value.
Result FSFILE_GetPriority(Handle handle, u32 *priority)
Gets a file's priority.
Result FSUSER_SwitchCleanupInvalidSaveData(bool enable)
Toggles cleaning up invalid save data.
Result FSUSER_GetLegacyRomHeader(FS_MediaType mediaType, u64 programId, void *header)
Gets the legacy ROM header of a program.
Result FSUSER_CardSlotPowerOff(bool *status)
Powers off the card slot.
FS_SecureValueSlot
Secure value slot.
Definition: fs.h:91
@ SECUREVALUE_SLOT_SD
SD application.
Definition: fs.h:92
Result FSUSER_CardNorDirectCpuWriteWithoutVerify(u32 address, u32 size, const void *input)
Executes a CARDNOR direct CPU write without verify.
Result FSUSER_OpenArchive(FS_Archive *archive, FS_ArchiveID id, FS_Path path)
Opens an archive.
Result FSFILE_Read(Handle handle, u32 *bytesRead, u64 offset, void *buffer, u32 size)
Reads from a file.
Result FSUSER_ClearSdmcLog(void)
Clears the SDMC log.
Result FSUSER_OpenFile(Handle *out, FS_Archive archive, FS_Path path, u32 openFlags, u32 attributes)
Opens a file.
Result FSUSER_CardNorDirectCommandWithAddress(u8 commandId, u32 address)
Executes a CARDNOR direct command with an address.
Result FSDIR_Control(Handle handle, FS_DirectoryAction action, void *input, u32 inputSize, void *output, u32 outputSize)
Performs a control operation on a directory.
FS_FileAction
File control actions.
Definition: fs.h:150
@ FS_WRITE_FLUSH
Flush.
Definition: fs.h:20
@ FS_WRITE_UPDATE_TIME
Update file timestamp.
Definition: fs.h:21
Result FSUSER_ReadExtSaveDataIcon(u32 *bytesRead, FS_ExtSaveDataInfo info, u32 smdhSize, u8 *smdh)
Reads the SMDH icon of ext save data.
Result FSUSER_CreateSeed(void)
Creates the FS seed.
Result FSUSER_StartDeviceMoveAsSource(FS_DeviceMoveContext *context)
Initiates a device move as the source device.
Result FSUSER_DeleteFile(FS_Archive archive, FS_Path path)
Deletes a file.
Result FSUSER_InitializeCtrFileSystem(void)
Initializes the CTR file system.
Result FSUSER_DeleteDirectory(FS_Archive archive, FS_Path path)
Deletes a directory, failing if it is not empty.
Result FSUSER_IsSdmcWritable(bool *writable)
Gets whether the SD card is writable.
FS_CardType
Definition: fs.h:122
@ CARD_CTR
CTR card.
Definition: fs.h:123
@ CARD_TWL
TWL card.
Definition: fs.h:124
Result FSUSER_SetSaveDataSecureValue(u64 value, FS_SecureValueSlot slot, u32 titleUniqueId, u8 titleVariation)
Sets the save data secure value.
Result FSFILE_Write(Handle handle, u32 *bytesWritten, u64 offset, const void *buffer, u32 size, u32 flags)
Writes to a file.
Result FSDIR_Read(Handle handle, u32 *entriesRead, u32 entryCount, FS_DirectoryEntry *entries)
Reads one or more directory entries.
Result FSUSER_ClearNandLog(void)
Clears the NAND log.
Result FSUSER_GetProgramLaunchInfo(FS_ProgramInfo *info, u32 processId)
Gets a process's program launch info.
Result FSUSER_ControlArchive(FS_Archive archive, FS_ArchiveAction action, void *input, u32 inputSize, void *output, u32 outputSize)
Performs a control operation on an archive.
Result FSUSER_StartDeviceMoveAsDestination(FS_DeviceMoveContext context, bool clear)
Initiates a device move as the destination device.
Result FSFILE_Control(Handle handle, FS_FileAction action, void *input, u32 inputSize, void *output, u32 outputSize)
Performs a control operation on a file.
Result FSUSER_GetSdmcCtrRootPath(u8 *out, u32 length)
Gets the CTR SDMC root path.
Result FSUSER_ExportIntegrityVerificationSeed(FS_IntegrityVerificationSeed *seed)
Exports the integrity verification seed.
Result FSUSER_AbnegateAccessRight(u32 accessRight)
Abnegates an access right.
FS_ArchiveAction
Archive control actions.
Definition: fs.h:135
@ ARCHIVE_ACTION_COMMIT_SAVE_DATA
Commits save data changes. No inputs/outputs.
Definition: fs.h:136
@ ARCHIVE_ACTION_GET_TIMESTAMP
Retrieves a file's last-modified timestamp. In: "u16*, UTF-16 Path", Out: "u64, Time Stamp".
Definition: fs.h:137
Result FSFILE_SetPriority(Handle handle, u32 priority)
Sets a file's priority.
Result FSUSER_GetSdmcLog(u8 *out, u32 length)
Gets the SDMC log.
Result FSUSER_DeleteDirectoryRecursively(FS_Archive archive, FS_Path path)
Deletes a directory, also deleting its contents.
Result FSUSER_UpdateSha256Context(const void *data, u32 inputSize, u8 *hash)
Hashes the given data and outputs a SHA256 hash.
Result FSUSER_CardSlotIsInserted(bool *inserted)
Gets whether a card is inserted.
Result FSUSER_SetArchivePriority(FS_Archive archive, u32 priority)
Sets an archive's priority.
Result FSUSER_GetSdmcCid(u8 *out, u32 length)
Gets the SDMC CID.
FS_SystemMediaType
System media types.
Definition: fs.h:43
@ SYSTEM_MEDIATYPE_CTR_NAND
CTR NAND.
Definition: fs.h:44
@ SYSTEM_MEDIATYPE_TWL_NAND
TWL NAND.
Definition: fs.h:45
@ SYSTEM_MEDIATYPE_SD
SD card.
Definition: fs.h:46
@ SYSTEM_MEDIATYPE_TWL_PHOTO
TWL Photo.
Definition: fs.h:47
Result FSUSER_DeleteAllExtSaveDataOnNand(void)
Deletes all ext save data on the NAND.
Result FSUSER_EnumerateExtSaveData(u32 *idsWritten, u32 idsSize, FS_MediaType mediaType, u32 idSize, bool shared, u8 *ids)
Enumerates ext save data.
Result FSUSER_SetPriority(u32 priority)
Sets the file system priority.
Result FSUSER_CardNorDirectWrite(u8 commandId, u32 size, const void *input)
Executes a CARDNOR direct write.
Result FSDIR_Close(Handle handle)
Closes a directory.
FS_SecureSaveAction
Secure save control actions.
Definition: fs.h:143
@ SECURESAVE_ACTION_FORMAT
Formats a save. No inputs/outputs.
Definition: fs.h:145
@ SECURESAVE_ACTION_DELETE
Deletes a save's secure value. In: "u64, ((SecureValueSlot << 32) | (TitleUniqueId << 8) | TitleVaria...
Definition: fs.h:144
Result FSUSER_RenameDirectory(FS_Archive srcArchive, FS_Path srcPath, FS_Archive dstArchive, FS_Path dstPath)
Renames a directory.
FS_SpecialContentType
Card SPI bus mode.
Definition: fs.h:115
@ SPECIALCONTENT_UPDATE
Update.
Definition: fs.h:116
@ SPECIALCONTENT_DLP_CHILD
DLP child.
Definition: fs.h:118
@ SPECIALCONTENT_MANUAL
Manual.
Definition: fs.h:117
Result FSFILE_SetAttributes(Handle handle, u32 attributes)
Sets the attributes of a file.
Result FSUSER_CreateDirectory(FS_Archive archive, FS_Path path, u32 attributes)
Creates a directory.
Handle * fsGetSessionHandle(void)
Gets the current FS session handle.
FS_Path fsMakePath(FS_PathType type, const void *path)
Creates an FS_Path instance.
FS_CardSpiBaudRate
Card SPI baud rate.
Definition: fs.h:97
@ BAUDRATE_4MHZ
4MHz.
Definition: fs.h:101
@ BAUDRATE_2MHZ
2MHz.
Definition: fs.h:100
@ BAUDRATE_16MHZ
16MHz.
Definition: fs.h:103
@ BAUDRATE_8MHZ
8MHz.
Definition: fs.h:102
@ BAUDRATE_1MHZ
1MHz.
Definition: fs.h:99
@ BAUDRATE_512KHZ
512KHz.
Definition: fs.h:98
Result FSUSER_GetSpecialContentIndex(u16 *index, FS_MediaType mediaType, u64 programId, FS_SpecialContentType type)
Gets a special content's index.
Result FSFILE_Close(Handle handle)
Closes a file.
Result FSUSER_InitializeWithSdkVersion(Handle session, u32 version)
Initializes a FSUSER session with an SDK version.
void fsUseSession(Handle session)
Sets the FSUSER session to use in the current thread.
void fsEndUseSession(void)
Disables the FSUSER session override in the current thread.
@ FS_ATTRIBUTE_HIDDEN
Hidden.
Definition: fs.h:28
@ FS_ATTRIBUTE_ARCHIVE
Archive.
Definition: fs.h:29
@ FS_ATTRIBUTE_DIRECTORY
Directory.
Definition: fs.h:27
@ FS_ATTRIBUTE_READ_ONLY
Read-only.
Definition: fs.h:30
Archive resource information.
Definition: fs.h:174
u32 clusterSize
Size of each cluster, in bytes.
Definition: fs.h:176
u32 totalClusters
Total number of clusters.
Definition: fs.h:177
u32 freeClusters
Number of free clusters.
Definition: fs.h:178
u32 sectorSize
Size of each sector, in bytes.
Definition: fs.h:175
Device move context.
Definition: fs.h:225
Directory entry.
Definition: fs.h:162
u8 valid
Valid flag. (Always 1)
Definition: fs.h:166
u8 reserved
Reserved.
Definition: fs.h:167
u32 attributes
Attributes.
Definition: fs.h:168
u64 fileSize
File size.
Definition: fs.h:169
Ext save data information.
Definition: fs.h:206
u32 reserved2
Reserved.
Definition: fs.h:211
FS_MediaType mediaType
Media type.
Definition: fs.h:207
u16 reserved1
Reserved.
Definition: fs.h:209
u64 saveId
Save ID.
Definition: fs.h:210
u8 unknown
Unknown.
Definition: fs.h:208
Integrity verification seed.
Definition: fs.h:199
Filesystem path data, detailing the specific target of an operation.
Definition: fs.h:232
const void * data
Pointer to FS path data.
Definition: fs.h:235
u32 size
FS path size.
Definition: fs.h:234
FS_PathType type
FS path type.
Definition: fs.h:233
Product information.
Definition: fs.h:191
u16 remasterVersion
Remaster version.
Definition: fs.h:194
Program information.
Definition: fs.h:183
FS_MediaType mediaType
Media type.
Definition: fs.h:185
u64 programId
Program ID.
Definition: fs.h:184
SDMC/NAND speed information.
Definition: fs.h:240
bool highSpeedModeEnabled
Whether or not High Speed Mode is enabled.
Definition: fs.h:241
u16 sdClkCtrl
The value of the SD_CLK_CTRL register.
Definition: fs.h:243
bool usesHighestClockRate
Whether or not a clock divider of 2 is being used.
Definition: fs.h:242
System save data information.
Definition: fs.h:216
u16 reserved
Reserved.
Definition: fs.h:219
FS_MediaType mediaType
Media type.
Definition: fs.h:217
u32 saveId
Save ID.
Definition: fs.h:220
u8 unknown
Unknown.
Definition: fs.h:218
Various system types.
#define BIT(n)
Creates a bitmask from a bit number.
Definition: types.h:47
uint64_t u64
64-bit unsigned integer
Definition: types.h:24
#define CTR_PACKED
Packs a struct (and other types?) so it won't include padding bytes.
Definition: types.h:52
uint8_t u8
would be nice if newlib had this already
Definition: types.h:21
u32 Handle
Resource handle.
Definition: types.h:41
s32 Result
Function result.
Definition: types.h:42
uint16_t u16
16-bit unsigned integer
Definition: types.h:22
uint32_t u32
32-bit unsigned integer
Definition: types.h:23