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_blockarea that holds inline data. - INLINE_
DOTDOT_ SIZE - Bytes at the head of an inline directory’s
i_blockthat 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.databytes an inline directory’s entries continue into, or an empty vector wheni_sizesays it fits ini_block. A size past 60 with no such xattr, or a shorter one, is corruption – the same ruleread_allapplies 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 ofi_block), the entries ini_block[4..60], then those incontinuation– thesystem.dataxattr value, empty when the directory fits ini_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_entriesoveri_blockand itsdir_continuation. - read_
range - Read a range from an inline-data file.
Returns the bytes copied into
dst, orOk(0)ifoffset >= size.