Skip to main content

Module subvolume_remove

Module subvolume_remove 

Source
Expand description

Removal of a directory tree whose directories may lack owner write permission. What: Remove a directory tree, making each directory the user owns writable on the way down. Why: The migration preserves permission bits, so a checkout can hold a mode-555 directory with files in it. Unlinking a file needs write permission on its directory, so std::fs::remove_dir_all stops at the first such directory and both the deletion of the old tree and the emptying of a subvolume fail partway. Every directory is opened without following links and given the owner’s read, write and search bits through its descriptor before the tree is removed; a directory the user does not own keeps its mode and the removal reports the operating system’s refusal.

In TS you’d write (pseudocode):

await rm(path, { recursive: true, force: true }); // after chmod u+rwx on every directory in it

Functions§

remove_tree
What: Remove path, whatever it is: a file or link is unlinked, a directory is emptied and removed. Why: Links are never followed, as remove_dir_all guarantees; see the module description for the permissions.