pub fn build_layer_fd_layout(
pipe_read: OwnedFd,
real_fds: Vec<OwnedFd>,
seed: u64,
) -> Result<LayerFdLayout>Expand description
Build the complete wire fd layout for a producer serving n_real real diff
directories.
This pure-ish (only I/O: pipe, /dev/null, memfd) function:
- Calls [
sparse_dir_slots] to compute the sparse placement. - Opens dummy fds (
/dev/nullalternating withmemfd) for gap slots. - Builds the dirfds region by interleaving real and dummy fds in slot order.
- Creates a keepalive pipe; the write end goes into
fds_all, the read end is returned inLayerFdLayout::keepalive_read. - Adds
n_extra_lifetime_fds(seed)extra dummy lifetime fds. - Prepends the
pipe_readfd sofds_all[0]is always the data pipe.
The caller is responsible for:
- Passing the correct
real_fds(in chain order) — the first real_fd gets slotreal_indices[0], the second getsreal_indices[1], etc. - Spawning the producer with
write_fd(not returned here; the caller opens the pipe and passeswrite_fdto the producer separately).
§Arguments
pipe_read— Read end of the data pipe (will becomefds_all[0]).real_fds— Pre-opened real diff-directory file descriptors, one per chain layer, in chain order.seed— Deterministic seed (seeseed_from_id).
§Errors
Returns io::Error if any dummy-fd or keepalive-pipe creation fails.