Skip to main content

Module inline_data

Module inline_data 

Source
Expand description

Inline data reading.

Spec: kernel.org/doc/html/latest/filesystems/ext4/inlinedata.html

When the INCOMPAT_INLINE_DATA feature is enabled and an inode has the EXT4_INLINE_DATA_FL flag, the file’s contents live inside the inode itself instead of being stored in extent-allocated data blocks.

Layout:

  • First 60 bytes of the file are stored in the i_block[60] array (the same field that normally holds the extent header / direct block pointers).
  • If the file is larger than 60 bytes, the remainder is stored as the value of a special xattr named system.data. Concatenate the two to get the full file content.
  • Maximum inline file size = 60 + (in-inode-xattr-region-size minus headers and other entries). Typically 60–~150 bytes for inode_size=256.

A directory uses the same two areas with one difference: the first 4 bytes of i_block are its parent’s inode number, and its entries start at byte 4 (see dir_entries).

Constants§

INLINE_BLOCK_SIZE
Size of the i_block area that holds inline data.
INLINE_DOTDOT_SIZE
Bytes at the head of an inline directory’s i_block that are not entries: the parent directory’s inode number, the implicit .. (format documentation, “Inline Directories”: “The first four bytes of i_block are the inode number of the parent directory”).

Functions§

dir_continuation
The system.data bytes an inline directory’s entries continue into, or an empty vector when i_size says it fits in i_block. A size past 60 with no such xattr, or a shorter one, is corruption – the same rule read_all applies to a file.
dir_entries
The entries of an inline-data directory, in the order the kernel’s readdir reports them: . (the directory itself), .. (read from bytes 0..4 of i_block), the entries in i_block[4..60], then those in continuation – the system.data xattr value, empty when the directory fits in i_block.
read_all
Read the contents of an inline-data file in full.
read_dir
Every entry of the inline-data directory dir_ino: dir_entries over i_block and its dir_continuation.
read_range
Read a range from an inline-data file. Returns the bytes copied into dst, or Ok(0) if offset >= size.