fn confine(dir: &Path, root: &Path) -> Result<()>
Refuses a directory that resolves, symlinks followed, to outside root. Both are canonicalised, so a root given through a symlink of its own is compared by where it really is.
root