Skip to main content

Module subvolume_entry_count

Module subvolume_entry_count 

Source
Expand description

The count of the entries under a checkout, from which the free space a migration needs follows. What: The count of the entries under a checkout: every file, directory and link below its root, counted once each. Why: The free space a migration needs is the metadata of its entries (subvolume_preflight.rs), so the refusal for too little space starts from how many entries the copy will write. The walk reads directory listings only, no file contents, and follows no link, as the copy pass does not.

In TS you’d write (pseudocode):

const entries: number = countEntries(root); // readdir on each directory, one count per name

Functions§

count_entries
What: How many entries are below root. &Path borrows the path read-only (TS: a string argument); u64 is an unsigned 64-bit integer (siblings: u32, usize). Why: A directory that cannot be listed (gone, or not readable) adds nothing, because the copy reports an unreadable directory with its own message and the preflight must not duplicate it. u64 rather than usize because the figure is multiplied into a byte count that is stored as u64 in the filesystem facts. Gotcha: A link to a directory counts as one entry and its target is not walked, unlike a TS readdir recursion that follows stat; the work stack below replaces recursion so a deep tree cannot overflow the call stack.