Skip to main content

split_root_operand

Function split_root_operand 

Source
pub async fn split_root_operand(path: &Path) -> Result<RootOperand>
Expand description

Decompose a root operand into the (parent, final_component) the fd-relative walk needs (see RootOperand): the parent prefix is opened with crate::safedir::Dir::open_parent_dir (trusted, follows symlinks) and the final component is then classified O_NOFOLLOW via child(name) below it.

Most operands split directly via parent() / file_name() (an empty parent meaning the current directory). An operand whose final component is . or .. (e.g. ., tree/..) has no file_name(), so it is first canonicalized to a concrete path — . becomes the current directory, tree/.. its grandparent — restoring the behavior of the pre-fd-walk path code, where rrm . / rchm -R … . operated on the current tree. (Canonicalizing only this branch never touches a normal operand, so a symlinked final component on the normal path is still opened O_NOFOLLOW; ./.. are themselves never symlinks.) The filesystem root / has no parent and cannot be expressed as parent + component, so it is rejected with a clear error.