Skip to main content

Module tree_search

Module tree_search 

Source
Expand description

The kernel’s tree search ioctl lets userspace read any internal btrfs tree (chunk, root, quota, …) by specifying a key range. Items are returned in batches; tree_search advances the cursor automatically and calls a closure once per item until the range is exhausted.

§Byte order

SearchHeader fields (objectid, offset, type) are in host byte order: the kernel fills them in through the ioctl layer. The data slice passed to the callback contains the raw on-disk item payload, which is little-endian; callers must use u64::from_le_bytes and friends when interpreting it.

§Ioctl version

This module uses BTRFS_IOC_TREE_SEARCH (v1) with its fixed 3992-byte result buffer. This is sufficient for all item types used by this crate; the v2 variant with a configurable buffer size is not needed.

Structs§

SearchHeader
Metadata returned for each item found by tree_search.
SearchKey
Parameters specifying which items to return from a tree search.

Functions§

tree_search
Walk every item in the tree that falls within key, calling f once for each one.