Skip to main content

Module worktree_trash_remove

Module worktree_trash_remove 

Source
Expand description

Removal of a directory tree beneath a held parent handle, never following a link. What: Remove a directory tree beneath a held parent directory: every directory is opened by one plain name below the handle of its parent without following a link, and every entry is unlinked from the handle of the directory that holds it. Why: A path string is resolved again by every call that takes it, so a directory replaced by a link between a check and the removal redirects the removal. Here no call resolves a path: a link, a mount point or a directory on another device is an error that names it, and the identity of the top directory is compared with the recorded one on the object that is opened, so a replacement is never emptied. A directory the owner cannot write to is given the owner’s permission bits through its descriptor on the way down, as subvolume_remove.rs does for the old tree of a conversion.

In TS you’d write (pseudocode):

await removeTreeBeneath({ label, parent, name, expected }); // throws a reason; the entry is left as it is when it is not the expected object

Enums§

Removal
What a removal found.

Functions§

remove_tree_beneath
What: Remove the directory name below parent with everything in it; label is the path of parent, used only in messages. Why: With expected set, the directory is removed only when it is that object: the identity is compared by name before the directory is opened and again on the opened object, so a replacement made between the two is left alone. The top directory must be on the device of parent. Nothing is followed and nothing outside the directory is touched. An entry that vanishes meanwhile counts as removed. Directories are entered with a work stack, so depth costs no recursion.