Inner FAT: Difference between revisions

Wwylele (talk | contribs)
m Filesystem Header: Nintendo please
Added Tools section
 
(3 intermediate revisions by 2 users not shown)
Line 15: Line 15:


== Layout Variants ==
== Layout Variants ==
Four variants of the file system layout has been identified. A summary diagram can be found here: [https://github.com/wwylele/3ds-save-tool/raw/master/inner-fat.png]
Four variants of the file system layout has been identified. A summary diagram:
 
[[File:Inner-fat.png]]


=== Savegame, <code>duplicate data = true</code> ===
=== Savegame, <code>duplicate data = true</code> ===
Line 58: Line 60:
** file entry table as well
** file entry table as well
** normal subfiles are NOT in the data region. They are in their DIFF containers instead.
** normal subfiles are NOT in the data region. They are in their DIFF containers instead.
The special file <code>00000000/00000001</code> is configured as external IVFC level 4 disabled, and all other device files are configured as it enabled.


=== Title database ===
=== Title database ===
Line 480: Line 484:


<pre>uint32_t GetBucket(
<pre>uint32_t GetBucket(
     char name[16 or 8], // For savegame/extdata, this takes all 16 bytes including trailing zeros; For title database, this is the 8-byte title ID
     uint8_t name[16 or 8], // For savegame/extdata, this takes all 16 bytes including trailing zeros; For title database, this is the 8-byte title ID
     uint32_t parent_dir_index,
     uint32_t parent_dir_index,
     uint32_t bucket_count
     uint32_t bucket_count
Line 495: Line 499:
}
}
</pre>
</pre>


== File Allocation Table ==
== File Allocation Table ==
Line 545: Line 548:
All free blocks that are not allocated to any files also form a node chain in the allocation table. The head index of this &quot;free chain&quot; is recorded in <code>FAT[0].Index_V</code>. Other fields of <code>FAT[0]</code> are all zero
All free blocks that are not allocated to any files also form a node chain in the allocation table. The head index of this &quot;free chain&quot; is recorded in <code>FAT[0].Index_V</code>. Other fields of <code>FAT[0]</code> are all zero


Here is an example: [https://raw.githubusercontent.com/wwylele/3ds-save-tool/master/disa-fat.png]
Here is an example:  
 
[[File:Disa-fat.png]]


For extdata, because only two "files" (directory and file entry tables) are allocated in the data region, and their size never changes once the extdata is created, they are guaranteed continuous in the data region, and the FAT degenerates to two big nodes. Therefore, instead of going through FAT, the offset and size of directory / file entry table can be found directly by offset = entry_table_starting block * data_region_block_size + data_region_offset and size = entry_table_block_count * data_region_block_size.
For extdata, because only two "files" (directory and file entry tables) are allocated in the data region, and their size never changes once the extdata is created, they are guaranteed continuous in the data region, and the FAT degenerates to two big nodes. Therefore, instead of going through FAT, the offset and size of directory / file entry table can be found directly by offset = entry_table_starting block * data_region_block_size + data_region_offset and size = entry_table_block_count * data_region_block_size.
==Tools==
https://github.com/wwylele/3ds-save-tool