Difference between revisions of "Inner FAT"

From 3dbrew
Jump to navigation Jump to search
(Start a new page to unify the filesystem doc of save/extdata/database)
 
(Layout Variants)
Line 13: Line 13:
  
 
The file allocation table (FAT) forms several linked lists inside, each of which represents a "file" allocated in the data region. Please refer to the File Allocation Table section below for more detail. In some variants, the directory entry table and the file entry table are also allocated as two special "files" in the data region, managed by the FAT, while in others they are stand-alone tables located outside the data region.
 
The file allocation table (FAT) forms several linked lists inside, each of which represents a "file" allocated in the data region. Please refer to the File Allocation Table section below for more detail. In some variants, the directory entry table and the file entry table are also allocated as two special "files" in the data region, managed by the FAT, while in others they are stand-alone tables located outside the data region.
 +
 +
== 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]
 +
 +
=== Savegame, <code>duplicate data = true</code> ===
 +
 +
Such savegame is a single DISA container that only has one partition which is always configured as external IVFC level 4 disabled (see [[DISA and DIFF|DISA]] format for details). All components are stored in this partition as
 +
 +
* filesystem header at the beginning
 +
* directory hash table
 +
* file hash table
 +
* file allocation table
 +
* data region
 +
** directory entry table is allocated inside data region
 +
** file entry table as well
 +
** all file data is also allocated here
 +
 +
In this layout, all data is duplicated by DISA's DPFS tree, which is what the parameter <code>duplicate data</code> implies.
 +
 +
=== Savegame, <code>duplicate data = false</code> ===
 +
Such savegame is a single DISA container that has two partitions. Partition A is always configured as external IVFC level 4 disabled, and partition B is configured as it enabled. Components are stored among the two partitions as
 +
 +
* Partition A
 +
** filesystem header at the beginning.
 +
** directory hash table
 +
** file hash table
 +
** (stand-alone) file allocation table
 +
** (stand-alone) directory entry table
 +
** file entry table
 +
* Partition B
 +
** used as data region entirely, and only has file data allocated.
 +
 +
In this layout, all file system metadata is duplicated by partition A DPFS tree, but file data is not as partition B has external IVFC level 4.
 +
 +
=== Extdata ===
 +
An extdata consists of several DIFF containers (device files), among which the special device file <code>00000000/00000001</code> contains the inner FAT system, while other devices contains normal subfiles of the extdata. Please refer to [[Extdata]] for detail. The special file <code>00000000/00000001</code> contists of the following components
 +
 +
* filesystem header at the beginning
 +
* directory hash table
 +
* file hash table
 +
* file allocation table (degenerate, because the data region only has two "files": the directory entry table and the file entry table)
 +
* data region
 +
** directory entry table allocated inside data region
 +
** file entry table as well
 +
** normal subfiles are NOT in the data region. They are in their DIFF containers instead.
 +
 +
=== Title database ===
 +
All [[Title Database]] files are DIFF containers. Except for <code>certs.db</code>, all of them uses this filesystem in the DIFF inner data, which consists of
 +
 +
* database-specific pre-header at the beginning (See [[Title Database]])
 +
* filesystem header
 +
* directory Hash Table (degenerate and always has only one bucket, as there is only one directory for "root")
 +
* file Hash Table
 +
* file allocation table
 +
* data region
 +
** directory entry table allocated inside data region (degenerate, as there is only one directory for "root")
 +
** file entry table as well
 +
** title entries (title info or ticket) are allocated as normal files in the data region as well.

Revision as of 22:24, 3 May 2019

This page describes a common FAT-like file system used in Savegames, Extdata and Title Database. This file system format has several variants depending on which kind of data it stores. All the three kinds of data that use this file system structure also happen to use the DISA and DIFF container as well, but there is no direct relationship between the file system and the DISA/DIFF container. All data formats described here is in the inner data of the DISA/DIFF container (i.e. IVFC level 4). Please refer to the DISA/DIFF page for how to unwrap it first before trying to extract the file system.

Overview

The file system consists of the following components:

  • header
  • directory hash table
  • file hash table
  • file allocation table
  • directory entry table
  • file entry table
  • data region

The file allocation table (FAT) forms several linked lists inside, each of which represents a "file" allocated in the data region. Please refer to the File Allocation Table section below for more detail. In some variants, the directory entry table and the file entry table are also allocated as two special "files" in the data region, managed by the FAT, while in others they are stand-alone tables located outside the data region.

Layout Variants

Four variants of the file system layout has been identified. A summary diagram can be found here: [1]

Savegame, duplicate data = true

Such savegame is a single DISA container that only has one partition which is always configured as external IVFC level 4 disabled (see DISA format for details). All components are stored in this partition as

  • filesystem header at the beginning
  • directory hash table
  • file hash table
  • file allocation table
  • data region
    • directory entry table is allocated inside data region
    • file entry table as well
    • all file data is also allocated here

In this layout, all data is duplicated by DISA's DPFS tree, which is what the parameter duplicate data implies.

Savegame, duplicate data = false

Such savegame is a single DISA container that has two partitions. Partition A is always configured as external IVFC level 4 disabled, and partition B is configured as it enabled. Components are stored among the two partitions as

  • Partition A
    • filesystem header at the beginning.
    • directory hash table
    • file hash table
    • (stand-alone) file allocation table
    • (stand-alone) directory entry table
    • file entry table
  • Partition B
    • used as data region entirely, and only has file data allocated.

In this layout, all file system metadata is duplicated by partition A DPFS tree, but file data is not as partition B has external IVFC level 4.

Extdata

An extdata consists of several DIFF containers (device files), among which the special device file 00000000/00000001 contains the inner FAT system, while other devices contains normal subfiles of the extdata. Please refer to Extdata for detail. The special file 00000000/00000001 contists of the following components

  • filesystem header at the beginning
  • directory hash table
  • file hash table
  • file allocation table (degenerate, because the data region only has two "files": the directory entry table and the file entry table)
  • data region
    • directory entry table allocated inside data region
    • file entry table as well
    • normal subfiles are NOT in the data region. They are in their DIFF containers instead.

Title database

All Title Database files are DIFF containers. Except for certs.db, all of them uses this filesystem in the DIFF inner data, which consists of

  • database-specific pre-header at the beginning (See Title Database)
  • filesystem header
  • directory Hash Table (degenerate and always has only one bucket, as there is only one directory for "root")
  • file Hash Table
  • file allocation table
  • data region
    • directory entry table allocated inside data region (degenerate, as there is only one directory for "root")
    • file entry table as well
    • title entries (title info or ticket) are allocated as normal files in the data region as well.