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