Product SiteDocumentation Site

4.3. Data Fork

The structure of the inode's data fork based is on the inode's type and di_format. It always starts at offset 100 (0x64) in the inode's space which is the start of the inode's "literal area". The size of the data fork is determined by the type and format. The maximum size is determined by the inode size and di_forkoff. In code, use the XFS_DFORK_PTR macro specifying XFS_DATA_FORK for the "which" parameter. Alternatively, the XFS_DFORK_DPTR macro can be used.
Each of the following sub-sections summarises the contents of the data fork based on the inode type.

4.3.1. Regular Files (S_IFREG)

The data fork specifies the file's data extents. The extents specify where the file's actual data is located within the filesystem. Extents can have 2 formats which is defined by the di_format value:
  • XFS_DINODE_FMT_EXTENTS: The extent data is fully contained within the inode which contains an array of extents to the filesystem blocks for the file's data. To access the extents, cast the return value from XFS_DFORK_DPTR to xfs_bmbt_rec_t*.
  • XFS_DINODE_FMT_BTREE: The extent data is contained in the leaves of a B+tree. The inode contains the root node of the tree and is accessed by casting the return value from XFS_DFORK_DPTR to xfs_bmdr_block_t*.
Details for each of these data extent formats are covered in the Data Extents section (Chapter 5, Data Extents) later on.